Search the Community
Showing results for tags 'AttackedBy'.
Found 1 result
My question is if there is a good way to react to being attacked and cast the appropriate buffs like protection from magical weapon in script? There are several limitations that I have discovered. AttackedBy does not work properly. AttackedBy([ANYONE],RANGED) does not work AttackedBy([ANYONE],MELEE) does not work AttackedBy([ANYONE],DEFAULT) works What I want to do is to cast WIZARD_MANTLE, WIZARD_IMPROVED_MANTLE, WIZARD_ABSOLUTE_IMMUNITY, WIZARD_PROTECTION_FROM_MAGIC_WEAPONS or WIZARD_PROTECTION_FROM_NORMAL_WEAPONS when it is appropriate. It could work most of the times to just use AttackedBy([ANYONE],DEFAULT) Range(LastAttackerOf(),10) when attacked by Melee for example (not guaranteed), but to know exactly what type of shield to cast, I need to know more about the attacker, so I use HasItemEquiped("MISTVA01",LastAttackerOf()) for example to check if the enemy is using the weapon with code MISTVA01 (vampiric mist use this). According to NearInfinity it is a +3 weapon, but when I try the code against a Vampiric Mist, it will detect the +3 weapon, but the mist attacks with a normal weapon apparently and level drain you, so the spell WIZARD_PROTECTION_FROM_MAGIC_WEAPONS does not work. What does work is WIZARD_PROTECTION_FROM_NORMAL_WEAPONS. Is there a better way to determine what spell to cast? I also tried HasItemEquipedReal, but it seems to do the same. The HitBy function works okay, except against for the CRUSHING constant which is always active for any type of damage for some reason. The problem with this function is that you need to get hit first, and even then you don't know exactly what the appropriate response is (protection vs magic or physical?).