trigger_transition: Handle the carrying-over of entity information based on 'globalname'.
This commit is contained in:
parent
f76c169671
commit
4b36ec3bb0
4 changed files with 140 additions and 1 deletions
|
@ -55,6 +55,7 @@ server/light.qc
|
|||
server/logic_auto.qc
|
||||
server/logic_relay.qc
|
||||
server/logic_timer.qc
|
||||
server/logic_case.qc
|
||||
server/stubs.qc
|
||||
server/infodecal.qc
|
||||
server/item_generic.qc
|
||||
|
@ -73,6 +74,7 @@ server/trigger_autosave.qc
|
|||
server/trigger_cdaudio.qc
|
||||
server/trigger_counter.qc
|
||||
server/trigger_hurt.qc
|
||||
server/trigger_transition.qc
|
||||
server/trigger_changelevel.qc
|
||||
server/trigger_endsection.qc
|
||||
server/trigger_changetarget.qc
|
||||
|
@ -80,7 +82,6 @@ server/trigger_look.qc
|
|||
server/trigger_once.qc
|
||||
server/trigger_multiple.qc
|
||||
server/trigger_teleport.qc
|
||||
server/trigger_transition.qc
|
||||
server/trigger_playerfreeze.qc
|
||||
server/trigger_relay.qc
|
||||
server/env_shooter.qc
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
/* overrides */
|
||||
virtual void Save(float);
|
||||
virtual void Restore(string,string);
|
||||
virtual void RestoreComplete(void);
|
||||
virtual void SpawnKey(string,string);
|
||||
virtual void Spawned(void);
|
||||
virtual void Respawn(void);
|
||||
|
@ -157,6 +158,13 @@ trigger_changelevel::Restore(string strKey, string strValue)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
trigger_changelevel::RestoreComplete(void)
|
||||
{
|
||||
super::RestoreComplete();
|
||||
SetSolid(SOLID_TRIGGER);
|
||||
}
|
||||
|
||||
void
|
||||
trigger_changelevel::SpawnKey(string strKey, string strValue)
|
||||
{
|
||||
|
@ -250,8 +258,17 @@ trigger_changelevel::Change(void)
|
|||
info_landmark lm = (info_landmark)e;
|
||||
/* found it */
|
||||
if (lm.targetname == m_strLandmark) {
|
||||
trigger_transition t;
|
||||
NSLog("^2trigger_changelevel::^3Change^7: Found landmark for %s", m_strLandmark);
|
||||
g_landmarkpos = m_activator.origin - lm.origin;
|
||||
|
||||
/* time to transition */
|
||||
t = (trigger_transition)find(world, ::targetname, m_strLandmark);
|
||||
|
||||
if (t) {
|
||||
t.SaveTransition();
|
||||
}
|
||||
|
||||
changelevel(m_strMap, m_strLandmark);
|
||||
break;
|
||||
}
|
||||
|
@ -318,3 +335,9 @@ Landmark_GetSpot(void)
|
|||
print(sprintf("^1ERROR^7: Landmark_GetSpot: Cannot find startspot '%s'!\n",startspot));
|
||||
return ips.origin;
|
||||
}
|
||||
|
||||
vector
|
||||
Landmark_GetPosition(void)
|
||||
{
|
||||
return g_landmarkpos;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ trigger_transition:NSBrushTrigger
|
|||
void trigger_transition(void);
|
||||
|
||||
virtual void Respawn(void);
|
||||
nonvirtual void SaveTransition(void);
|
||||
nonvirtual NSEntity FindCarrierEntity(string);
|
||||
nonvirtual void LoadTransition(void);
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -43,3 +46,109 @@ trigger_transition::Respawn(void)
|
|||
{
|
||||
InitBrushTrigger();
|
||||
}
|
||||
|
||||
void
|
||||
trigger_transition::SaveTransition(void)
|
||||
{
|
||||
int i = 0i;
|
||||
filestream transFile = fopen("trans.dat", FILE_WRITE);
|
||||
|
||||
if (transFile < 0) {
|
||||
error("Unable to write trans.dat for transitioning.");
|
||||
}
|
||||
|
||||
/* loop through all entities */
|
||||
for (NSEntity a = __NULL__; (a = (NSEntity)findfloat(a, ::identity, 1));) {
|
||||
print(sprintf("TRANSITION: %i %S %S\n", i, a.classname, a.m_strGlobalName));
|
||||
|
||||
if (a == this)
|
||||
continue;
|
||||
|
||||
if (WithinBounds(a) == true) {
|
||||
fputs(transFile, sprintf("ENTITY \"%i\" %S\n", i, a.classname));
|
||||
fputs(transFile, "{\n");
|
||||
a.Save(transFile);
|
||||
fputs(transFile, "}\n");
|
||||
} else if (a.m_strGlobalName) {
|
||||
fputs(transFile, sprintf("CONTINUE \"%i\" %S\n", i, a.m_strGlobalName));
|
||||
fputs(transFile, "{\n");
|
||||
a.Save(transFile);
|
||||
fputs(transFile, "}\n");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
fclose(transFile);
|
||||
}
|
||||
|
||||
NSEntity
|
||||
trigger_transition::FindCarrierEntity(string globalName)
|
||||
{
|
||||
for (NSEntity a = __NULL__; (a = (NSEntity)findfloat(a, ::identity, 1));) {
|
||||
if (a.m_strGlobalName == globalName) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return __NULL__;
|
||||
}
|
||||
|
||||
vector Landmark_GetPosition(void);
|
||||
|
||||
void
|
||||
trigger_transition::LoadTransition(void)
|
||||
{
|
||||
string lineFeed;
|
||||
bool carryEntity;
|
||||
NSEntity carrierEntity = __NULL__;
|
||||
|
||||
filestream transFile = fopen("trans.dat", FILE_READ);
|
||||
|
||||
if (transFile < 0) {
|
||||
error("this should never happen.");
|
||||
}
|
||||
|
||||
print(sprintf("Found transition file. Will transition over entities.\n"));
|
||||
|
||||
while ((lineFeed = fgets(transFile))) {
|
||||
int c = tokenize(lineFeed);
|
||||
|
||||
/* start of an entity */
|
||||
if (argv(0) == "{") {
|
||||
continue;
|
||||
} else if (argv(0) == "}") {
|
||||
carryEntity = false;
|
||||
carrierEntity = __NULL__;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == 3) {
|
||||
if (argv(0) == "CONTINUE") {
|
||||
carrierEntity = FindCarrierEntity(argv(2));
|
||||
carryEntity = true;
|
||||
} else if (argv(0) == "ENTITY") {
|
||||
//carrierEntity = spawn
|
||||
carryEntity = false;
|
||||
}
|
||||
} else if (c == 2) { /* key value pairs */
|
||||
if (carrierEntity) {
|
||||
switch (argv(0)) {
|
||||
case "model":
|
||||
case "modelindex":
|
||||
break;
|
||||
#if 0
|
||||
case "origin":
|
||||
vector newOrigin = stov(argv(1)) + Landmark_GetPosition();
|
||||
print(sprintf("Offsetting %S by %v\n", carrierEntity.m_strGlobalName, Landmark_GetPosition()));
|
||||
carrierEntity.Restore("origin", vtos(newOrigin));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
carrierEntity.Restore(argv(0), argv(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fremove("trans.dat");
|
||||
}
|
|
@ -142,6 +142,11 @@ PutClientInServer(void)
|
|||
if (g_ents_initialized)
|
||||
g_grMode.PlayerSpawn((NSClientPlayer)self);
|
||||
|
||||
/* handle transitions */
|
||||
if (whichpack("data/trans.dat")) {
|
||||
trigger_transition::LoadTransition();
|
||||
}
|
||||
|
||||
Plugin_PlayerEntered((NSClientPlayer)self);
|
||||
|
||||
/* activate all game_playerspawn entities */
|
||||
|
@ -364,6 +369,7 @@ init_respawn(void)
|
|||
}
|
||||
|
||||
print(sprintf("...%i entities spawned (%i inhibited)\n", g_ent_spawned, g_ent_spawned - endspawn));
|
||||
|
||||
remove(self);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue