adding more values to an specific item type?

Posted by Mopop on Sun 18 Dec 2005 06:38 PM — 14 posts, 46,301 views.

#0
The snippet im using is in ROM, It is highly crappy in smaug. I have edited it some to be more smaugish. But the one problem is with the 4th value is used to see what type of gun it is, what ammo it requires and how hard it recoils. It wont let me assign all those things to a value. So I was wondering the possiblity of creating more than 4 values?
USA #1
Smaug has 6 values, value0 to value5.
#2
Ah right how would i go about chaning the values? I looked over the object codes and couldnt find where the vaules are to be edited.
USA #3
In the code? Like this will set value0 to 1:
obj->value[0] = 1;
#4
Where can I find that at grep seems to geek out on me for some reason....
USA #5
What exactly do you want to do? You want to change the values... I really don't understand that.
#6
I'm trying to add a new item in a gun (remember the gun snippet? Well its not very good, like you said). So I dont know how to code a value for an item. I just need v1 to be gun type, v2 ammo type v3 recoil v4 and how much ammo it can hold. I never really did anything like this so its all new to me...
USA #7
You just code that in the snippet. There isn't a specific place to put it other than that.
#8
I know this, how tho I see in this snippet several
if (obj->value[0])

I dont know, can you tell me where to look for an example?
USA #9
Quote:
I know this, how tho I see in this snippet several
if (obj->value[0])


That will work fine if it's in the snippet already.

I already gave you an example:
Quote:
In the code? Like this will set value0 to 1:

obj->value[0] = 1;
USA #10
I think the problem here may be that you, Mopop, aren't explaining what it is that yur asking clearly enough. I'm guessing that what you're really after is how to change what the value of one of those v0 through v5 means, but only you can point out whether or not I'm guessing correctly.
#11
Yeah thats what I mean, I just didnt understand it. :(
USA #12
The best way I know to approach this would be to have you look over the way the v0 - v5 are used by other object types in the code for examples to use as guidance, you might start with grepping for salve since salves actually use all 6 values (you could even start looking in misc.c, but you might expand your review to include each of the other files that include salve information as well).
USA #13
You do not need to add anything new, the only thing you need to do is tell the code which value to look at. For example:

  if ( gun->value[4] == 0 )
    send_to_char( "You need to reload your weapon.\n\r", ch );


If remembering which values you need to use is too much for you, you can go as far as defining values in mud.h:

#define  V_GUNTYPE    0
#define  V_AMMOTYPE   1
#define  V_RECOIL     2
#define  V_CURAMMO    3

#define  MAXAMMO      15  // Clips can hold up to 15 bullets

then inside your snippet you would do something like:

do_reload:
  if ( gun->value[V_CURAMMO] <= MAXAMMO ) {
    bullets_left -= MAXAMMO - gun->value[V_CURAMMO];
    gun->value[V_CURAMMO] = MAXAMMO;
  }
  else {
    send_to_char( "Your clip is full.\n\r", ch );
  }