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

Go to the source code of this file.

Classes

class  PortoLaunch

Macros

#define X(BEGIN, P, END, class, prefix)

Functions

 MODEL (PORTAL, "models/portal.md3")
 MODEL (PORTO_ITEM, W_Model("g_porto.md3"))
 MODEL (PORTO_VIEW, W_Model("h_porto.iqm"))
 MODEL (PORTO_WORLD, W_Model("v_porto.md3"))
void Porto_Draw (entity this)
 REGISTER_WEAPON (PORTO, NEW(PortoLaunch))
 SOUND (PORTO_BOUNCE, "porto/bounce")
 SOUND (PORTO_CREATE, "porto/create")
 SOUND (PORTO_EXPIRE, "porto/expire")
 SOUND (PORTO_EXPLODE, "porto/explode")
 SOUND (PORTO_FIRE, "porto/fire")
 SOUND (PORTO_UNSUPPORTED, "porto/unsupported")
void W_Porto_Fail (entity this, bool failhard)
void W_Porto_Remove (entity p)

Variables

entity porto_current
float porto_forbidden
vector porto_v_angle
float porto_v_angle_held
vector right_vector

Macro Definition Documentation

◆ X

#define X ( BEGIN,
P,
END,
class,
prefix )
Value:
BEGIN(class) \
P(class, prefix, animtime, float, BOTH) \
P(class, prefix, lifetime, float, BOTH) \
P(class, prefix, refire, float, BOTH) \
P(class, prefix, secondary, float, NONE) \
P(class, prefix, speed, float, BOTH) \
P(class, prefix, switchdelay_drop, float, NONE) \
P(class, prefix, switchdelay_raise, float, NONE) \
P(class, prefix, weaponreplace, string, NONE) \
P(class, prefix, weaponstartoverride, float, NONE) \
P(class, prefix, weaponstart, float, NONE) \
P(class, prefix, weaponthrowable, float, NONE) \
END()
float lifetime
Definition powerups.qc:23
float speed
Definition dynlight.qc:9

Definition at line 38 of file porto.qh.

38#define X(BEGIN, P, END, class, prefix) \
39 BEGIN(class) \
40 P(class, prefix, animtime, float, BOTH) \
41 P(class, prefix, lifetime, float, BOTH) \
42 P(class, prefix, refire, float, BOTH) \
43 P(class, prefix, secondary, float, NONE) \
44 P(class, prefix, speed, float, BOTH) \
45 P(class, prefix, switchdelay_drop, float, NONE) \
46 P(class, prefix, switchdelay_raise, float, NONE) \
47 P(class, prefix, weaponreplace, string, NONE) \
48 P(class, prefix, weaponstartoverride, float, NONE) \
49 P(class, prefix, weaponstart, float, NONE) \
50 P(class, prefix, weaponthrowable, float, NONE) \
51 END()

Function Documentation

◆ MODEL() [1/4]

MODEL ( PORTAL ,
"models/portal.md3"  )

◆ MODEL() [2/4]

MODEL ( PORTO_ITEM ,
W_Model("g_porto.md3")  )

◆ MODEL() [3/4]

MODEL ( PORTO_VIEW ,
W_Model("h_porto.iqm")  )

◆ MODEL() [4/4]

MODEL ( PORTO_WORLD ,
W_Model("v_porto.md3")  )

◆ Porto_Draw()

void Porto_Draw ( entity this)

Definition at line 17 of file porto.qc.

