def potiondamage( char, target, potion, dmgbonus ):
	if potion.gettag('potiontype') == 11:
		damage = randint(POTION_LESSEREXPLOSION_RANGE[0], POTION_LESSEREXPLOSION_RANGE[1])
	elif potion.gettag('potiontype') == 12:
		damage = randint(POTION_EXPLOSION_RANGE[0], POTION_EXPLOSION_RANGE[1])
	elif potion.gettag('potiontype') == 13:
		damage = randint(POTION_GREATEREXPLOSION_RANGE[0], POTION_GREATEREXPLOSION_RANGE[1])
	else:
		damage = randint(POTION_LESSEREXPLOSION_RANGE[0], POTION_GREATEREXPLOSION_RANGE[1])
	if char.skill[ALCHEMY] == 1200:
		bonus = 10
	elif char.skill[ALCHEMY] >= 1100:
		bonus = randint(8,9)
	elif char.skill[ALCHEMY] >= 1000:
		bonus = randint(6,7)
	else:
		bonus = randint(0,5)
	if potion.amount > 1:
		damage = damage * potion.amount
	if dmgbonus > 1:
		damage = damage * dmgbonus
	damage += bonus
	if not potion.container:
		if char.distanceto(potion) > 1:
			damage = (damage / char.distanceto(potion))
	# Flamestrike effect
	if damage >= (target.maxhitpoints / 2):
		target.effect(0x3709, 10, 30)
	target.effect( explosions[randint(0,2)], 20, 10)
	energydamage(target, char, damage, fire=100 )
	return
    def hit(self, attacker, defender, damage):
        if not self.checkuse(attacker):
            return

        self.use(attacker)

        if defender.dead or defender.pos.map == 0xFF:
            return  # Out of reach

        if attacker.socket:
            attacker.socket.clilocmessage(1060090)  # You have delivered a crushing blow!
        if defender.socket:
            defender.socket.clilocmessage(1060091)  # You take extra damage from the crushing attack!

        defender.soundeffect(0x1E1)
        # defender.effect(0x377a, 1, 32)

        source = defender.pos
        target = defender.pos
        source.z += 50
        target.z += 20
        sendmovingeffect(source, target, model=0xFB4)

        amount = floor(0.5 * damage)
        if amount != 0:
            energydamage(defender, attacker, amount, physical=100, damagetype=DAMAGE_PHYSICAL)
	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 hit(self, attacker, defender, damage):
		if not self.checkuse(attacker):
			return

		# Clear Ability, then check if it really can be used
		clearability(attacker)
		
		if not defender.socket or not defender.itemonlayer(LAYER_MOUNT):
			if attacker.socket:
				attacker.socket.clilocmessage(1060848)
			return

		self.use(attacker) # Use Mana
		
		if attacker.socket:
			attacker.socket.clilocmessage(1060082)
			
		mounted = attacker.itemonlayer(LAYER_MOUNT)
		
		if mounted:
			defender.socket.clilocmessage(1062315)
		else:
			defender.socket.clilocmessage(1060083)
		
		defender.soundeffect(0x140)
		defender.effect(0x3728, 10, 15)
		
		defender.unmount()		

		# Make it impossible to mount a horse for 10 seconds
		defender.socket.settag('block_mount', wolfpack.currenttime() + 10000)
		
		if not mounted:
			energydamage(defender, attacker, random.randint(15, 25), physical=100, damagetype=DAMAGE_PHYSICAL)
Beispiel #5
0
    def hit(self, attacker, defender, damage):
        if not self.checkuse(attacker):
            return

        self.use(attacker)

        if defender.dead or defender.pos.map == 0xFF:
            return  # Out of reach

        if attacker.socket:
            attacker.socket.clilocmessage(
                1060090)  # You have delivered a crushing blow!
        if defender.socket:
            defender.socket.clilocmessage(
                1060091)  # You take extra damage from the crushing attack!

        defender.soundeffect(0x1e1)
        #defender.effect(0x377a, 1, 32)

        source = defender.pos
        target = defender.pos
        source.z += 50
        target.z += 20
        sendmovingeffect(source, target, model=0xfb4)

        amount = floor(0.5 * damage)
        if amount != 0:
            energydamage(defender,
                         attacker,
                         amount,
                         physical=100,
                         damagetype=DAMAGE_PHYSICAL)
Beispiel #6
0
    def cast(self, char, mode, args=[], target=None, item=None):
        if not self.consumerequirements(char, mode, args, target, item):
            return

        targets = []

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

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

            targets.append(target)

        char.soundeffect(0x212)
        char.soundeffect(0x206)
        char.effect(0x376A, 1, 29)
        char.effect(0x37C4, 1, 29)

        damage = ComputePowerValue(char, 10) + random.randint(0, 3)
        if damage < 8:
            damage = 8
        elif damage > 24:
            damage = 24

        for target in targets:
            energydamage(target, char, damage, 0, 0, 0, 0, 100)
	def cast(self, char, mode, args=[], target=None, item=None):
		if not self.consumerequirements(char, mode, args, target, item):
			return

		targets = []

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

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

			targets.append(target)

		char.soundeffect( 0x212 )
		char.soundeffect( 0x206 )
		char.effect(0x376A, 1, 29)
		char.effect(0x37C4, 1, 29)
		
		damage = ComputePowerValue( char, 10 ) + random.randint( 0, 3 )
		if damage < 8:
			damage = 8
		elif damage > 24:
			damage = 24

		for target in targets:
			energydamage(target, char, damage, 0, 0, 0, 0, 100)
