Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ladder.qc File Reference
#include "ladder.qh"
Include dependency graph for ladder.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void func_ladder_init (entity this)
void func_ladder_link (entity this)
bool func_ladder_send (entity this, entity to, int sf)
void func_ladder_think (entity this)
 spawnfunc (func_ladder)
 spawnfunc (func_water)

Function Documentation

◆ func_ladder_init()

void func_ladder_init ( entity this)

Definition at line 55 of file ladder.qc.

56{
59 func_ladder_link(this);
61 this.nextthink = time;
62
63 if(min(this.absmax.x - this.absmin.x, this.absmax.y - this.absmin.y) > 100)
64 return;
65
66 entity tracetest_ent = spawn();
67 setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
68 tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
69
70 vector top_min = (this.absmin + this.absmax) * 0.5;
71 top_min.z = this.absmax.z;
72 vector top_max = top_min;
73 top_max.z += PL_MAX_CONST.z - PL_MIN_CONST.z;
74 tracebox(top_max + jumpstepheightvec, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
76 {
77 tracebox(top_max + stepheightvec, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
79 {
80 tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
82 {
83 if(this.absmax.x - this.absmin.x > PL_MAX_CONST.x - PL_MIN_CONST.x
84 && this.absmax.y - this.absmin.y < this.absmax.x - this.absmin.x)
85 {
86 // move top on one side
87 top_max.y = top_min.y = this.absmin.y + (PL_MAX_CONST.y - PL_MIN_CONST.y) * 0.75;
88 }
89 else if(this.absmax.y - this.absmin.y > PL_MAX_CONST.y - PL_MIN_CONST.y
90 && this.absmax.x - this.absmin.x < this.absmax.y - this.absmin.y)
91 {
92 // move top on one side
93 top_max.x = top_min.x = this.absmin.x + (PL_MAX_CONST.x - PL_MIN_CONST.x) * 0.75;
94 }
95 tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
97 {
98 if(this.absmax.x - this.absmin.x > PL_MAX_CONST.x - PL_MIN_CONST.x
99 && this.absmax.y - this.absmin.y < this.absmax.x - this.absmin.x)
100 {
101 // alternatively on the other side
102 top_max.y = top_min.y = this.absmax.y - (PL_MAX_CONST.y - PL_MIN_CONST.y) * 0.75;
103 }
104 else if(this.absmax.y - this.absmin.y > PL_MAX_CONST.y - PL_MIN_CONST.y
105 && this.absmax.x - this.absmin.x < this.absmax.y - this.absmin.y)
106 {
107 // alternatively on the other side
108 top_max.x = top_min.x = this.absmax.x - (PL_MAX_CONST.x - PL_MIN_CONST.x) * 0.75;
109 }
110 tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
111 }
112 }
113 }
114 }
115 delete(tracetest_ent);
116 if(trace_startsolid || trace_endpos.z < this.absmax.z)
117 {
118 return;
119 }
120
121 this.bot_pickup = true; // allow bots to make use of this ladder
122 float cost = waypoint_getlinearcost(trace_endpos.z - this.absmin.z);
123 top_min = trace_endpos;
124 waypoint_spawnforteleporter_boxes(this, WAYPOINTFLAG_LADDER, this.absmin, this.absmax, top_min, top_min, cost);
125}
const int WAYPOINTFLAG_LADDER
Definition api.qh:19
float bot_pickup
Definition api.qh:43
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
const vector PL_MIN_CONST
Definition constants.qh:56
const vector PL_MAX_CONST
Definition constants.qh:55
const float MOVE_NOMONSTERS
float DPCONTENTS_BOTCLIP
float DPCONTENTS_SOLID
float DPCONTENTS_BODY
float effects
float DPCONTENTS_PLAYERCLIP
float time
vector trace_endpos
float trace_startsolid
float nextthink
vector absmax
const float EF_NODEPTHTEST
vector absmin
#define spawn
void func_ladder_link(entity this)
Definition ladder.qc:49
void func_ladder_think(entity this)
Definition ladder.qc:4
#define BITSET_ASSIGN(a, b)
Definition common.qh:104
float min(float f,...)
vector jumpstepheightvec
Definition navigation.qh:10
vector stepheightvec
Definition navigation.qh:11
#define setthink(e, f)
vector
Definition self.qh:92
void WarpZoneLib_ExactTrigger_Init(entity this, bool unsetmodel)
void waypoint_spawnforteleporter_boxes(entity e, int teleport_flag, vector org1, vector org2, vector destination1, vector destination2, float timetaken)
float waypoint_getlinearcost(float dist)

References absmax, absmin, BITSET_ASSIGN, bot_pickup, DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, EF_NODEPTHTEST, effects, entity(), func_ladder_link(), func_ladder_think(), jumpstepheightvec, min(), MOVE_NOMONSTERS, nextthink, PL_MAX_CONST, PL_MIN_CONST, setthink, spawn, stepheightvec, time, trace_endpos, trace_startsolid, vector, WarpZoneLib_ExactTrigger_Init(), waypoint_getlinearcost(), waypoint_spawnforteleporter_boxes(), and WAYPOINTFLAG_LADDER.

Referenced by spawnfunc(), and spawnfunc().

◆ func_ladder_link()

void func_ladder_link ( entity this)

Definition at line 49 of file ladder.qc.

50{
52 //this.model = "null";
53}
bool func_ladder_send(entity this, entity to, int sf)
Definition ladder.qc:36
void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
Definition triggers.qc:104

References entity(), func_ladder_send(), and trigger_link().

Referenced by func_ladder_init().

◆ func_ladder_send()

bool func_ladder_send ( entity this,
entity to,
int sf )

Definition at line 36 of file ladder.qc.

37{
38 WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER);
39
43
44 trigger_common_write(this, false);
45
46 return true;
47}
string classname
float skin
float speed
Definition dynlight.qc:9
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void WriteString(string data, float dest, float desto)
void WriteCoord(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
void trigger_common_write(entity this, bool withtarget)
Definition triggers.qc:110

References classname, entity(), MSG_ENTITY, skin, speed, trigger_common_write(), WriteByte(), WriteCoord(), WriteHeader, and WriteString().

Referenced by func_ladder_link().

◆ func_ladder_think()

void func_ladder_think ( entity this)

Definition at line 4 of file ladder.qc.

5{
6#ifdef CSQC
7 // TODO: check if this is what is causing the glitchiness when switching between them
8 float dt = time - this.move_time;
9 this.move_time = time;
10 if(dt <= 0) { return; }
11#endif
12
13 // set myself as current ladders where possible
14 IL_EACH(g_ladderents, it.ladder_entity == this,
15 {
16 it.ladder_entity = NULL;
17 IL_REMOVE(g_ladderents, it);
18 });
19
20 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.ladder_entity && IS_PLAYER(it) && it.move_movetype != MOVETYPE_NOCLIP && !IS_DEAD(it),
21 {
22 if (WarpZoneLib_ExactTrigger_Touch(this, it, false))
23 {
24 if(!it.ladder_entity)
26 it.ladder_entity = this;
27 }
28 });
29
30#ifdef SVQC
31 this.nextthink = time;
32#endif
33}
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
IntrusiveList g_ladderents
Definition ladder.qh:3
bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher, bool touchfunc)
Definition common.qc:815
float vlen(vector v)
float move_time
Definition movetypes.qh:77
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137

References absmax, absmin, entity(), FOREACH_ENTITY_RADIUS, func_ladder_think(), g_ladderents, IL_EACH, IL_PUSH(), IS_DEAD, IS_PLAYER, move_time, MOVETYPE_NOCLIP, nextthink, this, time, vlen(), void, and WarpZoneLib_ExactTrigger_Touch().

Referenced by func_ladder_init(), and func_ladder_think().

◆ spawnfunc() [1/2]

spawnfunc ( func_ladder )

Definition at line 127 of file ladder.qc.

128{
129 IL_PUSH(g_ladders, this); // TODO: also func_water? bots currently loop through func_ladder only
130
131 func_ladder_init(this);
132}
void func_ladder_init(entity this)
Definition ladder.qc:55
IntrusiveList g_ladders
Definition ladder.qh:7

References func_ladder_init(), g_ladders, and IL_PUSH().

◆ spawnfunc() [2/2]

spawnfunc ( func_water )

Definition at line 134 of file ladder.qc.

135{
136 func_ladder_init(this);
137}

References func_ladder_init().