SERVER: Make Teddies work with Soft_Restart

This commit is contained in:
cypress 2023-08-29 22:46:50 -04:00
parent ea90417314
commit aec68db169
4 changed files with 36 additions and 2 deletions

View file

@ -568,6 +568,21 @@ void (float achievement_id, float progress_value, optional entity who) UpdateAch
// Unrelated to engine, but custom functions
// *****************************************
// "Removes" an entity that is placed back on restart.
void(entity ent) Ent_FakeRemove =
{
ent.entity_removed = true;
ent.oldmodel = ent.model;
ent.oldorigin = ent.origin;
ent.bbmins = ent.mins;
ent.bbmaxs = ent.maxs;
ent.sprintflag = ent.solid;
ent.solid = SOLID_NOT;
setsize(ent, '0 0 0', '0 0 0');
setmodel(ent, "");
}
void(string modelname) Precache_Set = // Precache model, and set myself to it
{
modelname = convert_old_asset_path(modelname);

View file

@ -507,6 +507,7 @@ waypoint_ai waypoints[MAX_WAYPOINTS];
//Misc patch definitions
.string teddyremovetarget;
.float entity_removed;
.float oldz; // used for fall damage that does not truly work correctly

View file

@ -277,7 +277,7 @@ void() teddy_react =
t = find (world, teddyremovetarget, self.target);
if (t)
remove(t);
Ent_FakeRemove(t);
} else if (self.target) {
SUB_UseTargets();
}
@ -291,7 +291,7 @@ void() teddy_react =
if (self.noise)
sound (dummy, CHAN_ITEM, self.noise, 1, ATTN_NORM);
remove(self);
Ent_FakeRemove(self);
}
/*

View file

@ -238,6 +238,23 @@ void() GameRestart_ResetMysteryBox =
}
}
void() GameRestart_RestoreFakeRemovals =
{
entity ent = findfloat(world, entity_removed, true);
while(ent != world) {
ent.entity_removed = false;
ent.model = ent.oldmodel;
ent.origin = ent.oldorigin;
ent.mins = ent.bbmins;
ent.maxs = ent.bbmaxs;
ent.solid = ent.sprintflag;
setsize(ent, ent.mins, ent.maxs);
setmodel(ent, ent.model);
ent = findfloat(ent, entity_removed, true);
}
}
//moto -- put this here because it keeps soft_restart somewhat clean..
void(entity door) reclose_door = {
entity oldself;
@ -289,6 +306,7 @@ void() Soft_Restart = {
GameRestart_RepairBarricades(); // Make sure all barricades are fully repaired.
GameRestart_ResetPerkaColas(); // Turn all of the Perk-a-Cola lights off, reset states.
GameRestart_ResetMysteryBox(); // Clean up the Mystery Box, delete floating weapon, etc.
GameRestart_RestoreFakeRemovals(); // Puts back everything "removed" using Ent_FakeRemove().
//close doors
doors = findfloat(world, isopen, 1);