Beispiel #8
0
def hit(attacker, defender, weapon, time):
	combat.utilities.playhitsound(attacker, defender)

	(mindamage, maxdamage) = properties.getdamage(attacker)

	damage = random.randint(mindamage, maxdamage)
	damage = scaledamage(attacker, damage)

	# Give the defender a chance to absorb damage
	damage = absorbdamage(defender, damage)

	# Get the damage distribution of the attackers weapon
	(physical, fire, cold, poison, energy) = damagetypes(attacker)
	energydamage(defender, attacker, damage, physical, fire, cold, poison, energy, 0, DAMAGE_PHYSICAL)

	# Wear out the weapon
	if weapon:
		# poisoning
		if weapon.hastag( 'poisoning_uses' ):
			poisoning.hitEffect( defender, weapon )
		# 4% chance for losing one hitpoint
		if 0.04 >= random.random():
			if weapon.health > 0:
				weapon.health -= 1
				weapon.resendtooltip()
		if weapon.health <= 0:
			tobackpack(weapon, attacker)
			weapon.update()
			if attacker.socket:
				attacker.socket.clilocmessage(500645)
Beispiel #9
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)
	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 #11
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)
	def damage(self, char, target):
		target.effect(0x374a, 10, 15)
		target.soundeffect(0x213)

		damage = min(60, int((char.skill[MAGERY] / 10.0 + char.intelligence) / 5.0))
		damage = random.randint(damage, damage + 4)
		energydamage(target, char, damage, cold=100)
Beispiel #13
0
    def damage(self, char, target):
        target.effect(0x374a, 10, 15)
        target.soundeffect(0x213)

        damage = min(
            60, int((char.skill[MAGERY] / 10.0 + char.intelligence) / 5.0))
        damage = random.randint(damage, damage + 4)
        energydamage(target, char, damage, cold=100)
Beispiel #14
0
def splashdamage(attacker, effect, excludechar=None):
    (physical, cold, fire, poison, energy) = (0, 0, 0, 0, 0)

    if effect == SPLASHPHYSICAL:
        sound = 0x10e
        hue = 50
        physical = 100
    elif effect == SPLASHFIRE:
        sound = 0x11d
        hue = 1160
        fire = 100
    elif effect == SPLASHCOLD:
        sound = 0xfc
        hue = 2100
        cold = 100
    elif effect == SPLASHPOISON:
        sound = 0x205
        hue = 1166
        poison = 100
    elif effect == SPLASHENERGY:
        sound = 0x1f1
        hue = 120
        energy = 100
    else:
        raise RuntimeError, "Invalid effect passed to splashdamage: %s" % effect

    guild = attacker.guild  # Cache the guild
    party = attacker.guild  # Cache the party
    didsound = False  # Did we play a soundeffect yet?
    (mindamage,
     maxdamage) = properties.getdamage(attacker)  # Cache the min+maxdamage

    pos = attacker.pos
    chariterator = wolfpack.charregion(pos.x - 3, pos.y - 3, pos.x + 3,
                                       pos.y + 3, pos.map)
    target = chariterator.first
    while target:
        if attacker != target and excludechar != target and mayAreaHarm(
                attacker, target):
            tpos = target.pos

            # Calculate the real distance between the two characters
            distance = sqrt((pos.x - tpos.x) * (pos.x - tpos.x) +
                            (pos.y - tpos.y) * (pos.y - tpos.y))
            factor = min(1.0, (4 - distance) / 3)
            if factor > 0.0:
                damage = int(random.randint(mindamage, maxdamage) * factor)

                if damage > 0:
                    if not didsound:
                        attacker.soundeffect(sound)
                        didsound = True
                    target.effect(0x3779, 1, 15, hue)
                    energydamage(target, attacker, damage, physical, fire,
                                 cold, poison, energy, 0, DAMAGE_MAGICAL)

        target = chariterator.next
Beispiel #15
0
    def damage(self, char, target):
        distance = target.distanceto(char)
        damage = self.scaledamage(char, target, 17, 1, 5)

        if distance > 2:
            damage = max(1, damage * 0.25)
        elif distance == 2:
            damage = max(1, damage * 0.5)

        energydamage(target, char, damage, cold=100)
        target.effect(0x374a, 10, 30)
	def damage(self, char, target):
		distance = target.distanceto(char)
		damage = self.scaledamage(char, target, 17, 1, 5)

		if distance > 2:
			damage = max(1, damage * 0.25)
		elif distance == 2:
			damage = max(1, damage * 0.5)

		energydamage(target, char, damage, cold=100)
		target.effect(0x374a, 10, 30)
