Code:
[comment EA_slayer_damage_system]
Author: Patrick Bradshaw (Developer: Khaos)
Version: 1.2
NPC Side controlled slayer damage to consume less resources in combat with slayer damage.
Script checks to make sure players have slayer flags equipped in their slayer/super slayer/misc slayer variables and check against the enemies variables.
If these variables match the slayer damage token rises. This caps out at 3 with a check in the slayer_damage function (per EA handling). Ea says misc
and lesser don't stack; but that is redundant with a 300% cap anyhow and the checks within the script make sure you don't surpass this cap.
Items must contain the slayer flags for the player to equip. This in turn gets added to the player. So this does force OSI/EA standards of needing the item
equipped to get the benefits of the slayer damage or the bane of the opposing slayers.
NPCs need the slayer flag added to their character variables as well. Make sure they are set using the naming schema or the flag #.
There are additional functions added in case you might need them. ISSLAYER_LESSER, ISSLAYER_SUPER, ISSLAYER_MISC.
Updates:
Switched @Equip to @ItemEquip.
Fixed typo in first @ItemEquip check with calling slayer instead of slayerlesser.
Added calls for lesser slayers in the opposed aligned slayers. It is speculated they work in this fashion.
Added chance to hit. Nothing is specified how often this fires off. There is now a controlling def. Use 0 - 100. 100 there will be no check and always hits. 0 always fails.
Variables used on items and chars:
SLAYERLESSER
SLAYERSUPER
SLAYERMISC
[defname slayer_damage_control]
// Damage control
slayer_dam_l 3 // Lesser Slayer damage.
slayer_dam_s 2 // Super slayer damage.
slayer_dam_m 2 // Misc slayer damage (Talisman).
slayer_dam_o 2 // opposite aligned damage.
slayer_hit_ratio 100 // chance to hit with a slayer 100 always hits. Anything less and we will perform a test to hit.
// Attach to your players.
// Adds slayer flag info from an item to char.
[events e_slayers_pchars]
on=@ItemEquip
if (<act.slayerless> > 0)
slayerlesser |= <act.slayerlesser>
endif
if (<act.slayersuper> > 0)
slayersuper |= <act.slayersuper>
endif
if (<act.slayermisc> > 0)
slayermisc |= <act.slayermisc>
endif
return 0
// Removes slayer flag info char based on item.
on=@ItemUnequip
if (<act.slayerlesser> > 0)
slayerlesser &= ~<act.slayerlesser>
endif
if (<act.slayersuper> > 0)
slayersuper &= ~<act.slayersuper>
endif
if (<act.slayermisc> > 0)
slayermisc &= ~<act.slayermisc>
endif
return 0
// Attach to your NPCs
[events e_slayers_npcs]
on=@GetHit
if (<ddef.slayer_hit_ratio> == 0)
return 0
endif
if (<ddef.slayer_hit_ratio> != 100)
local.hit_chance=<r1,100>
if (<local.hit_chance> <= <def.slayer_hit_ratio>)
slayer_aligned_type
slayer_damage
return 0
endif
else
slayer_aligned_type
slayer_damage
return 0
endif
on=@Hit
if (<ddef.slayer_hit_ratio> == 0)
return 0
endif
if (<ddef.slayer_hit_ratio> != 100)
local.hit_chance=<r1,100>
if (<local.hit_chance> <= <def.slayer_hit_ratio>)
slayer_opposite_type
slayer_damage
return 0
endif
else
slayer_opposite_type
slayer_damage
return 0
endif
//
// FUNCTIONS
//
// Slayer Damage Parsing Function
[function slayer_damage]
if (<local.slayer.dam> > 3)
local.slayer.dam=3
endif
argn1 *= <eval <local.slayer.dam>>
// Aligned Slayer Damage PvM
[function slayer_aligned_type]
local.slayer=0
if (<slayerlesser> > 0)
check_slayer_l
endif
if (<slayersuper> > 0)
check_slayer_s
endif
if (<slayermisc> > 0)
check_slayer_m
endif
// Opposite Aligned Slayer Damage MvP
[function slayer_opposite_type]
local.slayer=0
if (<slayerlesser> > 0) || (<slayersuper> > 0)
if (<slayersuper> &= slayer_abyss) || (<slayerlesser> &= slayer_gargoyle) && (<src.slayersuper> &= slayer_fey|slayer_elemental) || (<src.slayerlesser> &= slayer_air_elemental|slayer_blood_elemental|slayer_earth_elemental|slayer_fire_elemental|slayer_poison_elemental|slayer_snow_elemental|slayer_water_elemental)
local.slayer.dam += <def.slayer_dam_o>
elif (<slayersuper> &= slayer_elemental) || (<src.slayerlesser> &= slayer_air_elemental|slayer_blood_elemental|slayer_earth_elemental|slayer_fire_elemental|slayer_poison_elemental|slayer_snow_elemental|slayer_water_elemental) && (<src.slayersuper> &= slayer_abyss) || (<src.slayerlesser> &= slayer_gargoyle)
local.slayer.dam += <def.slayer_dam_o>
elif (<slayersuper> &= slayer_fey) && (<src.slayersuper> &= slayer_abyss) || (<src.slayerlesser> &= slayer_gargoyle)
local.slayer.dam += <def.slayer_dam_o>
elif (<slayersuper> &= slayer_arachnid) || (<src.slayerlesser> &= slayer_scorpion|slayer_spider|slayer_terathan) && (<src.slayersuper> &= slayer_reptile) || (<src.slayerlesser> &= slayer_dragon|slayer_lizardman|slayer_ophidian|slayer_snake)
local.slayer.dam += <def.slayer_dam_o>
elif (<slayersuper> &= slayer_reptile) || (<src.slayerlesser> &= slayer_dragon|slayer_lizardman|slayer_ophidian|slayer_snake) && (<src.slayersuper> &= slayer_arachnid) || (<src.slayerlesser> &= slayer_scorpion|slayer_spider|slayer_terathan)
local.slayer.dam += <def.slayer_dam_o>
elif (<slayersuper> &= slayer_repond) || (<src.slayerlesser> &= slayer_goblin|slayer_orc|slayer_ogre|slayer_troll) && (<src.slayersuper> &= slayer_undead)
local.slayer.dam += <def.slayer_dam_o>
elif (<slayersuper> &= slayer_undead) && (<src.slayersuper> &= slayer_repond) || (<src.slayerlesser> &= slayer_goblin|slayer_orc|slayer_ogre|slayer_troll)
local.slayer.dam += <def.slayer_dam_o>
endif
endif
// Lesser Slayer Flag Checks
[function check_slayer_l]
if (<slayerlesser> > 0)
if (<slayerlesser> &= slayer_gargoyle) && (<src.slayerlesser> &= slayer_gargoyle)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_air_elemental) && (<src.slayerlesser> &= slayer_air_elemental)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_blood_elemental) && (<src.slayerlesser> &= slayer_blood_elemental)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_earth_elemental) && (<src.slayerlesser> &= slayer_earth_elemental)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_fire_elemental) && (<src.slayerlesser> &= slayer_fire_elemental)
local.slayer.dam += <def.slayer_dam_l>
elf (<slayerlesser> &= slayer_poison_elemental) && (<src.slayerlesser> &= slayer_poison_elemental)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_snow_elemental) && (<src.slayerlesser> &= slayer_snow_elemental)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_water_elemental) && (<src.slayerlesser> &= slayer_water_elemental)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_scorpion) && (<src.slayerlesser> &= slayer_scorpion)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_spider) && (<src.slayerlesser> &= slayer_spider)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_terathan) && (<src.slayerlesser> &= slayer_terathan)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_dragon) && (<src.slayerlesser> &= slayer_dragon)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_lizardman) && (<src.slayerlesser> &= slayer_lizardman)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_ophidian) && (<src.slayerlesser> &= slayer_ophidian)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_snake) && (<src.slayerlesser> &= slayer_snake)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_goblin) && (<src.slayerlesser> &= slayer_goblin)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_orc) && (<src.slayerlesser> &= slayer_orc)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_ogre) && (<src.slayerlesser> &= slayer_ogre)
local.slayer.dam += <def.slayer_dam_l>
elif (<slayerlesser> &= slayer_troll) && (<src.slayerlesser> &= slayer_troll)
local.slayer.dam += <def.slayer_dam_l>
endif
endif
// Super Slayer Flag Checks
[function check_slayer_s]
if (<slayersuper> > 0)
if (<slayersuper> &= slayer_abyss) && (<src.slayersuper> &= slayer_abyss)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_elemental) && (<src.slayersuper> &= slayer_elemental)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_fey) && (<src.slayersuper> &= slayer_fey)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_reptile) && (<src.slayersuper> &= slayer_reptile)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_arachnid) && (<src.slayersuper> &= slayer_arachnid)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_repond) && (<src.slayersuper> &= slayer_repond)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_undead) && (<src.slayersuper> &= slayer_undead)
local.slayer.dam += <def.slayer_dam_s>
elif (<slayersuper> &= slayer_vermin) && (<src.slayersuper> &= slayer_vermin)
local.slayer.dam += <def.slayer_dam_s>
endif
endif
// Misc Slayer Flag Checks (Talisman)
[function check_slayer_m]
if (<slayermisc> > 0)
if (<slayermisc> &slayer_bat) && (<src.slayermisc> &slayer_bat)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_bear) && (<src.slayermisc> &slayer_bear)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_beetle) && (<src.slayermisc> &slayer_beetle)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_bird) && (<src.slayermisc> &slayer_bird)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_bovine) && (<src.slayermisc> &slayer_bovine)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_flame) && (<src.slayermisc> &slayer_flame)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_ice) && (<src.slayermisc> &slayer_ice)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_mage) && (<src.slayermisc> &slayer_mage)
local.slayer.dam += <def.slayer_dam_m>
elif (<slayermisc> &slayer_wolf) && (<src.slayermisc> &slayer_wolf)
local.slayer.dam += <def.slayer_dam_m>
endif
endif
[function isslayer_lesser]
return <qval (<slayerlesser> != 0) ? 1 : 0 >
[function isslayer_super]
return <qval (<slayersuper> != 0) ? 1 : 0 >
[function isslayer_misc]
return <qval (<slayermisc> != 0) ? 1 : 0 >
//
// Slayer Flags
//
// Lesser Slayers
[defname slayer_lesser_flags]
slayer_gargoyle 01
slayer_air_elemental 02
slayer_blood_elemental 04
slayer_earth_elemental 08
slayer_fire_elemental 010
slayer_poison_elemental 020
slayer_snow_elemental 040
slayer_water_elemental 080
slayer_scorpion 0100
slayer_spider 0200
slayer_terathan 0400
slayer_dragon 0800
slayer_lizardman 01000
slayer_ophidian 02000
slayer_snake 04000
slayer_goblin 08000
slayer_orc 010000
slayer_ogre 020000
slayer_troll 040000
// Super Slayers
[defname slayer_super_flags]
slayer_abyss 01
slayer_elemental 02
slayer_fey 04
slayer_arachnid 08
slayer_reptile 010
slayer_repond 020
slayer_undead 040
slayer_vermin 080
slayer_demon slayer_abyss
slayer_daemon slayer_abyss
// Misc. Slayers (Talismans) Damage can stack on top of other slayers.
[defname slayer_misc_flags]
slayer_bat 01
slayer_bear 02
slayer_beetle 04
slayer_bird 08
slayer_bovine 010
slayer_flame 020
slayer_ice 040
slayer_mage 080
slayer_wolf 0100
[eof]