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)
81 sound(self, CHAN_PROJECTILE, "porto/unsupported.ogg", VOL_BASE, ATTN_NORM);
84 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
86 sound(self, CHAN_PROJECTILE, "porto/bounce.ogg", VOL_BASE, ATTN_NORM);
88 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
89 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
91 else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
93 sound(self, CHAN_PROJECTILE, "porto/unsupported.ogg", VOL_BASE, ATTN_NORM);
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, "porto/create.ogg", VOL_BASE, ATTN_NORM);
102 trace_plane_normal = norm;
103 centerprint(self.owner, "^1In^7-portal created.\n");
104 self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm);
105 self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm));
109 sound(self, CHAN_PROJECTILE, "porto/unsupported.ogg", VOL_BASE, ATTN_NORM);
110 trace_plane_normal = norm;
116 if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
118 sound(self, CHAN_PROJECTILE, "porto/create.ogg", VOL_BASE, ATTN_NORM);
119 trace_plane_normal = norm;
120 centerprint(self.owner, "^4Out^7-portal created.\n");
125 sound(self, CHAN_PROJECTILE, "porto/unsupported.ogg", VOL_BASE, ATTN_NORM);
132 void W_Porto_Attack (void)
136 if not(self.items & IT_UNLIMITED_AMMO)
137 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
138 W_SetupShot (self, '0 0 0', FALSE, 4, "porto/fire.ogg");
140 //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
144 gren.classname = "porto";
145 gren.bot_dodge = TRUE;
146 gren.bot_dodgerating = 200;
147 gren.movetype = MOVETYPE_BOUNCEMISSILE;
148 gren.solid = SOLID_BBOX;
149 gren.effects = EF_LOWPRECISION | EF_RED;
151 gren.modelflags = MF_GRENADE;
152 setmodel(gren, "models/grenademodel.md3"); // precision set above
153 setsize(gren, '0 0 0', '0 0 0');
154 setorigin(gren, w_shotorg);
156 gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
157 gren.think = W_Porto_Think;
158 gren.touch = W_Porto_Touch;
159 gren.velocity = w_shotdir * cvar("g_balance_porto_primary_speed");
160 if(self.items & IT_STRENGTH)
161 gren.velocity = gren.velocity * cvar("g_balance_powerup_strength_force");
162 W_SetupProjectileVelocity(gren);
164 gren.angles = vectoangles (gren.velocity);
165 gren.flags = FL_PROJECTILE;
167 gren.portal_id = time;
168 self.porto_current = gren;
169 gren.playerid = self.playerid;
170 fixedmakevectors(vectoangles(gren.velocity));
171 gren.right_vector = v_right;
173 gren.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
176 void spawnfunc_weapon_porto (void)
178 weapon_defaultspawnfunc(WEP_PORTO);
181 float w_porto(float req)
187 self.BUTTON_ATCK = FALSE;
188 self.BUTTON_ATCK2 = FALSE;
189 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
190 self.BUTTON_ATCK = TRUE;
192 else if (req == WR_THINK)
194 if(self.porto_v_angle_held)
196 if(!self.BUTTON_ATCK2)
199 WRITESPECTATABLE_MSG_ONE({
200 WriteByte(MSG_ONE, SVC_TEMPENTITY);
201 WriteByte(MSG_ONE, TE_CSQC_HOLDANGLES);
202 WriteByte(MSG_ONE, WEP_PORTO);
203 WriteByte(MSG_ONE, 0);
205 self.porto_v_angle_held = 0;
210 if(self.BUTTON_ATCK2)
212 self.porto_v_angle = self.v_angle;
214 WRITESPECTATABLE_MSG_ONE({
215 WriteByte(MSG_ONE, SVC_TEMPENTITY);
216 WriteByte(MSG_ONE, TE_CSQC_HOLDANGLES);
217 WriteByte(MSG_ONE, WEP_PORTO);
218 WriteByte(MSG_ONE, 1);
219 WriteCoord(MSG_ONE, self.v_angle_x);
220 WriteCoord(MSG_ONE, self.v_angle_y);
222 self.porto_v_angle_held = 1;
225 v_angle_save = self.v_angle;
226 if(self.porto_v_angle_held)
227 makevectors(self.porto_v_angle); // override the previously set angles
229 if (self.BUTTON_ATCK)
230 if (!self.porto_current)
231 if (!self.porto_forbidden)
232 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
235 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
238 else if (req == WR_PRECACHE)
240 precache_model ("models/grenademodel.md3");
241 precache_model ("models/weapons/g_porto.md3");
242 precache_model ("models/weapons/v_porto.md3");
243 precache_model ("models/weapons/w_porto.zym");
244 precache_model ("models/portal.md3");
245 precache_sound ("porto/bounce.ogg");
246 precache_sound ("porto/create.ogg");
247 precache_sound ("porto/expire.ogg");
248 precache_sound ("porto/explode.ogg");
249 precache_sound ("porto/fire.ogg");
250 precache_sound ("porto/unsupported.ogg");
252 else if (req == WR_SETUP)
253 weapon_setup(WEP_PORTO);
254 else if (req == WR_SUICIDEMESSAGE)
255 w_deathtypestring = "did the impossible";
256 else if (req == WR_KILLMESSAGE)
257 w_deathtypestring = "felt # doing the impossible";