Beispiel #17
0
def splashdamage(attacker, effect):
	(physical, cold, fire, poison, energy) = (0, 0, 0, 0, 0)
	
	if effect == SPLASHPHYSICAL:
		sound = 0x10e
		hue = 50
		physical = 100
	elif effect == SPLASHFIRE:
		sound = 0x11d
		hue = 1160
		fire = 100
	elif effect == SPLASHCOLD:
		sound = 0xfc
		hue = 2100
		cold = 100
	elif effect == SPLASHPOISON:
		sound = 0x205
		hue = 1166
		poison = 100
	elif effect == SPLASHENERGY:
		sound = 0x1f1
		hue = 120
		energy = 100
	else:
		raise RuntimeError, "Invalid effect passed to splashdamage: %s" % effect
		
	guild = attacker.guild # Cache the guild
	party = attacker.guild # Cache the party
	didsound = False # Did we play a soundeffect yet?
	(mindamage, maxdamage) = properties.getdamage(attacker) # Cache the min+maxdamage
	
	pos = attacker.pos
	chariterator = wolfpack.charregion(pos.x - 10, pos.y - 10, pos.x + 10, pos.y + 10, pos.map)
	target = chariterator.first
	while target:
		if attacker != target and (not party or party != target.party) and (not guild or guild != target.guild):
			if not target.dead and not target.invulnerable and not target.invisible and not target.hidden:
				tpos = target.pos

				# Calculate the real distance between the two characters				
				distance = sqrt((pos.x - tpos.x) * (pos.x - tpos.x) + (pos.y - tpos.y) * (pos.y - tpos.y))
				factor = min(1.0, (11 - distance) / 10)
				if factor > 0.0:
					damage = int(random.randint(mindamage, maxdamage) * factor)
					
					if damage > 0:
						if not didsound:
							attacker.soundeffect(sound)
							didsound = True
						target.effect(0x3779, 1, 15, hue)
						energydamage(target, attacker, damage, physical, fire, cold, poison, energy, 0, DAMAGE_MAGICAL)

		target = chariterator.next
def onCollide(char, item):
	if char.dead or char.invulnerable:
		return

	if not char.hastag( 'in_firefield' ):
		source = None
		if item.hastag('source'):
			source = wolfpack.findchar( int( item.gettag('source') ) )

		char.settag( 'in_firefield', 1)
		energydamage( char, source, 2, fire=100 )
		char.addtimer( 350, expire, [] )
	return 0
Beispiel #19
0
def onCollide(char, item):
    if char.dead or char.invulnerable or char.region.safe:
        return

    if not char.hastag('in_firefield'):
        source = None
        if item.hastag('source'):
            source = wolfpack.findchar(int(item.gettag('source')))

        char.settag('in_firefield', 1)
        energydamage(char, source, 2, fire=100)
        char.addtimer(350, expire, [])
    return 0
def hitharm(attacker, defender):
	if defender.invulnerable or defender.dead or defender.invisible or defender.hidden:
		return

	damage = scaledamage(attacker, 6, 9, 0.015)
	distance = defender.distanceto(attacker)
	
	if distance > 2:
		damage /= 4
	elif distance > 1:
		damage /= 2

	defender.effect(0x374a, 10, 30)
	defender.soundeffect(0xfc)

	energydamage(defender, attacker, damage, 0, 0, 100, 0, 0, 0, DAMAGE_MAGICAL)
Beispiel #21
0
def hitharm(attacker, defender):
	if defender.invulnerable or defender.dead or defender.invisible or defender.hidden or defender.region.safe:
		return

	damage = scaledamage(attacker, 6, 9, 0.015)
	distance = defender.distanceto(attacker)
	
	if distance > 2:
		damage /= 4
	elif distance > 1:
		damage /= 2

	defender.effect(0x374a, 10, 30)
	defender.soundeffect(0xfc)

	energydamage(defender, attacker, damage, 0, 0, 100, 0, 0, 0, DAMAGE_MAGICAL)
Beispiel #22
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 #23
0
def expire(char, arguments):
    if char.dead:
        char.deltag('in_firefield')
        return

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

    for item in items:
        if item.hasscript('magic.firefield'):
            source = None
            if item.hastag('source'):
                source = wolfpack.findchar(int(item.gettag('source')))

            energydamage(char, source, 2, fire=100)
            char.addtimer(350, expire, [])
            char.soundeffect(0x208)
            return

    char.deltag('in_firefield')
def expire(char, arguments):
	if char.dead :
		char.deltag( 'in_firefield' )
		return

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

	for item in items:
		if item.hasscript( 'magic.firefield' ):
			source = None
			if item.hastag('source'):
				source = wolfpack.findchar( int( item.gettag('source') ) )

			energydamage(char, source, 2, fire=100)
			char.addtimer(350, expire, [])
			char.soundeffect(0x208)
			return

	char.deltag( 'in_firefield' )
