Re: CODE <19980806023137.14742.qmail@hotmail.com>

From: Kevin Doherty (kdoherty@JURAI.NET)
Date: 08/05/98


Thus spake Nick Stout <cyberman_64@HOTMAIL.COM>:
>   Okay... I found a fire weapon snippet on the Circle snippet page, and
>I decided to adapt it. I am somewhat of a talented newbie coder, and
>this is the first time I have asked the Mail list for help.
>   I am keeping the ACMD(do_load_weapon), but i'm trying to make it so
>whenever a violence pulse goes by, it decreases the ammo by 1.
>   I do this with:
>GET_OBJ_VAL(weapon, 3) -= 1;
>
>   Basically, i dont remember how exactly i put it, but it said if a
>fire weapon was wielded, (i put this in "hit") it would decrease the
>ammo by 1, like that.

Are you iterating through every object in the game every PULSE_VIOLENCE?
That's a bad idea. I'd suggest looking at the DG Events package and using
events for this.

>   I compiled, and ran, and it crashed the mud. Why? Any gun code
>suggestion that would allow me to use guns that decrease ammo every
>pulse of attack?


For one thing, make sure the weapon is wielded by a PC (otherwise it'd
almost certainly be empty by the time a player got it).

Also, instead of
GET_OBJ_VAL(weapon,3) -= 1;
try something like:
GET_OBJ_VAL(weapon, 3) = MIN(GET_OBJ_VAL(weapon, 3) - 1, 0);

Because then you have the potential for the ammo value to wraparound.

--
Kevin Doherty, kdoherty@jurai.net
"Multiple exclamation marks are a sure sign of a diseased mind."
       -- Rincewind (from _Eric_)


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST