Skip to content

Commit

Permalink
add basic one-shot kill cheat
Browse files Browse the repository at this point in the history
`mdk` console command kills a monster when invoked without arguments, and it gibs a monster when invoked with an argument
progress #115
  • Loading branch information
alexey-lysiuk committed Nov 11, 2023
1 parent 48c0784 commit bfb6fdc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,35 @@ void Host_Resetdemos (void)
cls.demonum = 0;
}

static void Host_MDK_f(void)
{
if (cmd_source == src_command)
{
Cmd_ForwardToServer();
return;
}

if (pr_global_struct->deathmatch)
return;

edict_t* ent = SV_TraceEntity(SV_TRACE_ENTITY_SOLID);

if (ent && ent->v.health > 0.0f && ent->v.takedamage > 0.0f)
{
eval_t* diefunc = GetEdictFieldValue(ent, "th_die");

if (diefunc && diefunc->function)
{
ent->v.health = Cmd_Argc() > 1 ? -99.0f : -1.0f;
ent->v.think = diefunc->function;
ent->v.nextthink = 0.1f;

if ((int)ent->v.flags & FL_MONSTER)
MSG_WriteByte(&sv.reliable_datagram, svc_killedmonster);
}
}
}

//=============================================================================

/*
Expand Down Expand Up @@ -2318,6 +2347,7 @@ void Host_InitCommands (void)
Cmd_AddCommand ("name", Host_Name_f);
Cmd_AddCommand ("noclip", Host_Noclip_f);
Cmd_AddCommand ("setpos", Host_SetPos_f); //QuakeSpasm
Cmd_AddCommand ("mdk", Host_MDK_f);

Cmd_AddCommand ("say", Host_Say_f);
Cmd_AddCommand ("say_team", Host_Say_Team_f);
Expand Down
2 changes: 2 additions & 0 deletions Quake/sv_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ qboolean SV_ReadClientMessage (void)
ret = 1;
else if (q_strncasecmp(s, "setpos", 6) == 0)
ret = 1;
else if (q_strncasecmp(s, "mdk", 3) == 0)
ret = 1;
else if (q_strncasecmp(s, "say", 3) == 0)
ret = 1;
else if (q_strncasecmp(s, "say_team", 8) == 0)
Expand Down

0 comments on commit bfb6fdc

Please sign in to comment.