ID:146581
 
Code:
obj/var/equipable = 0
var/occupied = 0
var/weapon_occupied = 0
var/armor_occupied = 0
obj // needs to be tested and ask forum if they can help with making available both types
verb
equip()
set src in usr.contents
if(!equipable)
usr << "You can not equip this item."
return
if(equipable)
usr << "[weapon_occupied]"
while(weapon_occupied)
usr << "You already have something equiped."
return
while(armor_occupied)
usr << "You already have something equiped."
return
if(src.equip_types == "Weapon")
weapon_occupied = 1
occupied = 1
usr.added_on_attack += src.weapon_attack
src.suffix = " Equip"
usr << "You equip [src.name]."
usage = "Equip"
usr << "[weapon_occupied]"
usr << "[armor_occupied]"
if(src.equip_types == "Armor")
armor_occupied = 1
occupied = 1
usr.added_on_defense += src.armor_defense
src.suffix = " Equip"
usr << "You equip [src.name]."
usage = "Equip"


Problem description:Ok, as you can see, I have some debuging code. Now when weapon_occupied = 1, you're not allowed to equip another weapon. But, for some reason, when weapon_occupied is set to 1, so is armor_occupied. This then makes it so I can only equip either a weapon or an armor, when I should be able to equip 1 of each. Why?

Here is the code I think may work. I didn't find a use for occupied, so I took it out. By the way, using var/weapon_equipped = 0 sets the world's weapon_equipped variable to be false. It needs to be mob/var/weapon_equipped = 0 so you can set it to a mob. However, if you are making a single player game, how you defined the variable was fine.

What you did was check if something was equipped, and if it was, the whole proc was stopped. This way, it checks the src.type and checks if you have the src.type equipped already.

obj/var/equipable = 0
mob/var/weapon_occupied = 0
mob/var/armor_occupied = 0
obj/verb
Equip()
set src in usr.contents
if(!src.equipable)
usr << "You can not equip this item."
return
if(src.equipable)
if(src.equip_types == "Weapon")
if(usr.weapon_occupied)
usr << "You already have something equiped."
return
else
usr.weapon_occupied = 1
usr.added_on_attack += src.weapon_attack
src.suffix = " Equip"
usr << "You equip [src.name]."
usage = "Equip"
usr << "[weapon_occupied]"
if(src.equip_types == "Armor")
if(usr.weapon_occupied)
usr << "You already have something equiped."
return
else
usr.armor_occupied = 1
usr.added_on_defense += src.armor_defense
src.suffix = " Equip"
usr << "You equip [src.name]."
usage = "Equip"


Thank you, thank you very much.