4 /* function */ W_Porto,
5 /* ammotype */ ammo_none,
7 /* flags */ WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON,
9 /* color */ '0.5 0.5 0.5',
10 /* modelname */ "porto",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairporto 0.6",
13 /* wepimg */ "weaponporto",
14 /* refname */ "porto",
15 /* wepname */ _("Port-O-Launch")
18 #define PORTO_SETTINGS(w_cvar,w_prop) PORTO_SETTINGS_LIST(w_cvar, w_prop, PORTO, porto)
19 #define PORTO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, BOTH, animtime) \
21 w_cvar(id, sn, BOTH, lifetime) \
22 w_cvar(id, sn, BOTH, refire) \
23 w_cvar(id, sn, BOTH, speed) \
24 w_cvar(id, sn, NONE, secondary) \
25 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
26 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
27 w_prop(id, sn, string, weaponreplace, weaponreplace) \
28 w_prop(id, sn, float, weaponstart, weaponstart) \
29 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
30 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
33 PORTO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
34 .entity porto_current;
35 .vector porto_v_angle; // holds "held" view angles
36 .float porto_v_angle_held;
41 #include "../triggers/trigger/jumppads.qh"
43 void spawnfunc_weapon_porto(void) { weapon_defaultspawnfunc(WEP_PORTO); }
45 void W_Porto_Success(void)
47 if(self.realowner == world)
49 objerror("Cannot succeed successfully: no owner\n");
53 self.realowner.porto_current = world;
57 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
58 void W_Porto_Fail(float failhard)
60 if(self.realowner == world)
62 objerror("Cannot fail successfully: no owner\n");
69 Portal_ClearWithID(self.realowner, self.portal_id);
72 self.realowner.porto_current = world;
74 if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && self.realowner.deadflag == DEAD_NO && !(self.realowner.weapons & WEPSET_PORTO))
76 setsize(self, '-16 -16 0', '16 16 32');
77 setorigin(self, self.origin + trace_plane_normal);
78 if(move_out_of_solid(self))
81 self.velocity = trigger_push_calculatevelocity(self.origin, self.realowner, 128);
82 tracetoss(self, self);
83 if(vlen(trace_endpos - self.realowner.origin) < 128)
85 W_ThrowNewWeapon(self.realowner, WEP_PORTO, 0, self.origin, self.velocity);
86 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
93 void W_Porto_Remove(entity p)
95 if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
99 self = p.porto_current;
105 void W_Porto_Think(void)
107 trace_plane_normal = '0 0 0';
108 if(self.realowner.playerid != self.playerid)
114 void W_Porto_Touch(void)
118 // do not use PROJECTILE_TOUCH here
119 // FIXME but DO handle warpzones!
121 if(other.classname == "portal")
122 return; // handled by the portal
124 norm = trace_plane_normal;
125 if(trace_ent.iscreature)
127 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN.z, MOVE_WORLDONLY, self);
128 if(trace_fraction >= 1)
130 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
132 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
136 if(self.realowner.playerid != self.playerid)
138 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
141 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
143 spamsound(self, CH_SHOTS, "porto/bounce.wav", VOL_BASE, ATTEN_NORM);
145 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
146 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
148 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
150 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
153 Portal_ClearAll_PortalsOnly(self.realowner);
155 else if(self.cnt == 0)
158 if(Portal_SpawnInPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
160 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
161 trace_plane_normal = norm;
162 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN);
167 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
168 trace_plane_normal = norm;
172 else if(self.cnt == 1)
175 if(Portal_SpawnOutPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
177 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
178 trace_plane_normal = norm;
179 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
184 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
185 trace_plane_normal = norm;
189 else if(self.effects & EF_RED)
191 self.effects += EF_BLUE - EF_RED;
192 if(Portal_SpawnInPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
194 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
195 trace_plane_normal = norm;
196 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN);
197 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
198 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
199 CSQCProjectile(self, true, PROJECTILE_PORTO_BLUE, true); // change type
203 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
204 trace_plane_normal = norm;
205 Portal_ClearAll_PortalsOnly(self.realowner);
211 if(self.realowner.portal_in.portal_id == self.portal_id)
213 if(Portal_SpawnOutPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
215 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
216 trace_plane_normal = norm;
217 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
222 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
223 Portal_ClearAll_PortalsOnly(self.realowner);
229 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
230 Portal_ClearAll_PortalsOnly(self.realowner);
236 void W_Porto_Attack(float type)
240 W_SetupShot(self, false, 4, "porto/fire.wav", CH_WEAPON_A, 0);
241 // always shoot from the eye
242 w_shotdir = v_forward;
243 w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
245 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
249 gren.owner = gren.realowner = self;
250 gren.playerid = self.playerid;
251 gren.classname = "porto";
252 gren.bot_dodge = true;
253 gren.bot_dodgerating = 200;
254 gren.movetype = MOVETYPE_BOUNCEMISSILE;
255 PROJECTILE_MAKETRIGGER(gren);
256 gren.effects = EF_RED;
258 setorigin(gren, w_shotorg);
259 setsize(gren, '0 0 0', '0 0 0');
261 gren.nextthink = time + WEP_CVAR_BOTH(porto, (type <= 0), lifetime);
262 gren.think = W_Porto_Think;
263 gren.touch = W_Porto_Touch;
265 if(self.items & IT_STRENGTH)
266 W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed) * autocvar_g_balance_powerup_strength_force, 0);
268 W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed), 0);
270 gren.angles = vectoangles(gren.velocity);
271 gren.flags = FL_PROJECTILE;
273 gren.portal_id = time;
274 self.porto_current = gren;
275 gren.playerid = self.playerid;
276 fixedmakevectors(fixedvectoangles(gren.velocity));
277 gren.right_vector = v_right;
279 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
282 CSQCProjectile(gren, true, PROJECTILE_PORTO_BLUE, true);
284 CSQCProjectile(gren, true, PROJECTILE_PORTO_RED, true);
286 other = gren; MUTATOR_CALLHOOK(EditProjectile);
289 bool w_nexball_weapon(int req); // WEAPONTODO
290 bool W_Porto(int req)
292 //vector v_angle_save;
294 if(g_nexball) { return w_nexball_weapon(req); }
300 self.BUTTON_ATCK = false;
301 self.BUTTON_ATCK2 = false;
302 if(!WEP_CVAR(porto, secondary))
303 if(bot_aim(WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false))
304 self.BUTTON_ATCK = true;
310 PORTO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
315 if(WEP_CVAR(porto, secondary))
318 if(!self.porto_current)
319 if(!self.porto_forbidden)
320 if(weapon_prepareattack(0, WEP_CVAR_PRI(porto, refire)))
323 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
326 if(self.BUTTON_ATCK2)
327 if(!self.porto_current)
328 if(!self.porto_forbidden)
329 if(weapon_prepareattack(1, WEP_CVAR_SEC(porto, refire)))
332 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
337 if(self.porto_v_angle_held)
339 if(!self.BUTTON_ATCK2)
341 self.porto_v_angle_held = 0;
343 ClientData_Touch(self);
348 if(self.BUTTON_ATCK2)
350 self.porto_v_angle = self.v_angle;
351 self.porto_v_angle_held = 1;
353 ClientData_Touch(self);
356 if(self.porto_v_angle_held)
357 makevectors(self.porto_v_angle); // override the previously set angles
360 if(!self.porto_current)
361 if(!self.porto_forbidden)
362 if(weapon_prepareattack(0, WEP_CVAR_PRI(porto, refire)))
365 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
373 precache_model("models/weapons/g_porto.md3");
374 precache_model("models/weapons/v_porto.md3");
375 precache_model("models/weapons/h_porto.iqm");
376 precache_model("models/portal.md3");
377 precache_sound("porto/bounce.wav");
378 precache_sound("porto/create.wav");
379 precache_sound("porto/expire.wav");
380 precache_sound("porto/explode.wav");
381 precache_sound("porto/fire.wav");
382 precache_sound("porto/unsupported.wav");
383 PORTO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
388 self.ammo_field = ammo_none;
393 self.porto_current = world;
401 bool W_Porto(int req)
405 case WR_IMPACTEFFECT:
407 print("Since when does Porto send DamageInfo?\n");
417 // no weapon specific image for this weapon