For example;
for(var/obj/Inventory/Equipment/Weapon/Sword/W)
enemy.hp -= W.sworddmg
If I have two weapons classified under Sword it'll run that twice because of the nature of the for proc. How do I make it so it only runs it for the equipped item?
mob
proc
Equip(obj/Inventory/Equipment/E)
if(!istype(E) || !E.AllowEquip() || !(E.identifier in src.vars) || src.vars["[E.identifier]"])
return 0
E.OnEquip()
src << "You equip a\ [E]."
src.vars["[E.identifier]"] = E
E.suffix = "Equipped"
obj/Inventory/Equipment
Weapon
identifier = "weapon"
The equip proc and the identifier I used to help generate the picture a little better.
Though if anyone has any better ways of doing it I'd be glad to take the advice.