So the development of the mod has mostly been going pretty smooth so far, but I recently ran into a huge roadblock that's preventing me from implementing a very important visual clarity feature in the mod, and I've tried for 3 days coming up with various complicated attempted solutions that either don't work or present other issues.
This will be a lengthy post, so hopefully I've gotten all the relevant information in here. Anyway...
To start things off, the trademark mechanic of this mod is uberweapons, which work like this: you collect 3 of the same weapon without dying in between, and that weapon gets upgraded into its uberweapon version. The way this mechanic works in the code is that it uses a set of integer counters corresponding to each non-starter weapon, located in the gclient_s structure in g_local.h. Each time a weapon is picked up, that weapon's corresponding counter is incremented. Once the counter reaches 3, any uberweapon-specific functionality will start running. The uberweapons are not technically new, separate weapons - that would be impossible for me to do, because that would require defining 7 new weapons in weapon_t, which would exceed the MAX_WEAPONS limit of 16 as defined in q_shared.h - and of course I can't change that limit without totally screwing up the entire game. q_shared.h is pretty much untouchable for mods apart from a very few select sections.
Now, from a pure gameplay perspective, all of the uberweapon-related mechanics work just fine. But now I'm moving onto visual / audio coding, which of course involves doing a lot of work in cgame. To attempt to communicate with the client game, I defined 7 new entity flags in bg_public.h, which can be set in game and then - well, in theory anyway (more on that in a minute) - be read in cgame. Each time an uberweapon counter hits 3, the game will turn on the appropriate uberweapon flag with the intention of allowing cgame to know that the player has an uberweapon. Here are the flags and their values, respectively (they follow the hex notation format and sequencing as with the other eflags):
Code: Select all
#define EF_UW_SHOTGUN 0x01000000 // explosive shotgun
#define EF_UW_GRENADE 0x02000000 // multi grenade
#define EF_UW_ROCKET 0x04000000 // homing rocket
#define EF_UW_LIGHTNING 0x08000000 // arc lightning
#define EF_UW_PLASMA 0x10000000 // ion plasma
#define EF_UW_RAIL 0x20000000 // toxic rail
#define EF_UW_BFG 0x40000000 // bfg30k
Code: Select all
if (cent->currentState.weapon == WP_SHOTGUN && (cent->currentState.eFlags & EF_UW_SHOTGUN))
{
memcpy(&orbs, &torso, sizeof(torso));
orbs.hModel = cgs.media.uberShotgunOrbModel;
orbs.customSkin = 0;
VectorCopy(torso.origin, orbs.origin);
spinAngles[1] = cg.time * -0.2;
AnglesToAxis(spinAngles, orbs.axis);
trap_R_AddRefEntityToScene(&orbs);
}
I tried several methods to get this to work. Then I wrote this code in the PmoveSingle function in bg_pmove.c and it somehow started working:
Code: Select all
if (pm->ps->stats[STAT_UBERS] & UW_SHOTGUN)
{
pm->ps->eFlags |= EF_UW_SHOTGUN;
}


Code: Select all
if ( cent->currentState.eFlags & EF_KAMIKAZE )
{
memset( &skull, 0, sizeof(skull) );
VectorCopy( cent->lerpOrigin, skull.lightingOrigin );
skull.shadowPlane = shadowPlane;
skull.renderfx = renderfx;
if ( cent->currentState.eFlags & EF_DEAD ) {
// one skull bobbing above the dead body
angle = ((cg.time / 7) & 255) * (M_PI * 2) / 255;
if (angle > M_PI * 2)
angle -= (float)M_PI * 2;
dir[0] = sin(angle) * 20;
dir[1] = cos(angle) * 20;
angle = ((cg.time / 4) & 255) * (M_PI * 2) / 255;
dir[2] = 15 + sin(angle) * 8;
VectorAdd(torso.origin, dir, skull.origin);
<goes on from here...>
Here's another problem: Even though the CG_Player function can now read (cent->currentState.eFlags & EF_UW_SHOTGUN) because of the code I put in bg_pmove.c from earlier, it doesn't seem to be reflected everywhere in cgame. In cg_ents.c, in the CG_Missile function, it seems like it can't read cent->currentState.eFlags, even though CG_Player can. In this case I want homing rockets fired from an upgraded rocket launcher to play a beeping noise. As with EF_UW_SHOTGUN, I put the following code in PmoveSingle, right underneath the one for the shotgun:
Code: Select all
if (pm->ps->stats[STAT_UBERS] & UW_ROCKET)
{
pm->ps->eFlags |= EF_UW_ROCKET;
}
Code: Select all
// add missile sound
if ( weapon->missileSound )
{
vec3_t velocity;
BG_EvaluateTrajectoryDelta( ¢->currentState.pos, cg.time, velocity );
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, velocity, weapon->missileSound );
// right below is my code
if (weapon->trackSound && cent->currentState.eFlags & EF_UW_ROCKET) {
trap_S_AddLoopingSound(cent->currentState.number, cent->lerpOrigin, velocity, weapon->trackSound);
}
}
This is a lot to take in, so I'll just summarize my goals here - I want to:
- Create a visual effect that displays on any player that is currently using an uberweapon.
- Make homing rockets play a targeting alert sound if they are fired by a player using a Homing Rocket Launcher.
Two goals that sound very simple to achieve in theory, but apparently are monstrously difficult in practice.
Thanks for any assistance in advance!