Beispiel #25
0
def onUse(char, item):
    try:
        type = item.gettag('trap_type')
        damage = item.gettag('trap_damage')
        owner = wolfpack.findchar(int(item.gettag('trap_owner')))
    except:
        item.removescript('magic.trap')
        item.deltag('trap_type')
        item.deltag('trap_damage')
        item.deltag('trap_owner')
        return 0

    item.removescript('magic.trap')
    item.deltag('trap_type')
    item.deltag('trap_damage')
    item.deltag('trap_owner')

    char.message(502999)

    if not item.container:
        pos = item.pos
    else:
        item = item.getoutmostitem()
        if item.container:
            item = item.container
    pos = item.pos

    wolfpack.effect(0x36bd, wolfpack.coord(pos.x + 1, pos.y, pos.z, pos.map),
                    15, 15)
    wolfpack.effect(0x36bd, wolfpack.coord(pos.x, pos.y - 1, pos.z, pos.map),
                    15, 15)
    wolfpack.effect(0x36bd, wolfpack.coord(pos.x - 1, pos.y, pos.z, pos.map),
                    15, 15)
    wolfpack.effect(0x36bd, wolfpack.coord(pos.x, pos.y + 1, pos.z, pos.map),
                    15, 15)
    char.soundeffect(0x307)

    # Now Damage the Character
    if char.distanceto(item) <= 2:
        energydamage(char, owner, damage, fire=100)

    return 1
Beispiel #26
0
    def hit(self, attacker, defender, damage):
        if not self.checkuse(attacker):
            return

        # Clear Ability, then check if it really can be used
        clearability(attacker)

        if defender.dead or defender.pos.map == 0xFF:
            return  # Out of reach

        if not defender.socket or not defender.ismounted():
            if attacker.socket:
                attacker.socket.clilocmessage(1060848)
            return

        self.use(attacker)  # Use Mana

        if attacker.socket:
            attacker.socket.clilocmessage(1060082)

        mounted = attacker.ismounted()

        if mounted:
            defender.socket.clilocmessage(1062315)
        else:
            defender.socket.clilocmessage(1060083)

        defender.soundeffect(0x140)
        defender.effect(0x3728, 10, 15)

        defender.unmount()

        # Make it impossible to mount a horse for 10 seconds
        defender.socket.settag('block_mount',
                               wolfpack.time.currenttime() + 10000)

        if not mounted:
            energydamage(defender,
                         attacker,
                         random.randint(15, 25),
                         physical=100,
                         damagetype=DAMAGE_PHYSICAL)
    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)
	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)
	def damage(self, char, target):
		target.effect(0x3709, 10, 30)
		target.soundeffect(0x208)
		damage = self.scaledamage(char, target, 48, 1, 5)
		energydamage(target, char, damage, fire=100)
Beispiel #30
0
 def damage(self, char, target):
     target.effect(0x3709, 10, 30)
     target.soundeffect(0x208)
     damage = self.scaledamage(char, target, 48, 1, 5)
     energydamage(target, char, damage, fire=100)
Beispiel #31
0
    def damage(self, char, target):
        target.lightning()
        target.soundeffect(0x29)

        damage = self.scaledamage(char, target, 22, 1, 4)
        energydamage(target, char, damage, energy=100)
Beispiel #32
0
def dodamage(char, poison):
    damage = 1 + int(char.hitpoints * poison[3])
    damage = min(poison[2], max(poison[1], damage))
    energydamage(char, None, damage, poison=100)
