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)
64 if(other.classname == "portal")
65 return; // handled by the portal
67 norm = trace_plane_normal;
68 if(trace_ent.movetype == MOVETYPE_WALK)
70 traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_NORMAL, self);
71 if(trace_fraction >= 1)
73 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
75 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
79 if(self.owner.playerid != self.playerid)
83 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
86 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
87 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
89 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
93 else if(self.effects & EF_RED)
95 self.effects += EF_BLUE - EF_RED;
96 if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
98 trace_plane_normal = norm;
99 sound(self, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
100 centerprint(self.owner, "^1In^7-portal created.\n");
101 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
102 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
106 trace_plane_normal = norm;
112 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
114 trace_plane_normal = norm;
115 sound(self, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
116 centerprint(self.owner, "^4Out^7-portal created.\n");
127 void W_Porto_Attack (void)
131 if not(self.items & IT_UNLIMITED_AMMO)
132 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
133 W_SetupShot (self, '0 0 0', FALSE, 4, "weapons/grenade_fire.wav");
135 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
139 gren.classname = "porto";
140 gren.bot_dodge = TRUE;
141 gren.bot_dodgerating = 200;
142 gren.movetype = MOVETYPE_BOUNCEMISSILE;
143 gren.solid = SOLID_BBOX;
144 gren.effects = EF_LOWPRECISION | EF_RED;
146 gren.modelflags = MF_GRENADE;
147 setmodel(gren, "models/grenademodel.md3"); // precision set above
148 setsize(gren, '0 0 0', '0 0 0');
149 setorigin(gren, w_shotorg);
151 gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
152 gren.think = W_Porto_Think;
153 gren.touch = W_Porto_Touch;
154 gren.velocity = w_shotdir * cvar("g_balance_porto_primary_speed");
155 if(self.items & IT_STRENGTH)
156 gren.velocity = gren.velocity * cvar("g_balance_powerup_strength_force");
157 W_SetupProjectileVelocity(gren);
159 gren.angles = vectoangles (gren.velocity);
160 gren.flags = FL_PROJECTILE;
162 gren.portal_id = time;
163 self.porto_current = gren;
164 gren.playerid = self.playerid;
165 fixedmakevectors(vectoangles(gren.velocity));
166 gren.right_vector = v_right;
168 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
171 void spawnfunc_weapon_porto (void)
173 weapon_defaultspawnfunc(WEP_PORTO);
176 float w_porto(float req)
182 self.BUTTON_ATCK = FALSE;
183 self.BUTTON_ATCK2 = FALSE;
184 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
185 self.BUTTON_ATCK = TRUE;
187 else if (req == WR_THINK)
189 if(self.porto_v_angle_held)
191 if(!self.BUTTON_ATCK2)
194 WRITESPECTATABLE_MSG_ONE({
195 WriteByte(MSG_ONE, SVC_TEMPENTITY);
196 WriteByte(MSG_ONE, TE_CSQC_HOLDANGLES);
197 WriteByte(MSG_ONE, WEP_PORTO);
198 WriteByte(MSG_ONE, 0);
200 self.porto_v_angle_held = 0;
205 if(self.BUTTON_ATCK2)
207 self.porto_v_angle = self.v_angle;
209 WRITESPECTATABLE_MSG_ONE({
210 WriteByte(MSG_ONE, SVC_TEMPENTITY);
211 WriteByte(MSG_ONE, TE_CSQC_HOLDANGLES);
212 WriteByte(MSG_ONE, WEP_PORTO);
213 WriteByte(MSG_ONE, 1);
214 WriteCoord(MSG_ONE, self.v_angle_x);
215 WriteCoord(MSG_ONE, self.v_angle_y);
217 self.porto_v_angle_held = 1;
220 v_angle_save = self.v_angle;
221 if(self.porto_v_angle_held)
222 makevectors(self.porto_v_angle); // override the previously set angles
224 if (self.BUTTON_ATCK)
225 if (!self.porto_current)
226 if (!self.porto_forbidden)
227 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
230 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
233 else if (req == WR_PRECACHE)
235 precache_model ("models/grenademodel.md3");
236 precache_model ("models/weapons/g_porto.md3");
237 precache_model ("models/weapons/v_porto.md3");
238 precache_model ("models/weapons/w_porto.zym");
239 precache_sound ("weapons/grenade_fire.wav");
240 precache_model ("models/portal.md3");
242 else if (req == WR_SETUP)
243 weapon_setup(WEP_PORTO);
244 else if (req == WR_SUICIDEMESSAGE)
245 w_deathtypestring = "did the impossible";
246 else if (req == WR_KILLMESSAGE)
247 w_deathtypestring = "felt # doing the impossible";