Skip to content

Commit

Permalink
Add megahealth to item tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvensson committed May 24, 2024
1 parent 4f90c8c commit c9e5d64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions engine/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6703,32 +6703,32 @@ static void CL_ParseKtxItemTimer(void)
vec3_t org;
float start;

if (Cmd_Argc() < 3) {
Con_Printf("//ktx took: expected 3 args, got %d\n", Cmd_Argc());
if (Cmd_Argc() < 2) {
Con_Printf("ktx timer: expected 3 args, got %d\n", Cmd_Argc());
return;
}

duration = (float) strtod(Cmd_Argv(1), NULL);
if (duration <= 0) {
// mega needs special care as it decays in relation to player health
// mega comes via //ktx timer instead of //ktx took
return;
}

entnum = strtoul(Cmd_Argv(0), NULL, 0);
if (entnum < 0 || entnum >= cl_baselines_count) {
Con_Printf("//ktx took: entity index out of bounds: %d\n", entnum);
Con_Printf("ktx timer: entity index out of bounds: %d\n", entnum);
return;
}

ent = &cl_baselines[entnum];
if (ent->modelindex < 0 || ent->modelindex >= MAX_PRECACHE_MODELS) {
Con_Printf("//ktx took: model index out of bounds: %d (ent: %d)\n", ent->modelindex, entnum);
Con_Printf("ktx timer: model index out of bounds: %d (ent: %d)\n", ent->modelindex, entnum);
return;
}

mdl = cl.model_name[ent->modelindex];
if (!mdl) {
Con_Printf("//ktx took: could not find model name for index %d (ent: %d)\n", ent->modelindex, entnum);
Con_Printf("ktx timer: could not find model name for index %d (ent: %d)\n", ent->modelindex, entnum);
return;
}

Expand Down Expand Up @@ -6763,6 +6763,9 @@ static void CL_ParseKtxItemTimer(void)
break;
}
}
else if (!strcmp("maps/b_bh100.bsp", mdl)) {
rgb = 0xff69b4;
}
else if (!strcmp("progs/g_shot.mdl", mdl) ||
!strcmp("progs/g_nail.mdl", mdl) ||
!strcmp("progs/g_nail2.mdl", mdl) ||
Expand Down Expand Up @@ -7085,6 +7088,11 @@ static void CL_ParseStuffCmd(char *msg, int destsplit) //this protects stuffcmds
Cmd_TokenizeString(stufftext+11, false, false);
CL_ParseKtxItemTimer();
}
else if (!strncmp(stufftext, "//ktx timer ", 12)) //ktx timer <entnum> <timeout>
{
Cmd_TokenizeString(stufftext+12, false, false);
CL_ParseKtxItemTimer();
}
else if (!strncmp(stufftext, "//it ", 5)) //it <timeout> <org xyz> <radius> <rgb> <timername> <entnum>
{
Cmd_TokenizeString(stufftext+5, false, false);
Expand Down
1 change: 1 addition & 0 deletions engine/web/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static entity_mapping_t entity_mapping[] = {
{ "progs/g_rock.mdl", "tp_name_gl", IT_GRENADE_LAUNCHER, -1 },
{ "progs/g_rock2.mdl", "tp_name_rl", IT_ROCKET_LAUNCHER, -1 },
{ "progs/g_light.mdl", "tp_name_lg", IT_LIGHTNING, -1 },
{ "maps/b_bh100.bsp", "tp_name_mh", IT_SUPERHEALTH, -1 },
};

static const entity_mapping_t *find_entity(int entnum) {
Expand Down

0 comments on commit c9e5d64

Please sign in to comment.