Beispiel #33
0
def hit(attacker, defender, weapon, time):
	combat.utilities.playhitsound(attacker, defender)

	(mindamage, maxdamage) = properties.getdamage(attacker)

	damage = random.randint(mindamage, maxdamage)
	damage = scaledamage(attacker, damage, checkability = True)

	# Slaying? (only against NPCs)
	if weapon and defender.npc and checkSlaying(weapon, defender):
		defender.effect(0x37B9, 5, 10)
		damage *= 2

	# Get the ability used by the attacker
	ability = getability(attacker)
	
	# Scale Damage using a weapons ability
	if ability:
		damage = ability.scaledamage(attacker, defender, damage)

	# Enemy of One (chivalry)
	if attacker.npc:
		if defender.player:
			if defender.hastag( "enemyofonetype" ) and defender.gettag( "enemyofonetype" ) != attacker.id:
				damage *= 2
	if defender.npc: # only NPC
		if attacker.player:
			if attacker.hastag( "waitingforenemy" ):
				attacker.settag( "enemyofonetype", defender.id )
				attacker.deltag( "waitingforenemy" )
			if attacker.hastag( "enemyofonetype" ) and attacker.gettag( "enemyofonetype" ) == defender.id:
				defender.effect( 0x37B9, 10, 5 )
				damage += scaledamage(attacker, 50 )

	packInstinctBonus = GetPackInstinctBonus( attacker, defender )
	if packInstinctBonus:
		damage += scaledamage(attacker, packInstinctBonus)

	slayer = properties.fromitem(weapon, SLAYER)
	if slayer and slayer == "silver" and magic.necromancy.transformed(defender) and not defender.hasscript("magic.horrificbeast"):
		damage += scaledamage(attacker, 25 ) # Every necromancer transformation other than horrific beast takes an additional 25% damage

	# Give the defender a chance to absorb damage
	damage = absorbdamage(defender, damage)
	blocked = damage <= 0

	# If the attack was parried, the ability was wasted
	if AGEOFSHADOWS and blocked:
		if attacker.socket:
			attacker.socket.clilocmessage(1061140) # Your attack was parried
		clearability(attacker)

	ignorephysical = False
	if ability:
		ignorephysical = ability.ignorephysical

	# Get the damage distribution of the attackers weapon
	(physical, fire, cold, poison, energy) = damagetypes(attacker, defender)
	damagedone = energydamage(defender, attacker, damage, physical, fire, cold, poison, energy, 0, DAMAGE_PHYSICAL, ignorephysical=ignorephysical)

	# Wear out the weapon
	if weapon:
		# Leeching
		if not blocked:
			# Making default Leechs to prevent errors

			lifeleech = 0
			staminaleech = 0
			manaleech = 0

			leech = properties.fromitem(weapon, LIFELEECH)
			if leech and leech > random.randint(0, 99) and attacker.maxhitpoints > attacker.hitpoints:
				lifeleech = (damagedone * 30) / 100 # Leech 30% Health

			leech = properties.fromitem(weapon, STAMINALEECH)
			if leech and leech > random.randint(0, 99) and attacker.maxhitpoints > attacker.stamina:
				staminaleech = (damagedone * 100) / 100 # Leech 100% Stamina

			leech = properties.fromitem(weapon, MANALEECH)
			if leech and leech > random.randint(0, 99) and attacker.maxmana > attacker.mana:
				manaleech = (damagedone * 40) / 100 # Leech 40% Mana

			# Now leech life, stamina and mana
			if lifeleech > 0:
				attacker.hitpoints = min(attacker.maxhitpoints, attacker.hitpoints + lifeleech)
				attacker.updatehealth()

			if staminaleech > 0:
				attacker.stamina = min(attacker.maxstamina, attacker.stamina + staminaleech)
				attacker.updatehealth()

			if manaleech > 0:
				attacker.mana = min(attacker.maxmana, attacker.mana + manaleech)
				attacker.updatemana()

			# Poisoning (50% chance)
			if weapon.hastag('poisoning_uses'):
				poisoning_uses = int(weapon.gettag('poisoning_uses'))
				if poisoning_uses <= 0:
					weapon.deltag('poisoning_uses')
					weapon.resendtooltip()
				else:
					poisoning_uses -= 1
					if poisoning_uses <= 0:
						weapon.deltag('poisoning_uses')
						weapon.resendtooltip()
					else:
						weapon.settag('poisoning_uses', poisoning_uses)

					poisoning_strength = 0 # Assume lesser unless the tag tells so otherwise
					if weapon.hastag('poisoning_strength'):
						poisoning_strength = int(weapon.gettag('poisoning_strength'))
					if defender.hasscript("magic.evilomen") and poisoning_strength < 4:
						poisoning_strength += 1
					if random.random() >= 0.50:
						if system.poison.poison(defender, poisoning_strength):
							if attacker.socket:
								attacker.socket.clilocmessage(1008096, "", 0x3b2, 3, None, defender.name, False, False)
							if defender.socket:
								attacker.socket.clilocmessage(1008097, "", 0x3b2, 3, None, attacker.name, False, True)

			# Splash Damage
			for effectid in [SPLASHPHYSICAL, SPLASHFIRE, SPLASHCOLD, SPLASHPOISON, SPLASHENERGY]:
				effect = properties.fromitem(weapon, effectid)
				if effect and effect > random.randint(0, 99):
					splashdamage(attacker, effectid, excludechar = defender)

			# Hit Spell effects
			for (effectid, callback) in combat.hiteffects.EFFECTS.items():
				effect = properties.fromitem(weapon, effectid)
				if effect and effect > random.randint(0, 99):
					callback(attacker, defender)

		# Slime or Toxic Elemental, 4% chance for losing one hitpoint
		if weapon.maxhealth > 0 and ( (weapon.getintproperty( 'range', 1 ) <= 1 and (defender.id == 51 or defender.id == 158)) or 0.04 >= random.random() ):
			if (weapon.getintproperty( 'range', 1 ) <= 1 and (defender.id == 51 or defender.id == 158)):
				attacker.message( 500263, '' ) # *Acid blood scars your weapon!*

			# If it's a self repairing item, grant health instead of reducing it
			selfrepair = properties.fromitem(weapon, SELFREPAIR)
			if AGEOFSHADOWS and selfrepair > 0:
				if selfrepair > random.randint(0, 9):
					weapon.health += 2
					weapon.resendtooltip()
			else:
				if weapon.health > 0:
					weapon.health -= 1
				elif weapon.maxhealth > 1:
					weapon.maxhealth -= 1
					attacker.message( 1061121, '' ) # Your equipment is severely damaged.
				else:
					weapon.delete()
				if weapon:
					weapon.resendtooltip()

		#if weapon.health <= 0:
		#	tobackpack(weapon, attacker)
		#	weapon.update()
		#	if attacker.socket:
		#		attacker.socket.clilocmessage(500645)

	# Notify the weapon ability
	if not blocked and ability:
		ability.hit(attacker, defender, damage)
