3 .vector porto_v_angle; // holds "held" view angles
4 .float porto_v_angle_held;
7 void W_Porto_Success (void)
9 if(self.owner == world)
11 objerror("Cannot succeed successfully: no owner\n");
15 self.owner.porto_current = world;
19 float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
20 void W_Porto_Fail (float failhard)
22 if(self.owner == world)
24 objerror("Cannot fail successfully: no owner\n");
29 Portal_ClearWithID(self.owner, self.portal_id);
30 self.owner.porto_current = world;
32 if(!failhard && !(self.owner.weapons & WEPBIT_PORTO))
34 setsize (self, '-16 -16 0', '16 16 32');
35 setorigin(self, self.origin + trace_plane_normal);
36 if(move_out_of_solid(self))
39 self.velocity = trigger_push_calculatevelocity(self.origin, self.owner, 128);
40 tracetoss(self, self);
41 if(vlen(trace_endpos - self.owner.origin) < 128)
43 W_ThrowNewWeapon(self.owner, WEP_PORTO, 0, self.origin, self.velocity);
44 centerprint(self.owner, "^1Portal deployment failed.\n\n^2Catch it to try again!");
51 void W_Porto_Think (void)
53 trace_plane_normal = '0 0 0';
54 if(self.owner.playerid != self.playerid)
60 void W_Porto_Touch (void)
65 if(other.classname == "portal")
66 return; // handled by the portal
69 if(trace_ent.movetype == MOVETYPE_WALK)
71 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_NORMAL, self);
72 if(trace_fraction >= 1)
77 norm = trace_plane_normal;
78 if(self.owner.playerid != self.playerid)
82 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
87 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
88 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
91 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
96 else if(self.effects & EF_RED)
98 self.effects += EF_BLUE - EF_RED;
99 if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
101 sound(self, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
102 centerprint(self.owner, "^1In^7-portal created.\n");
103 trace_plane_normal = norm;
106 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
107 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
112 trace_plane_normal = norm;
118 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
120 sound(self, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
121 centerprint(self.owner, "^4Out^7-portal created.\n");
126 trace_plane_normal = norm;
133 void W_Porto_Attack (void)
137 if not(self.items & IT_UNLIMITED_AMMO)
138 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
139 W_SetupShot (self, '0 0 0', FALSE, 4, "weapons/grenade_fire.wav");
141 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
145 gren.classname = "porto";
146 gren.bot_dodge = TRUE;
147 gren.bot_dodgerating = 200;
148 gren.movetype = MOVETYPE_BOUNCEMISSILE;
149 gren.solid = SOLID_BBOX;
150 gren.effects = EF_LOWPRECISION | EF_RED;
152 gren.modelflags = MF_GRENADE;
153 setmodel(gren, "models/grenademodel.md3"); // precision set above
154 setsize(gren, '0 0 0', '0 0 0');
155 setorigin(gren, w_shotorg);
157 gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
158 gren.think = W_Porto_Think;
159 gren.touch = W_Porto_Touch;
160 gren.velocity = w_shotdir * cvar("g_balance_porto_primary_speed");
161 if(self.items & IT_STRENGTH)
162 gren.velocity = gren.velocity * cvar("g_balance_powerup_strength_force");
163 W_SetupProjectileVelocity(gren);
165 gren.angles = vectoangles (gren.velocity);
166 gren.flags = FL_PROJECTILE;
168 gren.portal_id = time;
169 self.porto_current = gren;
170 gren.playerid = self.playerid;
171 fixedmakevectors(vectoangles(gren.velocity));
172 gren.right_vector = v_right;
174 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
177 void spawnfunc_weapon_porto (void)
179 weapon_defaultspawnfunc(WEP_PORTO);
182 float w_porto(float req)
188 self.BUTTON_ATCK = FALSE;
189 self.BUTTON_ATCK2 = FALSE;
190 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
191 self.BUTTON_ATCK = TRUE;
193 else if (req == WR_THINK)
195 if(self.porto_v_angle_held)
197 if(!self.BUTTON_ATCK2)
200 WRITESPECTATABLE_MSG_ONE({
201 WriteByte(MSG_ONE, SVC_TEMPENTITY);
202 WriteByte(MSG_ONE, TE_CSQC_HOLDANGLES);
203 WriteByte(MSG_ONE, WEP_PORTO);
204 WriteByte(MSG_ONE, 0);
206 self.porto_v_angle_held = 0;
211 if(self.BUTTON_ATCK2)
213 self.porto_v_angle = self.v_angle;
215 WRITESPECTATABLE_MSG_ONE({
216 WriteByte(MSG_ONE, SVC_TEMPENTITY);
217 WriteByte(MSG_ONE, TE_CSQC_HOLDANGLES);
218 WriteByte(MSG_ONE, WEP_PORTO);
219 WriteByte(MSG_ONE, 1);
220 WriteCoord(MSG_ONE, self.v_angle_x);
221 WriteCoord(MSG_ONE, self.v_angle_y);
223 self.porto_v_angle_held = 1;
226 v_angle_save = self.v_angle;
227 if(self.porto_v_angle_held)
228 makevectors(self.porto_v_angle); // override the previously set angles
230 if (self.BUTTON_ATCK)
231 if (!self.porto_current)
232 if (!self.porto_forbidden)
233 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
236 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
239 else if (req == WR_PRECACHE)
241 precache_model ("models/grenademodel.md3");
242 precache_model ("models/weapons/g_porto.md3");
243 precache_model ("models/weapons/v_porto.md3");
244 precache_model ("models/weapons/w_porto.zym");
245 precache_sound ("weapons/grenade_fire.wav");
246 precache_model ("models/portal.md3");
248 else if (req == WR_SETUP)
249 weapon_setup(WEP_PORTO);
250 else if (req == WR_SUICIDEMESSAGE)
251 w_deathtypestring = "did the impossible";
252 else if (req == WR_KILLMESSAGE)
253 w_deathtypestring = "felt # doing the impossible";