djcev.com

//

Git Repos / fte_dogmode / qc / triggers / changelevel.qc

Last update to this file was on 2024-06-15 at 19:50.

Show changelevel.qc

//==============================================================================
// trigger_changelevel
//==============================================================================

//======================================================================
// constants
//======================================================================

#ifdef SSQC
const float TRIGGER_CHANGELEVEL_EXITOFF = 8; // was DT_EXITOFF
#endif

//======================================================================
// forward declarations
//======================================================================

#ifdef SSQC
// trigger_changelevel
void() trigger_changelevel_think;
void() trigger_changelevel_touch;
void() trigger_changelevel_use;
entity(entity src, vector org, string m) spawn_trigger_changelevel;
void(entity e) trigger_changelevel_init;
void() trigger_changelevel;
#endif

//------------------------------------------------------------------------------

#ifdef SSQC
/*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
*/
//----------------------------------------------------------------------
// class trigger_changelevel: base_trigger
// {
//--------------------------------------------------------------
// was changelevel_execute
//--------------------------------------------------------------
void() trigger_changelevel_think =
{
used_exit = self;
local entity pos;

intermission = 1;
WriteIntermission ();

// enforce a wait time before allowing changelevel
if (deathmatch)
intermission_exittime = time + 5;
else
intermission_exittime = time + 2;

WriteByte (MSG_ALL, SVC_CDTRACK);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 3);

pos = FindIntermission ();

other = findfloat (world, classtype, CT_PLAYER);
while (other != world)
{
other.velocity = '0 0 0';
other.view_ofs = '0 0 0';
other.angles = other.v_angle = pos.mangle;
// turn this way immediately
other.fixangle = TRUE;
other.nextthink = time + 0.5;
other.takedamage = DAMAGE_NO;
other.solid = SOLID_NOT;
other.movetype = MOVETYPE_NONE;
other.modelindex = 0;
setorigin (other, pos.origin);
fog_set_from_ent (other, pos);
other.SendFlags = 0xffffff;
other = findfloat (other, classtype, CT_PLAYER);
}

// Drake -- dumptruck_ds
if (cutscene)
{
// If player was in a cutscene when the level ended,
// restore viewsize.
pos = find (world, classname, "camera");
if (pos)
{
local string val;

val = ftos (pos.cnt);
cvar_set ("viewsize", val);
}
}

WriteByte (MSG_ALL, SVC_INTERMISSION);
};

//--------------------------------------------------------------
void() trigger_changelevel_touch =
{
if (self.estate != STATE_ACTIVE)
return;

// from Copper -- dumptruck_ds
if (sub_checkvalidtouch(other) == FALSE)
return;

if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) &&
(mapname != "start")))
{
t_damage2 (other, self, self, 50000);
return;
}

if (coop || deathmatch)
{
bprint (other.netname);
bprint (" exited the level\n");
}

nextmap = self.map;
sub_usetargets ();

if ((self.spawnflags & 16) && (deathmatch == 0))
{
// use info_player_start2 -- dumptruck_ds
item_sigil_touch2 ();
}

if ((self.spawnflags & 1) && (deathmatch == 0))
{
// NO_INTERMISSION
GotoNextMap ();
return;
}

self.touch = sub_null;
self.use = sub_null;

// we can't move people right now, because touch functions
// are called in the middle of C movement code, so set a
// think time to do it
self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
// trigger_changelevel_use
// dumptruck_ds based on hipnotic blocker_use; was named dt_exit_toggle
//--------------------------------------------------------------
void() trigger_changelevel_use =
{
if (self.estate != STATE_ACTIVE)
{
self.is_waiting = 0;
self.estate = STATE_ACTIVE;
}
else
{
self.is_waiting = 1;
self.estate = STATE_INACTIVE;
}
};

//--------------------------------------------------------------
entity(entity src, vector org, string m) spawn_trigger_changelevel =
{
local entity e = spawn ();
e.owner = src;
e.origin = org;
e.map = m;

trigger_changelevel_init (e);
return e;
};

//--------------------------------------------------------------
void(entity e) trigger_changelevel_init =
{
e.classname = "trigger_changelevel";
e.classtype = CT_TRIGGER_CHANGELEVEL;
e.think = trigger_changelevel_think;
e.touch = trigger_changelevel_touch;
e.use = trigger_changelevel_use;

// dumptruck_ds
if (e.spawnflags & TRIGGER_CHANGELEVEL_EXITOFF)
e.is_waiting = 1;

sub_checkwaiting (e);

if (!e.map)
objerror ("changelevel trigger doesn't have map");

base_trigger_init (e);

e.flags |= FL_NOCENTERPRINT;
};

//--------------------------------------------------------------
void() trigger_changelevel =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trigger_changelevel_init (self);
};
// };
#endif

Return to the top of this page or return to the overview of this repo.

Log changelevel.qc

Return to the top of this page or return to the overview of this repo.