2 REGISTER_WEAPON(PORTO, w_porto, 0, 0, WEP_TYPE_OTHER, 0, "porto" , "porto", _("Port-O-Launch"))
6 .vector porto_v_angle; // holds "held" view angles
7 .float porto_v_angle_held;
10 void W_Porto_SetAmmoCounter()
12 // this weapon doesn't have a reload system, so always set the clip to 0 when switching to it
13 self.clip_load = self.clip_size = 0; // also keeps crosshair ammo from displaying
16 void W_Porto_Success (void)
18 if(self.owner == world)
20 objerror("Cannot succeed successfully: no owner\n");
24 self.owner.porto_current = world;
28 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
29 void W_Porto_Fail (float failhard)
31 if(self.owner == world)
33 objerror("Cannot fail successfully: no owner\n");
38 Portal_ClearWithID(self.owner, self.portal_id);
39 self.owner.porto_current = world;
41 if(!failhard && self.owner.playerid == self.playerid && self.owner.deadflag == DEAD_NO && !(self.owner.weapons & WEPBIT_PORTO))
43 setsize (self, '-16 -16 0', '16 16 32');
44 setorigin(self, self.origin + trace_plane_normal);
45 if(move_out_of_solid(self))
48 self.velocity = trigger_push_calculatevelocity(self.origin, self.owner, 128);
49 tracetoss(self, self);
50 if(vlen(trace_endpos - self.owner.origin) < 128)
52 W_ThrowNewWeapon(self.owner, WEP_PORTO, 0, self.origin, self.velocity);
53 centerprint(self.owner, "^1Portal deployment failed.\n\n^2Catch it to try again!");
60 void W_Porto_Remove (entity p)
66 self = p.porto_current;
72 void W_Porto_Think (void)
74 trace_plane_normal = '0 0 0';
75 if(self.owner.playerid != self.playerid)
81 void W_Porto_Touch (void)
85 // do not use PROJECTILE_TOUCH here
87 if(other.classname == "portal")
88 return; // handled by the portal
90 norm = trace_plane_normal;
91 if(trace_ent.iscreature)
93 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_WORLDONLY, self);
94 if(trace_fraction >= 1)
96 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
98 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
102 if(self.owner.playerid != self.playerid)
104 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
107 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
109 spamsound(self, CHAN_PROJECTILE, "porto/bounce.wav", VOL_BASE, ATTN_NORM);
111 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
112 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
114 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
116 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
119 else if(self.effects & EF_RED)
121 self.effects += EF_BLUE - EF_RED;
122 if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
124 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
125 trace_plane_normal = norm;
126 centerprint(self.owner, "^1In^7-portal created.");
127 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
128 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
129 CSQCProjectile(self, TRUE, PROJECTILE_PORTO_BLUE, TRUE); // change type
133 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
134 trace_plane_normal = norm;
140 if(self.owner.portal_in.portal_id == self.portal_id)
142 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
144 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
145 trace_plane_normal = norm;
146 centerprint(self.owner, "^4Out^7-portal created.");
151 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
157 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
163 void W_Porto_Attack (void)
167 if not(self.items & IT_UNLIMITED_SUPERWEAPONS)
168 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
169 W_SetupShot (self, FALSE, 4, "porto/fire.wav", CHAN_WEAPON, 0);
170 // always shoot from the eye
171 w_shotdir = v_forward;
172 w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
174 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
178 gren.playerid = self.playerid;
179 gren.classname = "porto";
180 gren.bot_dodge = TRUE;
181 gren.bot_dodgerating = 200;
182 gren.movetype = MOVETYPE_BOUNCEMISSILE;
183 PROJECTILE_MAKETRIGGER(gren);
184 gren.effects = EF_RED;
186 setorigin(gren, w_shotorg);
187 setsize(gren, '0 0 0', '0 0 0');
189 gren.nextthink = time + autocvar_g_balance_porto_primary_lifetime;
190 gren.think = W_Porto_Think;
191 gren.touch = W_Porto_Touch;
192 if(self.items & IT_STRENGTH)
193 W_SetupProjectileVelocity(gren, autocvar_g_balance_porto_primary_speed * autocvar_g_balance_powerup_strength_force, 0);
195 W_SetupProjectileVelocity(gren, autocvar_g_balance_porto_primary_speed, 0);
197 gren.angles = vectoangles (gren.velocity);
198 gren.flags = FL_PROJECTILE;
200 gren.portal_id = time;
201 self.porto_current = gren;
202 gren.playerid = self.playerid;
203 fixedmakevectors(fixedvectoangles(gren.velocity));
204 gren.right_vector = v_right;
206 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
208 CSQCProjectile(gren, TRUE, PROJECTILE_PORTO_RED, TRUE);
210 other = gren; MUTATOR_CALLHOOK(EditProjectile);
213 void spawnfunc_weapon_porto (void)
215 weapon_defaultspawnfunc(WEP_PORTO);
218 float w_nexball_weapon(float req);
219 float w_porto(float req)
223 if (g_nexball) { return w_nexball_weapon(req); }
226 self.BUTTON_ATCK = FALSE;
227 self.BUTTON_ATCK2 = FALSE;
228 if(bot_aim(autocvar_g_balance_porto_primary_speed, 0, autocvar_g_balance_grenadelauncher_primary_lifetime, FALSE))
229 self.BUTTON_ATCK = TRUE;
231 else if (req == WR_THINK)
233 if(self.porto_v_angle_held)
235 if(!self.BUTTON_ATCK2)
237 self.porto_v_angle_held = 0;
239 ClientData_Touch(self);
244 if(self.BUTTON_ATCK2)
246 self.porto_v_angle = self.v_angle;
247 self.porto_v_angle_held = 1;
249 ClientData_Touch(self);
252 v_angle_save = self.v_angle;
253 if(self.porto_v_angle_held)
254 makevectors(self.porto_v_angle); // override the previously set angles
256 if (self.BUTTON_ATCK)
257 if (!self.porto_current)
258 if (!self.porto_forbidden)
259 if (weapon_prepareattack(0, autocvar_g_balance_porto_primary_refire))
262 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_porto_primary_animtime, w_ready);
265 else if (req == WR_PRECACHE)
267 precache_model ("models/weapons/g_porto.md3");
268 precache_model ("models/weapons/v_porto.md3");
269 precache_model ("models/weapons/h_porto.iqm");
270 precache_model ("models/portal.md3");
271 precache_sound ("porto/bounce.wav");
272 precache_sound ("porto/create.wav");
273 precache_sound ("porto/expire.wav");
274 precache_sound ("porto/explode.wav");
275 precache_sound ("porto/fire.wav");
276 precache_sound ("porto/unsupported.wav");
278 else if (req == WR_SETUP)
280 weapon_setup(WEP_PORTO);
281 W_Porto_SetAmmoCounter();
283 else if (req == WR_RESETPLAYER)
285 self.porto_current = world;
291 float w_porto(float req)
293 if(req == WR_IMPACTEFFECT)
295 print("Since when does Porto send DamageInfo?\n");
297 else if(req == WR_PRECACHE)
301 else if (req == WR_SUICIDEMESSAGE)
302 w_deathtypestring = _("%s did the impossible");
303 else if (req == WR_KILLMESSAGE)
304 w_deathtypestring = _("%s felt %s doing the impossible to him");