1 #include "sv_nexball.qh"
5 int autocvar_g_nexball_goalleadlimit;
6 #define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
8 bool autocvar_g_nexball_basketball_jumppad = true;
9 float autocvar_g_nexball_basketball_bouncefactor;
10 float autocvar_g_nexball_basketball_bouncestop;
11 float autocvar_g_nexball_basketball_carrier_highspeed;
12 bool autocvar_g_nexball_basketball_meter;
13 float autocvar_g_nexball_basketball_meter_maxpower;
14 float autocvar_g_nexball_basketball_meter_minpower;
15 float autocvar_g_nexball_delay_collect;
16 float autocvar_g_nexball_delay_goal;
17 float autocvar_g_nexball_delay_start;
18 bool autocvar_g_nexball_football_jumppad = true;
19 float autocvar_g_nexball_football_bouncefactor;
20 float autocvar_g_nexball_football_bouncestop;
21 bool autocvar_g_nexball_radar_showallplayers;
22 bool autocvar_g_nexball_sound_bounce;
23 int autocvar_g_nexball_trail_color;
24 bool autocvar_g_nexball_playerclip_collisions = true;
26 float autocvar_g_nexball_safepass_turnrate;
27 float autocvar_g_nexball_safepass_maxdist;
28 float autocvar_g_nexball_safepass_holdtime;
29 float autocvar_g_nexball_viewmodel_scale;
30 float autocvar_g_nexball_tackling;
31 vector autocvar_g_nexball_viewmodel_offset;
33 float autocvar_g_balance_nexball_primary_animtime;
34 float autocvar_g_balance_nexball_primary_refire;
35 float autocvar_g_balance_nexball_primary_speed;
36 float autocvar_g_balance_nexball_secondary_animtime;
37 float autocvar_g_balance_nexball_secondary_force;
38 float autocvar_g_balance_nexball_secondary_lifetime;
39 float autocvar_g_balance_nexball_secondary_refire;
40 float autocvar_g_balance_nexball_secondary_speed;
42 void basketball_touch(entity this, entity toucher);
43 void football_touch(entity this, entity toucher);
44 void ResetBall(entity this);
45 const int NBM_NONE = 0;
46 const int NBM_FOOTBALL = 2;
47 const int NBM_BASKETBALL = 4;
50 float OtherTeam(float t) //works only if there are two teams on the map!
53 e = find(NULL, classname, "nexball_team");
55 e = find(e, classname, "nexball_team");
59 const int ST_NEXBALL_GOALS = 1;
60 void nb_ScoreRules(int teams)
62 GameRules_scoring(teams, 0, 0, {
63 field_team(ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
64 field(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
65 field(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
69 void LogNB(string mode, entity actor)
72 if(!autocvar_sv_eventlog)
74 s = strcat(":nexball:", mode);
76 s = strcat(s, ":", ftos(actor.playerid));
80 void ball_restart(entity this)
83 DropBall(this, this.owner.origin, '0 0 0');
87 void nexball_setstatus(entity this)
89 this.items &= ~IT_KEY1;
92 if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
94 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_NEXBALL_RETURN_HELD));
95 entity e = this.ballcarried;
96 DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
100 this.items |= IT_KEY1;
104 void relocate_nexball(entity this)
106 tracebox(this.origin, BALL_MINS, BALL_MAXS, this.origin, true, this);
109 vector o = this.origin;
110 if (!move_out_of_solid(this)) {
111 objerror(this, "could not get out of solid at all!");
114 "^1NOTE: this map needs FIXING. %s at %s needs to be moved out of solid, e.g. by %s",
117 vtos(this.origin - o)
123 void DropOwner(entity this)
127 DropBall(this, ownr.origin, ownr.velocity);
128 makevectors(ownr.v_angle.y * '0 1 0');
129 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
130 UNSET_ONGROUND(ownr);
133 void GiveBall(entity plyr, entity ball)
135 .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
136 entity ownr = ball.owner;
139 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
140 ownr.ballcarried = NULL;
141 GameRules_scoring_vip(ownr, false);
142 if(STAT(NB_METERSTART, ownr))
144 STAT(NB_METERSTART, ownr) = 0;
145 ownr.(weaponentity).state = WS_READY;
147 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
151 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
154 //setattachment(ball, plyr, "");
155 setorigin(ball, plyr.origin + plyr.view_ofs);
157 if(ball.team != plyr.team)
158 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
160 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
161 ball.weaponentity_fld = weaponentity;
162 ball.team = plyr.team;
163 plyr.ballcarried = ball;
164 GameRules_scoring_vip(plyr, true);
165 ball.nb_dropper = plyr;
167 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
168 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
170 ball.velocity = '0 0 0';
171 set_movetype(ball, MOVETYPE_NONE);
172 settouch(ball, func_null);
173 ball.effects |= EF_NOSHADOW;
174 ball.scale = 1; // scale down.
176 WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
177 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
179 if(autocvar_g_nexball_basketball_delay_hold)
181 setthink(ball, DropOwner);
182 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
185 STAT(WEAPONS, plyr.(weaponentity)) = STAT(WEAPONS, plyr);
186 plyr.m_switchweapon = plyr.(weaponentity).m_weapon;
187 STAT(WEAPONS, plyr) = WEPSET(NEXBALL);
188 Weapon w = WEP_NEXBALL;
189 w.wr_resetplayer(w, plyr);
190 plyr.(weaponentity).m_switchweapon = WEP_NEXBALL;
191 W_SwitchWeapon(plyr, WEP_NEXBALL, weaponentity);
194 void DropBall(entity ball, vector org, vector vel)
196 ball.effects |= autocvar_g_nexball_basketball_effects_default;
197 ball.effects &= ~EF_NOSHADOW;
198 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
200 setattachment(ball, NULL, "");
201 setorigin(ball, org);
202 set_movetype(ball, MOVETYPE_BOUNCE);
203 UNSET_ONGROUND(ball);
204 ball.scale = ball_scale;
206 ball.nb_droptime = time;
207 settouch(ball, basketball_touch);
208 setthink(ball, ResetBall);
209 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
211 if(STAT(NB_METERSTART, ball.owner))
213 STAT(NB_METERSTART, ball.owner) = 0;
214 .entity weaponentity = ball.weaponentity_fld;
215 ball.owner.(weaponentity).state = WS_READY;
218 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
219 WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
220 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
222 entity e = ball.owner; ball.owner = NULL;
223 e.ballcarried = NULL;
224 GameRules_scoring_vip(e, false);
227 void InitBall(entity this)
229 if(game_stopped) return;
230 UNSET_ONGROUND(this);
231 set_movetype(this, MOVETYPE_BOUNCE);
232 if(this.classname == "nexball_basketball")
233 settouch(this, basketball_touch);
234 else if(this.classname == "nexball_football")
235 settouch(this, football_touch);
237 setthink(this, ResetBall);
238 this.nextthink = time + autocvar_g_nexball_delay_idle + 3;
242 _sound(this, CH_TRIGGER, this.noise1, VOL_BASE, ATTEN_NORM);
243 WaypointSprite_Ping(this.waypointsprite_attachedforcarrier);
247 void ResetBall(entity this)
249 if(this.cnt < 2) // step 1
251 if(time == this.teamtime)
252 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_NEXBALL_RETURN_HELD));
254 settouch(this, func_null);
255 set_movetype(this, MOVETYPE_NOCLIP);
256 this.velocity = '0 0 0'; // just in case?
258 LogNB("resetidle", NULL);
260 this.nextthink = time;
262 else if(this.cnt < 4) // step 2 and 3
264 // dprint("Step ", ftos(this.cnt), ": Calculated velocity: ", vtos(this.spawnorigin - this.origin), ", time: ", ftos(time), "\n");
265 this.velocity = (this.spawnorigin - this.origin) * (this.cnt - 1); // 1 or 0.5 second movement
266 this.nextthink = time + 0.5;
271 // dprint("Step 4: time: ", ftos(time), "\n");
272 if(vdist(this.origin - this.spawnorigin, >, 10)) // should not happen anymore
273 LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
274 vtos(this.origin - this.spawnorigin), " Velocity: ", vtos(this.velocity), "\n");
275 this.velocity = '0 0 0';
276 setorigin(this, this.spawnorigin); // make sure it's positioned correctly anyway
277 set_movetype(this, MOVETYPE_NONE);
278 setthink(this, InitBall);
279 this.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
283 void football_touch(entity this, entity toucher)
285 if(toucher.solid == SOLID_BSP)
287 if(time > this.lastground + 0.1)
289 _sound(this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
290 this.lastground = time;
292 if(this.velocity && !this.cnt)
293 this.nextthink = time + autocvar_g_nexball_delay_idle;
296 if (!IS_PLAYER(toucher) && !IS_VEHICLE(toucher))
298 if(GetResource(toucher, RES_HEALTH) < 1)
301 this.nextthink = time + autocvar_g_nexball_delay_idle;
303 this.pusher = toucher;
304 this.team = toucher.team;
306 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
309 this.velocity = toucher.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
311 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
313 makevectors(toucher.v_angle);
314 this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
316 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
318 makevectors(toucher.v_angle.y * '0 1 0');
319 this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
321 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
323 makevectors(toucher.v_angle);
324 this.velocity = toucher.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
326 this.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
329 void basketball_touch(entity this, entity toucher)
331 if(toucher.ballcarried)
333 football_touch(this, toucher);
336 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))
338 if(GetResource(toucher, RES_HEALTH) < 1)
340 LogNB("caught", toucher);
341 GiveBall(toucher, this);
343 else if(toucher.solid == SOLID_BSP)
345 _sound(this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
346 if(this.velocity && !this.cnt)
347 this.nextthink = min(time + autocvar_g_nexball_delay_idle, this.teamtime);
351 void GoalTouch(entity this, entity toucher)
354 float isclient, pscore, otherteam;
357 if(game_stopped) return;
358 if((this.spawnflags & GOAL_TOUCHPLAYER) && toucher.ballcarried)
359 ball = toucher.ballcarried;
362 if(ball.classname != "nexball_basketball")
363 if(ball.classname != "nexball_football")
365 if((!ball.pusher && this.team != GOAL_OUT) || ball.cnt)
367 EXACTTRIGGER_TOUCH(this, toucher);
370 if(NumTeams(nb_teams) == 2)
371 otherteam = OtherTeam(ball.team);
375 if((isclient = IS_CLIENT(ball.pusher)))
376 pname = ball.pusher.netname;
378 pname = "Someone (?)";
380 if(ball.team == this.team) //owngoal (regular goals)
382 LogNB("owngoal", ball.pusher);
383 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
386 else if(this.team == GOAL_FAULT)
388 LogNB("fault", ball.pusher);
389 if(NumTeams(nb_teams) == 2)
390 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
392 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
395 else if(this.team == GOAL_OUT)
397 LogNB("out", ball.pusher);
398 if((this.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
399 bprint(pname, "^7 went out of bounds.\n");
401 bprint("The ball was returned.\n");
406 LogNB(strcat("goal:", ftos(this.team)), ball.pusher);
407 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
411 _sound(ball, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NONE);
413 if(ball.team && pscore)
415 if(NumTeams(nb_teams) == 2 && pscore < 0)
416 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
418 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
423 GameRules_scoring_add(ball.pusher, NEXBALL_GOALS, pscore);
425 GameRules_scoring_add(ball.pusher, NEXBALL_FAULTS, -pscore);
428 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
429 DropBall(ball, ball.owner.origin, ball.owner.velocity);
431 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
434 setthink(ball, ResetBall);
435 if(ball.classname == "nexball_basketball")
436 settouch(ball, football_touch); // better than func_null: football control until the ball gets reset
437 ball.nextthink = time + autocvar_g_nexball_delay_goal * (this.team != GOAL_OUT);
440 //=======================//
442 //=======================//
443 spawnfunc(nexball_team)
450 this.team = this.cnt + 1;
453 void nb_spawnteam(string teamname, float teamcolor)
455 LOG_TRACE("^2spawned team ", teamname);
456 entity e = new(nexball_team);
457 e.netname = teamname;
465 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
467 for(e = NULL; (e = find(e, classname, "nexball_goal"));)
474 nb_spawnteam("Red", e.team-1) ;
482 nb_spawnteam("Blue", e.team-1) ;
490 nb_spawnteam("Yellow", e.team-1);
498 nb_spawnteam("Pink", e.team-1) ;
507 void nb_delayedinit(entity this)
509 if(find(NULL, classname, "nexball_team") == NULL)
511 nb_ScoreRules(nb_teams);
515 //=======================//
517 //=======================//
519 void SpawnBall(entity this)
521 if(!g_nexball) { delete(this); return; }
523 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
527 this.model = "models/nexball/ball.md3";
531 precache_model(this.model);
532 _setmodel(this, this.model);
533 setsize(this, BALL_MINS, BALL_MAXS);
534 ball_scale = this.scale;
536 relocate_nexball(this);
537 this.spawnorigin = this.origin;
539 this.effects = this.effects | EF_LOWPRECISION;
541 if(cvar(strcat("g_", this.classname, "_trail"))) //nexball_basketball :p
543 this.glow_color = autocvar_g_nexball_trail_color;
544 this.glow_trail = true;
547 set_movetype(this, MOVETYPE_FLY);
549 if(autocvar_g_nexball_playerclip_collisions)
550 this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP;
552 if(!autocvar_g_nexball_sound_bounce)
554 else if(this.noise == "")
555 this.noise = strzone(SND(NB_BOUNCE));
556 //bounce sound placeholder (FIXME)
557 if(this.noise1 == "")
558 this.noise1 = strzone(SND(NB_DROP));
559 //ball drop sound placeholder (FIXME)
560 if(this.noise2 == "")
561 this.noise2 = strzone(SND(NB_STEAL));
562 //stealing sound placeholder (FIXME)
563 if(this.noise) precache_sound(this.noise);
564 precache_sound(this.noise1);
565 precache_sound(this.noise2);
567 WaypointSprite_AttachCarrier(WP_NbBall, this, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
569 this.reset = ball_restart;
570 setthink(this, InitBall);
571 this.nextthink = game_starttime + autocvar_g_nexball_delay_start;
574 spawnfunc(nexball_basketball)
576 nexball_mode |= NBM_BASKETBALL;
577 this.classname = "nexball_basketball";
578 if (!(balls & BALL_BASKET))
581 CVTOV(g_nexball_basketball_effects_default);
582 CVTOV(g_nexball_basketball_delay_hold);
583 CVTOV(g_nexball_basketball_delay_hold_forteam);
584 CVTOV(g_nexball_basketball_teamsteal);
586 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
589 this.effects = autocvar_g_nexball_basketball_effects_default;
590 this.solid = SOLID_TRIGGER;
591 this.pushable = autocvar_g_nexball_basketball_jumppad;
592 balls |= BALL_BASKET;
593 this.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
594 this.bouncestop = autocvar_g_nexball_basketball_bouncestop;
598 spawnfunc(nexball_football)
600 nexball_mode |= NBM_FOOTBALL;
601 this.classname = "nexball_football";
602 this.solid = SOLID_TRIGGER;
604 this.pushable = autocvar_g_nexball_football_jumppad;
605 this.bouncefactor = autocvar_g_nexball_football_bouncefactor;
606 this.bouncestop = autocvar_g_nexball_football_bouncestop;
610 bool nb_Goal_Customize(entity this, entity client)
612 entity e = WaypointSprite_getviewentity(client);
613 entity wp_owner = this.owner;
614 if(SAME_TEAM(e, wp_owner)) { return false; }
619 void SpawnGoal(entity this)
621 if(!g_nexball) { delete(this); return; }
625 if(this.team != GOAL_OUT && Team_IsValidTeam(this.team))
627 entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (this.absmin + this.absmax) * 0.5, this, sprite, RADARICON_NONE);
628 wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0.5 0');
629 setcefc(this.sprite, nb_Goal_Customize);
632 this.classname = "nexball_goal";
634 this.noise = "ctf/respawn.wav";
635 precache_sound(this.noise);
636 settouch(this, GoalTouch);
639 spawnfunc(nexball_redgoal)
641 this.team = NUM_TEAM_1;
644 spawnfunc(nexball_bluegoal)
646 this.team = NUM_TEAM_2;
649 spawnfunc(nexball_yellowgoal)
651 this.team = NUM_TEAM_3;
654 spawnfunc(nexball_pinkgoal)
656 this.team = NUM_TEAM_4;
660 spawnfunc(nexball_fault)
662 this.team = GOAL_FAULT;
664 this.noise = strzone(SND(TYPEHIT));
668 spawnfunc(nexball_out)
670 this.team = GOAL_OUT;
672 this.noise = strzone(SND(TYPEHIT));
677 //Spawnfuncs preserved for compatibility
682 spawnfunc_nexball_football(this);
684 spawnfunc(ball_football)
686 spawnfunc_nexball_football(this);
688 spawnfunc(ball_basketball)
690 spawnfunc_nexball_basketball(this);
692 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
693 spawnfunc(ball_redgoal)
695 spawnfunc_nexball_bluegoal(this); // I blame Revenant
697 spawnfunc(ball_bluegoal)
699 spawnfunc_nexball_redgoal(this); // but he didn't mean to cause trouble :p
701 spawnfunc(ball_fault)
703 spawnfunc_nexball_fault(this);
705 spawnfunc(ball_bound)
707 spawnfunc_nexball_out(this);
710 bool ball_customize(entity this, entity client)
714 this.effects &= ~EF_FLAME;
716 setcefc(this, func_null);
720 if(client == this.owner)
722 this.scale = autocvar_g_nexball_viewmodel_scale;
724 this.effects |= EF_FLAME;
726 this.effects &= ~EF_FLAME;
730 this.effects &= ~EF_FLAME;
737 void nb_DropBall(entity player)
739 if(player.ballcarried && g_nexball)
740 DropBall(player.ballcarried, player.origin, player.velocity);
743 MUTATOR_HOOKFUNCTION(nb, ClientDisconnect)
745 entity player = M_ARGV(0, entity);
750 MUTATOR_HOOKFUNCTION(nb, PlayerDies)
752 entity frag_target = M_ARGV(2, entity);
754 nb_DropBall(frag_target);
757 MUTATOR_HOOKFUNCTION(nb, MakePlayerObserver)
759 entity player = M_ARGV(0, entity);
765 MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
767 entity player = M_ARGV(0, entity);
769 makevectors(player.v_angle);
770 if(nexball_mode & NBM_BASKETBALL)
772 if(player.ballcarried)
775 player.ballcarried.velocity = player.velocity;
776 setcefc(player.ballcarried, ball_customize);
778 vector org = player.origin + player.view_ofs +
779 v_forward * autocvar_g_nexball_viewmodel_offset.x +
780 v_right * autocvar_g_nexball_viewmodel_offset.y +
781 v_up * autocvar_g_nexball_viewmodel_offset.z;
782 setorigin(player.ballcarried, org);
785 if(autocvar_g_nexball_safepass_maxdist)
787 if(player.ballcarried.wait < time && player.ballcarried.enemy)
789 //centerprint(player, sprintf("Lost lock on %s", player.ballcarried.enemy.netname));
790 player.ballcarried.enemy = NULL;
794 //tracebox(player.origin + player.view_ofs, '-2 -2 -2', '2 2 2', player.origin + player.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
795 crosshair_trace(player);
797 IS_CLIENT(trace_ent) &&
798 !IS_DEAD(trace_ent) &&
799 trace_ent.team == player.team &&
800 vdist(trace_ent.origin - player.origin, <=, autocvar_g_nexball_safepass_maxdist) )
803 //if(player.ballcarried.enemy != trace_ent)
804 // centerprint(player, sprintf("Locked to %s", trace_ent.netname));
805 player.ballcarried.enemy = trace_ent;
806 player.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
814 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
816 .entity weaponentity = weaponentities[slot];
818 if(STAT(WEAPONS, player.(weaponentity)))
820 STAT(WEAPONS, player) = STAT(WEAPONS, player.(weaponentity));
821 Weapon w = WEP_NEXBALL;
822 w.wr_resetplayer(w, player);
823 player.(weaponentity).m_switchweapon = player.m_switchweapon;
824 W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
826 STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
833 nexball_setstatus(player);
836 MUTATOR_HOOKFUNCTION(nb, SpectateCopy)
838 entity spectatee = M_ARGV(0, entity);
839 entity client = M_ARGV(1, entity);
841 STAT(NB_METERSTART, client) = STAT(NB_METERSTART, spectatee);
844 MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
846 entity player = M_ARGV(0, entity);
848 STAT(NB_METERSTART, player) = 0;
849 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
851 .entity weaponentity = weaponentities[slot];
852 STAT(WEAPONS, player.(weaponentity)) = '0 0 0';
855 if (nexball_mode & NBM_BASKETBALL)
856 STAT(WEAPONS, player) |= WEPSET(NEXBALL);
858 STAT(WEAPONS, player) = '0 0 0';
863 MUTATOR_HOOKFUNCTION(nb, PlayerPhysics_UpdateStats)
865 entity player = M_ARGV(0, entity);
866 // these automatically reset, no need to worry
868 if(player.ballcarried)
869 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nexball_basketball_carrier_highspeed;
872 MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
874 //entity player = M_ARGV(0, entity);
875 entity wepent = M_ARGV(1, entity);
877 return wepent.m_weapon == WEP_NEXBALL;
880 MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
882 //entity player = M_ARGV(0, entity);
883 int wep = M_ARGV(1, int);
885 return wep == WEP_MORTAR.m_id; // TODO: what is this for?
888 MUTATOR_HOOKFUNCTION(nb, FilterItem)
890 entity item = M_ARGV(0, entity);
892 if(Item_IsLoot(item))
893 if(item.weapon == WEP_NEXBALL.m_id)
899 MUTATOR_HOOKFUNCTION(nb, ItemTouch)
901 entity item = M_ARGV(0, entity);
902 entity toucher = M_ARGV(1, entity);
904 if(item.weapon && toucher.ballcarried)
905 return MUT_ITEMTOUCH_RETURN; // no new weapons for you, mister!
907 return MUT_ITEMTOUCH_CONTINUE;
910 MUTATOR_HOOKFUNCTION(nb, TeamBalance_CheckAllowedTeams)
912 M_ARGV(1, string) = "nexball_team";
916 MUTATOR_HOOKFUNCTION(nb, WantWeapon)
918 M_ARGV(1, float) = 0; // weapon is set a few lines later, apparently
922 MUTATOR_HOOKFUNCTION(nb, DropSpecialItems)
924 entity frag_target = M_ARGV(0, entity);
926 if(frag_target.ballcarried)
927 DropBall(frag_target.ballcarried, frag_target.origin, frag_target.velocity);
932 MUTATOR_HOOKFUNCTION(nb, SendWaypoint)
934 M_ARGV(2, int) &= ~0x80;
937 REGISTER_MUTATOR(nb, false)
942 g_nexball_meter_period = autocvar_g_nexball_meter_period;
943 if(g_nexball_meter_period <= 0)
944 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
945 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
949 CVTOV(g_nexball_football_boost_forward); //100
950 CVTOV(g_nexball_football_boost_up); //200
951 CVTOV(g_nexball_delay_idle); //10
952 CVTOV(g_nexball_football_physics); //0
954 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
956 InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE);
957 WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
959 GameRules_teams(true);
960 GameRules_limit_score(autocvar_g_nexball_goallimit);
961 GameRules_limit_lead(autocvar_g_nexball_goalleadlimit);
964 MUTATOR_ONROLLBACK_OR_REMOVE
966 WEP_NEXBALL.spawnflags |= WEP_FLAG_MUTATORBLOCKED;