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 void spawnfunc_weapon_porto(void) { weapon_defaultspawnfunc(WEP_PORTO); }
43 void W_Porto_Success(void)
45 if(self.realowner == world)
47 objerror("Cannot succeed successfully: no owner\n");
51 self.realowner.porto_current = world;
55 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
56 void W_Porto_Fail(float failhard)
58 if(self.realowner == world)
60 objerror("Cannot fail successfully: no owner\n");
67 Portal_ClearWithID(self.realowner, self.portal_id);
70 self.realowner.porto_current = world;
72 if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && self.realowner.deadflag == DEAD_NO && !(self.realowner.weapons & WEPSET_PORTO))
74 setsize(self, '-16 -16 0', '16 16 32');
75 setorigin(self, self.origin + trace_plane_normal);
76 if(move_out_of_solid(self))
79 self.velocity = trigger_push_calculatevelocity(self.origin, self.realowner, 128);
80 tracetoss(self, self);
81 if(vlen(trace_endpos - self.realowner.origin) < 128)
83 W_ThrowNewWeapon(self.realowner, WEP_PORTO, 0, self.origin, self.velocity);
84 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
91 void W_Porto_Remove(entity p)
93 if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
97 self = p.porto_current;
103 void W_Porto_Think(void)
105 trace_plane_normal = '0 0 0';
106 if(self.realowner.playerid != self.playerid)
112 void W_Porto_Touch(void)
116 // do not use PROJECTILE_TOUCH here
117 // FIXME but DO handle warpzones!
119 if(other.classname == "portal")
120 return; // handled by the portal
122 norm = trace_plane_normal;
123 if(trace_ent.iscreature)
125 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_WORLDONLY, self);
126 if(trace_fraction >= 1)
128 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
130 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
134 if(self.realowner.playerid != self.playerid)
136 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
139 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
141 spamsound(self, CH_SHOTS, "porto/bounce.wav", VOL_BASE, ATTEN_NORM);
143 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
144 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
146 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
148 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
151 Portal_ClearAll_PortalsOnly(self.realowner);
153 else if(self.cnt == 0)
156 if(Portal_SpawnInPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
158 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
159 trace_plane_normal = norm;
160 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN);
165 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
166 trace_plane_normal = norm;
170 else if(self.cnt == 1)
173 if(Portal_SpawnOutPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
175 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
176 trace_plane_normal = norm;
177 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
182 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
183 trace_plane_normal = norm;
187 else if(self.effects & EF_RED)
189 self.effects += EF_BLUE - EF_RED;
190 if(Portal_SpawnInPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
192 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
193 trace_plane_normal = norm;
194 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN);
195 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
196 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
197 CSQCProjectile(self, TRUE, PROJECTILE_PORTO_BLUE, TRUE); // change type
201 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
202 trace_plane_normal = norm;
203 Portal_ClearAll_PortalsOnly(self.realowner);
209 if(self.realowner.portal_in.portal_id == self.portal_id)
211 if(Portal_SpawnOutPortalAtTrace(self.realowner, self.right_vector, self.portal_id))
213 sound(self, CH_SHOTS, "porto/create.wav", VOL_BASE, ATTEN_NORM);
214 trace_plane_normal = norm;
215 Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
220 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
221 Portal_ClearAll_PortalsOnly(self.realowner);
227 sound(self, CH_SHOTS, "porto/unsupported.wav", VOL_BASE, ATTEN_NORM);
228 Portal_ClearAll_PortalsOnly(self.realowner);
234 void W_Porto_Attack(float type)
238 W_SetupShot(self, FALSE, 4, "porto/fire.wav", CH_WEAPON_A, 0);
239 // always shoot from the eye
240 w_shotdir = v_forward;
241 w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
243 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
247 gren.owner = gren.realowner = self;
248 gren.playerid = self.playerid;
249 gren.classname = "porto";
250 gren.bot_dodge = TRUE;
251 gren.bot_dodgerating = 200;
252 gren.movetype = MOVETYPE_BOUNCEMISSILE;
253 PROJECTILE_MAKETRIGGER(gren);
254 gren.effects = EF_RED;
256 setorigin(gren, w_shotorg);
257 setsize(gren, '0 0 0', '0 0 0');
259 gren.nextthink = time + WEP_CVAR_BOTH(porto, (type <= 0), lifetime);
260 gren.think = W_Porto_Think;
261 gren.touch = W_Porto_Touch;
263 if(self.items & IT_STRENGTH)
264 W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed) * autocvar_g_balance_powerup_strength_force, 0);
266 W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed), 0);
268 gren.angles = vectoangles(gren.velocity);
269 gren.flags = FL_PROJECTILE;
271 gren.portal_id = time;
272 self.porto_current = gren;
273 gren.playerid = self.playerid;
274 fixedmakevectors(fixedvectoangles(gren.velocity));
275 gren.right_vector = v_right;
277 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
280 CSQCProjectile(gren, TRUE, PROJECTILE_PORTO_BLUE, TRUE);
282 CSQCProjectile(gren, TRUE, PROJECTILE_PORTO_RED, TRUE);
284 other = gren; MUTATOR_CALLHOOK(EditProjectile);
287 float w_nexball_weapon(float req); // WEAPONTODO
288 float W_Porto(float req)
290 //vector v_angle_save;
292 if(g_nexball) { return w_nexball_weapon(req); }
298 self.BUTTON_ATCK = FALSE;
299 self.BUTTON_ATCK2 = FALSE;
300 if(!WEP_CVAR(porto, secondary))
301 if(bot_aim(WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), FALSE))
302 self.BUTTON_ATCK = TRUE;
308 PORTO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
313 if(WEP_CVAR(porto, secondary))
316 if(!self.porto_current)
317 if(!self.porto_forbidden)
318 if(weapon_prepareattack(0, WEP_CVAR_PRI(porto, refire)))
321 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
324 if(self.BUTTON_ATCK2)
325 if(!self.porto_current)
326 if(!self.porto_forbidden)
327 if(weapon_prepareattack(1, WEP_CVAR_SEC(porto, refire)))
330 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
335 if(self.porto_v_angle_held)
337 if(!self.BUTTON_ATCK2)
339 self.porto_v_angle_held = 0;
341 ClientData_Touch(self);
346 if(self.BUTTON_ATCK2)
348 self.porto_v_angle = self.v_angle;
349 self.porto_v_angle_held = 1;
351 ClientData_Touch(self);
354 if(self.porto_v_angle_held)
355 makevectors(self.porto_v_angle); // override the previously set angles
358 if(!self.porto_current)
359 if(!self.porto_forbidden)
360 if(weapon_prepareattack(0, WEP_CVAR_PRI(porto, refire)))
363 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
371 precache_model("models/weapons/g_porto.md3");
372 precache_model("models/weapons/v_porto.md3");
373 precache_model("models/weapons/h_porto.iqm");
374 precache_model("models/portal.md3");
375 precache_sound("porto/bounce.wav");
376 precache_sound("porto/create.wav");
377 precache_sound("porto/expire.wav");
378 precache_sound("porto/explode.wav");
379 precache_sound("porto/fire.wav");
380 precache_sound("porto/unsupported.wav");
381 PORTO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
386 self.ammo_field = ammo_none;
391 self.porto_current = world;
399 float W_Porto(float req)
403 case WR_IMPACTEFFECT:
405 print("Since when does Porto send DamageInfo?\n");
415 // no weapon specific image for this weapon