Beispiel #1
0
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)

        targets = []
        damage = self.scaledamage(char, None, 48, 1, 5)

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 2)
        for target in chars:
            if mayAreaHarm(char, target):
                targets.append(target)

        # Re-scale the damage
        if len(targets) > 1:
            damage = ceil((damage * 2.0) / len(targets))

        for target in targets:
            target.lightning()
            target.soundeffect(0x29)

            self.harmchar(char, target)
            energydamage(target, char, damage, energy=100)
Beispiel #2
0
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 8)
        items = wolfpack.items(target.x, target.y, char.pos.map, 8)
        for target in chars:
            if char == target or not target.npc or target.summontimer == 0:
                continue

            if not mayAreaHarm(char, target):
                continue

            dispelChance = 50.0 + (100 * (
                (char.magery / 10.0 -
                 (target.getintproperty('dispeldifficulty', 1) / 10)) /
                ((target.getintproperty('dispelfocus', 1) / 10) * 2))) / 100.0

            if dispelChance > random.random():
                target.effect(0x3779, 10, 20)
                target.fight(char)
            else:
                wolfpack.effect(0x3728, target.pos, 8, 20)
                target.soundeffect(0x201)
                target.delete()

        # Field spells
        for item in items:
            if item.hastag('dispellable_field'):
                wolfpack.effect(0x376a, item.pos, 9, 20)
                item.soundeffect(0x201)
                item.delete()
Beispiel #3
0
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)

        if char.player:
            party = char.party
            guild = char.guild
        else:
            party = None
            guild = None

        # Enumerate chars
        range = 1 + int(char.skill[MAGERY] / 200.0)

        chars = wolfpack.chars(target.x, target.y, char.pos.map, range)
        for target in chars:
            if target == char:
                continue

            # We also ignore people from the same guild or party.
            # Or targets who are innocent.
            if (guild
                    and target.guild == guild) or (party
                                                   and target.party == party):
                continue

            if target.hidden:
                target.reveal()
                target.effect(0x375a, 9, 20)
                target.soundeffect(0x1fd)
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)

		if char.player:
			party = char.party
			guild = char.guild
		else:
			party = None
			guild = None

		# Enumerate chars
		range = 1 + int(char.skill[MAGERY] / 200.0)

		chars = wolfpack.chars(target.x, target.y, char.pos.map, range)
		for target in chars:
			if target == char:
				continue

			# We also ignore people from the same guild or party.
			# Or targets who are innocent.
			if (guild and target.guild == guild) or (party and target.party == party):
				continue

			if target.hidden:
				target.reveal()
				target.effect(0x375a, 9, 20)
				target.soundeffect(0x1fd)
Beispiel #5
0
def onUse(char, item):
    if not item.getoutmostitem() == char.getbackpack():
        char.socket.clilocmessage(
            1040019)  # The bola must be in your pack to use it.
    #elif char.itemonlayer( 1 ) or char.itemonlayer( 2 ):
    #	char.socket.clilocmessage( 1040015 ) # Your hands must be free to use this
    elif mounted(char):
        char.socket.clilocmessage(
            1040016)  # You cannot use this while riding a mount
    else:
        one = char.itemonlayer(1)
        two = char.itemonlayer(2)

        if one:
            char.getbackpack().additem(one)
        if two:
            char.getbackpack().additem(two)

        char.message(1049632, "")  # * You begin to swing the bola...*
        chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 16)
        for player in chars:
            if player != char and player.cansee(char):
                player.message(
                    1049633, str(char.name)
                )  # ~1_NAME~ begins to menacingly swing a bola...
        char.socket.attachtarget("bola.target", [item.serial])
    return True
def sendmovingeffect(source, target, model, hue=0, speed=1, rendermode=0):
	# Build the packet
	packet = wolfpack.packet(0xC0, 36)
	packet.setbyte(1, 0) # Moving
	packet.setint(2, 0) # Source
	packet.setint(6, 0) # Target
	packet.setshort(10, model) # Effect Model
	packet.setshort(12, source.x) # Source X
	packet.setshort(14, source.y) # Source Y
	packet.setbyte(16, source.z) # Source Z
	packet.setshort(17, target.x) # Target X
	packet.setshort(19, target.y) # Target Y
	packet.setbyte(21, target.z) # Target Z	
	packet.setbyte(22, speed) # Speed
	packet.setbyte(23, 0) # Duration
	packet.setshort(24, 0) # Unknown
	packet.setbyte(26, 1) # Fixed Direction
	packet.setbyte(27, 0) # Explode on Impact
	packet.setint(28, hue) # Hue
	packet.setint(32, rendermode) # Rendermode
	
	# Search for sockets at the source location
	chars = wolfpack.chars(source.x, source.y, source.map, 18)
	for char in chars:
		if char.socket:	
			packet.send(char.socket)
Beispiel #7
0
def sendmovingeffect(source, target, model, hue=0, speed=1, rendermode=0):
    # Build the packet
    packet = wolfpack.packet(0xC0, 36)
    packet.setbyte(1, 0)  # Moving
    packet.setint(2, 0)  # Source
    packet.setint(6, 0)  # Target
    packet.setshort(10, model)  # Effect Model
    packet.setshort(12, source.x)  # Source X
    packet.setshort(14, source.y)  # Source Y
    packet.setbyte(16, source.z)  # Source Z
    packet.setshort(17, target.x)  # Target X
    packet.setshort(19, target.y)  # Target Y
    packet.setbyte(21, target.z)  # Target Z
    packet.setbyte(22, speed)  # Speed
    packet.setbyte(23, 0)  # Duration
    packet.setshort(24, 0)  # Unknown
    packet.setbyte(26, 1)  # Fixed Direction
    packet.setbyte(27, 0)  # Explode on Impact
    packet.setint(28, hue)  # Hue
    packet.setint(32, rendermode)  # Rendermode

    # Search for sockets at the source location
    chars = wolfpack.chars(source.x, source.y, source.map, 18)
    for char in chars:
        if char.socket:
            packet.send(char.socket)
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)
        char.soundeffect(0x299)
        cured = 0

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
        for target in chars:
            target.effect(0x373A, 10, 15)
            target.soundeffect(0x1E0)

            if target.poison != -1:
                chance = (10000 + int(char.skill[MAGERY] * 7.5) - ((target.poison + 1) * 1750)) / 10000.0
                if chance >= random.random():
                    poison.cure(target)
                    cured += 1
                    if target.socket:
                        target.socket.clilocmessage(1010059)

        if cured > 0:
            if char.socket:
                char.socket.clilocmessage(1010058)
