From 21e8431e1a0b4a01d6b4c2e9e58782a7fab9ec15 Mon Sep 17 00:00:00 2001 From: "James R." Date: Tue, 12 Sep 2023 02:29:37 -0700 Subject: [PATCH 1/3] Add ufo_follow cheat, teleport UFO Catcher to player --- src/cvars.cpp | 1 + src/objects/ufo.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/cvars.cpp b/src/cvars.cpp index a143a507f..bdfa4599a 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -802,6 +802,7 @@ consvar_t cv_numlaps = OnlineCheat("numlaps", "Map default").values(numlaps_cons consvar_t cv_restrictskinchange = OnlineCheat("restrictskinchange", "Yes").yes_no().description("Don't let players change their skin in the middle of gameplay"); consvar_t cv_spbtest = OnlineCheat("spbtest", "Off").on_off().description("SPB can never target a player"); consvar_t cv_timescale = OnlineCheat(cvlist_timer)("timescale", "1.0").floating_point().min_max(FRACUNIT/20, 20*FRACUNIT).description("Overclock or slow down the game"); +consvar_t cv_ufo_follow = OnlineCheat("ufo_follow", "0").min_max(0, MAXPLAYERS).description("Make UFO Catcher folow this player"); // diff --git a/src/objects/ufo.c b/src/objects/ufo.c index 71ae0b585..de45c0361 100644 --- a/src/objects/ufo.c +++ b/src/objects/ufo.c @@ -10,6 +10,7 @@ /// \file ufo.c /// \brief Special Stage UFO + Emerald handler +#include "../command.h" #include "../doomdef.h" #include "../doomstat.h" #include "../info.h" @@ -337,8 +338,63 @@ waypoint_t *K_GetSpecialUFOWaypoint(mobj_t *ufo) return NULL; } +static void UFOMoveToDistance(mobj_t *ufo, UINT32 distancetofinish) +{ + waypoint_t *finishline = K_GetFinishLineWaypoint(); + const boolean useshortcuts = false; + const boolean huntbackwards = true; + path_t pathtofinish = {0}; + + if (finishline == NULL) + { + return; + } + + boolean pathfindsuccess = K_PathfindThruCircuit( + finishline, + distancetofinish, + &pathtofinish, + useshortcuts, + huntbackwards + ); + + if (pathfindsuccess == false) + { + return; + } + + pathfindnode_t *node = &pathtofinish.array[pathtofinish.numnodes - 1]; + + if (node->camefrom != NULL) + { + UINT32 a_to_b = (node->gscore - node->camefrom->gscore); + UINT32 overshot = (node->gscore - distancetofinish); + fixed_t f = FixedDiv(overshot, max(1, a_to_b)); + + mobj_t *a = ((waypoint_t*)node->camefrom->nodedata)->mobj; + mobj_t *b = ((waypoint_t*)node->nodedata)->mobj; + + UFOMoveTo( + ufo, + b->x - FixedMul(f, b->x - a->x), + b->y - FixedMul(f, b->y - a->y), + b->z - FixedMul(f, b->z - a->z) + ); + } + + Z_Free(pathtofinish.array); +} + static void UFOMove(mobj_t *ufo) { + extern consvar_t cv_ufo_follow; + + if (cv_ufo_follow.value) + { + UFOMoveToDistance(ufo, players[cv_ufo_follow.value - 1].distancetofinish); + return; + } + waypoint_t *curWaypoint = NULL; waypoint_t *destWaypoint = NULL; From d9d6a0da18cc08a3c497815ecaee97c1cd98672c Mon Sep 17 00:00:00 2001 From: "James R." Date: Tue, 12 Sep 2023 03:04:51 -0700 Subject: [PATCH 2/3] Add ufo_health cheat, set UFO Catcher health --- src/cvars.cpp | 1 + src/objects/ufo.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/cvars.cpp b/src/cvars.cpp index bdfa4599a..bcfedba5c 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -803,6 +803,7 @@ consvar_t cv_restrictskinchange = OnlineCheat("restrictskinchange", "Yes").yes_n consvar_t cv_spbtest = OnlineCheat("spbtest", "Off").on_off().description("SPB can never target a player"); consvar_t cv_timescale = OnlineCheat(cvlist_timer)("timescale", "1.0").floating_point().min_max(FRACUNIT/20, 20*FRACUNIT).description("Overclock or slow down the game"); consvar_t cv_ufo_follow = OnlineCheat("ufo_follow", "0").min_max(0, MAXPLAYERS).description("Make UFO Catcher folow this player"); +consvar_t cv_ufo_health = OnlineCheat("ufo_health", "100").min_max(0, 100).description("Override UFO Catcher health -- applied at spawn or when value is changed"); // diff --git a/src/objects/ufo.c b/src/objects/ufo.c index de45c0361..aa976f4d9 100644 --- a/src/objects/ufo.c +++ b/src/objects/ufo.c @@ -552,8 +552,34 @@ static void UFOUpdateSound(mobj_t *ufo) { } } +static void UFODebugSetHealth(mobj_t *ufo, UINT8 health) +{ + if (ufo->health == health + 1 || UFOEmeraldChase(ufo) == true) + { + return; + } + + extern consvar_t cv_ufo_follow; + + UINT8 pnum = max(1, cv_ufo_follow.value) - 1; + mobj_t *source = players[pnum].mo; + + if (playeringame[pnum] == false || P_MobjWasRemoved(source) == true) + { + return; + } + + ufo->health = health + 2; + Obj_SpecialUFODamage(ufo, ufo, source, DMG_NORMAL); // does 1 damage, updates pieces +} + void Obj_SpecialUFOThinker(mobj_t *ufo) { + { + extern consvar_t cv_ufo_health; + UFODebugSetHealth(ufo, cv_ufo_health.value); + } + UFOMove(ufo); UFOUpdateAngle(ufo); UFOUpdateDistanceToFinish(ufo); @@ -773,6 +799,11 @@ static UINT8 GetUFODamage(mobj_t *inflictor, UINT8 damageType) // Players deal damage relative to how many sneakers they used. return 15 * max(1, inflictor->player->numsneakers); } + case MT_SPECIAL_UFO: + { + // UFODebugSetHealth + return 1; + } default: { break; From 5abd0f7a6c429cc4522c14c662a569b7f68c7752 Mon Sep 17 00:00:00 2001 From: "James R." Date: Tue, 12 Sep 2023 18:22:53 -0700 Subject: [PATCH 3/3] UFOMove: check playeringame cv_ufo_follow --- src/objects/ufo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/objects/ufo.c b/src/objects/ufo.c index aa976f4d9..e9b983ac0 100644 --- a/src/objects/ufo.c +++ b/src/objects/ufo.c @@ -391,7 +391,10 @@ static void UFOMove(mobj_t *ufo) if (cv_ufo_follow.value) { - UFOMoveToDistance(ufo, players[cv_ufo_follow.value - 1].distancetofinish); + if (playeringame[cv_ufo_follow.value - 1]) + { + UFOMoveToDistance(ufo, players[cv_ufo_follow.value - 1].distancetofinish); + } return; }