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)
def onShowStatus(char, packet): damagebonus = properties.fromchar(char, DAMAGEBONUS) # Get weapon properties if applicable (mindamage, maxdamage) = properties.getdamage(char) # Scale damage mindamage = int(combat.aos.scaledamage(char, mindamage, 0)) maxdamage = int(combat.aos.scaledamage(char, maxdamage, 0)) packet.setshort(62, properties.fromchar( char, RESISTANCE_PHYSICAL)) # Physical resistance packet.setshort(70, properties.fromchar(char, RESISTANCE_FIRE)) # Fire Resistance packet.setshort(72, properties.fromchar(char, RESISTANCE_COLD)) # Cold Resistance packet.setshort(74, properties.fromchar( char, RESISTANCE_POISON)) # Poison Resistance packet.setshort(76, properties.fromchar( char, RESISTANCE_ENERGY)) # Energy Resistance packet.setshort(78, properties.fromchar(char, LUCK)) # Luck packet.setshort(80, mindamage) # Min. Damage packet.setshort(82, maxdamage) # Max. Damage if char.hastag('tithing_points'): packet.setint(84, char.gettag('tithing_points')) # Tithing Points else: packet.setint(84, 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
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 onShowStatus(char, packet): damagebonus = properties.fromchar(char, DAMAGEBONUS) # Get weapon properties if applicable (mindamage, maxdamage) = properties.getdamage(char) # Scale damage mindamage = int(combat.aos.scaledamage(char, mindamage, 0)) maxdamage = int(combat.aos.scaledamage(char, maxdamage, 0)) packet.setshort(62, properties.fromchar(char, RESISTANCE_PHYSICAL)) # Physical resistance packet.setshort(70, properties.fromchar(char, RESISTANCE_FIRE)) # Fire Resistance packet.setshort(72, properties.fromchar(char, RESISTANCE_COLD)) # Cold Resistance packet.setshort(74, properties.fromchar(char, RESISTANCE_POISON)) # Poison Resistance packet.setshort(76, properties.fromchar(char, RESISTANCE_ENERGY)) # Energy Resistance packet.setshort(78, 0) # Luck packet.setshort(80, mindamage) # Min. Damage packet.setshort(82, maxdamage) # Max. Damage
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)
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 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)