Quake 2 is another classic from id software.While not modded quite as much as it's predecessor or Q3A, it is still a blast to play and the mod's on offer are bundles of fun. Just step into Quake 2 Rocket Arena, armed with the new and almighty rocket and rail gun and you will be gibbing for hours on end.If you dig fast paced action, then load up the good ole Quake 2, fire up a mod or two and have some fun!

Post tutorial Report RSS Protection at start of spawn

Ever been angry at those people who stand near spawn points ALL day railing and launching rockets at those who just spawned? This will fix it. It is a VERY VERY small code, but useful..

Posted by on - Basic Server Side Coding

[page=Introduction]
This tutorial takes about 20 seconds, but it is REALLY helpful for those ultimate destruction mods, or a tourney mod.

[page=Making The Change]

Head on over to p_client.c, ClientBeginDeathmatch, which checks for respawns and resets all needed info. Right after the definitons, add this in:

// Do this to add 3 seconds worth of invincibility.
self->client->invincible_framenum = level.framenum + 30; // 10 frames per second.

Change 30 to whatever your hearts desire. 30 = 3, just add a 10 to the desired number. Using Invulnerability item gives you 300 seconds of it.

There you go. Mess around with it. This can be used with Quad too!

-Paril Kalashnikov

Post comment Comments
Basket_Case
Basket_Case - - 58 comments

You should add how to make this a CVar. Other than that, awsome.

Reply Good karma Bad karma+1 vote
QwazyWabbit
QwazyWabbit - - 3 comments

Define your cvar in g_main.c:

cvar_t *respawn_protect; // admin configurable respawn protection

Set it to a reasonable default value in g_save.c:

// the DM respawn invulnerability (defaults to 5 seconds)
respawn_protect = gi.cvar("respawn_protect", "5", 0); //QW// allow admin to control respawn invincibility time

Do some checking of it's value periodically, perhaps in CheckDMRules() to keep it somewhat sane.

if (respawn_protect->modified || initialization) {
//limit value ranges allowed for the respawn protection
if (respawn_protect->value <= 0) gi.cvar_set("respawn_protect","0");
if (respawn_protect->value >= 6) gi.cvar_set("respawn_protect","6");
respawn_protect->modified = false;
}

Setting the spawn protection properly belongs in PutClientInServer():

// start invulnerable for variable seconds in DM, but not teamplay.
if (deathmatch->value && !ctf->value) {
int spawntime;
spawntime = (int) (respawn_protect->value * 10);
ent->client->invincible_framenum = level.framenum + spawntime;
}

If your mod doesn't have a CTF mode then you can eliminate the checks for them:

int spawntime;
spawntime = (int) (respawn_protect->value * 10);
ent->client->invincible_framenum = level.framenum + spawntime;

Note that invincible_framenum and spawntime are integers and respawn_protect->value is a float so we cast it to int to shut the compiler up about the conversion.

Reply Good karma Bad karma+1 vote
QwazyWabbit
QwazyWabbit - - 3 comments

Define your cvar in g_main.c:

cvar_t *respawn_protect; // admin configurable respawn protection

Set it to a reasonable default value in g_save.c:

// the DM respawn invulnerability (defaults to 5 seconds)
respawn_protect = gi.cvar("respawn_protect", "5", 0); //QW// allow admin to control respawn invincibility time

Do some checking of it's value periodically, perhaps in CheckDMRules() to keep it somewhat sane.

if (respawn_protect->modified || initialization) {
//limit value ranges allowed for the respawn protection
if (respawn_protect->value <= 0) gi.cvar_set("respawn_protect","0");
if (respawn_protect->value >= 6) gi.cvar_set("respawn_protect","6");
respawn_protect->modified = false;
}

Setting the spawn protection properly belongs in PutClientInServer():

// start invulnerable for variable seconds in DM, but not teamplay.
if (deathmatch->value && !ctf->value) {
int spawntime;
spawntime = (int) (respawn_protect->value * 10);
ent->client->invincible_framenum = level.framenum + spawntime;
}

If your mod doesn't have a CTF mode then you can eliminate the checks for them:

int spawntime;
spawntime = (int) (respawn_protect->value * 10);
ent->client->invincible_framenum = level.framenum + spawntime;

Note that invincible_framenum and spawntime are integers and respawn_protect->value is a float so we cast it to int to shut the compiler up about the conversion.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: