2 REGISTER_WEAPON(PORTO, w_porto, 0, 0, WEP_TYPE_OTHER, 0, "porto" , "porto", "Port-O-Launch");
5 .vector porto_v_angle; // holds "held" view angles
6 .float porto_v_angle_held;
9 void W_Porto_Success (void)
11 if(self.owner == world)
13 objerror("Cannot succeed successfully: no owner\n");
17 self.owner.porto_current = world;
21 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
22 void W_Porto_Fail (float failhard)
24 if(self.owner == world)
26 objerror("Cannot fail successfully: no owner\n");
31 Portal_ClearWithID(self.owner, self.portal_id);
32 self.owner.porto_current = world;
34 if(!failhard && self.owner.playerid == self.playerid && self.owner.deadflag == DEAD_NO && !(self.owner.weapons & WEPBIT_PORTO))
36 setsize (self, '-16 -16 0', '16 16 32');
37 setorigin(self, self.origin + trace_plane_normal);
38 if(move_out_of_solid(self))
41 self.velocity = trigger_push_calculatevelocity(self.origin, self.owner, 128);
42 tracetoss(self, self);
43 if(vlen(trace_endpos - self.owner.origin) < 128)
45 W_ThrowNewWeapon(self.owner, WEP_PORTO, 0, self.origin, self.velocity);
46 centerprint(self.owner, "^1Portal deployment failed.\n\n^2Catch it to try again!");
53 void W_Porto_Remove (entity p)
59 self = p.porto_current;
65 void W_Porto_Think (void)
67 trace_plane_normal = '0 0 0';
68 if(self.owner.playerid != self.playerid)
74 void W_Porto_Touch (void)
78 // do not use PROJECTILE_TOUCH here
80 if(other.classname == "portal")
81 return; // handled by the portal
83 norm = trace_plane_normal;
84 if(trace_ent.iscreature)
86 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_WORLDONLY, self);
87 if(trace_fraction >= 1)
89 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
91 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
95 if(self.owner.playerid != self.playerid)
97 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
100 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
102 spamsound(self, CHAN_PROJECTILE, "porto/bounce.wav", VOL_BASE, ATTN_NORM);
104 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
105 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
107 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
109 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
112 else if(self.effects & EF_RED)
114 self.effects += EF_BLUE - EF_RED;
115 if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
117 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
118 trace_plane_normal = norm;
119 centerprint(self.owner, "^1In^7-portal created.");
120 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
121 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
122 CSQCProjectile(self, TRUE, PROJECTILE_PORTO_BLUE, TRUE); // change type
126 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
127 trace_plane_normal = norm;
133 if(self.owner.portal_in.portal_id == self.portal_id)
135 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
137 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
138 trace_plane_normal = norm;
139 centerprint(self.owner, "^4Out^7-portal created.");
144 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
150 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
156 void W_Porto_Attack (void)
160 if not(self.items & IT_UNLIMITED_SUPERWEAPONS)
161 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
162 W_SetupShot (self, FALSE, 4, "porto/fire.wav", 0);
163 // always shoot from the eye
164 w_shotdir = v_forward;
165 w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
167 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
171 gren.playerid = self.playerid;
172 gren.classname = "porto";
173 gren.bot_dodge = TRUE;
174 gren.bot_dodgerating = 200;
175 gren.movetype = MOVETYPE_BOUNCEMISSILE;
176 PROJECTILE_MAKETRIGGER(gren);
177 gren.effects = EF_RED;
179 setorigin(gren, w_shotorg);
180 setsize(gren, '0 0 0', '0 0 0');
182 gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
183 gren.think = W_Porto_Think;
184 gren.touch = W_Porto_Touch;
185 if(self.items & IT_STRENGTH)
186 W_SetupProjectileVelocity(gren, cvar("g_balance_porto_primary_speed") * cvar("g_balance_powerup_strength_force"), 0);
188 W_SetupProjectileVelocity(gren, cvar("g_balance_porto_primary_speed"), 0);
190 gren.angles = vectoangles (gren.velocity);
191 gren.flags = FL_PROJECTILE;
193 gren.portal_id = time;
194 self.porto_current = gren;
195 gren.playerid = self.playerid;
196 fixedmakevectors(fixedvectoangles(gren.velocity));
197 gren.right_vector = v_right;
199 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
201 CSQCProjectile(gren, TRUE, PROJECTILE_PORTO_RED, TRUE);
204 void spawnfunc_weapon_porto (void)
206 weapon_defaultspawnfunc(WEP_PORTO);
209 float w_nexball_weapon(float req);
210 float w_porto(float req)
214 if (g_nexball) { return w_nexball_weapon(req); }
217 self.BUTTON_ATCK = FALSE;
218 self.BUTTON_ATCK2 = FALSE;
219 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
220 self.BUTTON_ATCK = TRUE;
222 else if (req == WR_THINK)
224 if(self.porto_v_angle_held)
226 if(!self.BUTTON_ATCK2)
228 self.porto_v_angle_held = 0;
230 ClientData_Touch(self);
235 if(self.BUTTON_ATCK2)
237 self.porto_v_angle = self.v_angle;
238 self.porto_v_angle_held = 1;
240 ClientData_Touch(self);
243 v_angle_save = self.v_angle;
244 if(self.porto_v_angle_held)
245 makevectors(self.porto_v_angle); // override the previously set angles
247 if (self.BUTTON_ATCK)
248 if (!self.porto_current)
249 if (!self.porto_forbidden)
250 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
253 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
256 else if (req == WR_PRECACHE)
258 precache_model ("models/weapons/g_porto.md3");
259 precache_model ("models/weapons/v_porto.md3");
260 precache_model ("models/weapons/h_porto.iqm");
261 precache_model ("models/portal.md3");
262 precache_sound ("porto/bounce.wav");
263 precache_sound ("porto/create.wav");
264 precache_sound ("porto/expire.wav");
265 precache_sound ("porto/explode.wav");
266 precache_sound ("porto/fire.wav");
267 precache_sound ("porto/unsupported.wav");
269 else if (req == WR_SETUP)
270 weapon_setup(WEP_PORTO);
271 else if (req == WR_SUICIDEMESSAGE)
272 w_deathtypestring = "did the impossible";
273 else if (req == WR_KILLMESSAGE)
274 w_deathtypestring = "felt # doing the impossible to him";
275 else if (req == WR_RESETPLAYER)
277 self.porto_current = world;