Beispiel #9
0
def GetPackInstinctBonus( attacker, defender ):
	if attacker.player or defender.player:
		return 0

	packinstinct = attacker.getstrproperty('packinstinct', '')
	if not packinstinct or (not attacker.owner and not attacker.summoned):
		return 0

	master = attacker.owner
	if not master:
		return 0

	inPack = 1

	chars = wolfpack.chars(defender.pos.x, defender.pos.y, defender.pos.map, 1)
	for char in chars:
		if char != attacker:
			if packinstinct == char.getstrproperty('packinstinct', '') or char.player or (not char.owner and not char.summoned):
				continue

			theirMaster = char.owner
			if master == theirMaster and defender in char.getopponents():
				inPack += 1

	if inPack >= 5:
		return 100
	elif inPack >= 4:
		return 75
	elif inPack >=3:
		return 50
	elif inPack >= 2:
		return 25
	return 0
Beispiel #10
0
def onDamage(char, type, amount, source):
	# Find the spiderweb
	items = wolfpack.items(char.pos.x, char.pos.y, char.pos.map, 0)

	spiderweb = None

	for item in items:
		if item.hasscript( 'spiderweb' ):
			spiderweb = item
			break

	if spiderweb:
		if type == DAMAGE_MAGICAL:
			spiderweb.health = max(0, spiderweb.health - amount * 2)
		elif type == DAMAGE_PHYSICAL:
			spiderweb.health = max(0, spiderweb.health - amount * 4)

		if spiderweb.health == 0:
			spiderweb.delete()

			targets = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 0)

			for target in targets:
				target.removescript( 'spiderweb' )

	return amount
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)

		targets = []
		damage = self.scaledamage(char, None, 48, 1, 5)

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 2)
		for target in chars:
			if mayAreaHarm(char, target):
				targets.append(target)

		# Re-scale the damage
		if len(targets) > 1:
			damage = ceil((damage * 2.0) / len(targets))

		for target in targets:
			target.lightning()
			target.soundeffect(0x29)

			self.harmchar(char, target)
			energydamage(target, char, damage, energy=100)
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 8)
		items = wolfpack.items(target.x, target.y, char.pos.map, 8)
		for target in chars:
			if char == target or not target.npc or target.summontimer == 0:
				continue

			if not mayAreaHarm(char, target):
				continue

			dispelChance = 50.0 + (100 * ((char.magery / 10.0 - (target.getintproperty('dispeldifficulty', 1) / 10)) / ((target.getintproperty('dispelfocus', 1) / 10) * 2))) / 100.0

			if dispelChance > random.random():
				target.effect(0x3779, 10, 20)
				target.fight(char)
			else:
				wolfpack.effect(0x3728, target.pos, 8, 20)
				target.soundeffect(0x201)
				target.delete()

		# Field spells
		for item in items:
			if item.hastag('dispellable_field'):
				wolfpack.effect(0x376a, item.pos, 9, 20)
				item.soundeffect(0x201)
				item.delete()
Beispiel #13
0
def allshow(socket, command, arguments):
	player = socket.player
	offlineChars = wolfpack.chars(player.pos.x, player.pos.y, player.pos.map, player.visrange, True)
	for oc in offlineChars:
		socket.removeobject(oc)
		socket.sendobject(oc)
	socket.sysmessage( tr( "The offline characters on your screen have been revealed." ) )
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)

		if char.player:
			party = char.party
			guild = char.guild
		else:
			party = None
			guild = None

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
		for target in chars:
			if target == char:
				continue

			# We also ignore people from the same guild or party.
			# Or targets who are innocent.
			if (guild and target.guild == guild) or (party and target.party == party):
				continue

			if target.invulnerable or target.notoriety(char) == 1:
				continue

			target.effect(0x374a, 10, 15)
			target.soundeffect(0x1fb)

			self.harmchar(char, target)
			statmodifier(char, target, 3, 1)
	def cast(self, char, mode, args=[], target=None, item=None):
		if not self.consumerequirements(char, mode, args, target, item):
			return
		
		targets = []

		spellrange = 1 + int(char.skill[MAGERY] / 150.0)
		chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, spellrange)
		for target in chars:
			if not mayAreaHarm(char, target):
				continue

			if not char.canreach(target, spellrange):
				continue

			targets.append(target)

		for target in targets:
			target.soundeffect(0x2F3)
			self.harmchar(char, target)

			damage = target.hitpoints / 2
			if target.player:
				damage += random.randint(0, 15)

			if damage > 75:
				damage = 75
			elif damage < 15:
				damage = 15

			energydamage(target, char, damage, physical=100)
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)
		char.soundeffect(0x299)
		cured = 0

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
		for target in chars:
			# Check if we should affect the char
			if not mayAreaBenefit(char, target, includeinnocents = True):
				continue
		
			target.effect(0x373a, 10, 15)
			target.soundeffect(0x1e0)

			if target.poison != -1:
				chance = (10000 + int(char.skill[MAGERY] * 7.5) - ((target.poison + 1) * 1750)) / 10000.0
				if chance >= random.random():
					poison.cure(target)
					cured += 1
					if target.socket:
						target.socket.clilocmessage(1010059)

		if cured > 0 and char.socket:
			char.socket.clilocmessage(1010058)
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)

        if char.player:
            party = char.party
            guild = char.guild
        else:
            party = None
            guild = None

            # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 8)
        items = wolfpack.items(target.x, target.y, char.pos.map, 8)
        for target in chars:
            if char == target or not target.npc or target.summontimer == 0:
                continue

            if self.checkresist(char, target):
                target.effect(0x3779, 10, 20)
            else:
                wolfpack.effect(0x3728, target.pos, 8, 20)
                target.soundeffect(0x201)
                target.delete()

                # Field spells
        for item in items:
            if item.hastag("dispellable_field"):
                wolfpack.effect(0x376A, item.pos, 9, 20)
                item.soundeffect(0x201)
                item.delete()
Beispiel #18
0
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)
        char.soundeffect(0x299)
        cured = 0

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
        for target in chars:
            # Check if we should affect the char
            if not mayAreaBenefit(char, target, includeinnocents=True):
                continue

            target.effect(0x373a, 10, 15)
            target.soundeffect(0x1e0)

            if target.poison != -1:
                chance = (10000 + int(char.skill[MAGERY] * 7.5) -
                          ((target.poison + 1) * 1750)) / 10000.0
                if chance >= random.random():
                    poison.cure(target)
                    cured += 1
                    if target.socket:
                        target.socket.clilocmessage(1010059)

        if cured > 0 and char.socket:
            char.socket.clilocmessage(1010058)
Beispiel #19
0
    def cast(self, char, mode, args=[], target=None, item=None):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        targets = []

        spellrange = 1 + int(char.skill[MAGERY] / 150.0)
        chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map,
                               spellrange)
        for target in chars:
            if not mayAreaHarm(char, target):
                continue

            if not char.canreach(target, spellrange):
                continue

            targets.append(target)

        for target in targets:
            target.soundeffect(0x2F3)
            self.harmchar(char, target)

            damage = target.hitpoints / 2
            if target.player:
                damage += random.randint(0, 15)

            if damage > 75:
                damage = 75
            elif damage < 15:
                damage = 15

            energydamage(target, char, damage, physical=100)
