Git Repos / fte_dogmode / qc / triggers / ladder.qc
Last update to this file was on 2024-11-20 at 23:54.
Show ladder.qc
//==============================================================================
// trigger_ladder -- selections from Rubicon 2 qc by john fitzgibbons
//==============================================================================
//======================================================================
// forward declarations
//======================================================================
#ifdef CSQC
void(float isnew) trigger_ladder_netreceive;
#endif
#ifdef SSQC
float(entity to, float netflags) trigger_ladder_netsend;
#endif
#if defined(CSQC) || defined (SSQC)
void() trigger_ladder_touch;
void(entity e) trigger_ladder_init;
#endif
#ifdef SSQC
void() trigger_ladder;
#endif
//------------------------------------------------------------------------------
/*QUAKED trigger_ladder (.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
invisible ladder entity. when player is touching this entity, he can climb by pushing 'jump'
Keys:
"angle" the direction player must be facing to climb ladder
*/
//----------------------------------------------------------------------
// class trigger_ladder: base_trigger
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) trigger_ladder_netreceive =
{
local float netflags = ReadFloat ();
if (netflags & BASE_TRIGGER_NET_ORIGIN)
{
self.origin_x = ReadCoord ();
self.origin_y = ReadCoord ();
self.origin_z = ReadCoord ();
}
if (netflags & BASE_TRIGGER_NET_SIZE)
{
self.mins_x = ReadCoord ();
self.mins_y = ReadCoord ();
self.mins_z = ReadCoord ();
self.maxs_x = ReadCoord ();
self.maxs_y = ReadCoord ();
self.maxs_z = ReadCoord ();
}
if (netflags & BASE_TRIGGER_NET_MOVEDIR)
{
self.movedir_x = ReadShort () * (360 / 32767);
self.movedir_y = ReadShort () * (360 / 32767);
self.movedir_z = ReadShort () * (360 / 32767);
}
if (netflags & BASE_TRIGGER_NET_ANGLES)
{
self.angles_x = ReadAngle ();
self.angles_y = ReadAngle ();
self.angles_z = ReadAngle ();
}
if (netflags & BASE_TRIGGER_NET_ESTATE)
self.estate = ReadFloat ();
if (isnew)
trigger_ladder_init (self);
// make sure size and origin are set -- CEV
if (netflags & BASE_TRIGGER_NET_SIZE)
setsize (self, self.mins, self.maxs);
if (netflags & BASE_TRIGGER_NET_ORIGIN)
setorigin (self, self.origin);
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
float(entity to, float netflags) trigger_ladder_netsend =
{
WriteShort (MSG_ENTITY, self.classtype);
WriteFloat (MSG_ENTITY, netflags);
if (netflags & BASE_TRIGGER_NET_ORIGIN)
{
WriteCoord (MSG_ENTITY, self.origin_x);
WriteCoord (MSG_ENTITY, self.origin_y);
WriteCoord (MSG_ENTITY, self.origin_z);
}
if (netflags & BASE_TRIGGER_NET_SIZE)
{
WriteCoord (MSG_ENTITY, self.mins_x);
WriteCoord (MSG_ENTITY, self.mins_y);
WriteCoord (MSG_ENTITY, self.mins_z);
WriteCoord (MSG_ENTITY, self.maxs_x);
WriteCoord (MSG_ENTITY, self.maxs_y);
WriteCoord (MSG_ENTITY, self.maxs_z);
}
if (netflags & BASE_TRIGGER_NET_MOVEDIR)
{
WriteShort (MSG_ENTITY, self.movedir_x * (32767 / 360));
WriteShort (MSG_ENTITY, self.movedir_y * (32767 / 360));
WriteShort (MSG_ENTITY, self.movedir_z * (32767 / 360));
}
if (netflags & BASE_TRIGGER_NET_ANGLES)
{
WriteAngle (MSG_ENTITY, self.angles_x);
WriteAngle (MSG_ENTITY, self.angles_y);
WriteAngle (MSG_ENTITY, self.angles_z);
}
if (netflags & BASE_TRIGGER_NET_ESTATE)
WriteFloat (MSG_ENTITY, self.estate);
return TRUE;
};
#endif
#if defined(CSQC) || defined (SSQC)
//--------------------------------------------------------------
// trigger_ladder_touch
//--------------------------------------------------------------
void() trigger_ladder_touch =
{
// from Copper -- dumptruck_ds
if (sub_checkvalidtouch(other) == FALSE)
return;
// prevent the player "sticking" to a ladder if they are
// standing on the platform at the top of the ladder with
// the bottom of their bounding box flush with the top of
// the trigger -- iw
if (other.absmin_z + 1 >= self.absmax_z - 1)
return;
// if the trigger has an angles field, check player's
// facing direction
if (self.movedir != '0 0 0')
{
makevectors (other.angles);
if (v_forward * self.movedir < 0)
// not facing the right way
return;
}
// changed to PMFLAGS -- CEV
other.pm_flags |= PMF_ONLADDER;
};
#endif
#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) trigger_ladder_init =
{
e.classname = "trigger_ladder";
e.classtype = CT_TRIGGER_LADDER;
#ifdef SSQC
// ignore an "up" or "down" angle (doesn't make sense
// for a ladder)
if (e.angles_y == -1 || e.angles_y == -2)
{
dprint (sprintf("trigger_ladder_init: ignoring bad "
"'angle' value: %g\n", e.angles_y));
e.angles_y = 0;
}
#endif
base_trigger_init (e);
e.touch = trigger_ladder_touch;
#ifdef SSQC
sub_checkwaiting (e);
// trigger_ladder needs to be networked to the client. set
// our transmit function then full send the entity -- CEV
e.SendEntity = trigger_ladder_netsend;
e.SendFlags |= BASE_TRIGGER_NET_ORIGIN |
BASE_TRIGGER_NET_SIZE |
BASE_TRIGGER_NET_ESTATE |
BASE_TRIGGER_NET_ANGLES |
BASE_TRIGGER_NET_MOVEDIR;
#endif
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
void() trigger_ladder =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
trigger_ladder_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log ladder.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-11-20 | pmove refactor into prepoc macros, view bobbing | cev | +17 | -3 |
2024-07-17 | pmove changes, smooth crouching | cev | +1 | -1 |
2024-07-03 | pmove changes and fixes, improved climbing | cev | +1 | -1 |
2024-06-15 | Major update, committing as-is, will have bugs | cev | +113 | |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +37 | -20 |
2024-01-09 | Continue OO / Class-based refactor | cev | +13 | -14 |
2023-12-09 | Start OO / class-based refactor, work on items | cev | +52 | -50 |
2023-11-16 | pmove bug fixes, moved q3 compat code, cleanup | cev | +67 |
Return to the top of this page or return to the overview of this repo.