1 float autocvar_g_nexball_safepass_turnrate;
2 float autocvar_g_nexball_safepass_maxdist;
3 float autocvar_g_nexball_safepass_holdtime;
4 float autocvar_g_nexball_viewmodel_scale;
5 float autocvar_g_nexball_tackling;
6 vector autocvar_g_nexball_viewmodel_offset;
8 void basketball_touch();
12 #define NBM_FOOTBALL 2
13 #define NBM_BASKETBALL 4
16 float OtherTeam(float t) //works only if there are two teams on the map!
19 e = find(world, classname, "nexball_team");
21 e = find(e, classname, "nexball_team");
26 void LogNB(string mode, entity actor)
29 if(!autocvar_sv_eventlog)
31 s = strcat(":nexball:", mode);
33 s = strcat(s, ":", ftos(actor.playerid));
37 void ball_restart(void)
40 DropBall(self, self.owner.origin, '0 0 0');
44 void nexball_setstatus(void)
47 self.items &= ~IT_KEY1;
50 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
52 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
54 self = self.ballcarried;
55 DropBall(self, self.owner.origin, '0 0 0');
60 self.items |= IT_KEY1;
64 void relocate_nexball(void)
66 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, TRUE, self);
71 if(!move_out_of_solid(self))
72 objerror("could not get out of solid at all!");
73 print("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
74 print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x));
75 print(" ", ftos(self.origin_y - o_y));
76 print(" ", ftos(self.origin_z - o_z), "'\n");
85 DropBall(self, ownr.origin, ownr.velocity);
86 makevectors(ownr.v_angle_y * '0 1 0');
87 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
88 ownr.flags &= ~FL_ONGROUND;
91 void GiveBall(entity plyr, entity ball)
95 if((ownr = ball.owner))
97 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
98 ownr.ballcarried = world;
102 ownr.weaponentity.state = WS_READY;
104 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
108 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
111 //setattachment(ball, plyr, "");
112 setorigin(ball, plyr.origin + plyr.view_ofs);
114 if(ball.team != plyr.team)
115 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
117 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
118 ball.team = plyr.team;
119 plyr.ballcarried = ball;
120 ball.nb_dropper = plyr;
122 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
123 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
125 ball.velocity = '0 0 0';
126 ball.movetype = MOVETYPE_NONE;
127 ball.touch = func_null;
128 ball.effects |= EF_NOSHADOW;
129 ball.scale = 1; // scale down.
131 WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
132 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
134 if(autocvar_g_nexball_basketball_delay_hold)
136 ball.think = DropOwner;
137 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
142 self.weaponentity.weapons = self.weapons;
143 self.weaponentity.switchweapon = self.weapon;
144 self.weapons = WEPSET_PORTO;
145 weapon_action(WEP_PORTO, WR_RESETPLAYER);
146 self.switchweapon = WEP_PORTO;
147 W_SwitchWeapon(WEP_PORTO);
151 void DropBall(entity ball, vector org, vector vel)
153 ball.effects |= autocvar_g_nexball_basketball_effects_default;
154 ball.effects &= ~EF_NOSHADOW;
155 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
157 setattachment(ball, world, "");
158 setorigin(ball, org);
159 ball.movetype = MOVETYPE_BOUNCE;
160 ball.flags &= ~FL_ONGROUND;
161 ball.scale = ball_scale;
163 ball.nb_droptime = time;
164 ball.touch = basketball_touch;
165 ball.think = ResetBall;
166 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
168 if(ball.owner.metertime)
170 ball.owner.metertime = 0;
171 ball.owner.weaponentity.state = WS_READY;
174 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
175 WaypointSprite_Spawn("nb-ball", 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // no health bar please
176 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
178 ball.owner.ballcarried = world;
185 self.flags &= ~FL_ONGROUND;
186 self.movetype = MOVETYPE_BOUNCE;
187 if(self.classname == "nexball_basketball")
188 self.touch = basketball_touch;
189 else if(self.classname == "nexball_football")
190 self.touch = football_touch;
192 self.think = ResetBall;
193 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
197 sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
198 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
199 LogNB("init", world);
204 if(self.cnt < 2) // step 1
206 if(time == self.teamtime)
207 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
209 self.touch = func_null;
210 self.movetype = MOVETYPE_NOCLIP;
211 self.velocity = '0 0 0'; // just in case?
213 LogNB("resetidle", world);
215 self.nextthink = time;
217 else if(self.cnt < 4) // step 2 and 3
219 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
220 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
221 self.nextthink = time + 0.5;
226 // dprint("Step 4: time: ", ftos(time), "\n");
227 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
228 dprint("The ball moved too far away from its spawn origin.\nOffset: ",
229 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
230 self.velocity = '0 0 0';
231 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
232 self.movetype = MOVETYPE_NONE;
233 self.think = InitBall;
234 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
238 void football_touch(void)
240 if(other.solid == SOLID_BSP)
242 if(time > self.lastground + 0.1)
244 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
245 self.lastground = time;
247 if(vlen(self.velocity) && !self.cnt)
248 self.nextthink = time + autocvar_g_nexball_delay_idle;
251 if (!IS_PLAYER(other))
256 self.nextthink = time + autocvar_g_nexball_delay_idle;
259 self.team = other.team;
261 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
263 if(vlen(other.velocity))
264 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
266 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
268 makevectors(other.v_angle);
269 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
271 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
273 makevectors(other.v_angle_y * '0 1 0');
274 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
276 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
278 makevectors(other.v_angle);
279 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
281 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
284 void basketball_touch(void)
286 if(other.ballcarried)
291 if(!self.cnt && IS_PLAYER(other) && !other.frozen && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
293 if(other.health <= 0)
295 LogNB("caught", other);
296 GiveBall(other, self);
298 else if(other.solid == SOLID_BSP)
300 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
301 if(vlen(self.velocity) && !self.cnt)
302 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
309 float isclient, pscore, otherteam;
313 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
314 ball = other.ballcarried;
317 if(ball.classname != "nexball_basketball")
318 if(ball.classname != "nexball_football")
320 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
326 otherteam = OtherTeam(ball.team);
330 if((isclient = IS_CLIENT(ball.pusher)))
331 pname = ball.pusher.netname;
333 pname = "Someone (?)";
335 if(ball.team == self.team) //owngoal (regular goals)
337 LogNB("owngoal", ball.pusher);
338 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
341 else if(self.team == GOAL_FAULT)
343 LogNB("fault", ball.pusher);
345 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
347 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
350 else if(self.team == GOAL_OUT)
352 LogNB("out", ball.pusher);
353 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
354 bprint(pname, "^7 went out of bounds.\n");
356 bprint("The ball was returned.\n");
361 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
362 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
366 sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
368 if(ball.team && pscore)
370 if(nb_teams == 2 && pscore < 0)
371 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
373 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
378 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
380 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
383 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
384 DropBall(ball, ball.owner.origin, ball.owner.velocity);
386 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
389 ball.think = ResetBall;
390 if(ball.classname == "nexball_basketball")
391 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
392 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
395 //=======================//
397 //=======================//
398 void spawnfunc_nexball_team(void)
405 self.team = self.cnt + 1;
408 void nb_spawnteam(string teamname, float teamcolor)
410 dprint("^2spawned team ", teamname, "\n");
413 e.classname = "nexball_team";
414 e.netname = teamname;
420 void nb_spawnteams(void)
422 float t_r = 0, t_b = 0, t_y = 0, t_p = 0;
424 for(e = world; (e = find(e, classname, "nexball_goal"));)
431 nb_spawnteam("Red", e.team-1) ;
438 nb_spawnteam("Blue", e.team-1) ;
445 nb_spawnteam("Yellow", e.team-1);
452 nb_spawnteam("Pink", e.team-1) ;
461 void nb_ScoreRules(float teams)
463 ScoreRules_basics(teams, 0, 0, TRUE);
464 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
465 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
466 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
467 ScoreRules_basics_end();
470 void nb_delayedinit(void)
472 if(find(world, classname, "nexball_team") == world)
474 nb_ScoreRules(nb_teams);
478 //=======================//
480 //=======================//
484 if(!g_nexball) { remove(self); return; }
486 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
490 self.model = "models/nexball/ball.md3";
494 precache_model(self.model);
495 setmodel(self, self.model);
496 setsize(self, BALL_MINS, BALL_MAXS);
497 ball_scale = self.scale;
500 self.spawnorigin = self.origin;
502 self.effects = self.effects | EF_LOWPRECISION;
504 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
506 self.glow_color = autocvar_g_nexball_trail_color;
507 self.glow_trail = TRUE;
510 self.movetype = MOVETYPE_FLY;
512 if(!autocvar_g_nexball_sound_bounce)
514 else if(self.noise == "")
515 self.noise = "sound/nexball/bounce.wav";
516 //bounce sound placeholder (FIXME)
517 if(self.noise1 == "")
518 self.noise1 = "sound/nexball/drop.wav";
519 //ball drop sound placeholder (FIXME)
520 if(self.noise2 == "")
521 self.noise2 = "sound/nexball/steal.wav";
522 //stealing sound placeholder (FIXME)
523 if(self.noise) precache_sound(self.noise);
524 precache_sound(self.noise1);
525 precache_sound(self.noise2);
527 WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
529 self.reset = ball_restart;
530 self.think = InitBall;
531 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
534 void spawnfunc_nexball_basketball(void)
536 nexball_mode |= NBM_BASKETBALL;
537 self.classname = "nexball_basketball";
538 if (!(balls & BALL_BASKET))
541 CVTOV(g_nexball_basketball_effects_default);
542 CVTOV(g_nexball_basketball_delay_hold);
543 CVTOV(g_nexball_basketball_delay_hold_forteam);
544 CVTOV(g_nexball_basketball_teamsteal);
546 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
549 self.effects = autocvar_g_nexball_basketball_effects_default;
550 self.solid = SOLID_TRIGGER;
551 balls |= BALL_BASKET;
552 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
553 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
557 void spawnfunc_nexball_football(void)
559 nexball_mode |= NBM_FOOTBALL;
560 self.classname = "nexball_football";
561 self.solid = SOLID_TRIGGER;
563 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
564 self.bouncestop = autocvar_g_nexball_football_bouncestop;
568 float nb_Goal_Customize()
571 e = WaypointSprite_getviewentity(other);
572 wp_owner = self.owner;
573 if(SAME_TEAM(e, wp_owner)) { return FALSE; }
580 if(!g_nexball) { remove(self); return; }
584 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
586 WaypointSprite_SpawnFixed("goal", (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE, ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0'));
587 self.sprite.customizeentityforclient = nb_Goal_Customize;
590 self.classname = "nexball_goal";
592 self.noise = "ctf/respawn.wav";
593 precache_sound(self.noise);
594 self.touch = GoalTouch;
597 void spawnfunc_nexball_redgoal(void)
599 self.team = NUM_TEAM_1;
602 void spawnfunc_nexball_bluegoal(void)
604 self.team = NUM_TEAM_2;
607 void spawnfunc_nexball_yellowgoal(void)
609 self.team = NUM_TEAM_3;
612 void spawnfunc_nexball_pinkgoal(void)
614 self.team = NUM_TEAM_4;
618 void spawnfunc_nexball_fault(void)
620 self.team = GOAL_FAULT;
622 self.noise = "misc/typehit.wav";
626 void spawnfunc_nexball_out(void)
628 self.team = GOAL_OUT;
630 self.noise = "misc/typehit.wav";
635 //Spawnfuncs preserved for compatibility
638 void spawnfunc_ball(void)
640 spawnfunc_nexball_football();
642 void spawnfunc_ball_football(void)
644 spawnfunc_nexball_football();
646 void spawnfunc_ball_basketball(void)
648 spawnfunc_nexball_basketball();
650 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
651 void spawnfunc_ball_redgoal(void)
653 spawnfunc_nexball_bluegoal(); // I blame Revenant
655 void spawnfunc_ball_bluegoal(void)
657 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
659 void spawnfunc_ball_fault(void)
661 spawnfunc_nexball_fault();
663 void spawnfunc_ball_bound(void)
665 spawnfunc_nexball_out();
668 //=======================//
670 //=======================//
673 void W_Nexball_Think()
675 //dprint("W_Nexball_Think\n");
676 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
677 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
678 vector old_dir = normalize(self.velocity);
679 float _speed = vlen(self.velocity);
680 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
681 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
683 self.velocity = new_vel;
685 self.nextthink = time;
688 void W_Nexball_Touch(void)
690 entity ball, attacker;
691 attacker = self.owner;
692 //self.think = func_null;
693 //self.enemy = world;
696 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
697 if((ball = other.ballcarried) && !other.deadflag && (IS_PLAYER(attacker)))
699 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
700 other.flags &= ~FL_ONGROUND;
701 if(!attacker.ballcarried)
703 LogNB("stole", attacker);
704 sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
706 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
708 attacker.teamkill_complain = time + 5;
709 attacker.teamkill_soundtime = time + 0.4;
710 attacker.teamkill_soundsource = other;
713 GiveBall(attacker, other.ballcarried);
719 void W_Nexball_Attack(float t)
723 if(!(ball = self.ballcarried))
726 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
727 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
731 self.metertime = 0; // Shot failed, hide the power meter
735 //Calculate multiplier
740 mi = autocvar_g_nexball_basketball_meter_minpower;
741 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
742 //One triangle wave period with 1 as max
743 mul = 2 * mod(t, g_nexball_meter_period) / g_nexball_meter_period;
746 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
749 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE));
752 //TODO: use the speed_up cvar too ??
755 void W_Nexball_Attack2(void)
757 if(self.ballcarried.enemy)
759 entity _ball = self.ballcarried;
760 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
761 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
762 _ball.think = W_Nexball_Think;
763 _ball.nextthink = time;
767 if(!autocvar_g_nexball_tackling)
771 if(!(balls & BALL_BASKET))
773 W_SetupShot(self, FALSE, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
774 // pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
777 missile.owner = self;
778 missile.classname = "ballstealer";
780 missile.movetype = MOVETYPE_FLY;
781 PROJECTILE_MAKETRIGGER(missile);
783 //setmodel(missile, "models/elaser.mdl"); // precision set below
784 setsize(missile, '0 0 0', '0 0 0');
785 setorigin(missile, w_shotorg);
787 W_SetupProjectileVelocity(missile, autocvar_g_balance_nexball_secondary_speed, 0);
788 missile.angles = vectoangles(missile.velocity);
789 missile.touch = W_Nexball_Touch;
790 missile.think = SUB_Remove;
791 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
793 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
794 missile.flags = FL_PROJECTILE;
796 CSQCProjectile(missile, TRUE, PROJECTILE_ELECTRO, TRUE);
799 float ball_customize()
803 self.effects &= ~EF_FLAME;
805 self.customizeentityforclient = func_null;
809 if(other == self.owner)
811 self.scale = autocvar_g_nexball_viewmodel_scale;
813 self.effects |= EF_FLAME;
815 self.effects &= ~EF_FLAME;
819 self.effects &= ~EF_FLAME;
826 float w_nexball_weapon(float req)
831 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
832 if(autocvar_g_nexball_basketball_meter)
834 if(self.ballcarried && !self.metertime)
835 self.metertime = time;
837 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
841 W_Nexball_Attack(-1);
842 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
844 if(self.BUTTON_ATCK2)
845 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
848 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
851 if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
853 W_Nexball_Attack(time - self.metertime);
854 // DropBall or stealing will set metertime back to 0
855 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
858 else if(req == WR_PRECACHE)
860 precache_model("models/weapons/g_porto.md3");
861 precache_model("models/weapons/v_porto.md3");
862 precache_model("models/weapons/h_porto.iqm");
863 precache_model("models/elaser.mdl");
864 precache_sound("nexball/shoot1.wav");
865 precache_sound("nexball/shoot2.wav");
866 precache_sound("misc/typehit.wav");
868 else if(req == WR_SETUP)
870 weapon_setup(WEP_PORTO);
872 // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE
876 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
878 if(self.ballcarried && g_nexball)
879 DropBall(self.ballcarried, self.origin, self.velocity);
884 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
886 makevectors(self.v_angle);
887 if(nexball_mode & NBM_BASKETBALL)
892 self.ballcarried.velocity = self.velocity;
893 self.ballcarried.customizeentityforclient = ball_customize;
895 setorigin(self.ballcarried, self.origin + self.view_ofs +
896 v_forward * autocvar_g_nexball_viewmodel_offset_x +
897 v_right * autocvar_g_nexball_viewmodel_offset_y +
898 v_up * autocvar_g_nexball_viewmodel_offset_z);
901 if(autocvar_g_nexball_safepass_maxdist)
903 if(self.ballcarried.wait < time && self.ballcarried.enemy)
905 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
906 self.ballcarried.enemy = world;
910 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
911 crosshair_trace(self);
913 IS_CLIENT(trace_ent) &&
914 trace_ent.deadflag == DEAD_NO &&
915 trace_ent.team == self.team &&
916 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
919 //if(self.ballcarried.enemy != trace_ent)
920 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
921 self.ballcarried.enemy = trace_ent;
922 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
930 if(self.weaponentity.weapons)
932 self.weapons = self.weaponentity.weapons;
933 weapon_action(WEP_PORTO, WR_RESETPLAYER);
934 self.switchweapon = self.weaponentity.switchweapon;
935 W_SwitchWeapon(self.switchweapon);
937 self.weaponentity.weapons = '0 0 0';
948 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
950 self.weaponentity.weapons = '0 0 0';
952 if(nexball_mode & NBM_BASKETBALL)
953 self.weapons |= WEPSET_PORTO;
955 self.weapons = '0 0 0';
960 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
964 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
965 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
970 MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
972 start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
977 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
979 if(self.weapon == WEP_GRENADE_LAUNCHER)
985 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
987 if(self.classname == "droppedweapon")
988 if(self.weapon == WEP_GRENADE_LAUNCHER)
994 MUTATOR_DEFINITION(gamemode_nexball)
996 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
997 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
998 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
999 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
1000 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
1001 MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
1002 MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
1003 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
1004 MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
1008 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1009 if(g_nexball_meter_period <= 0)
1010 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1011 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1012 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
1014 w_porto(WR_PRECACHE); // abuse
1018 CVTOV(g_nexball_football_boost_forward); //100
1019 CVTOV(g_nexball_football_boost_up); //200
1020 CVTOV(g_nexball_delay_idle); //10
1021 CVTOV(g_nexball_football_physics); //0
1023 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
1025 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
1028 MUTATOR_ONROLLBACK_OR_REMOVE
1030 // we actually cannot roll back nb_delayedinit here
1031 // BUT: we don't need to! If this gets called, adding always
1037 print("This is a game type and it cannot be removed at runtime.");