def hitlightning(attacker, defender):
	if defender.invulnerable or defender.dead or defender.invisible or defender.hidden:
		return

	defender.lightning()
	energydamage(defender, attacker, scaledamage(attacker, 6, 9, 0.02), 0, 0, 0, 0, 100, 0, DAMAGE_MAGICAL)
Beispiel #35
0
def damage_callback(defender, args):
	(attacker, damage) = (wolfpack.findchar(args[0]), args[1])
	if attacker and defender and not defender.invulnerable and not defender.dead and not defender.invisible and not defender.hidden and not defender.region.safe:
		energydamage(defender, attacker, damage, 0, 100, 0, 0, 0, 0, DAMAGE_MAGICAL)
Beispiel #36
0
def hitlightning(attacker, defender):
	if defender.invulnerable or defender.dead or defender.invisible or defender.hidden or defender.region.safe:
		return

	defender.lightning()
	energydamage(defender, attacker, scaledamage(attacker, 6, 9, 0.02), 0, 0, 0, 0, 100, 0, DAMAGE_MAGICAL)
Beispiel #37
0
def hit(attacker, defender, weapon, time):
    combat.utilities.playhitsound(attacker, defender)

    (mindamage, maxdamage) = properties.getdamage(attacker)

    damage = random.randint(mindamage, maxdamage)
    damage = scaledamage(attacker, damage, checkability=True)

    # Slaying? (only against NPCs)
    if weapon and defender.npc and checkSlaying(weapon, defender):
        defender.effect(0x37B9, 5, 10)
        damage *= 2

    # Get the ability used by the attacker
    ability = getability(attacker)

    # Scale Damage using a weapons ability
    if ability:
        damage = ability.scaledamage(attacker, defender, damage)

    # Enemy of One (chivalry)
    if attacker.npc:
        if defender.player:
            if defender.hastag("enemyofonetype") and defender.gettag(
                    "enemyofonetype") != attacker.id:
                damage *= 2
    if defender.npc:  # only NPC
        if attacker.player:
            if attacker.hastag("waitingforenemy"):
                attacker.settag("enemyofonetype", defender.id)
                attacker.deltag("waitingforenemy")
            if attacker.hastag("enemyofonetype") and attacker.gettag(
                    "enemyofonetype") == defender.id:
                defender.effect(0x37B9, 10, 5)
                damage += scaledamage(attacker, 50)

    packInstinctBonus = GetPackInstinctBonus(attacker, defender)
    if packInstinctBonus:
        damage += scaledamage(attacker, packInstinctBonus)

    slayer = properties.fromitem(weapon, SLAYER)
    if slayer and slayer == "silver" and magic.necromancy.transformed(
            defender) and not defender.hasscript("magic.horrificbeast"):
        damage += scaledamage(
            attacker, 25
        )  # Every necromancer transformation other than horrific beast takes an additional 25% damage

    # Give the defender a chance to absorb damage
    damage = absorbdamage(defender, damage)
    blocked = damage <= 0

    # If the attack was parried, the ability was wasted
    if AGEOFSHADOWS and blocked:
        if attacker.socket:
            attacker.socket.clilocmessage(1061140)  # Your attack was parried
        clearability(attacker)

    ignorephysical = False
    if ability:
        ignorephysical = ability.ignorephysical

    # Get the damage distribution of the attackers weapon
    (physical, fire, cold, poison, energy) = damagetypes(attacker, defender)
    damagedone = energydamage(defender,
                              attacker,
                              damage,
                              physical,
                              fire,
                              cold,
                              poison,
                              energy,
                              0,
                              DAMAGE_PHYSICAL,
                              ignorephysical=ignorephysical)

    # Wear out the weapon
    if weapon:
        # Leeching
        if not blocked:
            # Making default Leechs to prevent errors

            lifeleech = 0
            staminaleech = 0
            manaleech = 0

            leech = properties.fromitem(weapon, LIFELEECH)
            if leech and leech > random.randint(
                    0, 99) and attacker.maxhitpoints > attacker.hitpoints:
                lifeleech = (damagedone * 30) / 100  # Leech 30% Health

            leech = properties.fromitem(weapon, STAMINALEECH)
            if leech and leech > random.randint(
                    0, 99) and attacker.maxhitpoints > attacker.stamina:
                staminaleech = (damagedone * 100) / 100  # Leech 100% Stamina

            leech = properties.fromitem(weapon, MANALEECH)
            if leech and leech > random.randint(
                    0, 99) and attacker.maxmana > attacker.mana:
                manaleech = (damagedone * 40) / 100  # Leech 40% Mana

            # Now leech life, stamina and mana
            if lifeleech > 0:
                attacker.hitpoints = min(attacker.maxhitpoints,
                                         attacker.hitpoints + lifeleech)
                attacker.updatehealth()

            if staminaleech > 0:
                attacker.stamina = min(attacker.maxstamina,
                                       attacker.stamina + staminaleech)
                attacker.updatehealth()

            if manaleech > 0:
                attacker.mana = min(attacker.maxmana,
                                    attacker.mana + manaleech)
                attacker.updatemana()

            # Poisoning (50% chance)
            if weapon.hastag('poisoning_uses'):
                poisoning_uses = int(weapon.gettag('poisoning_uses'))
                if poisoning_uses <= 0:
                    weapon.deltag('poisoning_uses')
                    weapon.resendtooltip()
                else:
                    poisoning_uses -= 1
                    if poisoning_uses <= 0:
                        weapon.deltag('poisoning_uses')
                        weapon.resendtooltip()
                    else:
                        weapon.settag('poisoning_uses', poisoning_uses)

                    poisoning_strength = 0  # Assume lesser unless the tag tells so otherwise
                    if weapon.hastag('poisoning_strength'):
                        poisoning_strength = int(
                            weapon.gettag('poisoning_strength'))
                    if defender.hasscript(
                            "magic.evilomen") and poisoning_strength < 4:
                        poisoning_strength += 1
                    if random.random() >= 0.50:
                        if system.poison.poison(defender, poisoning_strength):
                            if attacker.socket:
                                attacker.socket.clilocmessage(
                                    1008096, "", 0x3b2, 3, None, defender.name,
                                    False, False)
                            if defender.socket:
                                attacker.socket.clilocmessage(
                                    1008097, "", 0x3b2, 3, None, attacker.name,
                                    False, True)

            # Splash Damage
            for effectid in [
                    SPLASHPHYSICAL, SPLASHFIRE, SPLASHCOLD, SPLASHPOISON,
                    SPLASHENERGY
            ]:
                effect = properties.fromitem(weapon, effectid)
                if effect and effect > random.randint(0, 99):
                    splashdamage(attacker, effectid, excludechar=defender)

            # Hit Spell effects
            for (effectid, callback) in combat.hiteffects.EFFECTS.items():
                effect = properties.fromitem(weapon, effectid)
                if effect and effect > random.randint(0, 99):
                    callback(attacker, defender)

        # Slime or Toxic Elemental, 4% chance for losing one hitpoint
        if weapon.maxhealth > 0 and (
            (weapon.getintproperty('range', 1) <= 1 and
             (defender.id == 51 or defender.id == 158))
                or 0.04 >= random.random()):
            if (weapon.getintproperty('range', 1) <= 1
                    and (defender.id == 51 or defender.id == 158)):
                attacker.message(500263, '')  # *Acid blood scars your weapon!*

            # If it's a self repairing item, grant health instead of reducing it
            selfrepair = properties.fromitem(weapon, SELFREPAIR)
            if AGEOFSHADOWS and selfrepair > 0:
                if selfrepair > random.randint(0, 9):
                    weapon.health += 2
                    weapon.resendtooltip()
            else:
                if weapon.health > 0:
                    weapon.health -= 1
                elif weapon.maxhealth > 1:
                    weapon.maxhealth -= 1
                    attacker.message(1061121,
                                     '')  # Your equipment is severely damaged.
                else:
                    weapon.delete()
                if weapon:
                    weapon.resendtooltip()

        #if weapon.health <= 0:
        #	tobackpack(weapon, attacker)
        #	weapon.update()
        #	if attacker.socket:
        #		attacker.socket.clilocmessage(500645)

    # Notify the weapon ability
    if not blocked and ability:
        ability.hit(attacker, defender, damage)