Beispiel #20
0
def attack_target(char, arguments, target):
    if not target.char or target.char == char:
        char.socket.sysmessage(tr("Your pets cannot attack that."))
        return

    (pet, all) = arguments
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    attack_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                attack_target(char, [follower.serial, False], target)
    else:
        pet = wolfpack.findchar(pet)
        if target.char == pet:
            char.socket.sysmessage(tr("Your pet refuses to kill itself."))
            return
        if pet and (pet.owner == char or char.gm) and pet.distanceto(char) < 18:
            startfight(pet, target.char)
            pet.fight(target.char)

            # right here we need to not interrupt the target, but i can't register a fight unless i do, right? not sure.
            target.char.fight(pet)
            target.char.follow(pet)

            go_target(char, arguments, target)
            follow_target(char, arguments, target)
            pet.sound(SND_ATTACK)
Beispiel #21
0
def attack_target(char, arguments, target):
    if not target.char or target.char == char:
        char.socket.sysmessage(tr('Your pets cannot attack that.'))
        return

    (pet, all) = arguments
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    attack_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                attack_target(char, [follower.serial, False], target)
    else:
        pet = wolfpack.findchar(pet)
        if target.char == pet:
            char.socket.sysmessage(tr('Your pet refuses to kill itself.'))
            return
        if pet and (pet.owner == char
                    or char.gm) and pet.distanceto(char) < 18:
            startfight(pet, target.char)
            pet.fight(target.char)

            # right here we need to not interrupt the target, but i can't register a fight unless i do, right? not sure.
            target.char.fight(pet)
            target.char.follow(pet)

            go_target(char, arguments, target)
            follow_target(char, arguments, target)
            pet.sound(SND_ATTACK)
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		if not self.consumerequirements(char, mode, args, target, item):
			return

		xdiff = abs(target.x - char.pos.x)
		ydiff = abs(target.y - char.pos.y)

		positions = []

		# North/South
		if xdiff > ydiff:
			itemid = 0x3922
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

		# West/East
		else:
			itemid = 0x3915
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

		serials = []
		char.soundeffect(0x20c)

		total = (char.skill[MAGERY] + char.skill[POISONING]) / 2.0
		if total >= 1000:
			level = 3
		elif total > 850:
			level = 2
		elif total > 650:
			level = 1
		else:
			level = 0

		for pos in positions:
			newitem = wolfpack.newitem(1)
			newitem.id = itemid
			#newitem.direction = 29
			newitem.moveto(pos)
			newitem.decay = 0 # Dont decay. TempEffect will take care of them
			newitem.settag('dispellable_field', 1)
			newitem.settag('level', level)
			newitem.addscript( 'magic.poisonfield' )
			newitem.update()
			serials.append(newitem.serial)

			# Affect chars who are occupying the field cells
			chars = wolfpack.chars( newitem.pos.x, newitem.pos.y, newitem.pos.map, 0 )
			for affected in chars:
				if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
					newitem.callevent(EVENT_COLLIDE, (affected, newitem))

		duration = int((3 + char.skill[MAGERY] / 25.0) * 1000)
		wolfpack.addtimer(duration, field_expire, serials, 1)
Beispiel #23
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # West / East
        if xdiff > ydiff:
            itemid = 0x3996
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x, target.y + i, target.z,
                                   target.map))

        # North South
        else:
            itemid = 0x398c
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x + i, target.y, target.z,
                                   target.map))

        serials = []

        char.soundeffect(0x20c)

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            #newitem.direction = 29
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.settag('dispellable_field', 1)
            newitem.settag('source', char.serial)
            newitem.addscript('magic.firefield')
            newitem.update()
            serials.append(newitem.serial)

            # Affect chars who are occupying the field cells
            chars = wolfpack.chars(newitem.pos.x, newitem.pos.y,
                                   newitem.pos.map, 0)
            if len(chars) > 0:
                for affected in chars:
                    if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
                        newitem.callevent(EVENT_COLLIDE, (affected, newitem))

        duration = int((4 + char.skill[MAGERY] * 0.05) * 1000)
        wolfpack.addtimer(duration, field_expire, serials, 1)
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)
		char.soundeffect(0x299)
		cured = 0

		if char.player:
			party = char.party
			guild = char.guild
		else:
			party = None
			guild = None

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
		for target in chars:
			if not target.player:
				continue

			if target == char or (guild and target.guild == guild) or (party and target.party == party):
				# Toggle Protection
				if target.propertyflags & 0x20000:
					target.propertyflags &= ~ 0x20000
					target.effect(0x375a, 9, 20)
					target.soundeffect(0x1ed)

					try:
						if target.hastag('protection_skill'):
							skill = int(target.gettag('protection_skill'))
							if target.skill[MAGICRESISTANCE] + skill > target.skillcap[MAGICRESISTANCE]:
								target.skill[MAGICRESISTANCE] = target.skillcap[MAGICRESISTANCE]
							else:
								target.skill[MAGICRESISTANCE] += skill
					except:
						pass
					target.deltag('protection_skill')
				else:
					target.propertyflags |= 0x20000
					target.effect(0x375a, 9, 20)
					target.soundeffect(0x1e9)

					# Remove Magic Resistance Skill
					amount = 35 - int(target.skill[INSCRIPTION] / 200)
					if target.skill[MAGICRESISTANCE] - amount < 0:
						amount = target.skill[MAGICRESISTANCE]

					target.settag('protection_skill', amount)
					target.skill[MAGICRESISTANCE] -= amount

				if target.socket:
					target.socket.resendstatus()
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not char.canreach(target, 10):
            char.message(500237)
            return

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # West / East
        if xdiff > ydiff:
            itemid = 0x3996
            for i in range(-2, 3):
                positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

                # North South
        else:
            itemid = 0x398C
            for i in range(-2, 3):
                positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

        serials = []

        char.soundeffect(0x20C)

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            # newitem.direction = 29
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.settag("dispellable_field", 1)
            newitem.settag("source", char.serial)
            newitem.addscript("magic.firefield")
            newitem.update()
            serials.append(newitem.serial)

            # Affect chars who are occupying the field cells
            chars = wolfpack.chars(newitem.pos.x, newitem.pos.y, newitem.pos.map, 0)
            if len(chars) > 0:
                for affected in chars:
                    if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
                        newitem.callevent(EVENT_COLLIDE, (affected, newitem))

        duration = int((4 + char.skill[MAGERY] * 0.05) * 1000)
        wolfpack.addtimer(duration, "magic.utilities.field_expire", serials, 1)
