From 3742a511abfbca2f9b0cf3f9ca655b16a8f32719 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 29 Sep 2024 23:06:23 +0300 Subject: [PATCH] game: sync monster_start definition --- src/game/g_monster.c | 202 ++++++++++++----------- src/game/header/local.h | 6 +- src/game/monster/assassin/assassin.c | 3 +- src/game/monster/beast/beast.c | 3 +- src/game/monster/elflord/elflord.c | 3 +- src/game/monster/gkrokon/gkrokon.c | 6 +- src/game/monster/gorgon/gorgon.c | 3 +- src/game/monster/harpy/harpy.c | 6 +- src/game/monster/imp/imp.c | 6 +- src/game/monster/morcalavin/morcalavin.c | 3 +- src/game/monster/mssithra/mssithra.c | 3 +- src/game/monster/plagueelf/plagueelf.c | 3 +- src/game/monster/priestess/priestess.c | 3 +- src/game/monster/rat/rat.c | 3 +- src/game/savegame/tables/gamefunc_decs.h | 12 +- 15 files changed, 134 insertions(+), 131 deletions(-) diff --git a/src/game/g_monster.c b/src/game/g_monster.c index 674ccf5ba..843b6a7f5 100644 --- a/src/game/g_monster.c +++ b/src/game/g_monster.c @@ -586,24 +586,26 @@ void monster_use (edict_t *self, edict_t *other, edict_t *activator) void monster_start_go (edict_t *self); - -/*------------------------------------------------------------------------- - monster_triggered_spawn --------------------------------------------------------------------------*/ -void monster_triggered_spawn (edict_t *self) +void +monster_triggered_spawn(edict_t *self) { vec3_t pos; + if (!self) + { + return; + } + self->s.origin[2] += 1; - KillBox (self); + KillBox(self); self->solid = SOLID_BBOX; self->movetype = PHYSICSTYPE_STEP; self->svflags &= ~SVF_NOCLIENT; self->air_finished = level.time + M_HOLD_BREATH_TIME; - gi.linkentity (self); + gi.linkentity(self); - monster_start_go (self); + monster_start_go(self); if((self->classID==CID_ASSASSIN) && (self->spawnflags & MSF_ASS_TPORTAMBUSH)) { @@ -614,7 +616,7 @@ void monster_triggered_spawn (edict_t *self) } else if (self->enemy && !(self->spawnflags & MSF_AMBUSH) && !(self->enemy->flags & FL_NOTARGET)) { - FoundTarget (self, true); + FoundTarget(self, true); } else { @@ -622,25 +624,36 @@ void monster_triggered_spawn (edict_t *self) } } -/*------------------------------------------------------------------------- - monster_triggered_spawn_use --------------------------------------------------------------------------*/ -void monster_triggered_spawn_use (edict_t *self, edict_t *other, edict_t *activator) +void +monster_triggered_spawn_use(edict_t *self, edict_t *other /* unused */, edict_t *activator) { - // we have a one frame delay here so we don't telefrag the guy who activated us + if (!self || !activator) + { + return; + } + + /* we have a one frame delay here so we + don't telefrag the guy who activated us */ self->spawnflags &= ~MSF_ASLEEP; self->think = monster_triggered_spawn; self->nextthink = level.time + FRAMETIME; + if (activator->client) + { self->enemy = activator; + } + self->use = monster_use; } -/*------------------------------------------------------------------------- - monster_triggered_start --------------------------------------------------------------------------*/ -void monster_triggered_start (edict_t *self) +void +monster_triggered_start(edict_t *self) { + if (!self) + { + return; + } + self->solid = SOLID_NOT; self->movetype = PHYSICSTYPE_NONE; self->svflags |= SVF_NOCLIENT; @@ -648,36 +661,41 @@ void monster_triggered_start (edict_t *self) self->use = monster_triggered_spawn_use; } - /* -================ -monster_death_use - -When a monster dies, it fires all of its targets with the current -enemy as activator. -================ -*/ -void monster_death_use (edict_t *self) + * When a monster dies, it fires all of its targets + * with the current enemy as activator. + */ +void +monster_death_use(edict_t *self) { - self->flags &= ~(FL_FLY|FL_SWIM); + if (!self) + { + return; + } + + self->flags &= ~(FL_FLY | FL_SWIM); // self->monsterinfo.aiflags &= AI_GOOD_GUY;//WHY mask out everything above this flag??? if (self->item) { - Drop_Item (self, self->item); + Drop_Item(self, self->item); self->item = NULL; } - if (self->target) - G_UseTargets (self, self->enemy); - if (self->deathtarget) { self->target = self->deathtarget; - G_UseTargets (self, self->enemy); } + + if (!self->target) + { + return; + } + + G_UseTargets(self, self->enemy); } +/* ================================================================== */ //============================================================================ @@ -717,10 +735,8 @@ void MG_CheckInGround (edict_t *self) } } -/*------------------------------------------------------------------------- - monster_start --------------------------------------------------------------------------*/ -qboolean monster_start (edict_t *self) +qboolean +monster_start(edict_t *self) { if ((deathmatch->value == 1) && !((int)sv_cheats->value & self_spawn)) { @@ -743,26 +759,17 @@ qboolean monster_start (edict_t *self) self->monsterinfo.alert = defaultMonsterAlerted;//I don't understand why I get a warning here... self->max_health = self->health; + self->clipmask = MASK_MONSTERSOLID; if(!self->materialtype) self->materialtype = MAT_FLESH; // Stop the camera clipping with monsters, except the trial beast. - if(self->classID!=CID_TBEAST) + if(self->classID != CID_TBEAST) + { self->s.effects|=EF_CAMERA_NO_CLIP; -// jmarshall - we will add real shadows, this is clogging up the effects system. - //if (G_MonsterShadow[self->classID].useShadow) - //{ - // gi.CreateEffect(&self->s, - // FX_SHADOW, - // CEF_OWNERS_ORIGIN, - // self->s.origin, - // "f", - // G_MonsterShadow[self->classID].scale); - //} -// jmarshall end - + } self->s.skinnum = 0; self->deadflag = DEAD_NO; @@ -771,14 +778,20 @@ qboolean monster_start (edict_t *self) self->monsterinfo.nextframeindex = -1; if (!self->monsterinfo.checkattack) + { self->monsterinfo.checkattack = M_CheckAttack; - VectorCopy (self->s.origin, self->s.old_origin); + } + + VectorCopy(self->s.origin, self->s.old_origin); if (st.item) { self->item = playerExport->FindItemByClassname (st.item); if (!self->item) - gi.dprintf("%s at %s has bad item: %s\n", self->classname, vtos(self->s.origin), st.item); + { + gi.dprintf("%s at %s has bad item: %s\n", self->classname, + vtos(self->s.origin), st.item); + } } // randomize what frame they start on @@ -817,18 +830,23 @@ void MG_BBoxAndOriginAdjustForScale (edict_t *self) gi.linkentity(self); } -/*------------------------------------------------------------------------- - monster_start_go --------------------------------------------------------------------------*/ -void monster_start_go (edict_t *self) +void +monster_start_go(edict_t *self) { - vec3_t v; + vec3_t v; float volume; + if (!self) + { + return; + } + self->nextthink = level.time + FRAMETIME; if (self->health <= 0) + { return; + } MG_BBoxAndOriginAdjustForScale(self); MG_CheckInGround(self); @@ -893,7 +911,7 @@ void monster_start_go (edict_t *self) self->target = NULL; } - // validate combattarget + /* validate combattarget */ if (self->combattarget) { edict_t *target; @@ -976,11 +994,8 @@ void monster_start_go (edict_t *self) self->think = monster_think; } - -/*------------------------------------------------------------------------- - walkmonster_start_go --------------------------------------------------------------------------*/ -void walkmonster_start_go (edict_t *self) +void +walkmonster_start_go(edict_t *self) { if (!(self->spawnflags & MSF_ASLEEP) && level.time < 1) { @@ -1001,56 +1016,54 @@ void walkmonster_start_go (edict_t *self) monster_triggered_start (self); } -/*------------------------------------------------------------------------- - walkmonster_start --------------------------------------------------------------------------*/ -qboolean walkmonster_start (edict_t *self) +void +walkmonster_start(edict_t *self) { + if (!self) + { + return; + } + self->think = walkmonster_start_go; - if (!monster_start(self)) - return false; // Failed initialization - else - return true; + monster_start(self); } - -/*------------------------------------------------------------------------- - flymonster_start_go --------------------------------------------------------------------------*/ -void flymonster_start_go (edict_t *self) +void +flymonster_start_go (edict_t *self) { if (!M_walkmove (self, 0, 0)) + { gi.dprintf ("%s in solid at %s\n", self->classname, vtos(self->s.origin)); + } if (!self->yaw_speed) + { self->yaw_speed = 10; + } if(!self->viewheight) + { self->viewheight = 25; + } monster_start_go (self); if (self->spawnflags & MSF_ASLEEP) + { monster_triggered_start (self); + } } - -/*------------------------------------------------------------------------- - flymonster_start --------------------------------------------------------------------------*/ -qboolean flymonster_start (edict_t *self) +void +flymonster_start(edict_t *self) { self->flags |= FL_FLY; self->think = flymonster_start_go; - if (!monster_start(self)) - return false; // Failed initialization - else - return true; + monster_start(self); } - /*------------------------------------------------------------------------- swimmonster_start_go -------------------------------------------------------------------------*/ @@ -1066,19 +1079,18 @@ void swimmonster_start_go (edict_t *self) monster_triggered_start (self); } -/*------------------------------------------------------------------------- - swimmonster_start --------------------------------------------------------------------------*/ -qboolean swimmonster_start (edict_t *self) +void +swimmonster_start(edict_t *self) { + if (!self) + { + return; + } + self->flags |= FL_SWIM; self->think = swimmonster_start_go; M_CatagorizePosition (self); - - if (!monster_start(self)) - return false; // Failed initialization - else - return true; + monster_start(self); } /* diff --git a/src/game/header/local.h b/src/game/header/local.h index 7db2019c9..62b027834 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -992,9 +992,9 @@ void T_DamageRadiusFromLoc(vec3_t origin, edict_t *inflictor, edict_t *attacker, /* g_monster.c */ void M_droptofloor(edict_t *ent); void monster_think(edict_t *self); -qboolean walkmonster_start(edict_t *self); -qboolean swimmonster_start(edict_t *self); -qboolean flymonster_start(edict_t *self); +void walkmonster_start(edict_t *self); +void swimmonster_start(edict_t *self); +void flymonster_start(edict_t *self); void AttackFinished(edict_t *self, float time); void PauseTime(edict_t *self, float time); void monster_death_use(edict_t *self); diff --git a/src/game/monster/assassin/assassin.c b/src/game/monster/assassin/assassin.c index d4355f441..c22f6d846 100644 --- a/src/game/monster/assassin/assassin.c +++ b/src/game/monster/assassin/assassin.c @@ -2886,8 +2886,7 @@ void SP_monster_assassin (edict_t *self) if(self->spawnflags & MSF_ASS_TPORTAMBUSH) self->spawnflags|=MSF_ASLEEP; - if (!walkmonster_start(self)) // Unsuccessful initialization. - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_ASSASSIN; diff --git a/src/game/monster/beast/beast.c b/src/game/monster/beast/beast.c index 0a317f6e7..c6d865189 100644 --- a/src/game/monster/beast/beast.c +++ b/src/game/monster/beast/beast.c @@ -2712,8 +2712,7 @@ void SP_monster_trial_beast (edict_t *self) return; } - if (!walkmonster_start (self)) // Incomplete initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_TBEAST; diff --git a/src/game/monster/elflord/elflord.c b/src/game/monster/elflord/elflord.c index 188e7c55a..3782f8136 100644 --- a/src/game/monster/elflord/elflord.c +++ b/src/game/monster/elflord/elflord.c @@ -802,8 +802,7 @@ Celestial Watcher void SP_monster_elflord (edict_t *self) { // Generic Monster Initialization - if (!flymonster_start(self)) - return; // Failed initialization + flymonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_ELFLORD; diff --git a/src/game/monster/gkrokon/gkrokon.c b/src/game/monster/gkrokon/gkrokon.c index 2944c973c..d594e7bbb 100644 --- a/src/game/monster/gkrokon/gkrokon.c +++ b/src/game/monster/gkrokon/gkrokon.c @@ -1072,10 +1072,10 @@ wakeup_distance = 1024 NOTE: A value of zero will result in defaults, if you actually want zero as the value, use -1 */ -void SP_Monster_Gkrokon(edict_t *self) +void +SP_Monster_Gkrokon(edict_t *self) { - if (!walkmonster_start(self)) // Failed initialization - return; + walkmonster_start(self); self->msgHandler=DefaultMsgHandler; self->classID=CID_GKROKON; diff --git a/src/game/monster/gorgon/gorgon.c b/src/game/monster/gorgon/gorgon.c index 02131fd00..4216abfbd 100644 --- a/src/game/monster/gorgon/gorgon.c +++ b/src/game/monster/gorgon/gorgon.c @@ -2320,8 +2320,7 @@ void SP_monster_gorgon (edict_t *self) } // Generic Monster Initialization - if (!walkmonster_start(self)) // Failed initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_GORGON; diff --git a/src/game/monster/harpy/harpy.c b/src/game/monster/harpy/harpy.c index fe77b235c..ae558d452 100644 --- a/src/game/monster/harpy/harpy.c +++ b/src/game/monster/harpy/harpy.c @@ -1635,10 +1635,10 @@ CIRCLING - harpy circles around in the air "pain_target" - monsters will fire this target the first time it gets hurt (only once) */ -void SP_monster_harpy(edict_t *self) +void +SP_monster_harpy(edict_t *self) { - if (!flymonster_start(self)) - return; // Failed initialization + flymonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_HARPY; diff --git a/src/game/monster/imp/imp.c b/src/game/monster/imp/imp.c index 5ecbffae4..6f4df25d8 100644 --- a/src/game/monster/imp/imp.c +++ b/src/game/monster/imp/imp.c @@ -1398,10 +1398,10 @@ wakeup_distance = 1024 NOTE: A value of zero will result in defaults, if you actually want zero as the value, use -1 */ -void SP_monster_imp(edict_t *self) +void +SP_monster_imp(edict_t *self) { - if (!flymonster_start(self)) - return; // Failed initialization + flymonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_IMP; diff --git a/src/game/monster/morcalavin/morcalavin.c b/src/game/monster/morcalavin/morcalavin.c index 0d9041575..85e0c99a5 100644 --- a/src/game/monster/morcalavin/morcalavin.c +++ b/src/game/monster/morcalavin/morcalavin.c @@ -1894,8 +1894,7 @@ Morky */ void SP_monster_morcalavin (edict_t *self) { - if (!walkmonster_start(self)) // Failed initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_MORK; diff --git a/src/game/monster/mssithra/mssithra.c b/src/game/monster/mssithra/mssithra.c index 9f04628dc..b107d606d 100644 --- a/src/game/monster/mssithra/mssithra.c +++ b/src/game/monster/mssithra/mssithra.c @@ -731,8 +731,7 @@ NOTE: A value of zero will result in defaults, if you actually want zero as the void SP_monster_mssithra (edict_t *self) { // Generic Monster Initialization - if (!walkmonster_start (self)) // failed initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_MSSITHRA; diff --git a/src/game/monster/plagueelf/plagueelf.c b/src/game/monster/plagueelf/plagueelf.c index dfd806a05..9c3a2a73d 100644 --- a/src/game/monster/plagueelf/plagueelf.c +++ b/src/game/monster/plagueelf/plagueelf.c @@ -1974,8 +1974,7 @@ void SP_monster_plagueElf (edict_t *self) self->classID = CID_PLAGUEELF; - if (!walkmonster_start(self)) // Failed initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->monsterinfo.dismember = plagueElf_dismember; diff --git a/src/game/monster/priestess/priestess.c b/src/game/monster/priestess/priestess.c index 5d3691268..fd0651d0c 100644 --- a/src/game/monster/priestess/priestess.c +++ b/src/game/monster/priestess/priestess.c @@ -1628,8 +1628,7 @@ void SP_monster_high_priestess (edict_t *self) return; } - if (!walkmonster_start(self)) // Failed initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_HIGHPRIESTESS; diff --git a/src/game/monster/rat/rat.c b/src/game/monster/rat/rat.c index a49ea016f..9c4922436 100644 --- a/src/game/monster/rat/rat.c +++ b/src/game/monster/rat/rat.c @@ -787,8 +787,7 @@ COWARD - Runs away void SP_monster_rat_giant (edict_t *self) { // Generic Monster Initialization - if (!walkmonster_start(self)) // Failed initialization - return; + walkmonster_start(self); self->msgHandler = DefaultMsgHandler; self->classID = CID_RAT; diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index 034440ed0..b8f34259a 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -733,8 +733,8 @@ extern void flyer_stand ( edict_t * self ) ; extern void flyer_start ( edict_t * self ) ; extern void flyer_stop ( edict_t * self ) ; extern void flyer_walk ( edict_t * self ) ; -// extern void flymonster_start ( edict_t * self ) ; -// extern void flymonster_start_go ( edict_t * self ) ; +extern void flymonster_start ( edict_t * self ) ; +extern void flymonster_start_go ( edict_t * self ) ; extern void force_wall_think ( edict_t * self ) ; extern void force_wall_use ( edict_t * self , edict_t * other , edict_t * activator ) ; extern void func_clock_format_countdown ( edict_t * self ) ; @@ -1314,8 +1314,8 @@ extern void supertank_run ( edict_t * self ) ; extern void supertank_search ( edict_t * self ) ; extern void supertank_stand ( edict_t * self ) ; extern void supertank_walk ( edict_t * self ) ; -// extern void swimmonster_start ( edict_t * self ) ; -// extern void swimmonster_start_go ( edict_t * self ) ; +extern void swimmonster_start ( edict_t * self ) ; +extern void swimmonster_start_go ( edict_t * self ) ; extern void swing_sword_step ( edict_t * self ) ; extern void takeoff_goal ( edict_t * self ) ; extern void tank_attack ( edict_t * self ) ; @@ -1447,8 +1447,8 @@ extern void vengeance_think ( edict_t * self ) ; extern void vengeance_touch ( edict_t * self , edict_t * other , cplane_t * plane , csurface_t * surf ) ; extern void viewthing_think ( edict_t * ent ) ; extern void wait_and_change_think ( edict_t * ent ) ; -// extern void walkmonster_start ( edict_t * self ) ; -// extern void walkmonster_start_go ( edict_t * self ) ; +extern void walkmonster_start ( edict_t * self ) ; +extern void walkmonster_start_go ( edict_t * self ) ; extern void water_to_land ( edict_t * self ) ; extern void weapon_bfg_fire ( edict_t * ent ) ; extern void weapon_chainfist_fire ( edict_t * ent ) ;