ID:179470
 
Ok i am stumped on this This is hard to explain so i will try my hardest
OK
first when i had my equip verb in my game i was able to equip a coppersword and say i had a club with me too i could un equip the the club(wich was never equpied in the first place)and it would register me as un equpied the copper sword but only taking the stats away from when you would un equip a club, so i could keep doing that and get strenght for ever
I tried to fixe but now i can alwasy equip a copper sword and it still says you have something equiped but i get strength for it even when it says that
I hoped i explained it good Here is my code for equiping things
obj/bamboo
icon='icons.dmi'
icon_state="bamboo"
verb/Get()
set src in oview(1)
usr.contents+=new/obj/bamboo
del(src)
verb/Drop()
set src in usr.contents
if(usr.M>=1)
usr<<"You Have Something Equiped"
else
src.Move(usr.loc)
verb/Equip()
set src in usr.contents
if(usr.M>=1)
usr<<"You already have something Equiped"
if(usr.MX>=1)
usr<<"You already have something Equiped"
if(usr.MXB>=1)
usr<<"You already have something Equiped"
else
suffix+="Equiped"
usr.M=1
usr.attack+=2
verb/Unequip()
set src in usr.contents
if(usr.M<=0)
usr<<"You have nothing Equiped"
else
suffix=null
usr.attack-=2
usr.M=0
obj/club
icon='icons.dmi'
icon_state="club"
verb/Get()
set src in oview(1)
usr.contents+=new/obj/club
del(src)
verb/Drop()
set src in usr.contents
if(usr.MX>=1)
usr<<"You have something equpied"
else
src.Move(usr.loc)
verb/Equip()
set src in usr.contents
if(usr.M>=1)
usr<<"You already have something Equiped"
if(usr.MX>=1)
usr<<"You already have something Equiped"
if(usr.MXB>=1)
usr<<"You already have something Equiped"
else
suffix+="Equiped"
usr.MX=1
usr.attack+=4
verb/Unequip()
set src in usr.contents
if(usr.MX<=0)
usr<<"You have nothing Equiped"
else
suffix=null
usr.attack-=4
usr.MX=0
obj/coppersword
icon='icons.dmi'
icon_state="coppersword"
verb/Get()
set src in oview(1)
usr.contents+=new/obj/coppersword
del(src)
verb/Drop()
set src in usr.contents
if(usr.MXB>=1)
usr<<"You already have something Equiped"
else
src.Move(usr.loc)
verb/Equip()
set src in usr.contents
if(usr.M>=1)
usr<<"You already have something Equiped"
if(usr.MX>=1)
usr<<"You already have something Equiped"
if(usr.MXB>=1)
usr<<"You already have something Equiped"
else
suffix+="Equiped"
usr.MXB=1
usr.attack+=8
verb/Unequip()
set src in usr.contents
if(usr.MXB<=0)
usr<<"You have nothing Equiped"
else
suffix=null
usr.attack-=8
usr.MXB=0
Thank you for any help
i appreciate it
I'm not looking at your source code (because it looks quite long and unconcise) but I will show you a simple code to equip/unequip items correctly:
mob
var/weapon_equipped = 0
var/str = 0
obj
weapons
var/equipped = 0
var/strplus = 0
verb/Equip()
set src in usr.contents
if(!usr.weapon_equipped && !src.equipped)
usr << "You equip [src]."
src.suffix = "Equipped"
src.equipped = 1
usr.weapon_equipped = 1
usr.str += src.strplus
else
usr << "You cannot do that."
verb/UnEquip()
set src in usr.contents
if(usr.weapon_equipped && src.equipped)
usr << "You unequip [src]."
src.suffix = null
src.equipped = 0
usr.weapon_equipped = 0
usr.str -= src.strplus
This doesn't solve your problem directly, but I have a suggestion about the way to handle equipped items giving stat boosts.

The way I handle this in MLAAS is to have a single procedure to recalculate your current stats based on your items and buffs. I keep separate variables for base stats and current stats. When a recalculation is done, you set your stats to the base value, then iterate through all buffs and equipment to get your current stats.

I call the procedure any time anyone un/equips or drops an item, applies a buff (stims in my game), dies, or levels. Here's a mini-sample of what I mean:
obj/weapon
var
str_bonus
health_bonus
equipped = FALSE
club
str_bonus = 3 // this item gives you a +3 strength
verb
equip()
equipped = TRUE
// add your equip code here
usr.recalc_stats()
unequip()
equipped = FALSE
// add your unequip code here
usr.recalc_stats()
mob
var
strength
base_strength
health
base_health

proc/recalc_stats()
strength = base_strength
health = base_health
for(var/obj/weapon/W in src.contents)
if(W.equipped)
strength += W.str_bonus
health += W.health_bonus


I think this approach is much safer than adding and subtracting a stat when you equip or unequip an item. If there are any problems at all with your stats, they are completely fixed any time recalc_stats() is called. It also won't matter if someone uses the equip() or unequip() verbs repeatedly on the same item... it still calculates it all properly.

In response to Skysaw
Great idea! I never thought of that... I may use that strategy some time in the future.
Take a look at Nadrew's weapon system, it does exacly what you want.