ID:178937
 
I'm having a problem with my equipping code. To make my verbs more compact, I want to make it so that I only have one equip verb. The problem is that if I have two of the same weapon, it won't let me unequip the weapon. Any help is appreciated.
-------
obj
weapons
icon = 'weapons.dmi'
verb
EquipWeapon()
set src in usr
if (usr.weapon == 1)
if (src.suffix == "Equipped")
usr.strequip -= src.strbonus
usr.defequip -= src.defbonus
usr.aglequip -= src.aglbonus
usr.luckequip -= src.luckbonus
usr.intequip -= src.intbonus
src.suffix = ""
usr.weaponname = ""
usr.weapon = 0
usr << "You have unequipped the [src.name]."
else
usr << "You must unequip the [usr.weaponname]"
else
if (usr.class in src.classallow)
if (usr.chargender in src.genderallow)
usr.strequip += src.strbonus
usr.defequip += src.defbonus
usr.aglequip += src.aglbonus
usr.luckequip += src.luckbonus
usr.intequip += src.intbonus
src.suffix += "Equipped"
usr.weaponname = "[src.name]"
usr.weapon = 1
usr << "You have equipped the [src.name]."
else
usr << "You cannot equip the [src.name]."
else
usr << "You cannot equip the [src.name]."

get()
set src in oview(0)
src.Move(usr)
DropWeapon()
set src in usr
if (src.suffix == "Equipped")
usr << "[src.name] is equipped. You must first unequip it."
else
src.Move(usr.loc)
You may want to check out Nadrew's weapon system.
In response to Nadrew
I did, but when I loaded my save, it wouldn't have the unequip option. If I could save that, then I would be set. Any suggestions???
In response to Rubius
It wasn't designed to work with a saving system, maybe one of these days I'll make it work with one, but not today. You'll have to dumb it down to simple vars.
In response to Nadrew
I think there's demo's by Eponick and Richter of weapons. One is S&I and the other is demo on many things.
In response to Super16
I didn't think about the saving process for my system, it's not designed for plug and play, which is why it's in demos. You'd be better off going with one of the less advanced simple systems.
In response to Nadrew
Okay, the code does work if I right click on the item in the inventory list, which is more than good enough for me right now. My question is how do you make a verb not show up in the 'Commands' panel, but when you right click on the object show? And while I'm on the subject, how do you make other verbs show up on other panels. Thanks.
I think one source of your trouble is the way you've designed the weapon var. This shouldn't be a number: It should be a reference to the weapon. The way you've got it set up now, your code basically says "I have a weapon, but I don't know what it is, so let's go check the inventory and see which item is the weapon." This of course gets very time consuming every time, and it's unnecessary.

Equpping a weapon should look more like this:
...  // check to see if you can equip it, etc.
usr.weapon=src
suffix="(equipped)"
usr << "You equip [src]."

And unequipping would be like this:
...
if(usr.weapon==src)
usr.weapon=null
suffix=null
usr << "You unequip [src]."
else
...

Lummox JR