5 int autocvar_g_nexball_goalleadlimit;
6 #define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
8 float autocvar_g_nexball_basketball_bouncefactor;
9 float autocvar_g_nexball_basketball_bouncestop;
10 float autocvar_g_nexball_basketball_carrier_highspeed;
11 bool autocvar_g_nexball_basketball_meter;
12 float autocvar_g_nexball_basketball_meter_maxpower;
13 float autocvar_g_nexball_basketball_meter_minpower;
14 float autocvar_g_nexball_delay_collect;
15 float autocvar_g_nexball_delay_goal;
16 float autocvar_g_nexball_delay_start;
17 float autocvar_g_nexball_football_bouncefactor;
18 float autocvar_g_nexball_football_bouncestop;
19 bool autocvar_g_nexball_radar_showallplayers;
20 bool autocvar_g_nexball_sound_bounce;
21 int autocvar_g_nexball_trail_color;
23 float autocvar_g_nexball_safepass_turnrate;
24 float autocvar_g_nexball_safepass_maxdist;
25 float autocvar_g_nexball_safepass_holdtime;
26 float autocvar_g_nexball_viewmodel_scale;
27 float autocvar_g_nexball_tackling;
28 vector autocvar_g_nexball_viewmodel_offset;
30 float autocvar_g_balance_nexball_primary_animtime;
31 float autocvar_g_balance_nexball_primary_refire;
32 float autocvar_g_balance_nexball_primary_speed;
33 float autocvar_g_balance_nexball_secondary_animtime;
34 float autocvar_g_balance_nexball_secondary_force;
35 float autocvar_g_balance_nexball_secondary_lifetime;
36 float autocvar_g_balance_nexball_secondary_refire;
37 float autocvar_g_balance_nexball_secondary_speed;
39 void basketball_touch();
40 void football_touch();
42 const int NBM_NONE = 0;
43 const int NBM_FOOTBALL = 2;
44 const int NBM_BASKETBALL = 4;
47 float OtherTeam(float t) //works only if there are two teams on the map!
50 e = find(world, classname, "nexball_team");
52 e = find(e, classname, "nexball_team");
56 const float ST_NEXBALL_GOALS = 1;
57 const float SP_NEXBALL_GOALS = 4;
58 const float SP_NEXBALL_FAULTS = 5;
59 void nb_ScoreRules(float teams)
61 ScoreRules_basics(teams, 0, 0, true);
62 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
63 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
64 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
65 ScoreRules_basics_end();
68 void LogNB(string mode, entity actor)
71 if(!autocvar_sv_eventlog)
73 s = strcat(":nexball:", mode);
75 s = strcat(s, ":", ftos(actor.playerid));
79 void ball_restart(void)
82 DropBall(self, self.owner.origin, '0 0 0');
86 void nexball_setstatus(void)
88 self.items &= ~IT_KEY1;
91 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
93 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
94 setself(self.ballcarried);
95 DropBall(self, self.owner.origin, '0 0 0');
100 self.items |= IT_KEY1;
104 void relocate_nexball(void)
106 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
111 if(!move_out_of_solid(self))
112 objerror("could not get out of solid at all!");
113 LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
114 LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
115 LOG_INFO(" ", ftos(self.origin.y - o.y));
116 LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
125 DropBall(self, ownr.origin, ownr.velocity);
126 makevectors(ownr.v_angle.y * '0 1 0');
127 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
128 ownr.flags &= ~FL_ONGROUND;
131 void GiveBall(entity plyr, entity ball)
135 if((ownr = ball.owner))
137 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
138 ownr.ballcarried = world;
142 ownr.weaponentity.state = WS_READY;
144 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
148 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
151 //setattachment(ball, plyr, "");
152 setorigin(ball, plyr.origin + plyr.view_ofs);
154 if(ball.team != plyr.team)
155 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
157 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
158 ball.team = plyr.team;
159 plyr.ballcarried = ball;
160 ball.nb_dropper = plyr;
162 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
163 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
165 ball.velocity = '0 0 0';
166 ball.movetype = MOVETYPE_NONE;
167 ball.touch = func_null;
168 ball.effects |= EF_NOSHADOW;
169 ball.scale = 1; // scale down.
171 WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
172 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
174 if(autocvar_g_nexball_basketball_delay_hold)
176 ball.think = DropOwner;
177 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
180 plyr.weaponentity.weapons = plyr.weapons;
181 plyr.weaponentity.switchweapon = plyr.weapon;
182 plyr.weapons = WEPSET(NEXBALL);
184 Weapon w = WEP_NEXBALL;
186 plyr.switchweapon = WEP_NEXBALL.m_id;
187 W_SwitchWeapon(WEP_NEXBALL.m_id);
191 void DropBall(entity ball, vector org, vector vel)
193 ball.effects |= autocvar_g_nexball_basketball_effects_default;
194 ball.effects &= ~EF_NOSHADOW;
195 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
197 setattachment(ball, world, "");
198 setorigin(ball, org);
199 ball.movetype = MOVETYPE_BOUNCE;
200 ball.flags &= ~FL_ONGROUND;
201 ball.scale = ball_scale;
203 ball.nb_droptime = time;
204 ball.touch = basketball_touch;
205 ball.think = ResetBall;
206 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
208 if(ball.owner.metertime)
210 ball.owner.metertime = 0;
211 ball.owner.weaponentity.state = WS_READY;
214 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
215 WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
216 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
218 ball.owner.ballcarried = world;
225 self.flags &= ~FL_ONGROUND;
226 self.movetype = MOVETYPE_BOUNCE;
227 if(self.classname == "nexball_basketball")
228 self.touch = basketball_touch;
229 else if(self.classname == "nexball_football")
230 self.touch = football_touch;
232 self.think = ResetBall;
233 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
237 _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
238 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
239 LogNB("init", world);
244 if(self.cnt < 2) // step 1
246 if(time == self.teamtime)
247 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
249 self.touch = func_null;
250 self.movetype = MOVETYPE_NOCLIP;
251 self.velocity = '0 0 0'; // just in case?
253 LogNB("resetidle", world);
255 self.nextthink = time;
257 else if(self.cnt < 4) // step 2 and 3
259 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
260 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
261 self.nextthink = time + 0.5;
266 // dprint("Step 4: time: ", ftos(time), "\n");
267 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
268 LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
269 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
270 self.velocity = '0 0 0';
271 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
272 self.movetype = MOVETYPE_NONE;
273 self.think = InitBall;
274 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
278 void football_touch(void)
280 if(other.solid == SOLID_BSP)
282 if(time > self.lastground + 0.1)
284 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
285 self.lastground = time;
287 if(vlen(self.velocity) && !self.cnt)
288 self.nextthink = time + autocvar_g_nexball_delay_idle;
291 if (!IS_PLAYER(other))
296 self.nextthink = time + autocvar_g_nexball_delay_idle;
299 self.team = other.team;
301 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
303 if(vlen(other.velocity))
304 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
306 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
308 makevectors(other.v_angle);
309 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
311 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
313 makevectors(other.v_angle.y * '0 1 0');
314 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
316 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
318 makevectors(other.v_angle);
319 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
321 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
324 void basketball_touch(void)
326 if(other.ballcarried)
331 if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
333 if(other.health <= 0)
335 LogNB("caught", other);
336 GiveBall(other, self);
338 else if(other.solid == SOLID_BSP)
340 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
341 if(vlen(self.velocity) && !self.cnt)
342 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
349 float isclient, pscore, otherteam;
353 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
354 ball = other.ballcarried;
357 if(ball.classname != "nexball_basketball")
358 if(ball.classname != "nexball_football")
360 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
366 otherteam = OtherTeam(ball.team);
370 if((isclient = IS_CLIENT(ball.pusher)))
371 pname = ball.pusher.netname;
373 pname = "Someone (?)";
375 if(ball.team == self.team) //owngoal (regular goals)
377 LogNB("owngoal", ball.pusher);
378 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
381 else if(self.team == GOAL_FAULT)
383 LogNB("fault", ball.pusher);
385 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
387 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
390 else if(self.team == GOAL_OUT)
392 LogNB("out", ball.pusher);
393 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
394 bprint(pname, "^7 went out of bounds.\n");
396 bprint("The ball was returned.\n");
401 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
402 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
406 _sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
408 if(ball.team && pscore)
410 if(nb_teams == 2 && pscore < 0)
411 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
413 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
418 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
420 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
423 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
424 DropBall(ball, ball.owner.origin, ball.owner.velocity);
426 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
429 ball.think = ResetBall;
430 if(ball.classname == "nexball_basketball")
431 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
432 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
435 //=======================//
437 //=======================//
438 spawnfunc(nexball_team)
445 self.team = self.cnt + 1;
448 void nb_spawnteam(string teamname, float teamcolor)
450 LOG_TRACE("^2spawned team ", teamname, "\n");
453 e.classname = "nexball_team";
454 e.netname = teamname;
460 void nb_spawnteams(void)
462 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
464 for(e = world; (e = find(e, classname, "nexball_goal"));)
471 nb_spawnteam("Red", e.team-1) ;
478 nb_spawnteam("Blue", e.team-1) ;
485 nb_spawnteam("Yellow", e.team-1);
492 nb_spawnteam("Pink", e.team-1) ;
500 void nb_delayedinit(void)
502 if(find(world, classname, "nexball_team") == world)
504 nb_ScoreRules(nb_teams);
508 //=======================//
510 //=======================//
514 if(!g_nexball) { remove(self); return; }
516 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
520 self.model = "models/nexball/ball.md3";
524 precache_model(self.model);
525 _setmodel(self, self.model);
526 setsize(self, BALL_MINS, BALL_MAXS);
527 ball_scale = self.scale;
530 self.spawnorigin = self.origin;
532 self.effects = self.effects | EF_LOWPRECISION;
534 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
536 self.glow_color = autocvar_g_nexball_trail_color;
537 self.glow_trail = true;
540 self.movetype = MOVETYPE_FLY;
542 if(!autocvar_g_nexball_sound_bounce)
544 else if(self.noise == "")
545 self.noise = SND(NB_BOUNCE);
546 //bounce sound placeholder (FIXME)
547 if(self.noise1 == "")
548 self.noise1 = SND(NB_DROP);
549 //ball drop sound placeholder (FIXME)
550 if(self.noise2 == "")
551 self.noise2 = SND(NB_STEAL);
552 //stealing sound placeholder (FIXME)
553 if(self.noise) precache_sound(self.noise);
554 precache_sound(self.noise1);
555 precache_sound(self.noise2);
557 WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
559 self.reset = ball_restart;
560 self.think = InitBall;
561 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
564 spawnfunc(nexball_basketball)
566 nexball_mode |= NBM_BASKETBALL;
567 self.classname = "nexball_basketball";
568 if (!(balls & BALL_BASKET))
571 CVTOV(g_nexball_basketball_effects_default);
572 CVTOV(g_nexball_basketball_delay_hold);
573 CVTOV(g_nexball_basketball_delay_hold_forteam);
574 CVTOV(g_nexball_basketball_teamsteal);
576 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
579 self.effects = autocvar_g_nexball_basketball_effects_default;
580 self.solid = SOLID_TRIGGER;
581 balls |= BALL_BASKET;
582 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
583 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
587 spawnfunc(nexball_football)
589 nexball_mode |= NBM_FOOTBALL;
590 self.classname = "nexball_football";
591 self.solid = SOLID_TRIGGER;
593 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
594 self.bouncestop = autocvar_g_nexball_football_bouncestop;
598 float nb_Goal_Customize()
601 e = WaypointSprite_getviewentity(other);
602 wp_owner = self.owner;
603 if(SAME_TEAM(e, wp_owner)) { return false; }
610 if(!g_nexball) { remove(self); return; }
614 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
616 entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
617 wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
618 self.sprite.customizeentityforclient = nb_Goal_Customize;
621 self.classname = "nexball_goal";
623 self.noise = "ctf/respawn.wav";
624 precache_sound(self.noise);
625 self.touch = GoalTouch;
628 spawnfunc(nexball_redgoal)
630 self.team = NUM_TEAM_1;
633 spawnfunc(nexball_bluegoal)
635 self.team = NUM_TEAM_2;
638 spawnfunc(nexball_yellowgoal)
640 self.team = NUM_TEAM_3;
643 spawnfunc(nexball_pinkgoal)
645 self.team = NUM_TEAM_4;
649 spawnfunc(nexball_fault)
651 self.team = GOAL_FAULT;
653 self.noise = SND(TYPEHIT);
657 spawnfunc(nexball_out)
659 self.team = GOAL_OUT;
661 self.noise = SND(TYPEHIT);
666 //Spawnfuncs preserved for compatibility
671 spawnfunc_nexball_football(this);
673 spawnfunc(ball_football)
675 spawnfunc_nexball_football(this);
677 spawnfunc(ball_basketball)
679 spawnfunc_nexball_basketball(this);
681 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
682 spawnfunc(ball_redgoal)
684 spawnfunc_nexball_bluegoal(this); // I blame Revenant
686 spawnfunc(ball_bluegoal)
688 spawnfunc_nexball_redgoal(this); // but he didn't mean to cause trouble :p
690 spawnfunc(ball_fault)
692 spawnfunc_nexball_fault(this);
694 spawnfunc(ball_bound)
696 spawnfunc_nexball_out(this);
699 //=======================//
701 //=======================//
704 void W_Nexball_Think()
706 //dprint("W_Nexball_Think\n");
707 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
708 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
709 vector old_dir = normalize(self.velocity);
710 float _speed = vlen(self.velocity);
711 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
712 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
714 self.velocity = new_vel;
716 self.nextthink = time;
719 void W_Nexball_Touch(void)
721 entity ball, attacker;
722 attacker = self.owner;
723 //self.think = func_null;
724 //self.enemy = world;
727 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
728 if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
730 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
731 other.flags &= ~FL_ONGROUND;
732 if(!attacker.ballcarried)
734 LogNB("stole", attacker);
735 _sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
737 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
739 attacker.teamkill_complain = time + 5;
740 attacker.teamkill_soundtime = time + 0.4;
741 attacker.teamkill_soundsource = other;
744 GiveBall(attacker, other.ballcarried);
750 void W_Nexball_Attack(float t)
754 if(!(ball = self.ballcarried))
757 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
758 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
762 self.metertime = 0; // Shot failed, hide the power meter
766 //Calculate multiplier
771 mi = autocvar_g_nexball_basketball_meter_minpower;
772 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
773 //One triangle wave period with 1 as max
774 mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
777 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
780 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
783 //TODO: use the speed_up cvar too ??
786 vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
788 void W_Nexball_Attack2(void)
790 if(self.ballcarried.enemy)
792 entity _ball = self.ballcarried;
793 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
794 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
795 _ball.think = W_Nexball_Think;
796 _ball.nextthink = time;
800 if(!autocvar_g_nexball_tackling)
803 W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
804 entity missile = spawn();
806 missile.owner = self;
807 missile.classname = "ballstealer";
809 missile.movetype = MOVETYPE_FLY;
810 PROJECTILE_MAKETRIGGER(missile);
812 //setmodel(missile, "models/elaser.mdl"); // precision set below
813 setsize(missile, '0 0 0', '0 0 0');
814 setorigin(missile, w_shotorg);
816 W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
817 missile.angles = vectoangles(missile.velocity);
818 missile.touch = W_Nexball_Touch;
819 missile.think = SUB_Remove;
820 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
822 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
823 missile.flags = FL_PROJECTILE;
825 CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
828 float ball_customize()
832 self.effects &= ~EF_FLAME;
834 self.customizeentityforclient = func_null;
838 if(other == self.owner)
840 self.scale = autocvar_g_nexball_viewmodel_scale;
842 self.effects |= EF_FLAME;
844 self.effects &= ~EF_FLAME;
848 self.effects &= ~EF_FLAME;
855 METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2))
858 if(weapon_prepareattack(thiswep, actor, false, autocvar_g_balance_nexball_primary_refire))
859 if(autocvar_g_nexball_basketball_meter)
861 if(self.ballcarried && !self.metertime)
862 self.metertime = time;
864 weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
868 W_Nexball_Attack(-1);
869 weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
872 if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_nexball_secondary_refire))
875 weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
878 if(!fire1 && self.metertime && self.ballcarried)
880 W_Nexball_Attack(time - self.metertime);
881 // DropBall or stealing will set metertime back to 0
882 weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
885 METHOD(BallStealer, wr_setup, void(BallStealer thiswep))
887 //weapon_setup(WEP_PORTO.m_id);
889 METHOD(BallStealer, wr_checkammo1, bool(BallStealer thiswep))
893 METHOD(BallStealer, wr_checkammo2, bool(BallStealer thiswep))
898 void nb_DropBall(entity player)
900 if(player.ballcarried && g_nexball)
901 DropBall(player.ballcarried, player.origin, player.velocity);
904 MUTATOR_HOOKFUNCTION(nb, ClientDisconnect)
910 MUTATOR_HOOKFUNCTION(nb, PlayerDies)
916 MUTATOR_HOOKFUNCTION(nb, MakePlayerObserver)
922 MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
924 makevectors(self.v_angle);
925 if(nexball_mode & NBM_BASKETBALL)
930 self.ballcarried.velocity = self.velocity;
931 self.ballcarried.customizeentityforclient = ball_customize;
933 setorigin(self.ballcarried, self.origin + self.view_ofs +
934 v_forward * autocvar_g_nexball_viewmodel_offset.x +
935 v_right * autocvar_g_nexball_viewmodel_offset.y +
936 v_up * autocvar_g_nexball_viewmodel_offset.z);
939 if(autocvar_g_nexball_safepass_maxdist)
941 if(self.ballcarried.wait < time && self.ballcarried.enemy)
943 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
944 self.ballcarried.enemy = world;
948 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
949 crosshair_trace(self);
951 IS_CLIENT(trace_ent) &&
952 trace_ent.deadflag == DEAD_NO &&
953 trace_ent.team == self.team &&
954 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
957 //if(self.ballcarried.enemy != trace_ent)
958 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
959 self.ballcarried.enemy = trace_ent;
960 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
968 if(self.weaponentity.weapons)
970 self.weapons = self.weaponentity.weapons;
971 Weapon w = WEP_NEXBALL;
973 self.switchweapon = self.weaponentity.switchweapon;
974 W_SwitchWeapon(self.switchweapon);
976 self.weaponentity.weapons = '0 0 0';
987 MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
989 self.weaponentity.weapons = '0 0 0';
991 if(nexball_mode & NBM_BASKETBALL)
992 self.weapons |= WEPSET(NEXBALL);
994 self.weapons = '0 0 0';
999 .float stat_sv_airspeedlimit_nonqw;
1000 .float stat_sv_maxspeed;
1002 MUTATOR_HOOKFUNCTION(nb, PlayerPhysics)
1004 if(self.ballcarried)
1006 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
1007 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
1012 MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
1014 if(self.weapon == WEP_NEXBALL.m_id)
1020 MUTATOR_HOOKFUNCTION(nb, FilterItem)
1022 if(self.classname == "droppedweapon")
1023 if(self.weapon == WEP_NEXBALL.m_id)
1029 MUTATOR_HOOKFUNCTION(nb, GetTeamCount)
1031 ret_string = "nexball_team";
1035 MUTATOR_HOOKFUNCTION(nb, WantWeapon)
1037 ret_float = 0; // weapon is set a few lines later, apparently
1041 MUTATOR_HOOKFUNCTION(nb, DropSpecialItems)
1043 if(frag_target.ballcarried)
1044 DropBall(frag_target.ballcarried, frag_target.origin, frag_target.velocity);
1049 MUTATOR_HOOKFUNCTION(nb, SendWaypoint)
1051 wp_sendflags &= ~0x80;
1055 REGISTER_MUTATOR(nb, g_nexball)
1058 SetLimits(autocvar_g_nexball_goallimit, autocvar_g_nexball_goalleadlimit, -1, -1);
1059 have_team_spawns = -1; // request team spawns
1063 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1064 if(g_nexball_meter_period <= 0)
1065 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1066 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1067 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
1071 CVTOV(g_nexball_football_boost_forward); //100
1072 CVTOV(g_nexball_football_boost_up); //200
1073 CVTOV(g_nexball_delay_idle); //10
1074 CVTOV(g_nexball_football_physics); //0
1076 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
1078 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
1079 WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
1082 MUTATOR_ONROLLBACK_OR_REMOVE
1084 WEP_NEXBALL.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
1085 // we actually cannot roll back nb_delayedinit here
1086 // BUT: we don't need to! If this gets called, adding always
1092 LOG_INFO("This is a game type and it cannot be removed at runtime.");