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_Success (void)
12 if(self.owner == world)
14 objerror("Cannot succeed successfully: no owner\n");
18 self.owner.porto_current = world;
22 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
23 void W_Porto_Fail (float failhard)
25 if(self.owner == world)
27 objerror("Cannot fail successfully: no owner\n");
32 Portal_ClearWithID(self.owner, self.portal_id);
33 self.owner.porto_current = world;
35 if(!failhard && self.owner.playerid == self.playerid && self.owner.deadflag == DEAD_NO && !(self.owner.weapons & WEPBIT_PORTO))
37 setsize (self, '-16 -16 0', '16 16 32');
38 setorigin(self, self.origin + trace_plane_normal);
39 if(move_out_of_solid(self))
42 self.velocity = trigger_push_calculatevelocity(self.origin, self.owner, 128);
43 tracetoss(self, self);
44 if(vlen(trace_endpos - self.owner.origin) < 128)
46 W_ThrowNewWeapon(self.owner, WEP_PORTO, 0, self.origin, self.velocity);
47 centerprint(self.owner, "^1Portal deployment failed.\n\n^2Catch it to try again!");
54 void W_Porto_Remove (entity p)
60 self = p.porto_current;
66 void W_Porto_Think (void)
68 trace_plane_normal = '0 0 0';
69 if(self.owner.playerid != self.playerid)
75 void W_Porto_Touch (void)
79 // do not use PROJECTILE_TOUCH here
81 if(other.classname == "portal")
82 return; // handled by the portal
84 norm = trace_plane_normal;
85 if(trace_ent.iscreature)
87 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_WORLDONLY, self);
88 if(trace_fraction >= 1)
90 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
92 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
96 if(self.owner.playerid != self.playerid)
98 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
101 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
103 spamsound(self, CHAN_PROJECTILE, "porto/bounce.wav", VOL_BASE, ATTN_NORM);
105 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
106 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
108 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
110 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
113 else if(self.effects & EF_RED)
115 self.effects += EF_BLUE - EF_RED;
116 if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
118 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
119 trace_plane_normal = norm;
120 centerprint(self.owner, "^1In^7-portal created.");
121 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
122 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
123 CSQCProjectile(self, TRUE, PROJECTILE_PORTO_BLUE, TRUE); // change type
127 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
128 trace_plane_normal = norm;
134 if(self.owner.portal_in.portal_id == self.portal_id)
136 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
138 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
139 trace_plane_normal = norm;
140 centerprint(self.owner, "^4Out^7-portal created.");
145 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
151 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
157 void W_Porto_Attack (void)
161 if not(self.items & IT_UNLIMITED_SUPERWEAPONS)
162 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
163 W_SetupShot (self, FALSE, 4, "porto/fire.wav", 0);
164 // always shoot from the eye
165 w_shotdir = v_forward;
166 w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
168 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
172 gren.playerid = self.playerid;
173 gren.classname = "porto";
174 gren.bot_dodge = TRUE;
175 gren.bot_dodgerating = 200;
176 gren.movetype = MOVETYPE_BOUNCEMISSILE;
177 PROJECTILE_MAKETRIGGER(gren);
178 gren.effects = EF_RED;
180 setorigin(gren, w_shotorg);
181 setsize(gren, '0 0 0', '0 0 0');
183 gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
184 gren.think = W_Porto_Think;
185 gren.touch = W_Porto_Touch;
186 if(self.items & IT_STRENGTH)
187 W_SetupProjectileVelocity(gren, cvar("g_balance_porto_primary_speed") * cvar("g_balance_powerup_strength_force"), 0);
189 W_SetupProjectileVelocity(gren, cvar("g_balance_porto_primary_speed"), 0);
191 gren.angles = vectoangles (gren.velocity);
192 gren.flags = FL_PROJECTILE;
194 gren.portal_id = time;
195 self.porto_current = gren;
196 gren.playerid = self.playerid;
197 fixedmakevectors(fixedvectoangles(gren.velocity));
198 gren.right_vector = v_right;
200 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
202 CSQCProjectile(gren, TRUE, PROJECTILE_PORTO_RED, TRUE);
205 void spawnfunc_weapon_porto (void)
207 weapon_defaultspawnfunc(WEP_PORTO);
210 float w_nexball_weapon(float req);
211 float w_porto(float req)
215 if (g_nexball) { return w_nexball_weapon(req); }
218 self.BUTTON_ATCK = FALSE;
219 self.BUTTON_ATCK2 = FALSE;
220 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
221 self.BUTTON_ATCK = TRUE;
223 else if (req == WR_THINK)
225 if(self.porto_v_angle_held)
227 if(!self.BUTTON_ATCK2)
229 self.porto_v_angle_held = 0;
231 ClientData_Touch(self);
236 if(self.BUTTON_ATCK2)
238 self.porto_v_angle = self.v_angle;
239 self.porto_v_angle_held = 1;
241 ClientData_Touch(self);
244 v_angle_save = self.v_angle;
245 if(self.porto_v_angle_held)
246 makevectors(self.porto_v_angle); // override the previously set angles
248 if (self.BUTTON_ATCK)
249 if (!self.porto_current)
250 if (!self.porto_forbidden)
251 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
254 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
257 else if (req == WR_PRECACHE)
259 precache_model ("models/weapons/g_porto.md3");
260 precache_model ("models/weapons/v_porto.md3");
261 precache_model ("models/weapons/h_porto.iqm");
262 precache_model ("models/portal.md3");
263 precache_sound ("porto/bounce.wav");
264 precache_sound ("porto/create.wav");
265 precache_sound ("porto/expire.wav");
266 precache_sound ("porto/explode.wav");
267 precache_sound ("porto/fire.wav");
268 precache_sound ("porto/unsupported.wav");
270 else if (req == WR_SETUP)
271 weapon_setup(WEP_PORTO);
272 else if (req == WR_RESETPLAYER)
274 self.porto_current = world;
280 float w_porto(float req)
282 if(req == WR_IMPACTEFFECT)
284 print("Since when does Porto send DamageInfo?\n");
286 else if(req == WR_PRECACHE)
290 else if (req == WR_SUICIDEMESSAGE)
291 w_deathtypestring = "did the impossible";
292 else if (req == WR_KILLMESSAGE)
293 w_deathtypestring = "felt # doing the impossible to him";