Beispiel #26
0
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)
        char.soundeffect(0x299)

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
        for target in chars:
            if not target.player:
                continue

            # Check if we should affect the char
            if not mayAreaBenefit(char, target):
                continue

            # Toggle Protection
            if target.propertyflags & 0x20000:
                target.propertyflags &= ~0x20000
                target.effect(0x375a, 9, 20)
                target.soundeffect(0x1ed)

                try:
                    if target.hastag('protection_skill'):
                        skill = int(target.gettag('protection_skill'))
                        if target.skill[
                                MAGICRESISTANCE] + skill > target.skillcap[
                                    MAGICRESISTANCE]:
                            target.skill[MAGICRESISTANCE] = target.skillcap[
                                MAGICRESISTANCE]
                        else:
                            target.skill[MAGICRESISTANCE] += skill
                except:
                    pass
                target.deltag('protection_skill')
            else:
                target.propertyflags |= 0x20000
                target.effect(0x375a, 9, 20)
                target.soundeffect(0x1e9)

                # Remove Magic Resistance Skill
                amount = 35 - int(target.skill[INSCRIPTION] / 200)
                if target.skill[MAGICRESISTANCE] - amount < 0:
                    amount = target.skill[MAGICRESISTANCE]

                target.settag('protection_skill', amount)
                target.skill[MAGICRESISTANCE] -= amount

            if target.socket:
                target.socket.resendstatus()
Beispiel #27
0
def trackWhatResponse(char, args, response):
    success = char.checkskill(TRACKING, 0, 211)
    if not success:
        char.socket.clilocmessage(
            1018092)  # You see no evidence of those in the area.
        return

    char.checkskill(TRACKING, 211, 1000)  # Passive gain

    ran = 10 + (char.skill[TRACKING] / 10)

    button = response.button

    liste = []
    for charcible in wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, ran):
        if not charcible.invisible and not charcible.dead and CheckDifficulty(
                char, charcible):
            # Track players
            if button == 4:
                if charcible.player and not charcible == char:
                    liste.append(charcible)

            elif charcible.npc:
                # Track humans
                if button == 3 and charcible.bodytype == 4:
                    liste.append(charcible)
                # Track monsters
                elif button == 2 and charcible.bodytype == 1:
                    liste.append(charcible)
                # Track animals
                elif button == 1 and charcible.bodytype == 3:
                    liste.append(charcible)

        #charcible = iterator.next

    if len(liste) == 0:
        if target.button in [3, 4]:
            char.socket.clilocmessage(
                502995, '', GRAY)  # You see no evidence of people in the area.
        elif target.button == 1:
            char.socket.clilocmessage(
                502991, '',
                GRAY)  # You see no evidence of animals in the area.
        else:
            char.socket.clilocmessage(
                502993, '',
                GRAY)  # You see no evidence of creatures in the area.
    else:
        TrackWhoGump(char, liste, 1, ran)
        char.socket.clilocmessage(
            1018093)  # Select the one you would like to track.
Beispiel #28
0
def follow_me(char, pet, all=False):
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    follow_me(char, follower, False)
        else:
            for follower in char.followers:
                follow_me(char, follower, False)
    if pet and (pet.owner == char or char.gm or isPetFriend(char, pet)) and pet.distanceto(char) < 18:
        stopfight(pet)
        pet.follow(char)
        pet.sound(SND_ATTACK)
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)
		char.soundeffect(0x299)

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
		for target in chars:
			if not target.player:
				continue
				
			# Check if we should affect the char
			if not mayAreaBenefit(char, target):
				continue

			# Toggle Protection
			if target.propertyflags & 0x20000:
				target.propertyflags &= ~ 0x20000
				target.effect(0x375a, 9, 20)
				target.soundeffect(0x1ed)

				try:
					if target.hastag('protection_skill'):
						skill = int(target.gettag('protection_skill'))
						if target.skill[MAGICRESISTANCE] + skill > target.skillcap[MAGICRESISTANCE]:
							target.skill[MAGICRESISTANCE] = target.skillcap[MAGICRESISTANCE]
						else:
							target.skill[MAGICRESISTANCE] += skill
				except:
					pass
				target.deltag('protection_skill')
			else:
				target.propertyflags |= 0x20000
				target.effect(0x375a, 9, 20)
				target.soundeffect(0x1e9)

				# Remove Magic Resistance Skill
				amount = 35 - int(target.skill[INSCRIPTION] / 200)
				if target.skill[MAGICRESISTANCE] - amount < 0:
					amount = target.skill[MAGICRESISTANCE]

				target.settag('protection_skill', amount)
				target.skill[MAGICRESISTANCE] -= amount

			if target.socket:
				target.socket.resendstatus()
Beispiel #30
0
def autoclose( item, args ):
	if not item or not item.hastag( 'opencount' ):
		return

	# Are we supposed to close this door?
	opencount = int( item.gettag( 'opencount' ) )

	# We are not supposed to close this door
	if opencount != args[0]:
		return

	"""
	# NOTE!
	# We need to put in a form of character checking for the location
	# where the door closes, this way the door doesn't close ON people.
	"""
	blocked = 0
	chars = []
	for door in doors:
		if door[1] == item.id:
			chars = wolfpack.chars( item.pos.x - door[2], item.pos.y - door[3], item.pos.map, 0 )
	for bchar in chars:
		if bchar.pos.z == item.pos.z:
			blocked = 1
			break
		elif bchar.pos.z < item.pos.z and bchar.pos.z >= ( item.pos.z - 5):
			blocked = 1
			break
		elif bchar.pos.z > item.pos.z and bchar.pos.z <= ( item.pos.z + 5):
			blocked = 1
			break

	if blocked == 1:
		item.addtimer( CLOSEDOOR_DELAY, autoclose, [ int(item.gettag('opencount')) ], True )
	else:
		# Find the door definition for this item
		for door in doors:
			if door[1] == item.id:
				pos = item.pos
				# Change the door id and update the clients around it
				item.id = door[0]
				item.moveto( pos.x - door[2], pos.y - door[3], pos.z )
				if item.hastag( 'opened' ):
					item.deltag( 'opened' )
				item.update()

				# Soundeffect (close)
				item.soundeffect( door[5] )
Beispiel #31
0
def follow_me(char, pet, all=False):
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    follow_me(char, follower, False)
        else:
            for follower in char.followers:
                follow_me(char, follower, False)
    if pet and (pet.owner == char or char.gm
                or isPetFriend(char, pet)) and pet.distanceto(char) < 18:
        stopfight(pet)
        pet.follow(char)
        pet.sound(SND_ATTACK)
Beispiel #32
0
def come(char, pet, all=False):
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    come(char, follower, False)
        else:
            for follower in char.followers:
                come(char, follower, False)
    elif pet and (pet.owner == char or char.gm) and pet.distanceto(char) < 18:
        stopfight(pet)
        pet.guarding = None
        pet.goto(char.pos)
        pet.sound(SND_ATTACK)