18{
19 if (spectatee_status || intermission == 1 || intermission == 2 || STAT(HEALTH) <= 0 || WEP_CVAR(WEP_PORTO, secondary))
20 return;
21
22 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
23 {
24 entity wepent = viewmodels[slot];
25
26 if (wepent.activeweapon != WEP_PORTO)
27 continue;
28
29 vector pos = view_origin;
32 pos += v_right * -wepent.movedir.y
33 + v_up * wepent.movedir.z;
34
35 if (wepent.angles_held_status)
36 {
37 makevectors(wepent.angles_held);
38 dir = v_forward;
39 }
40
41 wepent.polyline[0] = pos;
42
43 int portal_number = 0, portal1_idx = 1, portal_max = 2;
44 int n = 1 + 2; // 2 lines == 3 points
45 for (int idx = 0; idx < n && idx < polyline_length - 1; )
46 {
47 traceline(pos, pos + 65536 * dir, true, this);
49 pos = trace_endpos;
50 wepent.polyline[++idx] = pos;
52 {
53 ++n;
54 continue;
55 }
57 {
58 n = max(2, idx);
59 break;
60 }
61 // check size
62 {
63 vector ang = vectoangles2(trace_plane_normal, dir);
64 ang.x = -ang.x;
66 if (!CheckWireframeBox(this, pos - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
67 {
68 n = max(2, idx);
69 break;
70 }
71 }
72 ++portal_number;
73 if (portal_number >= portal_max)
74 break;
75 if (portal_number == 1)
76 portal1_idx = idx;
77 }
78 for (int idx = 0; idx < n - 1; ++idx)
79 {
80 vector p = wepent.polyline[idx];
81 vector q = wepent.polyline[idx + 1];
82 if (idx == 0)
83 p -= view_up * 16; // line from player
84 vector rgb = (idx < portal1_idx) ? '1 0 0' : '0 0 1';
85 Draw_CylindricLine(p, q, 4, "", 1, 0, rgb, 0.5, DRAWFLAG_NORMAL, view_origin);
86 }
87 }
88}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector view_origin
Definition main.qh:109
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition main.qh:197
vector view_up
Definition main.qh:109
vector view_forward
Definition main.qh:109
float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz)
Definition util.qc:580
void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg)
Definition draw.qh:11
vector v_up
const float DRAWFLAG_NORMAL
float trace_dphitcontents
float Q3SURFACEFLAG_SLICK
vector view_angles
float DPCONTENTS_PLAYERCLIP
vector v_right
vector trace_endpos
float trace_dphitq3surfaceflags
float intermission
vector v_forward
float Q3SURFACEFLAG_NOIMPACT
vector trace_plane_normal
#define STAT(...)
Definition stats.qh:82
vector warpzone_save_view_angles
Definition client.qh:9
float max(float f,...)
const int polyline_length
Definition porto.qc:15
#define makevectors
Definition post.qh:21
vector
Definition self.qh:92
vector vector ang
Definition self.qh:92
int dir
Definition impulse.qc:89
ERASEABLE vector reflect(vector dir, vector norm)
Definition vector.qh:136
int autocvar_chase_active
Definition view.qh:17
entity viewmodels[MAX_WEAPONSLOTS]
Definition view.qh:108
#define WEP_CVAR(wep, name)
Definition all.qh:337
const int MAX_WEAPONSLOTS
Definition weapon.qh:16

References ang, autocvar_chase_active, CheckWireframeBox(), dir, DPCONTENTS_PLAYERCLIP, Draw_CylindricLine(), DRAWFLAG_NORMAL, entity(), intermission, makevectors, max(), MAX_WEAPONSLOTS, polyline_length, Q3SURFACEFLAG_NOIMPACT, Q3SURFACEFLAG_SLICK, reflect(), spectatee_status, STAT, trace_dphitcontents, trace_dphitq3surfaceflags, trace_endpos, trace_plane_normal, v_forward, v_right, v_up, vector, view_angles, view_forward, view_origin, view_up, viewmodels, warpzone_save_view_angles, and WEP_CVAR.

Referenced by STATIC_INIT().

◆ REGISTER_WEAPON()

REGISTER_WEAPON ( PORTO ,
NEW(PortoLaunch)  )

◆ SOUND() [1/6]

SOUND ( PORTO_BOUNCE ,
"porto/bounce"  )

◆ SOUND() [2/6]

SOUND ( PORTO_CREATE ,
"porto/create"  )

◆ SOUND() [3/6]

SOUND ( PORTO_EXPIRE ,
"porto/expire"  )

