ID:147424
 
mob/Stat() var/Weight = 0 if(locate(/obj) in src.contents) for(var/obj/O in src.contents) Weight += O:itemWeight if(Weight > 0) stat("Weight: [Weight]") src.PackWeight = Weight ..() mob/Move() if(src.AllowMove == 0) return if(src.PackWeight > src.Strength * 2) usr << "[BadMessage]Your pack is too heavy!" return ..()

I'm trying to make it so if your packweight var is greater than your strength times 2 you can't move. Above is the code I use. My problem is that you can't move after you drop stuff. It lets you move right up until it gets too heavy to move and then you can't move again. Any help would be appreciated. Thanks.
Insayne
I made an environment to test this and the procedures you sent worked fine. The problem is most likely in your drop verb. Could you please post that?
In response to Xallius
<code>obj/verb/Drop() set name = "Drop" set src in usr if(usr.DropGetDelay == 0) if(src.suffix == "Equipped") Unequip(src) src.loc = usr.loc usr.DropGetDelay = 1 spawn(10) usr.DropGetDelay = 0</code>

It's an odd thing because the code looks perfect to me... But yet after it's dropped I can't move and I know it's something to do with the pack weight because I use my edit verb and check my packweight and it's at what it was before it was dropped.
Aww, that's no fun, just make it slow them down a whole lot if their pack is too heavy. :)

And, for the sake of lag, DO NOT calculate the weight in Stat(). Calculate it in Get/Drop.


<code>mob var/PackWeight = 0 var/Strength = 10 var/AllowMove = 1 Move() if(!src.AllowMove) return if(src.PackWeight > (src.Strength * 2)) var/overflow = src.PackWeight - (src.Strength * 2) sleep(round(overflow / 10)) ..() Stat() statpanel("Status") stat("Pack Weight: [src.PackWeight]") obj var/Weight = 1 verb/Get() set src in usr.loc if(src.Move(usr)) usr << "You get \the [src]." usr.PackWeight += src.Weight else usr << "You can't get \the [src]." verb/Drop() set src in usr.contents if(src.Move(usr.loc)) usr << "You drop \the [src]." usr.PackWeight -= src.Weight else usr << "You can't drop \the [src]."</code>


[Edit]
Also, you may want to create a custom Step() proc that gets called by client directional keys, instead of using Move() for this, since Move() gets used in other things, like teleporting them around, and adding delays there can mess stuff up.

<code>mob proc/Step(dir) if(!src.AllowMove) return if(src.PackWeight > (src.Strength * 2)) var/overflow = src.PackWeight - (src.Strength * 2) sleep(round(overflow / 10)) src.Move(get_step(src, dir)) client North() mob.Step(NORTH) Northeast() ... East() ...</code>
In response to InsayneWrapper
Your drop() verb as well as the rest of the work you have posted works fine. I've tested it all in a test enviroment. Are you sure that the object is dropped when u call the drop() verb? For example, can you see the object under you? Also, have you "equipped" the object?