4 int autocvar_cl_eventchase_nexball = 1;
6 REGISTER_MUTATOR(cl_nb, true);
8 MUTATOR_HOOKFUNCTION(cl_nb, WantEventchase)
10 if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
18 int autocvar_g_nexball_goalleadlimit;
19 #define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
21 bool autocvar_g_nexball_basketball_jumppad = true;
22 float autocvar_g_nexball_basketball_bouncefactor;
23 float autocvar_g_nexball_basketball_bouncestop;
24 float autocvar_g_nexball_basketball_carrier_highspeed;
25 bool autocvar_g_nexball_basketball_meter;
26 float autocvar_g_nexball_basketball_meter_maxpower;
27 float autocvar_g_nexball_basketball_meter_minpower;
28 float autocvar_g_nexball_delay_collect;
29 float autocvar_g_nexball_delay_goal;
30 float autocvar_g_nexball_delay_start;
31 bool autocvar_g_nexball_football_jumppad = true;
32 float autocvar_g_nexball_football_bouncefactor;
33 float autocvar_g_nexball_football_bouncestop;
34 bool autocvar_g_nexball_radar_showallplayers;
35 bool autocvar_g_nexball_sound_bounce;
36 int autocvar_g_nexball_trail_color;
37 bool autocvar_g_nexball_playerclip_collisions = true;
39 float autocvar_g_nexball_safepass_turnrate;
40 float autocvar_g_nexball_safepass_maxdist;
41 float autocvar_g_nexball_safepass_holdtime;
42 float autocvar_g_nexball_viewmodel_scale;
43 float autocvar_g_nexball_tackling;
44 vector autocvar_g_nexball_viewmodel_offset;
46 float autocvar_g_balance_nexball_primary_animtime;
47 float autocvar_g_balance_nexball_primary_refire;
48 float autocvar_g_balance_nexball_primary_speed;
49 float autocvar_g_balance_nexball_secondary_animtime;
50 float autocvar_g_balance_nexball_secondary_force;
51 float autocvar_g_balance_nexball_secondary_lifetime;
52 float autocvar_g_balance_nexball_secondary_refire;
53 float autocvar_g_balance_nexball_secondary_speed;
55 void basketball_touch(entity this, entity toucher);
56 void football_touch(entity this, entity toucher);
57 void ResetBall(entity this);
58 const int NBM_NONE = 0;
59 const int NBM_FOOTBALL = 2;
60 const int NBM_BASKETBALL = 4;
63 float OtherTeam(float t) //works only if there are two teams on the map!
66 e = find(NULL, classname, "nexball_team");
68 e = find(e, classname, "nexball_team");
72 const int ST_NEXBALL_GOALS = 1;
73 void nb_ScoreRules(int teams)
75 GameRules_scoring(teams, 0, 0, {
76 field_team(ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
77 field(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
78 field(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
82 void LogNB(string mode, entity actor)
85 if(!autocvar_sv_eventlog)
87 s = strcat(":nexball:", mode);
89 s = strcat(s, ":", ftos(actor.playerid));
93 void ball_restart(entity this)
96 DropBall(this, this.owner.origin, '0 0 0');
100 void nexball_setstatus(entity this)
102 this.items &= ~IT_KEY1;
105 if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
107 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_NEXBALL_RETURN_HELD));
108 entity e = this.ballcarried;
109 DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
113 this.items |= IT_KEY1;
117 void relocate_nexball(entity this)
119 tracebox(this.origin, BALL_MINS, BALL_MAXS, this.origin, true, this);
122 vector o = this.origin;
123 if (!move_out_of_solid(this)) {
124 objerror(this, "could not get out of solid at all!");
127 "^1NOTE: this map needs FIXING. %s at %s needs to be moved out of solid, e.g. by %s",
130 vtos(this.origin - o)
136 void DropOwner(entity this)
140 DropBall(this, ownr.origin, ownr.velocity);
141 makevectors(ownr.v_angle.y * '0 1 0');
142 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
143 UNSET_ONGROUND(ownr);
146 void GiveBall(entity plyr, entity ball)
148 .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
149 entity ownr = ball.owner;
152 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
153 ownr.ballcarried = NULL;
154 GameRules_scoring_vip(ownr, false);
155 if(STAT(NB_METERSTART, ownr))
157 STAT(NB_METERSTART, ownr) = 0;
158 ownr.(weaponentity).state = WS_READY;
160 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
164 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
167 //setattachment(ball, plyr, "");
168 setorigin(ball, plyr.origin + plyr.view_ofs);
170 if(ball.team != plyr.team)
171 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
173 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
174 ball.weaponentity_fld = weaponentity;
175 ball.team = plyr.team;
176 plyr.ballcarried = ball;
177 GameRules_scoring_vip(plyr, true);
178 ball.nb_dropper = plyr;
180 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
181 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
183 ball.velocity = '0 0 0';
184 set_movetype(ball, MOVETYPE_NONE);
185 settouch(ball, func_null);
186 ball.effects |= EF_NOSHADOW;
187 ball.scale = 1; // scale down.
189 WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
190 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
192 if(autocvar_g_nexball_basketball_delay_hold)
194 setthink(ball, DropOwner);
195 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
198 STAT(WEAPONS, plyr.(weaponentity)) = STAT(WEAPONS, plyr);
199 plyr.m_switchweapon = plyr.(weaponentity).m_weapon;
200 STAT(WEAPONS, plyr) = WEPSET(NEXBALL);
201 Weapon w = WEP_NEXBALL;
202 w.wr_resetplayer(w, plyr);
203 plyr.(weaponentity).m_switchweapon = WEP_NEXBALL;
204 W_SwitchWeapon(plyr, WEP_NEXBALL, weaponentity);
207 void DropBall(entity ball, vector org, vector vel)
209 ball.effects |= autocvar_g_nexball_basketball_effects_default;
210 ball.effects &= ~EF_NOSHADOW;
211 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
213 setattachment(ball, NULL, "");
214 setorigin(ball, org);
215 set_movetype(ball, MOVETYPE_BOUNCE);
216 UNSET_ONGROUND(ball);
217 ball.scale = ball_scale;
219 ball.nb_droptime = time;
220 settouch(ball, basketball_touch);
221 setthink(ball, ResetBall);
222 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
224 if(STAT(NB_METERSTART, ball.owner))
226 STAT(NB_METERSTART, ball.owner) = 0;
227 .entity weaponentity = ball.weaponentity_fld;
228 ball.owner.(weaponentity).state = WS_READY;
231 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
232 WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
233 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
235 entity e = ball.owner; ball.owner = NULL;
236 e.ballcarried = NULL;
237 GameRules_scoring_vip(e, false);
240 void InitBall(entity this)
242 if(game_stopped) return;
243 UNSET_ONGROUND(this);
244 set_movetype(this, MOVETYPE_BOUNCE);
245 if(this.classname == "nexball_basketball")
246 settouch(this, basketball_touch);
247 else if(this.classname == "nexball_football")
248 settouch(this, football_touch);
250 setthink(this, ResetBall);
251 this.nextthink = time + autocvar_g_nexball_delay_idle + 3;
255 _sound(this, CH_TRIGGER, this.noise1, VOL_BASE, ATTEN_NORM);
256 WaypointSprite_Ping(this.waypointsprite_attachedforcarrier);
260 void ResetBall(entity this)
262 if(this.cnt < 2) // step 1
264 if(time == this.teamtime)
265 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_NEXBALL_RETURN_HELD));
267 settouch(this, func_null);
268 set_movetype(this, MOVETYPE_NOCLIP);
269 this.velocity = '0 0 0'; // just in case?
271 LogNB("resetidle", NULL);
273 this.nextthink = time;
275 else if(this.cnt < 4) // step 2 and 3
277 // dprint("Step ", ftos(this.cnt), ": Calculated velocity: ", vtos(this.spawnorigin - this.origin), ", time: ", ftos(time), "\n");
278 this.velocity = (this.spawnorigin - this.origin) * (this.cnt - 1); // 1 or 0.5 second movement
279 this.nextthink = time + 0.5;
284 // dprint("Step 4: time: ", ftos(time), "\n");
285 if(vdist(this.origin - this.spawnorigin, >, 10)) // should not happen anymore
286 LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
287 vtos(this.origin - this.spawnorigin), " Velocity: ", vtos(this.velocity), "\n");
288 this.velocity = '0 0 0';
289 setorigin(this, this.spawnorigin); // make sure it's positioned correctly anyway
290 set_movetype(this, MOVETYPE_NONE);
291 setthink(this, InitBall);
292 this.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
296 void football_touch(entity this, entity toucher)
298 if(toucher.solid == SOLID_BSP)
300 if(time > this.lastground + 0.1)
302 _sound(this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
303 this.lastground = time;
305 if(this.velocity && !this.cnt)
306 this.nextthink = time + autocvar_g_nexball_delay_idle;
309 if (!IS_PLAYER(toucher))
311 if(toucher.health < 1)
314 this.nextthink = time + autocvar_g_nexball_delay_idle;
316 this.pusher = toucher;
317 this.team = toucher.team;
319 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
322 this.velocity = toucher.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
324 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
326 makevectors(toucher.v_angle);
327 this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
329 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
331 makevectors(toucher.v_angle.y * '0 1 0');
332 this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
334 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
336 makevectors(toucher.v_angle);
337 this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
339 this.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
342 void basketball_touch(entity this, entity toucher)
344 if(toucher.ballcarried)
346 football_touch(this, toucher);
349 if(!this.cnt && IS_PLAYER(toucher) && !STAT(FROZEN, toucher) && !IS_DEAD(toucher) && (toucher != this.nb_dropper || time > this.nb_droptime + autocvar_g_nexball_delay_collect))
351 if(toucher.health <= 0)
353 LogNB("caught", toucher);
354 GiveBall(toucher, this);
356 else if(toucher.solid == SOLID_BSP)
358 _sound(this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
359 if(this.velocity && !this.cnt)
360 this.nextthink = min(time + autocvar_g_nexball_delay_idle, this.teamtime);
364 void GoalTouch(entity this, entity toucher)
367 float isclient, pscore, otherteam;
370 if(game_stopped) return;
371 if((this.spawnflags & GOAL_TOUCHPLAYER) && toucher.ballcarried)
372 ball = toucher.ballcarried;
375 if(ball.classname != "nexball_basketball")
376 if(ball.classname != "nexball_football")
378 if((!ball.pusher && this.team != GOAL_OUT) || ball.cnt)
380 EXACTTRIGGER_TOUCH(this, toucher);
383 if(NumTeams(nb_teams) == 2)
384 otherteam = OtherTeam(ball.team);
388 if((isclient = IS_CLIENT(ball.pusher)))
389 pname = ball.pusher.netname;
391 pname = "Someone (?)";
393 if(ball.team == this.team) //owngoal (regular goals)
395 LogNB("owngoal", ball.pusher);
396 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
399 else if(this.team == GOAL_FAULT)
401 LogNB("fault", ball.pusher);
402 if(NumTeams(nb_teams) == 2)
403 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
405 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
408 else if(this.team == GOAL_OUT)
410 LogNB("out", ball.pusher);
411 if((this.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
412 bprint(pname, "^7 went out of bounds.\n");
414 bprint("The ball was returned.\n");
419 LogNB(strcat("goal:", ftos(this.team)), ball.pusher);
420 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
424 _sound(ball, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NONE);
426 if(ball.team && pscore)
428 if(NumTeams(nb_teams) == 2 && pscore < 0)
429 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
431 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
436 GameRules_scoring_add(ball.pusher, NEXBALL_GOALS, pscore);
438 GameRules_scoring_add(ball.pusher, NEXBALL_FAULTS, -pscore);
441 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
442 DropBall(ball, ball.owner.origin, ball.owner.velocity);
444 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
447 setthink(ball, ResetBall);
448 if(ball.classname == "nexball_basketball")
449 settouch(ball, football_touch); // better than func_null: football control until the ball gets reset
450 ball.nextthink = time + autocvar_g_nexball_delay_goal * (this.team != GOAL_OUT);
453 //=======================//
455 //=======================//
456 spawnfunc(nexball_team)
463 this.team = this.cnt + 1;
466 void nb_spawnteam(string teamname, float teamcolor)
468 LOG_TRACE("^2spawned team ", teamname);
469 entity e = new(nexball_team);
470 e.netname = teamname;
478 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
480 for(e = NULL; (e = find(e, classname, "nexball_goal"));)
487 nb_spawnteam("Red", e.team-1) ;
495 nb_spawnteam("Blue", e.team-1) ;
503 nb_spawnteam("Yellow", e.team-1);
511 nb_spawnteam("Pink", e.team-1) ;
520 void nb_delayedinit(entity this)
522 if(find(NULL, classname, "nexball_team") == NULL)
524 nb_ScoreRules(nb_teams);
528 //=======================//
530 //=======================//
532 void SpawnBall(entity this)
534 if(!g_nexball) { delete(this); return; }
536 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
540 this.model = "models/nexball/ball.md3";
544 precache_model(this.model);
545 _setmodel(this, this.model);
546 setsize(this, BALL_MINS, BALL_MAXS);
547 ball_scale = this.scale;
549 relocate_nexball(this);
550 this.spawnorigin = this.origin;
552 this.effects = this.effects | EF_LOWPRECISION;
554 if(cvar(strcat("g_", this.classname, "_trail"))) //nexball_basketball :p
556 this.glow_color = autocvar_g_nexball_trail_color;
557 this.glow_trail = true;
560 set_movetype(this, MOVETYPE_FLY);
562 if(autocvar_g_nexball_playerclip_collisions)
563 this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP;
565 if(!autocvar_g_nexball_sound_bounce)
567 else if(this.noise == "")
568 this.noise = strzone(SND(NB_BOUNCE));
569 //bounce sound placeholder (FIXME)
570 if(this.noise1 == "")
571 this.noise1 = strzone(SND(NB_DROP));
572 //ball drop sound placeholder (FIXME)
573 if(this.noise2 == "")
574 this.noise2 = strzone(SND(NB_STEAL));
575 //stealing sound placeholder (FIXME)
576 if(this.noise) precache_sound(this.noise);
577 precache_sound(this.noise1);
578 precache_sound(this.noise2);
580 WaypointSprite_AttachCarrier(WP_NbBall, this, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
582 this.reset = ball_restart;
583 setthink(this, InitBall);
584 this.nextthink = game_starttime + autocvar_g_nexball_delay_start;
587 spawnfunc(nexball_basketball)
589 nexball_mode |= NBM_BASKETBALL;
590 this.classname = "nexball_basketball";
591 if (!(balls & BALL_BASKET))
594 CVTOV(g_nexball_basketball_effects_default);
595 CVTOV(g_nexball_basketball_delay_hold);
596 CVTOV(g_nexball_basketball_delay_hold_forteam);
597 CVTOV(g_nexball_basketball_teamsteal);
599 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
602 this.effects = autocvar_g_nexball_basketball_effects_default;
603 this.solid = SOLID_TRIGGER;
604 this.pushable = autocvar_g_nexball_basketball_jumppad;
605 balls |= BALL_BASKET;
606 this.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
607 this.bouncestop = autocvar_g_nexball_basketball_bouncestop;
611 spawnfunc(nexball_football)
613 nexball_mode |= NBM_FOOTBALL;
614 this.classname = "nexball_football";
615 this.solid = SOLID_TRIGGER;
617 this.pushable = autocvar_g_nexball_football_jumppad;
618 this.bouncefactor = autocvar_g_nexball_football_bouncefactor;
619 this.bouncestop = autocvar_g_nexball_football_bouncestop;
623 bool nb_Goal_Customize(entity this, entity client)
625 entity e = WaypointSprite_getviewentity(client);
626 entity wp_owner = this.owner;
627 if(SAME_TEAM(e, wp_owner)) { return false; }
632 void SpawnGoal(entity this)
634 if(!g_nexball) { delete(this); return; }
638 if(this.team != GOAL_OUT && Team_IsValidTeam(this.team))
640 entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (this.absmin + this.absmax) * 0.5, this, sprite, RADARICON_NONE);
641 wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0.5 0');
642 setcefc(this.sprite, nb_Goal_Customize);
645 this.classname = "nexball_goal";
647 this.noise = "ctf/respawn.wav";
648 precache_sound(this.noise);
649 settouch(this, GoalTouch);
652 spawnfunc(nexball_redgoal)
654 this.team = NUM_TEAM_1;
657 spawnfunc(nexball_bluegoal)
659 this.team = NUM_TEAM_2;
662 spawnfunc(nexball_yellowgoal)
664 this.team = NUM_TEAM_3;
667 spawnfunc(nexball_pinkgoal)
669 this.team = NUM_TEAM_4;
673 spawnfunc(nexball_fault)
675 this.team = GOAL_FAULT;
677 this.noise = strzone(SND(TYPEHIT));
681 spawnfunc(nexball_out)
683 this.team = GOAL_OUT;
685 this.noise = strzone(SND(TYPEHIT));
690 //Spawnfuncs preserved for compatibility
695 spawnfunc_nexball_football(this);
697 spawnfunc(ball_football)
699 spawnfunc_nexball_football(this);
701 spawnfunc(ball_basketball)
703 spawnfunc_nexball_basketball(this);
705 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
706 spawnfunc(ball_redgoal)
708 spawnfunc_nexball_bluegoal(this); // I blame Revenant
710 spawnfunc(ball_bluegoal)
712 spawnfunc_nexball_redgoal(this); // but he didn't mean to cause trouble :p
714 spawnfunc(ball_fault)
716 spawnfunc_nexball_fault(this);
718 spawnfunc(ball_bound)
720 spawnfunc_nexball_out(this);
723 bool ball_customize(entity this, entity client)
727 this.effects &= ~EF_FLAME;
729 setcefc(this, func_null);
733 if(client == this.owner)
735 this.scale = autocvar_g_nexball_viewmodel_scale;
737 this.effects |= EF_FLAME;
739 this.effects &= ~EF_FLAME;
743 this.effects &= ~EF_FLAME;
750 void nb_DropBall(entity player)
752 if(player.ballcarried && g_nexball)
753 DropBall(player.ballcarried, player.origin, player.velocity);
756 MUTATOR_HOOKFUNCTION(nb, ClientDisconnect)
758 entity player = M_ARGV(0, entity);
763 MUTATOR_HOOKFUNCTION(nb, PlayerDies)
765 entity frag_target = M_ARGV(2, entity);
767 nb_DropBall(frag_target);
770 MUTATOR_HOOKFUNCTION(nb, MakePlayerObserver)
772 entity player = M_ARGV(0, entity);
778 MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
780 entity player = M_ARGV(0, entity);
782 makevectors(player.v_angle);
783 if(nexball_mode & NBM_BASKETBALL)
785 if(player.ballcarried)
788 player.ballcarried.velocity = player.velocity;
789 setcefc(player.ballcarried, ball_customize);
791 vector org = player.origin + player.view_ofs +
792 v_forward * autocvar_g_nexball_viewmodel_offset.x +
793 v_right * autocvar_g_nexball_viewmodel_offset.y +
794 v_up * autocvar_g_nexball_viewmodel_offset.z;
795 setorigin(player.ballcarried, org);
798 if(autocvar_g_nexball_safepass_maxdist)
800 if(player.ballcarried.wait < time && player.ballcarried.enemy)
802 //centerprint(player, sprintf("Lost lock on %s", player.ballcarried.enemy.netname));
803 player.ballcarried.enemy = NULL;
807 //tracebox(player.origin + player.view_ofs, '-2 -2 -2', '2 2 2', player.origin + player.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
808 crosshair_trace(player);
810 IS_CLIENT(trace_ent) &&
811 !IS_DEAD(trace_ent) &&
812 trace_ent.team == player.team &&
813 vdist(trace_ent.origin - player.origin, <=, autocvar_g_nexball_safepass_maxdist) )
816 //if(player.ballcarried.enemy != trace_ent)
817 // centerprint(player, sprintf("Locked to %s", trace_ent.netname));
818 player.ballcarried.enemy = trace_ent;
819 player.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
827 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
829 .entity weaponentity = weaponentities[slot];
831 if(STAT(WEAPONS, player.(weaponentity)))
833 STAT(WEAPONS, player) = STAT(WEAPONS, player.(weaponentity));
834 Weapon w = WEP_NEXBALL;
835 w.wr_resetplayer(w, player);
836 player.(weaponentity).m_switchweapon = player.m_switchweapon;
837 W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
839 STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
846 nexball_setstatus(player);
849 MUTATOR_HOOKFUNCTION(nb, SpectateCopy)
851 entity spectatee = M_ARGV(0, entity);
852 entity client = M_ARGV(1, entity);
854 STAT(NB_METERSTART, client) = STAT(NB_METERSTART, spectatee);
857 MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
859 entity player = M_ARGV(0, entity);
861 STAT(NB_METERSTART, player) = 0;
862 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
864 .entity weaponentity = weaponentities[slot];
865 STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
868 if (nexball_mode & NBM_BASKETBALL)
869 STAT(WEAPONS, player) |= WEPSET(NEXBALL);
871 STAT(WEAPONS, player) = '0 0 0';
876 MUTATOR_HOOKFUNCTION(nb, PlayerPhysics_UpdateStats)
878 entity player = M_ARGV(0, entity);
879 // these automatically reset, no need to worry
881 if(player.ballcarried)
882 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nexball_basketball_carrier_highspeed;
885 MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
887 //entity player = M_ARGV(0, entity);
888 entity wepent = M_ARGV(1, entity);
890 return wepent.m_weapon == WEP_NEXBALL;
893 MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
895 //entity player = M_ARGV(0, entity);
896 int wep = M_ARGV(1, int);
898 return wep == WEP_MORTAR.m_id; // TODO: what is this for?
901 MUTATOR_HOOKFUNCTION(nb, FilterItem)
903 entity item = M_ARGV(0, entity);
905 if(Item_IsLoot(item))
906 if(item.weapon == WEP_NEXBALL.m_id)
912 MUTATOR_HOOKFUNCTION(nb, ItemTouch)
914 entity item = M_ARGV(0, entity);
915 entity toucher = M_ARGV(1, entity);
917 if(item.weapon && toucher.ballcarried)
918 return MUT_ITEMTOUCH_RETURN; // no new weapons for you, mister!
920 return MUT_ITEMTOUCH_CONTINUE;
923 MUTATOR_HOOKFUNCTION(nb, TeamBalance_CheckAllowedTeams)
925 M_ARGV(1, string) = "nexball_team";
929 MUTATOR_HOOKFUNCTION(nb, WantWeapon)
931 M_ARGV(1, float) = 0; // weapon is set a few lines later, apparently
935 MUTATOR_HOOKFUNCTION(nb, DropSpecialItems)
937 entity frag_target = M_ARGV(0, entity);
939 if(frag_target.ballcarried)
940 DropBall(frag_target.ballcarried, frag_target.origin, frag_target.velocity);
945 MUTATOR_HOOKFUNCTION(nb, SendWaypoint)
947 M_ARGV(2, int) &= ~0x80;
950 REGISTER_MUTATOR(nb, g_nexball)
955 g_nexball_meter_period = autocvar_g_nexball_meter_period;
956 if(g_nexball_meter_period <= 0)
957 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
958 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
962 CVTOV(g_nexball_football_boost_forward); //100
963 CVTOV(g_nexball_football_boost_up); //200
964 CVTOV(g_nexball_delay_idle); //10
965 CVTOV(g_nexball_football_physics); //0
967 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
969 InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE);
970 WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
972 GameRules_teams(true);
973 GameRules_limit_score(autocvar_g_nexball_goallimit);
974 GameRules_limit_lead(autocvar_g_nexball_goalleadlimit);
977 MUTATOR_ONROLLBACK_OR_REMOVE
979 WEP_NEXBALL.spawnflags |= WEP_FLAG_MUTATORBLOCKED;