ID:175880
 
obj
DblClick()
set src in usr
if(src.suffix == "Equipped")
src.suffix = null
usr.attack-=src.attackadd
usr.defense-=src.defadd
usr.maxmagic-=src.maxmagicadd
usr.maxhealth-=src.hpadd

else
src.suffix = "Equipped"
usr.attack+=src.attackadd
usr.defense+=src.defadd
usr.maxmagic+=src.maxmagicadd
usr.maxhealth+=src.hpadd

How do I make it so I can only equip one weapon at a time, 1 armor at a time, and 5 rings at a time?
mob/var/hasarmor = 0

then check if the player's hasarmor vare is 0 before putting armor on.

Siientx
In response to Siientx
Now, why would you ever do that?

mob/var/obj/armor = null

Then, if(armor) you have armor equipped, else you don't. Just set armor to the object you equip. Do the same for weapons, helmets, whatever.

For rings, you'll need a list...

mob/var/list/rings = list()

Then, if(rings.len < 5) you have a finger left to put a ring on, else you don't.
In response to Garthor
Garthor wrote:
For rings, you'll need a list...

mob/var/list/rings = list()

Then, if(rings.len < 5) you have a finger left to put a ring on, else you don't.

However, the ring list has to be initialized with New(), or else mobs will share the same list.
mob
var/list/rings

New()
rings=list()
Or, you can simply initialize the list as needed, when a ring is put on.
mob
// returns 1 if successful, 0 if not
proc/WearRing(obj/ring/R)
if(!rings) rings=list()
if(rings.len>=5) return 0
rings+=R
return 1

proc/RemoveRing(obj/ring/R)
if(!rings || !(R in rings)) return 0
if(R.iscursed) return 0
rings-=R
return 1

Lummox JR
In response to Lummox JR
Hmm, I've never encountered that problem with the initializing it outside of New() before....
In response to Garthor
Garthor wrote:
Hmm, I've never encountered that problem with the initializing it outside of New() before....

If you initialize a list at compile-time, all objects of that type (and descended from it) use the same list.

Lummox JR
In response to Lummox JR
Ah, never noticed that.