djcev.com

//

Git Repos / fte_dogmode / qc / triggers / camera.qc

Last update to this file was on 2024-01-09 at 11:09.

Show camera.qc

//==============================================================================
// trigger_camera, trigger_camera_point -- was in cutscene.qc
//==============================================================================

class base_trigger_camera: base_trigger
{
float is_removed;

//--------------------------------------------------------------
// camera_activate -- PM: Called from either touch or use.
//--------------------------------------------------------------
nonvirtual void(entity who) camera_activate =
{
// only activate for player, 1st time touched
if (who.health <= 0)
return;
// In case of Alien Quake facehugger kill.
if (who.deadflag)
return;
if (who.classname != "player")
return;

// You can't touch/use this again.
this.is_removed = TRUE;

// If player is on ground, take him off ground so no one
// gets confused
who.flags = who.flags - (who.flags & FL_ONGROUND);

// put a dummy where the player was
spawn_dummy (who);

// find camera
local entity t;

t = find (world, ::targetname, this.target);
/*
if (vision)
{
if (!t)
objerror ("couldn't find target");
}
else
{
*/
local entity fpt;

while ((t != world) &&
(t.classname != "info_movie_camera"))
{
t = find (t, ::targetname, this.target);
}

if (!t)
objerror ("couldn't find target");

// find focal point
fpt = find (world, ::targetname, this.focal_point);
if (!fpt)
objerror ("You must have a focal point!\n");
else
// movedir used to calc focal dir
who.movedir = fpt.origin;
/*
}
*/

// Go to the camera - not in this function, because touch
// functions are called while looping through c code, and
// you don't want to move the player, or something like that?

// save camera position, etc.
who.enemy = t;
// save script number
who.script = this.script;
// save delay for page 1
who.script_delay = this.script_delay;

/*
if (vision)
{
// PM: Don't try instant start because that
// breaks soeexit.bsp.
who.nextthink = time + 0.05;
who.think = go_camera;
}
else
{
*/
SUB_Think (who, go_camera);
/*
}
*/

activator = this;
sub_usetargets ();

// Remove the trigger_camera from level
this.nextthink = time + 0.1;
this.think = sub_remove;
};

//--------------------------------------------------------------
virtual void() camera_touch =
{
if (this.targetname != __NULL__ && this.targetname != "")
if (this.nextthink < time)
return;

if (this.cnt == -1)
return;

this.camera_activate (other);
};

//--------------------------------------------------------------
virtual void() camera_point_touch =
{
this.camera_activate (other);
};

//--------------------------------------------------------------
virtual void() camera_use =
{
local entity pl;

// Only one in single-player.
pl = findfloat (world, ::classtype, CT_PLAYER);
this.camera_activate (pl);

// Old code.
/*
this.nextthink = time + 100000;
// make sure even still objects get hit
force_retouch = 2;
this.think = __NULL__;
*/
};

//--------------------------------------------------------------
virtual void(float pt) trigger_camera_spawn =
{
// Update: Don't let dmsp muck up cutscenes and vice versa.
// PM: Fix -- abort if removed.
if (deathmatch || coop)
{
remove (this);
return;
}

this.is_removed = FALSE;

if (pt)
{
// The new way, this is for you Tronyn.
init_point_trigger ();
if (!this.targetname)
this.touch = this.camera_point_touch;
}
else
{
// The old way...
init_trigger ();
// PM: Must always allow touch because some
// old maps need it.
this.touch = this.camera_touch;
}

// find the destination
if (!this.target)
objerror ("Camera trigger with no target");
this.use = this.camera_use;
};
};

/*QUAKED trigger_camera (.5 .5 .5) ? X 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
A player touching this will be transported to the corresponding
info_movie_camera entity. You must set the "target" field, and put a
info_movie_camera with a "targetname" field that matches. The "script"
key gives a starting script number, and the "script_delay" key is the
amount of time(seconds) to stay on the first script page.

If the trigger_camera has a targetname, it will only enter camera mode
after it has been fired.
*/
class trigger_camera: base_trigger_camera
{
//--------------------------------------------------------------
virtual void() init_spawned =
{
trigger_camera_spawn (FALSE);
};

//--------------------------------------------------------------
void() trigger_camera =
{
this.classtype = CT_TRIGGER_CAMERA;
};
};

/*QUAKED trigger_camera_point (.5 .5 .5) X 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 this is triggered the player will be transported to the corresponding
info_movie_camera entity. You must set the "target" field, and put a
info_movie_camera with a "targetname" field that matches. The "script"
key gives a starting script number, and the "script_delay" key is the
amount of time(seconds) to stay on the first script page.
*/
class trigger_camera_point: base_trigger_camera
{
//--------------------------------------------------------------
virtual void() init_spawned =
{
this.trigger_camera_spawn (TRUE);
};

//--------------------------------------------------------------
void() trigger_camera_point =
{
this.classtype = CT_TRIGGER_CAMERA_POINT;
};
};

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

Log camera.qc

Date Commit Message Author + -
2024-01-09 Continue OO / Class-based refactor cev +20 -8
2023-12-09 Start OO / class-based refactor, work on items cev +209  

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