Beispiel #33
0
def come(char, pet, all=False):
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    come(char, follower, False)
        else:
            for follower in char.followers:
                come(char, follower, False)
    elif pet and (pet.owner == char or char.gm) and pet.distanceto(char) < 18:
        stopfight(pet)
        pet.guarding = None
        pet.goto(char.pos)
        pet.sound(SND_ATTACK)
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		if not self.consumerequirements(char, mode, args, target, item):
			return

		xdiff = abs(target.x - char.pos.x)
		ydiff = abs(target.y - char.pos.y)

		positions = []

		# West / East
		if xdiff > ydiff:
			itemid = 0x3967
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

		# North South
		else:
			itemid = 0x3979
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

		serials = []

		char.soundeffect(0x20b)

		for pos in positions:
			newitem = wolfpack.newitem(1)
			newitem.id = itemid
			newitem.moveto(pos)
			newitem.decay = 0 # Dont decay. TempEffect will take care of them
			newitem.settag('dispellable_field', 1)
			newitem.settag('strength', char.skill[self.damageskill])
			newitem.addscript( 'magic.paralyzefield' )
			newitem.update()
			serials.append(newitem.serial)
			wolfpack.effect(0x376A, newitem.pos, 9, 10)

			# Affect chars who are occupying the field cells
			chars = wolfpack.chars( newitem.pos.x, newitem.pos.y, newitem.pos.map, 0 )
			for affected in chars:
				if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
					newitem.callevent(EVENT_COLLIDE, (affected, newitem))

		duration = int((3 + char.skill[MAGERY] / 30.0) * 1000)
		wolfpack.addtimer(duration, field_expire, serials, 1)
def caught_func( char, victim, tosteal ):
	char.socket.sysmessage( tr( "You have been caught!" ) )
	# Human being
	if victim.npc:
		victim.say(tr( "Guards! A thief is amoung us!" ), 0x09)
		# we must implement a callguards method available in python
	if victim.notoriety( char ) == 0x01:
		char.criminal()
	if victim.player and victim.player.socket:
		victim.socket.showspeech(victim, tr( "You notice %s trying to steal %s from you." ) % (char.name, tosteal.getname()))
	message = u"You notice %s trying to steal from %s." % (char.name, victim.name)
	# Everyone within 7 Tiles notices us
	chars =  wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 7)
	for guy in chars:
		if guy.player and guy.socket and not char:
			guy.socket.showspeech(victim, message)
	return True
Beispiel #36
0
def stroke(char, arguments):
	strokes = arguments[0]

	# First: Check if the character disconnected
	# If he did, save the strokes and level and restore it later
	if char.player and not char.socket and char.logouttime == 0:
		if not char.hasscript( 'system.poison' ):
			char.settag( 'poison_strokes', strokes )
			char.addscript( 'system.poison' )
		return

	if not POISONS.has_key(char.poison):
		if char.poison != -1:
			char.poison = -1
			char.updateflags()
		return

	poison = POISONS[char.poison]

	# Show a message if the cycle is ok
	if strokes % poison[7] == 0:
		chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 18)
		for viewer in chars:
			if viewer.socket and viewer.cansee(char):
				if viewer != char:
					viewer.socket.clilocmessage(1042858 + char.poison * 2, char.name, 34, 3, char)
				else:
					viewer.socket.clilocmessage(1042857 + char.poison * 2, '', 34, 3, char)

	damage = 1 + int(char.hitpoints * poison[3])
	damage = min(poison[2], max(poison[1], damage))
	energydamage(char, None, damage, poison=100)

	# See if we should add another timer
	strokes += 1
	if strokes == poison[6]:
		if char.poison != -1:
			char.poison = -1
			char.updateflags()
		if char.socket:
			char.socket.clilocmessage(502136)
		return

	char.addtimer(poison[5], "system.poison.stroke", [strokes], 0, 0, "poison_timer")
Beispiel #37
0
def go_target(char, arguments, target):
    (pet, all) = arguments
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    go_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                go_target(char, [follower.serial, False], target)
    else:
        pet = wolfpack.findchar(pet)
        if pet and (pet.owner == char or char.gm) and pet.distanceto(char) < 18:
            stopfight(pet)
            pet.guarding = None
            pet.goto(target.pos)
            pet.sound(SND_ATTACK)
def trackWhatResponse( char, args, response ):
	success = char.checkskill( TRACKING, 0, 211 )
	if not success:
		char.socket.clilocmessage( 1018092 ) # You see no evidence of those in the area.
		return
	
	char.checkskill( TRACKING, 211, 1000 ) # Passive gain

	ran= 10 + ( char.skill[ TRACKING ] / 10 )
	
	button = response.button
	
	liste=[]
	for charcible in wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, ran):
		if not charcible.invisible and not charcible.dead and CheckDifficulty(char, charcible):
			# Track players
			if button == 4:
				if charcible.player and not charcible == char:
					liste.append(charcible)

			elif charcible.npc:
				# Track humans
				if button == 3 and charcible.bodytype == 4:
					liste.append(charcible)
				# Track monsters
				elif button == 2 and charcible.bodytype == 1:
					liste.append(charcible)
				# Track animals
				elif button == 1 and charcible.bodytype == 3:
					liste.append(charcible)

		#charcible = iterator.next

	if len(liste) == 0:
		if target.button in [3, 4]:
			char.socket.clilocmessage( 502995, '', GRAY ) # You see no evidence of people in the area.
		elif target.button == 1:
			char.socket.clilocmessage( 502991, '', GRAY ) # You see no evidence of animals in the area.
		else:
			char.socket.clilocmessage( 502993, '', GRAY ) # You see no evidence of creatures in the area.
	else:
		TrackWhoGump(char, liste, 1, ran)
		char.socket.clilocmessage( 1018093 ) # Select the one you would like to track.
Beispiel #39
0
def go_target(char, arguments, target):
    (pet, all) = arguments
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    go_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                go_target(char, [follower.serial, False], target)
    else:
        pet = wolfpack.findchar(pet)
        if pet and (pet.owner == char
                    or char.gm) and pet.distanceto(char) < 18:
            stopfight(pet)
            pet.guarding = None
            pet.goto(target.pos)
            pet.sound(SND_ATTACK)
	def target(self, char, mode, targettype, target, args, item):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		char.turnto(target)

		# Enumerate chars
		chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
		for target in chars:
			if target == char:
				continue

			if not mayAreaHarm(char, target):
				continue

			target.effect(0x374a, 10, 15)
			target.soundeffect(0x1fb)

			self.harmchar(char, target)
			statmodifier(char, target, 3, 1)
Beispiel #41
0
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 3)
        for target in chars:
            if target == char:
                continue

            if not mayAreaHarm(char, target):
                continue

            target.effect(0x374a, 10, 15)
            target.soundeffect(0x1fb)

            self.harmchar(char, target)
            statmodifier(char, target, 3, 1)
Beispiel #42
0
def caught_func(char, victim, tosteal):
    char.socket.sysmessage(tr("You have been caught!"))
    # Human being
    if victim.npc:
        victim.say(tr("Guards! A thief is amoung us!"), 0x09)
        # we must implement a callguards method available in python
    if victim.notoriety(char) == 0x01:
        char.criminal()
    if victim.player and victim.player.socket:
        victim.socket.showspeech(
            victim,
            tr("You notice %s trying to steal %s from you.") %
            (char.name, tosteal.getname()))
    message = u"You notice %s trying to steal from %s." % (char.name,
                                                           victim.name)
    # Everyone within 7 Tiles notices us
    chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 7)
    for guy in chars:
        if guy.player and guy.socket and not char:
            guy.socket.showspeech(victim, message)
    return True
Beispiel #43
0
def follow_target(char, arguments, target):
    if not target.char:
        char.socket.sysmessage(tr("Your pets can only follow characters."))
        return

    (pet, all) = arguments
    pet = wolfpack.findchar(pet)
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    follow_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                follow_target(char, [follower.serial, False], target)
    elif pet and (pet.owner == char or char.gm or isPetFriend(char, pet)) and pet.distanceto(char) < 18:
        pet.guarding = None
        pet.follow(target.char)
        pet.sound(SND_ATTACK)
Beispiel #44
0
def follow_target(char, arguments, target):
    if not target.char:
        char.socket.sysmessage(tr('Your pets can only follow characters.'))
        return

    (pet, all) = arguments
    pet = wolfpack.findchar(pet)
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    follow_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                follow_target(char, [follower.serial, False], target)
    elif pet and (pet.owner == char or char.gm
                  or isPetFriend(char, pet)) and pet.distanceto(char) < 18:
        pet.guarding = None
        pet.follow(target.char)
        pet.sound(SND_ATTACK)
    def target(self, char, mode, targettype, target, args, item):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        char.turnto(target)

        if char.player:
            party = char.party
            guild = char.guild
        else:
            party = None
            guild = None

        targets = []
        damage = self.scaledamage(char, None, 48, 1, 5)

        # Enumerate chars
        chars = wolfpack.chars(target.x, target.y, char.pos.map, 2)
        for target in chars:
            if target == char:
                continue

                # We also ignore people from the same guild or party.
                # Or targets who are innocent.
            if (guild and target.guild == guild) or (party and target.party == party):
                continue

            targets.append(target)

            # Re-scale the damage
        if len(targets) > 1:
            damage = ceil((damage * 2.0) / len(targets))

        for target in targets:
            target.lightning()
            target.soundeffect(0x29)

            self.harmchar(char, target)
            energydamage(target, char, damage, energy=100)
Beispiel #46
0
def onUse( char, item ):
	if not item.getoutmostitem() == char.getbackpack():
		char.socket.clilocmessage( 1040019 ) # The bola must be in your pack to use it.
	#elif char.itemonlayer( 1 ) or char.itemonlayer( 2 ):
	#	char.socket.clilocmessage( 1040015 ) # Your hands must be free to use this
	elif mounted( char ):
		char.socket.clilocmessage( 1040016 ) # You cannot use this while riding a mount
	else:
		one = char.itemonlayer( 1 )
		two = char.itemonlayer( 2 )

		if one:
			char.getbackpack().additem( one )
		if two:
			char.getbackpack().additem( two )

		char.message( 1049632, "" ) # * You begin to swing the bola...*
		chars = wolfpack.chars( char.pos.x, char.pos.y, char.pos.map, 16 )
		for player in chars:
			if player != char and player.cansee(char):
				player.message( 1049633, str(char.name) ) # ~1_NAME~ begins to menacingly swing a bola...
		char.socket.attachtarget( "bola.target", [item.serial] )
	return True
	def cast(self, char, mode, args=[], target=None, item=None):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		if char.player:
			party = char.party
			guild = char.guild
		else:
			party = None
			guild = None

		targets = []

		spellrange = 1 + int(char.skill[MAGERY] / 150.0)
		chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, spellrange)
		for target in chars:
			if target == char:
				continue

			if (guild and target.guild == guild) or (party and target.party == party):
				continue

			if not char.canreach(target, spellrange):
				continue

			targets.append(target)

		for target in targets:
			target.soundeffect(0x2F3)
			self.harmchar(char, target)

			damage = target.hitpoints / 2
			if target.player:
				damage += random.randint(0, 15)

			damage = min(100, max(15, damage))
			energydamage(target, char, damage, physical=100)
Beispiel #48
0
def GetPackInstinctBonus(attacker, defender):
    if attacker.player or defender.player:
        return 0

    packinstinct = attacker.getstrproperty('packinstinct', '')
    if not packinstinct or (not attacker.owner and not attacker.summoned):
        return 0

    master = attacker.owner
    if not master:
        return 0

    inPack = 1

    chars = wolfpack.chars(defender.pos.x, defender.pos.y, defender.pos.map, 1)
    for char in chars:
        if char != attacker:
            if packinstinct == char.getstrproperty(
                    'packinstinct',
                    '') or char.player or (not char.owner
                                           and not char.summoned):
                continue

            theirMaster = char.owner
            if master == theirMaster and defender in char.getopponents():
                inPack += 1

    if inPack >= 5:
        return 100
    elif inPack >= 4:
        return 75
    elif inPack >= 3:
        return 50
    elif inPack >= 2:
        return 25
    return 0
Beispiel #49
0
def opendoor( char, item ):
	pos = item.pos

	# Search the door information
	for door in doors:
		# Use this door information
		if door[0] == item.id:
			# Change the Door id and resend
			item.id = door[1]
			item.moveto( pos.x + door[2], pos.y + door[3], pos.z )
			item.update()

			# Soundeffect (open)
			char.soundeffect( door[4] )

			# This is used to track multiple open/close actions
			# We cannot dispel the effect on the item, so we have
			# to do it this way.
			if not item.hastag('opencount'):
				opencount = 1
			else:
				opencount = int(item.gettag('opencount')) + 1

			item.settag('opencount', str(opencount))

			if not item.hastag('opened'):
				item.settag('opened', 'true')

			# Add an autoclose tempeffect
			item.addtimer( CLOSEDOOR_DELAY, autoclose, [ opencount ], True )

			# Refresh a House if we opened it
			# Multis are completely broken right now. add refresh later here
			#multi = wolfpack.findmulti( item.pos )

			#if multi and multi.ishouse():
				# Only Owners and Friends can refresh a house
			#	if multi.owner == char or char in multi.friends:
			#		char.message( 'You refresh the house' )

			return True

		# Return to the original state
		elif door[1] == item.id:
			blocked = 0
			chars = None
			chars = wolfpack.chars( item.pos.x - door[2], item.pos.y - door[3], item.pos.map, 0 )
			if chars:
				for bchar in chars:
					if bchar.pos.z == item.pos.z:
						blocked = 1
						break
					elif bchar.pos.z < item.pos.z and bchar.pos.z >= ( item.pos.z - 5):
						blocked = 1
						break
					elif bchar.pos.z > item.pos.z and bchar.pos.z <= ( item.pos.z + 5):
						blocked = 1
						break

			if blocked == 1:
				char.socket.sysmessage( tr("There is someone blocking the door!") )
				return True
			else:
				pos = item.pos
				# Change the door id and update the clients around it
				item.id = door[0]
				item.moveto( pos.x - door[2], pos.y - door[3], pos.z )
				if item.hastag('opened'):
					item.deltag( 'opened' )
				item.update()
				# Soundeffect (close)
				char.soundeffect( door[5] )

			return True

	return False