Beispiel #38
0
 def damage(self, char, target):
     damage = self.scaledamage(char, target, 10, 1, 4)
     energydamage(target, char, damage, fire=100)
	def damage(self, char, target):
		damage = self.scaledamage(char, target, 38, 1, 5)
		energydamage(target, char, damage, energy=100)
Beispiel #40
0
def dodamage(char, poison):
	damage = 1 + int(char.hitpoints * poison[3])
	damage = min(poison[2], max(poison[1], damage))
	energydamage(char, None, damage, poison=100)
	def damage(self, char, target):
		target.soundeffect(0x307)
		target.effect(0x36BD, 20, 10)
		damage = self.scaledamage(char, target, 38, 1, 5)
		energydamage(target, char, damage, fire=100)
Beispiel #42
0
 def damage(self, char, target):
     target.soundeffect(0x307)
     target.effect(0x36BD, 20, 10)
     damage = self.scaledamage(char, target, 38, 1, 5)
     energydamage(target, char, damage, fire=100)
Beispiel #43
0
def hit(attacker, defender, weapon, time):
	combat.utilities.playhitsound(attacker, defender)

	(mindamage, maxdamage) = properties.getdamage(attacker)

	damage = random.randint(mindamage, maxdamage)
	damage = scaledamage(attacker, damage, checkability = True)

	# Slaying? (only against NPCs)
	if weapon and defender.npc and checkSlaying(weapon, defender):
		defender.effect(0x37B9, 5, 10)
		damage *= 2

	# Get the ability used by the attacker
	ability = getability(attacker)
	
	# Scale Damage using a weapons ability
	if ability:
		damage = ability.scaledamage(attacker, defender, damage)

	# Give the defender a chance to absorb damage
	damage = absorbdamage(defender, damage)
	
	# If the attack was parried, the ability was wasted
	if damage == 0 and ability:
		ability.use(attacker)
		if attacker.socket:
			attacker.socket.clilocmessage(1061140) # Your attack was parried
		ability = None # Reset ability

	ignorephysical = False
	if ability:
		ignorephysical = ability.ignorephysical

	# Get the damage distribution of the attackers weapon
	(physical, fire, cold, poison, energy) = damagetypes(attacker)
	damagedone = energydamage(defender, attacker, damage, physical, fire, cold, poison, energy, 0, DAMAGE_PHYSICAL, ignorephysical=ignorephysical)

	# Wear out the weapon
	if weapon:
		# Leeching
		leech = properties.fromitem(weapon, LIFELEECH)
		if leech and leech > random.randint(0, 99) and attacker.maxhitpoints > attacker.hitpoints:
			amount = (damagedone * 30) / 100 # Leech 30% Health
			if amount > 0:
				attacker.hitpoints = min(attacker.maxhitpoints, attacker.hitpoints + amount)
				attacker.updatehealth()
			
		leech = properties.fromitem(weapon, STAMINALEECH)
		if leech and leech > random.randint(0, 99) and attacker.maxhitpoints > attacker.stamina:
			amount = (damagedone * 100) / 100 # Leech 100% Stamina
			if amount > 0:
				attacker.stamina = min(attacker.maxstamina, attacker.stamina + amount)
				attacker.updatehealth()

		leech = properties.fromitem(weapon, MANALEECH)
		if leech and leech > random.randint(0, 99) and attacker.maxmana > attacker.mana:
			amount = (damagedone * 40) / 100 # Leech 40% Mana
			if amount > 0:
				attacker.mana = min(attacker.maxmana, attacker.mana + amount)
				attacker.updatemana()

		# Splash Damage
		for effectid in [SPLASHPHYSICAL, SPLASHFIRE, SPLASHCOLD, SPLASHPOISON, SPLASHENERGY]:
			effect = properties.fromitem(weapon, effectid)
			if effect and effect > random.randint(0, 99):
				splashdamage(attacker, effectid)
				
		# Hit Spell effects
		for (effectid, callback) in combat.hiteffects.EFFECTS.items():
			effect = properties.fromitem(weapon, effectid)
			if effect and effect > random.randint(0, 99):
				callback(attacker, defender)

		# poisoning doesn't work that way anymore
		#if weapon.hastag( 'poisoning_uses' ):
		#	poisoning.hitEffect( defender, weapon )
		
		# 4% chance for losing one hitpoint
		if 0.04 >= random.random():
			# If it's a self repairing item, grant health instead of reducing it
			selfrepair = properties.fromitem(weapon, SELFREPAIR)
			if selfrepair > 0 and weapon.health < weapon.maxhealth - 1:
				if selfrepair > random.randint(0, 9):
					weapon.health += 2
					weapon.resendtooltip()
			elif weapon.health > 0:
				weapon.health -= 1
				weapon.resendtooltip()
		if weapon.health <= 0:
			tobackpack(weapon, attacker)
			weapon.update()
			if attacker.socket:
				attacker.socket.clilocmessage(500645)
	
	# Notify the weapon ability
	if ability:
		ability.hit(attacker, defender, damage)
Beispiel #44
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

	# 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)

	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], stroke, [strokes], 0, 0, "poison_timer")
def damage_callback(defender, args):
	(attacker, damage) = (wolfpack.findchar(args[0]), args[1])
	if attacker and defender and not defender.invulnerable and not defender.dead and not defender.invisible and not defender.hidden:
		energydamage(defender, attacker, damage, 0, 100, 0, 0, 0, 0, DAMAGE_MAGICAL)
	def damage(self, char, target):
		target.lightning()
		target.soundeffect(0x29)

		damage = self.scaledamage(char, target, 22, 1, 4)
		energydamage(target, char, damage, energy=100)
	def damage(self, char, target):
		damage = self.scaledamage(char, target, 19, 1, 5)
		energydamage(target, char, damage, fire=100)
Beispiel #48
0
 def damage(self, char, target):
     damage = self.scaledamage(char, target, 38, 1, 5)
     energydamage(target, char, damage, energy=100)