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.realowner == world)
14 objerror("Cannot succeed successfully: no owner\n");
18 self.realowner.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.realowner == world)
27 objerror("Cannot fail successfully: no owner\n");
32 Portal_ClearWithID(self.realowner, self.portal_id);
33 self.realowner.porto_current = world;
35 if(!failhard && self.realowner.playerid == self.playerid && self.realowner.deadflag == DEAD_NO && !(self.realowner.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.realowner, 128);
43 tracetoss(self, self);
44 if(vlen(trace_endpos - self.realowner.origin) < 128)
46 W_ThrowNewWeapon(self.realowner, WEP_PORTO, 0, self.origin, self.velocity);
47 centerprint(self.realowner, "^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.realowner.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.realowner.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.realowner, 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.realowner, "^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.realowner.portal_in.portal_id == self.portal_id)
136 if(Portal_SpawnOutPortalAtTrace(self.realowner, 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.realowner, "^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", CHAN_WEAPON, 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);
171 gren.owner = gren.realowner = self;
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 + autocvar_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, autocvar_g_balance_porto_primary_speed * autocvar_g_balance_powerup_strength_force, 0);
189 W_SetupProjectileVelocity(gren, autocvar_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);
204 other = gren; MUTATOR_CALLHOOK(EditProjectile);
207 void spawnfunc_weapon_porto (void)
209 weapon_defaultspawnfunc(WEP_PORTO);
212 float w_nexball_weapon(float req);
213 float w_porto(float req)
217 if (g_nexball) { return w_nexball_weapon(req); }
220 self.BUTTON_ATCK = FALSE;
221 self.BUTTON_ATCK2 = FALSE;
222 if(bot_aim(autocvar_g_balance_porto_primary_speed, 0, autocvar_g_balance_grenadelauncher_primary_lifetime, FALSE))
223 self.BUTTON_ATCK = TRUE;
225 else if (req == WR_THINK)
227 if(self.porto_v_angle_held)
229 if(!self.BUTTON_ATCK2)
231 self.porto_v_angle_held = 0;
233 ClientData_Touch(self);
238 if(self.BUTTON_ATCK2)
240 self.porto_v_angle = self.v_angle;
241 self.porto_v_angle_held = 1;
243 ClientData_Touch(self);
246 v_angle_save = self.v_angle;
247 if(self.porto_v_angle_held)
248 makevectors(self.porto_v_angle); // override the previously set angles
250 if (self.BUTTON_ATCK)
251 if (!self.porto_current)
252 if (!self.porto_forbidden)
253 if (weapon_prepareattack(0, autocvar_g_balance_porto_primary_refire))
256 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_porto_primary_animtime, w_ready);
259 else if (req == WR_PRECACHE)
261 precache_model ("models/weapons/g_porto.md3");
262 precache_model ("models/weapons/v_porto.md3");
263 precache_model ("models/weapons/h_porto.iqm");
264 precache_model ("models/portal.md3");
265 precache_sound ("porto/bounce.wav");
266 precache_sound ("porto/create.wav");
267 precache_sound ("porto/expire.wav");
268 precache_sound ("porto/explode.wav");
269 precache_sound ("porto/fire.wav");
270 precache_sound ("porto/unsupported.wav");
272 else if (req == WR_SETUP)
274 weapon_setup(WEP_PORTO);
275 self.current_ammo = ammo_none;
277 else if (req == WR_RESETPLAYER)
279 self.porto_current = world;
285 float w_porto(float req)
287 if(req == WR_IMPACTEFFECT)
289 print("Since when does Porto send DamageInfo?\n");
291 else if(req == WR_PRECACHE)
295 else if (req == WR_SUICIDEMESSAGE)
296 w_deathtypestring = _("%s did the impossible");
297 else if (req == WR_KILLMESSAGE)
298 w_deathtypestring = _("%s felt %s doing the impossible to him");