Beispiel #50
0
def response(char, args, target):
    if not char:
        return

    if skills.skilltable[DETECTINGHIDDEN][skills.UNHIDE] and char.hidden:
        char.reveal()

    # if we are in our house : reveal all hidden chars in this house
    # w/o checking skill
    house = wolfpack.findmulti(char.pos)
    # it's our house
    if house and house.owner == char.serial:
        # get all chars in this house
        chars = house.chars()
        # set visible to the chars
        for echar in chars:
            if echar.hidden and echar.serial != char.serial:
                echar.hidden = 0
                echar.update()
        # do we need to checkskill ?
        return

    char.socket.settag('skill_delay',
                       int(wolfpack.time.currenttime() + DETECTHIDDEN_DELAY))

    skill = char.skill[DETECTINGHIDDEN]
    reveal_range = int(skill / 100)

    success = char.checkskill(DETECTINGHIDDEN, 0, 1000)
    if not success:
        reveal_range /= 2

    pos = None
    item = None
    found = False
    if target.pos:
        pos = target.pos
    if target.item:
        item = target.item
    # when we target at a position : hidden people, dungeon trap, faction trap
    if pos:
        x = pos.x
        y = pos.y
        map = pos.map
        # first, we test hidden chars
        chars = wolfpack.chars(x, y, map, reveal_range)
        for tchar in chars:
            if not tchar.gm:
                # hidden using hiding skill
                if tchar.hidden:
                    ss = skill + random.randint(0, 21) - 10
                    ts = tchar.skill[HIDING] + random.randint(0, 21) - 10
                    if ss >= ts:
                        reveal_char(tchar)
                        found = True
                # hidden using invisibility spell
                #elif tchar.hasscript('skills.stealth'):
                #	# FIXME : only hidden with lower skill will be revealed
                #	if tchar.skill[ MAGERY ] <= skill:
                #		reveal_char( tchar )
        # next, dungeon / faction traps
        items = wolfpack.items(x, y, map, reveal_range)
        for titem in items:
            if titem.id in dungeon_traps:
                if not titem.visible:
                    if titem.hastag('level'):
                        level = item.gettag('level')
                    else:
                        level = 1
                    # level from 1 to 5
                    if skill / 2 >= level:
                        titem.addtimer(DUNGEON_TRAP_REVEAL_DURATION, hide_trap,
                                       [titem.visible])
                        titem.visible = 1
                        titem.update()
                        found = True
            # faction trap : no idea yet
    # now, we deal with the trap boxes - show trap items as color
    if item:
        char.socket.sysmessage("detecting trap box is not implemented yet.")
    elif not found:
        char.socket.clilocmessage(500817)  # You can see nothing hidden there.
Beispiel #51
0
def response(char, args, target):
    if not char.socket.hastag('peacemaking_instrument'):
        return False
    # you can only target chars
    if not target.char:
        char.socket.clilocmessage(1049528)  # You cannot calm that!
        return True
    instrument = wolfpack.finditem(
        char.socket.gettag('peacemaking_instrument'))
    if not instrument:
        return False

    if skills.skilltable[PEACEMAKING][skills.UNHIDE] and char.hidden:
        char.reveal()

    char.socket.deltag('peacemaking_instrument')
    char.socket.settag('skill_delay',
                       int(wolfpack.time.currenttime() + PEACE_DELAY))

    # if target him/her self : standard (regional) mode
    # anyone including npcs can re-target and start fight
    peace_range = skills.musicianship.bard_range(char)
    if char == target.char:

        result = char.checkskill(MUSICIANSHIP, 0, 1000)
        skills.musicianship.play_instrument(char, instrument, result)
        # fail to play well
        if not result:
            char.socket.clilocmessage(
                500612, "", 0x3b2,
                3)  # You play poorly, and there is no effect.
            return True
        result = char.checkskill(PEACEMAKING, 0, 1000)
        # fail on peacemaking
        if not result:
            char.socket.clilocmessage(
                500613, "", 0x3b2,
                3)  # You attempt to calm everyone, but fail.
            return True
        char.socket.clilocmessage(500615, "", 0x3b2, 3)
        creatures = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map,
                                   peace_range)
        for creature in creatures:
            if char.canreach(creature, peace_range):
                # stop combat
                # player chars
                if creature.socket:
                    creature.socket.clilocmessage(
                        500616, "", 0x3b2, 3
                    )  # You hear lovely music, and forget to continue battling!
    # target another player or - effect will go some duration
    else:
        if not target.char:
            return False
        creature = target.char

        if not char.canreach(target.char, peace_range):
            char.socket.clilocmessage(500618, "", 0x3b2, 3)
        elif creature.npc and creature.hasscript('skills.peacemaking'):
            char.socket.clilocmessage(
                1049527)  # That creature is already being calmed.
        elif not char.checkskill(MUSICIANSHIP, 0, 1000):
            skills.musicianship.play_instrument(char, instrument, False)
            char.socket.clilocmessage(
                500612, "", 0x3b2,
                3)  # You play poorly, and there is no effect.
        else:
            # bard difficulty
            diff = skills.musicianship.GetDifficultyFor(
                char, instrument, creature) - 10.0
            music = char.skill[MUSICIANSHIP] / 10.0
            if music > 100.0:
                diff -= (music - 100.0) * 0.5

            result = char.checkskill(PEACEMAKING, diff - 25.0, diff + 25.0)
            skills.musicianship.play_instrument(char, instrument, result)
            if not result:
                char.socket.clilocmessage(
                    1049531, "", 0x3b2,
                    3)  # You attempt to calm your target, but fail.
                return True

            char.socket.clilocmessage(
                1049532)  # You play hypnotic music, calming your target.

            duration = 100 - (diff / 1.5)
            if duration > 120:
                duration = 120
            elif duration < 10:
                duration = 10
            # NPC
            if creature.npc:
                # stop combat
                # do not start combat for the duration while not attacked
                creature.addscript('skills.peacemaking')
                creature.addtimer(duration * 1000, release, [])
            # Player chars
            else:
                creature.socket.clilocmessage(
                    500616
                )  # You hear lovely music, and forget to continue battling!
                creature.war = False
                creature.attacktarget = None
                creature.updateflags()  # war is a flag, isn't it?
    return True
