
Cloaking!!!!!
We snipers
just love to be invisible when we shoot people.
This tutorial will show
you how to add toggleable cloaking to your mod. While turned on you will
be completely invisible, but your cells will drain. Add in the
lines that are blue and
remove any lines that are pink.
First open up g_cmds.c
and place this command right below the wave command under clientcommands.
else
if (Q_stricmp (cmd, "wave") == 0)
Cmd_Wave_f (ent);
else if (Q_stricmp (cmd, "cloak") == 0)
Cmd_Cloak_f(ent);
Next add this right above
the clientcommand section:
/*
======================
Cloaking
======================
*/
void Cmd_Cloak_f (edict_t *ent) // PSY: IR Goggles
{
if (ent->client->cloak) // we're on
{
ent->client->cloak = 0;
gi.cprintf(ent,PRINT_HIGH,"Cloaking OFF\n");
ent->svflags &=
~SVF_NOCLIENT;
}
else // we're off
{
ent->client->cloak = 1;
ent->client->cloakrun = 0;
ent->client->cloakoff = 0;
gi.cprintf(ent,PRINT_HIGH,"Claoking ON\n");
gi.sound(ent, CHAN_ITEM,
gi.soundindex("floater/fltpain1.wav"), 1, ATTN_NORM, 0);
ent->svflags |= SVF_NOCLIENT;
}
}
This just uses the svflag
called noclient to make a player invisible and it prints a message telling you
that you cloaked or uncloaked. Next in clientthink in p_client.c add this
right before the gi.linkentity(ent):
if (ent->client->cloak) { if (ent->client->pers.inventory[ITEM_INDEX(FindItem("Cells"))] >= 1) { ent->client->cloakrun ++; if (ent->client->cloakrun == 10) { ent->client->pers.inventory[ITEM_INDEX(FindItem("Cells"))] -= 1; ent->client->cloakrun = 0; } } else { ent->svflags &= ~SVF_NOCLIENT; ent->client->cloak = 0;}
if (ent->client->pers.inventory[ITEM_INDEX(FindItem("Cells"))] < 1) { ent->client->cloakoff ++; if (ent->client->cloakoff == 1) {gi.cprintf(ent,PRINT_HIGH,"Cloaking OFF\n");
ent->svflags &= ~SVF_NOCLIENT; ent->client->cloak = 0; ent->client->cloakoff = 2; }}
}
![]()
This section runs a counter that will drain cells
continuously while you have the cloaking on.
Next add these variables to the gclient_s structure in
g_local.h:
![]()
int cloak;
int cloakrun;
int cloakoff;
![]()
Now if any of you snipers want to be sick, and I do mean really
sick, you can take away the railtrail entity in g_weapon.c so you shoot
invisible slugs!
Here’s how to do it:
Open up g_weapon.c and go down to the fire_rail function.
Modifiy it like so:
![]()
}
//send gun puff / flash
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_GUNSHOT);
gi.WritePosition (tr.endpos);
gi.WriteDir (tr.plane.normal);
gi.multicast (tr.endpos, MULTICAST_PHS);
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_RAILTRAIL);
gi.WritePosition (start);
gi.WritePosition (tr.endpos);
gi.multicast (self->s.origin,
MULTICAST_PHS);
// gi.multicast (start, MULTICAST_PHS);
if (water)
{
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_RAILTRAIL);
gi.WritePosition (start);
gi.WritePosition (tr.endpos);
gi.multicast (tr.endpos, MULTICAST_PHS);
}
![]()
Now you know how to cloak and have invisible trails!
As long as nobody bumps into you and you aren’t hit by anything,
you will be able to pick off everyone and they won’t know where it came from!
Tutorial
by Willi