Adding a variable?


(sniser) #1

Hi, want to add armour (among other things, e.g. I’d like players to actually have a breath reserve, instead of having full breath instantly when getting out of water, etc.). Now I’m totally confused on where to add it, it needs to be seen clientside too. However, it isn’t really necessary that it gets transferred to other players.

In q_shared.c above the playerstate_t structure it says “you can’t add anything to this without modifying the code in msg.c”, but there is no msg.c?

So:

a.) What do I have to keep in mind when adding things to the playerstate, ie. stuff that’s gets transferred to all (not necessary for armour or breath, but maybe other stuff later on).

b.) The same as a.), only that just the server and the respective player have it?

I’m sure there must be some basic quake modding tut on this, but I haven’t found it yet :confused:


(Lanz) #2

What you do is that you use the vars given to you instead of adding new ones to playerstate_t. For the breather thing I would suggest adding it as a Powerup for example, thinking of it there’s something like that already there PW_BREATHER. Usually what you need to do is check to see what is being used and where, sometimes there are arrays for example that isn’t fully used etc.


(digibob) #3

msg.c is part of the engine source, so you cannot modify it, i.e. you shouldn’t really touch anything in qshared at all, as a modder.

as Lanz suggests, just find unused fields in the current structure, and use them to do what you want.

some people might tell you that modifying the player/entity state structures is possbile, and yes, it is, but you have to be really, really careful, and know exactly what you are doing, so i wouldn’t recommend it for people new to the source, nor would it likely help you much anyway.


(sniser) #4

Thanks for the replies. I already considered using the PW_ stuff (there seem to be 4 unused slots after removing breather, nofatigue and the electric and fire damage protection thingies)… but I was hoping for something more extendable… and I kinda dislike variables having different meanings and being “abused”… I’m sure it’s necessary for efficiency, but DAMN it’s ugly :stuck_out_tongue: I’ll stick to the the powerups array for now, try to understand bit operators etc. and then I’ll be fine (e.g. armour doesn’t need to be higher than 256, breath will never be above 6553x etc.)

But what about server side only things that doesn’t need to survive respawns? Is there a place for that stuff, or is it not possible to add anything to that at all? If all fails I could still just make global arrays and reset the values if a client disconnects or spawns etc, but I’d prefer something more convenient if at all possible (read: something that protects ET from my idiocy regarding pointers and arrays :banana:).


(digibob) #5

For anything on the server, just add fields to the gentity_t struct, or abuse existing fields.