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, float 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 34 of file porto.qh.

34#define X(BEGIN, P, END, class, prefix) \
35 BEGIN(class) \
36 P(class, prefix, animtime, float, BOTH) \
37 P(class, prefix, lifetime, float, BOTH) \
38 P(class, prefix, refire, float, BOTH) \
39 P(class, prefix, secondary, float, NONE) \
40 P(class, prefix, speed, float, BOTH) \
41 P(class, prefix, switchdelay_drop, float, NONE) \
42 P(class, prefix, switchdelay_raise, float, NONE) \
43 P(class, prefix, weaponreplace, string,NONE) \
44 P(class, prefix, weaponstartoverride, float, NONE) \
45 P(class, prefix, weaponstart, float, NONE) \
46 P(class, prefix, weaponthrowable, float, NONE) \
47 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)) return;
20
21 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
22 {
23 entity wepent = viewmodels[slot];
24
25 if (wepent.activeweapon != WEP_PORTO) continue;
26
27 vector pos = view_origin;
30 pos += v_right * -wepent.movedir.y
31 + v_up * wepent.movedir.z;
32
33 if (wepent.angles_held_status)
34 {
35 makevectors(wepent.angles_held);
36 dir = v_forward;
37 }
38
39 wepent.polyline[0] = pos;
40
41 int portal_number = 0, portal1_idx = 1, portal_max = 2;
42 int n = 1 + 2; // 2 lines == 3 points
43 for (int idx = 0; idx < n && idx < polyline_length - 1; )
44 {
45 traceline(pos, pos + 65536 * dir, true, this);
47 pos = trace_endpos;
48 wepent.polyline[++idx] = pos;
50 {
51 n += 1;
52 continue;
53 }
55 {
56 n = max(2, idx);
57 break;
58 }
59 // check size
60 {
61 vector ang = vectoangles2(trace_plane_normal, dir);
62 ang.x = -ang.x;
64 if (!CheckWireframeBox(this, pos - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
65 {
66 n = max(2, idx);
67 break;
68 }
69 }
70 portal_number += 1;
71 if (portal_number >= portal_max) break;
72 if (portal_number == 1) portal1_idx = idx;
73 }
74 for (int idx = 0; idx < n - 1; ++idx)
75 {
76 vector p = wepent.polyline[idx], q = wepent.polyline[idx + 1];
77 if (idx == 0) p -= view_up * 16; // line from player
78 vector rgb = (idx < portal1_idx) ? '1 0 0' : '0 0 1';
79 Draw_CylindricLine(p, q, 4, "", 1, 0, rgb, 0.5, DRAWFLAG_NORMAL, view_origin);
80 }
81 }
82}
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:582
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:133
int autocvar_chase_active
Definition view.qh:17
entity viewmodels[MAX_WEAPONSLOTS]
Definition view.qh:108
#define WEP_CVAR(wep, name)
Definition all.qh:321
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,
float failhard )

Definition at line 108 of file porto.qc.

109{
110 if(this.realowner == NULL)
111 {
112 objerror(this, "Cannot fail successfully: no owner\n");
113 return;
114 }
115
116 // no portals here!
117 if(this.cnt < 0)
118 {
120 }
121
122 this.realowner.porto_current = NULL;
123
124 if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(STAT(WEAPONS, this.realowner) & WEPSET(PORTO)))
125 {
126 // FIXME: item properties should be obtained from the registry
127 setsize(this, ITEM_D_MINS, ITEM_D_MAXS);
128 setorigin(this, this.origin + trace_plane_normal);
129 if(nudgeoutofsolid_OrFallback(this))
130 {
131 this.flags = FL_ITEM;
132 IL_PUSH(g_items, this);
133 this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128, this);
134 tracetoss(this, this);
135 if(vdist(trace_endpos - this.realowner.origin, <, 128))
136 {
137 .entity weaponentity = this.weaponentity_fld;
138 W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity, weaponentity);
139 Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
140 }
141 }
142 }
143 delete(this);
144}
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:245
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:616
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:125
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)
Definition throwing.qc:22
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
#define WEPSET(id)
Definition all.qh:45
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 146 of file porto.qc.

147{
148 if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
149 {
150 W_Porto_Fail(p.porto_current, 1);
151 }
152}
void W_Porto_Fail(entity this, float failhard)
Definition porto.qc:108

References entity(), and W_Porto_Fail().

Referenced by Portal_ClearAll(), and Portal_ClearAllLater().

Variable Documentation

◆ porto_current

entity porto_current

Definition at line 61 of file porto.qh.

◆ porto_forbidden

float porto_forbidden

Definition at line 65 of file porto.qh.

◆ porto_v_angle

vector porto_v_angle

Definition at line 62 of file porto.qh.

◆ porto_v_angle_held

float porto_v_angle_held

Definition at line 63 of file porto.qh.

◆ right_vector

vector right_vector

Definition at line 64 of file porto.qh.

Referenced by W_Porto_Touch().