2 .vector porto_v_angle; // holds "held" view angles
3 .float porto_v_angle_held;
6 void W_Porto_Success (void)
8 if(self.owner == world)
10 objerror("Cannot succeed successfully: no owner\n");
14 self.owner.porto_current = world;
18 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
19 void W_Porto_Fail (float failhard)
21 if(self.owner == world)
23 objerror("Cannot fail successfully: no owner\n");
28 Portal_ClearWithID(self.owner, self.portal_id);
29 self.owner.porto_current = world;
31 if(!failhard && self.owner.playerid == self.playerid && self.owner.deadflag == DEAD_NO && !(self.owner.weapons & WEPBIT_PORTO))
33 setsize (self, '-16 -16 0', '16 16 32');
34 setorigin(self, self.origin + trace_plane_normal);
35 if(move_out_of_solid(self))
38 self.velocity = trigger_push_calculatevelocity(self.origin, self.owner, 128);
39 tracetoss(self, self);
40 if(vlen(trace_endpos - self.owner.origin) < 128)
42 W_ThrowNewWeapon(self.owner, WEP_PORTO, 0, self.origin, self.velocity);
43 centerprint(self.owner, "^1Portal deployment failed.\n\n^2Catch it to try again!");
50 void W_Porto_Remove (entity p)
56 self = p.porto_current;
62 void W_Porto_Think (void)
64 trace_plane_normal = '0 0 0';
65 if(self.owner.playerid != self.playerid)
71 void W_Porto_Touch (void)
75 // do not use PROJECTILE_TOUCH here
77 if(other.classname == "portal")
78 return; // handled by the portal
80 norm = trace_plane_normal;
81 if(trace_ent.iscreature)
83 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_WORLDONLY, self);
84 if(trace_fraction >= 1)
86 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
88 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
92 if(self.owner.playerid != self.playerid)
94 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
97 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
99 spamsound(self, CHAN_PROJECTILE, "porto/bounce.wav", VOL_BASE, ATTN_NORM);
101 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
102 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
104 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
106 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
109 else if(self.effects & EF_RED)
111 self.effects += EF_BLUE - EF_RED;
112 if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
114 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
115 trace_plane_normal = norm;
116 centerprint(self.owner, "^1In^7-portal created.");
117 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
118 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
119 CSQCProjectile(self, TRUE, PROJECTILE_PORTO_BLUE, TRUE); // change type
123 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
124 trace_plane_normal = norm;
130 if(self.owner.portal_in.portal_id == self.portal_id)
132 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
134 sound(self, CHAN_PROJECTILE, "porto/create.wav", VOL_BASE, ATTN_NORM);
135 trace_plane_normal = norm;
136 centerprint(self.owner, "^4Out^7-portal created.");
141 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
147 sound(self, CHAN_PROJECTILE, "porto/unsupported.wav", VOL_BASE, ATTN_NORM);
153 void W_Porto_Attack (void)
157 if not(self.items & IT_UNLIMITED_SUPERWEAPONS)
158 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
159 W_SetupShot (self, FALSE, 4, "porto/fire.wav", 0);
160 // always shoot from the eye
161 w_shotdir = v_forward;
162 w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
164 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
168 gren.playerid = self.playerid;
169 gren.classname = "porto";
170 gren.bot_dodge = TRUE;
171 gren.bot_dodgerating = 200;
172 gren.movetype = MOVETYPE_BOUNCEMISSILE;
173 PROJECTILE_MAKETRIGGER(gren);
174 gren.effects = EF_RED;
176 setorigin(gren, w_shotorg);
177 setsize(gren, '0 0 0', '0 0 0');
179 gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
180 gren.think = W_Porto_Think;
181 gren.touch = W_Porto_Touch;
182 gren.velocity = w_shotdir * cvar("g_balance_porto_primary_speed");
183 if(self.items & IT_STRENGTH)
184 gren.velocity = gren.velocity * cvar("g_balance_powerup_strength_force");
185 W_SetupProjectileVelocity(gren);
187 gren.angles = vectoangles (gren.velocity);
188 gren.flags = FL_PROJECTILE;
190 gren.portal_id = time;
191 self.porto_current = gren;
192 gren.playerid = self.playerid;
193 fixedmakevectors(vectoangles(gren.velocity));
194 gren.right_vector = v_right;
196 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
198 CSQCProjectile(gren, TRUE, PROJECTILE_PORTO_RED, TRUE);
201 void spawnfunc_weapon_porto (void)
203 weapon_defaultspawnfunc(WEP_PORTO);
206 float w_nexball_weapon(float req);
207 float w_porto(float req)
211 if (g_nexball) { return w_nexball_weapon(req); }
214 self.BUTTON_ATCK = FALSE;
215 self.BUTTON_ATCK2 = FALSE;
216 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
217 self.BUTTON_ATCK = TRUE;
219 else if (req == WR_THINK)
221 if(self.porto_v_angle_held)
223 if(!self.BUTTON_ATCK2)
225 self.porto_v_angle_held = 0;
227 ClientData_Touch(self);
232 if(self.BUTTON_ATCK2)
234 self.porto_v_angle = self.v_angle;
235 self.porto_v_angle_held = 1;
237 ClientData_Touch(self);
240 v_angle_save = self.v_angle;
241 if(self.porto_v_angle_held)
242 makevectors(self.porto_v_angle); // override the previously set angles
244 if (self.BUTTON_ATCK)
245 if (!self.porto_current)
246 if (!self.porto_forbidden)
247 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
250 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
253 else if (req == WR_PRECACHE)
255 precache_model ("models/weapons/g_porto.md3");
256 precache_model ("models/weapons/v_porto.md3");
257 precache_model ("models/weapons/h_porto.dpm");
258 precache_model ("models/portal.md3");
259 precache_sound ("porto/bounce.wav");
260 precache_sound ("porto/create.wav");
261 precache_sound ("porto/expire.wav");
262 precache_sound ("porto/explode.wav");
263 precache_sound ("porto/fire.wav");
264 precache_sound ("porto/unsupported.wav");
266 else if (req == WR_SETUP)
267 weapon_setup(WEP_PORTO);
268 else if (req == WR_SUICIDEMESSAGE)
269 w_deathtypestring = "did the impossible";
270 else if (req == WR_KILLMESSAGE)
271 w_deathtypestring = "felt # doing the impossible to him";