Beispiel #52
0
def target(player, arguments, target):
    # Check the green thorn first
    item = wolfpack.finditem(arguments[0])

    # Check if we have the item in our backpack
    if not item or item.getoutmostitem() != player.getbackpack():
        player.socket.clilocmessage(
            1042038)  # You must have the object in your backpack to use it.
        return

    # Check the green thorn delay
    if not checkUse(player):
        player.message(
            1061908
        )  # * You must wait a while before planting another thorn. *
        return

    # This check should only happen for solen hives
    if player.pos.map not in [0, 1]:
        player.message(
            tr("No solen lairs exist on this facet.  Try again in Trammel or Felucca."
               ), 0x2b2)
        return

    # Can we reach the target location?
    if not player.canreach(target.pos, 3):
        player.message(502825)  # That location is too far away
        return

    # Get the land-tile id at the given location
    landid = wolfpack.map(target.pos.x, target.pos.y, player.pos.map)['id']

    callback = None  # Callback for the green thorns effect

    # Check which effect should be used for the landtile type
    if landid in DIRT_TILES:
        callback = dirtCallback

    elif landid in FURROWS_TILES:
        callback = furrowsCallback

    elif landid in SWAMP_TILES:
        callback = swampCallback

    elif landid in SNOW_TILES:
        callback = snowCallback

    elif landid in SAND_TILES:
        callback = sandCallback

    if not callback:
        player.message(1061913)
    else:
        if item.amount <= 1:
            item.delete()
        else:
            item.amount -= 1
            item.update()

        # Show a message that we're planting a thorn
        player.socket.clilocmessage(
            1061914, "", 0x961, 3, player, "", False,
            True)  # * You push the strange green thorn into the ground *
        listeners = wolfpack.chars(player.pos.x, player.pos.y, player.pos.map,
                                   18)

        for listener in listeners:
            if listener != player and listener.socket:
                listener.socket.clilocmessage(
                    1061915, player.name, 0x961, 3, player, "", False, True
                )  # * ~1_PLAYER_NAME~ pushes a strange green thorn into the ground. *

        # Set the next use delay for this kind of item
        player.socket.settag('greenthorn_delay',
                             wolfpack.time.currenttime() + GREENTHORN_DELAY)

        # Start the effect
        player.addtimer(2500, callback, [target.pos, 0])
Beispiel #53
0
def stroke(char, arguments):
    strokes = arguments[0]

    # First: Check if the character disconnected
    # If he did, save the strokes and level and restore it later
    if char.player and not char.socket and char.logouttime == 0:
        if not char.hasscript('system.poison'):
            char.settag('poison_strokes', strokes)
            char.addscript('system.poison')
        return

    if not char.poison in POISONS:
        if char.poison != -1:
            char.poison = -1
            char.updateflags()
        return

    # Check for orange petals
    if char.hastag(
            'orangepetals') and char.poison <= ORANGEPETALS_RESIST_LEVEL:
        # Cure Poison
        if char.poison != -1:
            char.poison = -1
            char.updateflags()

        char.message(
            tr("* You feel yourself resisting the effects of the poison *"),
            0x3f)

        # Show to everyone else
        listeners = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 18)
        text = unicode(tr("* %s seems resistant to the poison *")) % unicode(
            char.name)

        for listener in listeners:
            if listener != char and listener.socket:
                listener.socket.showspeech(char, text, 0x3f)

        return

    poison = POISONS[char.poison]

    # Show a message if the cycle is ok
    if strokes % poison[7] == 0:
        chars = wolfpack.chars(char.pos.x, char.pos.y, char.pos.map, 18)
        for viewer in chars:
            if viewer.socket and viewer.cansee(char):
                if viewer != char:
                    viewer.socket.clilocmessage(1042858 + char.poison * 2,
                                                char.name, 34, 3, char)
                else:
                    viewer.socket.clilocmessage(1042857 + char.poison * 2, '',
                                                34, 3, char)

    dodamage(char, poison)

    # See if we should add another timer
    strokes += 1
    if strokes == poison[6]:
        if char.poison != -1:
            char.poison = -1
            char.updateflags()
        if char.socket:
            char.socket.clilocmessage(502136)
        return

    char.addtimer(poison[5], stroke, [strokes], 0, 0, "poison_timer")
Beispiel #54
0
def usehorn(char, firehorn, loc):
    if not checkuse(char, firehorn):
        return False

    char.socket.settag('firehorn_delay',
                       wolfpack.time.currenttime() + FIREHORN_DELAY)

    music = char.skill[MUSICIANSHIP]

    sucChance = 500 + (music - 775) * 2
    dSucChance = sucChance / 1000.0

    if not checksuccess(char, dSucChance):
        char.socket.clilocmessage(1049618)  # The horn emits a pathetic squeak.
        char.soundeffect(0x18a)
        return False

    char.useresource(AMOUNT, 0xf8c)

    char.soundeffect(0x15f)
    char.movingeffect(0x36d4, loc, 1, 0, 5)

    eable = wolfpack.chars(loc.x, loc.y, loc.map, RANGE)

    targets = []
    for mobile in eable:
        if mayAreaHarm(char, mobile, excludeself=True, includeinnocents=True):
            targets.append(mobile)
            playerVsPlayer = False
            if mobile.player:
                playerVsPlayer = True

    if len(targets) > 0:
        prov = char.skill[PROVOCATION] / 10
        entic = char.skill[ENTICEMENT] / 10
        peace = char.skill[PEACEMAKING] / 10

        minDamage = 0
        maxDamage = 0

        musicScaled = music + max(0, music - 900) * 2
        provScaled = prov + max(0, prov - 900) * 2
        enticScaled = entic + max(0, entic - 900) * 2
        peaceScaled = peace + max(0, peace - 900) * 2

        weightAvg = (musicScaled + provScaled * 3 + enticScaled * 3 +
                     peaceScaled) / 80

        avgDamage = 0
        if playerVsPlayer:
            avgDamage = weightAvg / 3
        else:
            avgDamage = weightAvg / 2

        minDamage = (avgDamage * 9) / 10
        maxDamage = (avgDamage * 10) / 9

        damage = random.randint(minDamage, maxDamage)

        if len(targets) > 1:
            damage = (damage * 2) / len(targets)

        for i in targets:
            if i.checkskill(MAGICRESISTANCE, 0, 1200):
                damage *= 0.5
                if i.socket:
                    i.socket.clilocmessage(
                        501783)  # You feel yourself resisting magical energy.
                if not i.attacktarget:
                    i.fight(char)
                i.damage(1, damage, char)
                i.effect(0x3709, 10, 30)
                i.say("tes")

    if random.random() < BREAK_CHANCE:
        char.socket.clilocmessage(
            1049619)  # The fire horn crumbles in your hands.
        firehorn.delete()
Beispiel #55
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # North/South
        if xdiff > ydiff:
            itemid = 0x3922
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x, target.y + i, target.z,
                                   target.map))

        # West/East
        else:
            itemid = 0x3915
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x + i, target.y, target.z,
                                   target.map))

        serials = []
        char.soundeffect(0x20c)

        total = (char.skill[MAGERY] + char.skill[POISONING]) / 2.0
        if total >= 1000:
            level = 3
        elif total > 850:
            level = 2
        elif total > 650:
            level = 1
        else:
            level = 0

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            #newitem.direction = 29
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.settag('dispellable_field', 1)
            newitem.settag('level', level)
            newitem.addscript('magic.poisonfield')
            newitem.update()
            serials.append(newitem.serial)

            # Affect chars who are occupying the field cells
            chars = wolfpack.chars(newitem.pos.x, newitem.pos.y,
                                   newitem.pos.map, 0)
            for affected in chars:
                if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
                    newitem.callevent(EVENT_COLLIDE, (affected, newitem))

        duration = int((3 + char.skill[MAGERY] / 25.0) * 1000)
        wolfpack.addtimer(duration, field_expire, serials, 1)