◆ SOUND() [4/6]

SOUND ( PORTO_EXPLODE ,
"porto/explode"  )

◆ SOUND() [5/6]

SOUND ( PORTO_FIRE ,
"porto/fire"  )

◆ SOUND() [6/6]

SOUND ( PORTO_UNSUPPORTED ,
"porto/unsupported"  )

◆ W_Porto_Fail()

void W_Porto_Fail ( entity this,
bool failhard )

Definition at line 114 of file porto.qc.

115{
116 if (this.realowner == NULL)
117 {
118 objerror(this, "Cannot fail successfully: no owner\n");
119 return;
120 }
121
122 // no portals here!
123 if (this.cnt < 0)
125
126 this.realowner.porto_current = NULL;
127
128 if (this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid
129 && !IS_DEAD(this.realowner) && !(STAT(WEAPONS, this.realowner) & WEPSET(PORTO)))
130 {
131 // FIXME: item properties should be obtained from the registry
132 setsize(this, ITEM_D_MINS, ITEM_D_MAXS);
133 setorigin(this, this.origin + trace_plane_normal);
134 if (nudgeoutofsolid_OrFallback(this))
135 {
136 this.flags = FL_ITEM;
137 IL_PUSH(g_items, this);
138 this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128, this);
139 tracetoss(this, this);
140 if (vdist(trace_endpos - this.realowner.origin, <, 128))
141 {
142 .entity weaponentity = this.weaponentity_fld;
143 W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity, weaponentity);
144 Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
145 }
146 }
147 }
148 delete(this);
149}
float cnt
Definition powerups.qc:24
const vector ITEM_D_MAXS
Definition item.qh:83
const vector ITEM_D_MINS
Definition item.qh:82
#define IS_DEAD(s)
Definition player.qh:244
const int FL_ITEM
Definition constants.qh:77
float flags
vector velocity
vector origin
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
void Portal_ClearWithID(entity own, float id)
Definition portals.qc:614
float portal_id
Definition portals.qh:6
#define NULL
Definition post.qh:14
#define objerror
Definition pre.qh:8
IntrusiveList g_items
Definition items.qh:119
vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity pushed_entity)
Definition jumppads.qc:32
entity realowner
float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo,.entity weaponentity)
Returns amount of ammo used, or -1 for failure, or 0 for no ammo count.
Definition throwing.qc:22
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
#define WEPSET(id)
Definition all.qh:47
entity weaponentity_fld

References cnt, entity(), FL_ITEM, flags, g_items, IL_PUSH(), IS_DEAD, ITEM_D_MAXS, ITEM_D_MINS, NULL, objerror, origin, Portal_ClearWithID(), portal_id, realowner, Send_Notification(), STAT, trace_endpos, trace_plane_normal, trigger_push_calculatevelocity(), vdist, velocity, W_ThrowNewWeapon(), weaponentity_fld, and WEPSET.

Referenced by checkpoint_passed(), W_Porto_Remove(), W_Porto_Think(), and W_Porto_Touch().

◆ W_Porto_Remove()

void W_Porto_Remove ( entity p)

Definition at line 151 of file porto.qc.

152{
153 if (p.porto_current.realowner == p && p.porto_current.classname == "porto")
154 W_Porto_Fail(p.porto_current, true);
155}
void W_Porto_Fail(entity this, bool failhard)
Definition porto.qc:114

References entity(), and W_Porto_Fail().

Referenced by Portal_ClearAll(), and Portal_ClearAllLater().

Variable Documentation

◆ porto_current

entity porto_current

Definition at line 65 of file porto.qh.

◆ porto_forbidden

float porto_forbidden

Definition at line 69 of file porto.qh.

◆ porto_v_angle

vector porto_v_angle

Definition at line 66 of file porto.qh.

◆ porto_v_angle_held

float porto_v_angle_held

Definition at line 67 of file porto.qh.

◆ right_vector

vector right_vector

Definition at line 68 of file porto.qh.

Referenced by W_Porto_Touch().