djcev.com

//

Git Repos / fte_dogmode / qc / base_trigger.qc

Last update to this file was on 2024-11-20 at 23:54.

Show base_trigger.qc

//==============================================================================
// base_trigger.qc -- trigger base class
//==============================================================================

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

#if defined(CSQC) || defined(SSQC)
const float BASE_TRIGGER_NET_ORIGIN = 1<<0; // origin has changed
const float BASE_TRIGGER_NET_SIZE = 1<<1; // size (mins, maxs) has changed
const float BASE_TRIGGER_NET_STATE = 1<<2; // state has changed
const float BASE_TRIGGER_NET_ESTATE = 1<<3; // estate has changed
const float BASE_TRIGGER_NET_MOVEDIR = 1<<4; // movedir has changed
const float BASE_TRIGGER_NET_SPEED = 1<<5; // speed has changed
const float BASE_TRIGGER_NET_ANGLES = 1<<6; // angle has changed
#endif

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

// base_trigger
#ifdef SSQC
void(entity e) sub_checkwaiting;
void() sub_endwaiting;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) base_trigger_point_init;
void(entity e) base_trigger_init;
#endif
#ifdef SSQC
strip void() base_trigger;
#endif

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

//----------------------------------------------------------------------
// class base_trigger: base_mapentity
// {
//==============================================================
// Subs
//==============================================================

#ifdef SSQC
//--------------------------------------------------------------
void(entity e) sub_checkwaiting =
{
if (e.is_waiting <= 0)
return;

// store current use to swap later
e.olduse = e.use;
e.use = sub_endwaiting;
e.estate = STATE_INACTIVE;

dprint (sprintf("sub_checkwaiting: spawned a waiting "
"%s with targetname %s and target %s\n",
e.classname, e.targetname, e.target));

if (e.SendEntity)
e.SendFlags |= BASE_TRIGGER_NET_ESTATE;
};

//--------------------------------------------------------------
void() sub_endwaiting =
{
self.is_waiting = FALSE;
self.estate = STATE_ACTIVE;

if (self.use == sub_endwaiting)
self.use = self.olduse;

// special case for teleports, makes it ignore the
// fact that it has a targetname when touched
if (self.classtype == CT_TRIGGER_TELEPORT)
self.is_waiting = -1;

if (self.SendEntity)
self.SendFlags |= BASE_TRIGGER_NET_ESTATE;
};
#endif

//==============================================================
// Constructor & Spawn Functions
//==============================================================

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
// InitPointTrigger -- Drake -- dumptruck_ds
// PM: The point trigger version of InitTrigger.
//--------------------------------------------------------------
void(entity e) base_trigger_point_init =
{
local vector v1, v2;

v1 = e.origin;
v2 = v1 + e.mangle;
e.model = "";
setorigin (e, '0 0 0');

// Calls 'setmodel', so do first.
base_trigger_init (e);

// Calling 'setmodel' resets entity size.
setsize (e, v1, v2);
};

//--------------------------------------------------------------
// InitTrigger
//--------------------------------------------------------------
void(entity e) base_trigger_init =
{
base_mapentity_init (e);

e.classgroup |= CG_TRIGGER;

#ifdef SSQC
// trigger angles are used for one-way touches.
// An angle of 0 is assumed to mean no restrictions, so use a
// yaw of 360 instead.
if (e.angles != '0 0 0')
sub_setmovedir (e);
#endif

e.solid = SOLID_TRIGGER;

#ifdef SSQC
// set size and link into world
setmodel (e, e.model);
e.movetype = MOVETYPE_NONE;
e.modelindex = 0;
e.model = "";
#endif
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
strip void() base_trigger =
{
base_trigger_init (self);
};
// };
#endif

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

Log base_trigger.qc

Date Commit Message Author + -
2024-11-20 pmove refactor into prepoc macros, view bobbing cev +1  
2024-06-15 Major update, committing as-is, will have bugs cev +38 -2
2024-04-12 Moveable gibs, heads, some bugfixes cev +1  
2024-03-24 2nd pass refactor, rework QC class structure cev +62 -82
2024-01-31 Class based monster refactor & start projectiles cev +24 -15
2024-01-09 Continue OO / Class-based refactor cev +118  

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