Cloaking


(VTX-aussie) #1

Ok well am intermediate to this mod making i have a vague knowledge of making but kinda learn from other people code,
i know that RTCW is made on a Quake3 engine and most of the code is the same i have come across www.planetquake/code3arena site which gives tuts on making a mod for quake.
Well there are several things that i would like to add into my mod and i was wondering if there is a way of doing some changes to it. if anyone can help with the following would be appricated.

this is so that the player becomes cloaked, for a certain time, or untill its health decreases
In the g_local.h file


#define FL_CLOAK               0x00010000     // health cloaking

in g_cmds.c


/*
=================
Cmd_Cloak_f
=================
*/
void Cmd_Cloak_f( gentity_t *ent ) {

	char *msg; // message to player

	ent->flags ^= FL_CLOAK;

	if (!(ent->flags & FL_CLOAK)) {
		msg = "Cloaking OFF
";
		ent->client->ps.powerups[PW_INVIS] = level.time;
		// Removes the invisible powerup from the player
	}        
	else {
		msg = "Cloaking ON
";
		ent->client->ps.powerups[PW_INVIS] = level.time + 1000000000;
		// Gives the invisible powerup to the player
	}

	trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
}

and adding in the command to console


else if (Q_stricmp (cmd, "cloak") == 0)
	Cmd_Cloak_f( ent );

in the g_active file


if (!(ent->flags & FL_CLOAK)) {
	// count down health when over max and not cloaked.
	if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] ) { 
		ent->health--;
	}
} 
else {
	// count down health when cloaked.
	ent->health--;
	if ( ent->health < 11) {
		ent->flags ^= FL_CLOAK;
		ent->client->ps.powerups[PW_INVIS] = level.time;
	}
}

in the g_combat file


if (self->flags & FL_CLOAK) {
	// remove the invisible powerup if the player is cloaked.
	self->client->ps.powerups[PW_INVIS] = level.time;
} 

I know something has to be changed its probally real simple but all it is doing now is making the name of the player disappear
Thank for reading
and i hope someone can help me out


(kamikazee) #2

I’ve coded somewhat for Q3 and ET, but I’m not an expert on this so you may want some more help here.
In ET, the cloak code has been removed, but in Q3 there was this function:
(found in Q3\src\cgame\cg_players.c)

void CG_AddRefEntityWithPowerups( refEntity_t *ent, entityState_t *state, int team ) {

	if ( state->powerups & ( 1 << PW_INVIS ) ) {
		ent->customShader = cgs.media.invisShader;
		trap_R_AddRefEntityToScene( ent );
	} else {
		/*
		if ( state->eFlags & EF_KAMIKAZE ) {
			if (team == TEAM_BLUE)
				ent->customShader = cgs.media.blueKamikazeShader;
			else
				ent->customShader = cgs.media.redKamikazeShader;
			trap_R_AddRefEntityToScene( ent );
		}
		else {*/
			trap_R_AddRefEntityToScene( ent );
		//}

		if ( state->powerups & ( 1 << PW_QUAD ) )
		{
			if (team == TEAM_RED)
				ent->customShader = cgs.media.redQuadShader;
			else
				ent->customShader = cgs.media.quadShader;
			trap_R_AddRefEntityToScene( ent );
		}
		if ( state->powerups & ( 1 << PW_REGEN ) ) {
			if ( ( ( cg.time / 100 ) % 10 ) == 1 ) {
				ent->customShader = cgs.media.regenShader;
				trap_R_AddRefEntityToScene( ent );
			}
		}
		if ( state->powerups & ( 1 << PW_BATTLESUIT ) ) {
			ent->customShader = cgs.media.battleSuitShader;
			trap_R_AddRefEntityToScene( ent );
		}
	}
}

So you may add at the start of the current function (under variable delcarations) in RTCW something like this:

if ( state->powerups & ( 1 << PW_INVIS ) ) {
		ent->customShader = cgs.media.invisShader;
		trap_R_AddRefEntityToScene( ent );
		return;
	}

I’m quite sure this doesn’t work by simply copy/pasting it, you’ll have to rename the “state” references in my snippet of code to the name they use in the function header.
This may do the trick though, if most parts of Q3 are still there…


(vtxaussie) #3

i found this tutorial on q2 but dont know if it would work


{
		VectorCopy (pm.viewangles, client->v_angle);
		VectorCopy (pm.viewangles, client->ps.viewangles);	}
+if (ucmd->forwardmove != 0 ||  ucmd->sidemove  != 0 && ent->svflags &
SVF_NOCLIENT)+{+	ent->svflags &= ~SVF_NOCLIENT;+}	gi.linkentity (ent);

(elliotbelt) #4

looks fun but i dont no a thing about scripting or modding