1 #include "gamemode_nexball.qh"
6 float autocvar_g_nexball_basketball_bouncefactor;
7 float autocvar_g_nexball_basketball_bouncestop;
8 float autocvar_g_nexball_basketball_carrier_highspeed;
9 bool autocvar_g_nexball_basketball_meter;
10 float autocvar_g_nexball_basketball_meter_maxpower;
11 float autocvar_g_nexball_basketball_meter_minpower;
12 float autocvar_g_nexball_delay_collect;
13 float autocvar_g_nexball_delay_goal;
14 float autocvar_g_nexball_delay_start;
15 float autocvar_g_nexball_football_bouncefactor;
16 float autocvar_g_nexball_football_bouncestop;
17 bool autocvar_g_nexball_radar_showallplayers;
18 bool autocvar_g_nexball_sound_bounce;
19 int autocvar_g_nexball_trail_color;
21 float autocvar_g_nexball_safepass_turnrate;
22 float autocvar_g_nexball_safepass_maxdist;
23 float autocvar_g_nexball_safepass_holdtime;
24 float autocvar_g_nexball_viewmodel_scale;
25 float autocvar_g_nexball_tackling;
26 vector autocvar_g_nexball_viewmodel_offset;
28 void basketball_touch();
29 void football_touch();
31 const float NBM_NONE = 0;
32 const float NBM_FOOTBALL = 2;
33 const float NBM_BASKETBALL = 4;
36 float OtherTeam(float t) //works only if there are two teams on the map!
39 e = find(world, classname, "nexball_team");
41 e = find(e, classname, "nexball_team");
45 const float ST_NEXBALL_GOALS = 1;
46 const float SP_NEXBALL_GOALS = 4;
47 const float SP_NEXBALL_FAULTS = 5;
48 void nb_ScoreRules(float teams)
50 ScoreRules_basics(teams, 0, 0, true);
51 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
52 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
53 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
54 ScoreRules_basics_end();
57 void LogNB(string mode, entity actor)
60 if(!autocvar_sv_eventlog)
62 s = strcat(":nexball:", mode);
64 s = strcat(s, ":", ftos(actor.playerid));
68 void ball_restart(void)
71 DropBall(self, self.owner.origin, '0 0 0');
75 void nexball_setstatus(void)
77 self.items &= ~IT_KEY1;
80 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
82 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
83 setself(self.ballcarried);
84 DropBall(self, self.owner.origin, '0 0 0');
89 self.items |= IT_KEY1;
93 void relocate_nexball(void)
95 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
100 if(!move_out_of_solid(self))
101 objerror("could not get out of solid at all!");
102 LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
103 LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
104 LOG_INFO(" ", ftos(self.origin.y - o.y));
105 LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
114 DropBall(self, ownr.origin, ownr.velocity);
115 makevectors(ownr.v_angle.y * '0 1 0');
116 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
117 ownr.flags &= ~FL_ONGROUND;
120 void GiveBall(entity plyr, entity ball)
124 if((ownr = ball.owner))
126 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
127 ownr.ballcarried = world;
131 ownr.weaponentity.state = WS_READY;
133 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
137 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
140 //setattachment(ball, plyr, "");
141 setorigin(ball, plyr.origin + plyr.view_ofs);
143 if(ball.team != plyr.team)
144 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
146 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
147 ball.team = plyr.team;
148 plyr.ballcarried = ball;
149 ball.nb_dropper = plyr;
151 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
152 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
154 ball.velocity = '0 0 0';
155 ball.movetype = MOVETYPE_NONE;
156 ball.touch = func_null;
157 ball.effects |= EF_NOSHADOW;
158 ball.scale = 1; // scale down.
160 WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
161 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
163 if(autocvar_g_nexball_basketball_delay_hold)
165 ball.think = DropOwner;
166 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
169 plyr.weaponentity.weapons = plyr.weapons;
170 plyr.weaponentity.switchweapon = plyr.weapon;
171 plyr.weapons = WEPSET(NEXBALL);
173 Weapon w = WEP_NEXBALL;
175 plyr.switchweapon = WEP_NEXBALL.m_id;
176 W_SwitchWeapon(WEP_NEXBALL.m_id);
180 void DropBall(entity ball, vector org, vector vel)
182 ball.effects |= autocvar_g_nexball_basketball_effects_default;
183 ball.effects &= ~EF_NOSHADOW;
184 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
186 setattachment(ball, world, "");
187 setorigin(ball, org);
188 ball.movetype = MOVETYPE_BOUNCE;
189 ball.flags &= ~FL_ONGROUND;
190 ball.scale = ball_scale;
192 ball.nb_droptime = time;
193 ball.touch = basketball_touch;
194 ball.think = ResetBall;
195 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
197 if(ball.owner.metertime)
199 ball.owner.metertime = 0;
200 ball.owner.weaponentity.state = WS_READY;
203 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
204 WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
205 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
207 ball.owner.ballcarried = world;
214 self.flags &= ~FL_ONGROUND;
215 self.movetype = MOVETYPE_BOUNCE;
216 if(self.classname == "nexball_basketball")
217 self.touch = basketball_touch;
218 else if(self.classname == "nexball_football")
219 self.touch = football_touch;
221 self.think = ResetBall;
222 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
226 _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
227 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
228 LogNB("init", world);
233 if(self.cnt < 2) // step 1
235 if(time == self.teamtime)
236 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
238 self.touch = func_null;
239 self.movetype = MOVETYPE_NOCLIP;
240 self.velocity = '0 0 0'; // just in case?
242 LogNB("resetidle", world);
244 self.nextthink = time;
246 else if(self.cnt < 4) // step 2 and 3
248 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
249 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
250 self.nextthink = time + 0.5;
255 // dprint("Step 4: time: ", ftos(time), "\n");
256 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
257 LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
258 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
259 self.velocity = '0 0 0';
260 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
261 self.movetype = MOVETYPE_NONE;
262 self.think = InitBall;
263 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
267 void football_touch(void)
269 if(other.solid == SOLID_BSP)
271 if(time > self.lastground + 0.1)
273 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
274 self.lastground = time;
276 if(vlen(self.velocity) && !self.cnt)
277 self.nextthink = time + autocvar_g_nexball_delay_idle;
280 if (!IS_PLAYER(other))
285 self.nextthink = time + autocvar_g_nexball_delay_idle;
288 self.team = other.team;
290 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
292 if(vlen(other.velocity))
293 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
295 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
297 makevectors(other.v_angle);
298 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
300 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
302 makevectors(other.v_angle.y * '0 1 0');
303 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
305 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
307 makevectors(other.v_angle);
308 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
310 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
313 void basketball_touch(void)
315 if(other.ballcarried)
320 if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
322 if(other.health <= 0)
324 LogNB("caught", other);
325 GiveBall(other, self);
327 else if(other.solid == SOLID_BSP)
329 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
330 if(vlen(self.velocity) && !self.cnt)
331 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
338 float isclient, pscore, otherteam;
342 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
343 ball = other.ballcarried;
346 if(ball.classname != "nexball_basketball")
347 if(ball.classname != "nexball_football")
349 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
355 otherteam = OtherTeam(ball.team);
359 if((isclient = IS_CLIENT(ball.pusher)))
360 pname = ball.pusher.netname;
362 pname = "Someone (?)";
364 if(ball.team == self.team) //owngoal (regular goals)
366 LogNB("owngoal", ball.pusher);
367 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
370 else if(self.team == GOAL_FAULT)
372 LogNB("fault", ball.pusher);
374 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
376 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
379 else if(self.team == GOAL_OUT)
381 LogNB("out", ball.pusher);
382 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
383 bprint(pname, "^7 went out of bounds.\n");
385 bprint("The ball was returned.\n");
390 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
391 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
395 _sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
397 if(ball.team && pscore)
399 if(nb_teams == 2 && pscore < 0)
400 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
402 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
407 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
409 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
412 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
413 DropBall(ball, ball.owner.origin, ball.owner.velocity);
415 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
418 ball.think = ResetBall;
419 if(ball.classname == "nexball_basketball")
420 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
421 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
424 //=======================//
426 //=======================//
427 spawnfunc(nexball_team)
434 self.team = self.cnt + 1;
437 void nb_spawnteam(string teamname, float teamcolor)
439 LOG_TRACE("^2spawned team ", teamname, "\n");
442 e.classname = "nexball_team";
443 e.netname = teamname;
449 void nb_spawnteams(void)
451 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
453 for(e = world; (e = find(e, classname, "nexball_goal"));)
460 nb_spawnteam("Red", e.team-1) ;
467 nb_spawnteam("Blue", e.team-1) ;
474 nb_spawnteam("Yellow", e.team-1);
481 nb_spawnteam("Pink", e.team-1) ;
489 void nb_delayedinit(void)
491 if(find(world, classname, "nexball_team") == world)
493 nb_ScoreRules(nb_teams);
497 //=======================//
499 //=======================//
503 if(!g_nexball) { remove(self); return; }
505 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
509 self.model = "models/nexball/ball.md3";
513 precache_model(self.model);
514 _setmodel(self, self.model);
515 setsize(self, BALL_MINS, BALL_MAXS);
516 ball_scale = self.scale;
519 self.spawnorigin = self.origin;
521 self.effects = self.effects | EF_LOWPRECISION;
523 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
525 self.glow_color = autocvar_g_nexball_trail_color;
526 self.glow_trail = true;
529 self.movetype = MOVETYPE_FLY;
531 if(!autocvar_g_nexball_sound_bounce)
533 else if(self.noise == "")
534 self.noise = SND(NB_BOUNCE);
535 //bounce sound placeholder (FIXME)
536 if(self.noise1 == "")
537 self.noise1 = SND(NB_DROP);
538 //ball drop sound placeholder (FIXME)
539 if(self.noise2 == "")
540 self.noise2 = SND(NB_STEAL);
541 //stealing sound placeholder (FIXME)
542 if(self.noise) precache_sound(self.noise);
543 precache_sound(self.noise1);
544 precache_sound(self.noise2);
546 WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
548 self.reset = ball_restart;
549 self.think = InitBall;
550 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
553 spawnfunc(nexball_basketball)
555 nexball_mode |= NBM_BASKETBALL;
556 self.classname = "nexball_basketball";
557 if (!(balls & BALL_BASKET))
560 CVTOV(g_nexball_basketball_effects_default);
561 CVTOV(g_nexball_basketball_delay_hold);
562 CVTOV(g_nexball_basketball_delay_hold_forteam);
563 CVTOV(g_nexball_basketball_teamsteal);
565 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
568 self.effects = autocvar_g_nexball_basketball_effects_default;
569 self.solid = SOLID_TRIGGER;
570 balls |= BALL_BASKET;
571 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
572 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
576 spawnfunc(nexball_football)
578 nexball_mode |= NBM_FOOTBALL;
579 self.classname = "nexball_football";
580 self.solid = SOLID_TRIGGER;
582 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
583 self.bouncestop = autocvar_g_nexball_football_bouncestop;
587 float nb_Goal_Customize()
590 e = WaypointSprite_getviewentity(other);
591 wp_owner = self.owner;
592 if(SAME_TEAM(e, wp_owner)) { return false; }
599 if(!g_nexball) { remove(self); return; }
603 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
605 entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
606 wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
607 self.sprite.customizeentityforclient = nb_Goal_Customize;
610 self.classname = "nexball_goal";
612 self.noise = "ctf/respawn.wav";
613 precache_sound(self.noise);
614 self.touch = GoalTouch;
617 spawnfunc(nexball_redgoal)
619 self.team = NUM_TEAM_1;
622 spawnfunc(nexball_bluegoal)
624 self.team = NUM_TEAM_2;
627 spawnfunc(nexball_yellowgoal)
629 self.team = NUM_TEAM_3;
632 spawnfunc(nexball_pinkgoal)
634 self.team = NUM_TEAM_4;
638 spawnfunc(nexball_fault)
640 self.team = GOAL_FAULT;
642 self.noise = SND(TYPEHIT);
646 spawnfunc(nexball_out)
648 self.team = GOAL_OUT;
650 self.noise = SND(TYPEHIT);
655 //Spawnfuncs preserved for compatibility
660 spawnfunc_nexball_football(this);
662 spawnfunc(ball_football)
664 spawnfunc_nexball_football(this);
666 spawnfunc(ball_basketball)
668 spawnfunc_nexball_basketball(this);
670 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
671 spawnfunc(ball_redgoal)
673 spawnfunc_nexball_bluegoal(this); // I blame Revenant
675 spawnfunc(ball_bluegoal)
677 spawnfunc_nexball_redgoal(this); // but he didn't mean to cause trouble :p
679 spawnfunc(ball_fault)
681 spawnfunc_nexball_fault(this);
683 spawnfunc(ball_bound)
685 spawnfunc_nexball_out(this);
688 //=======================//
690 //=======================//
693 void W_Nexball_Think()
695 //dprint("W_Nexball_Think\n");
696 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
697 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
698 vector old_dir = normalize(self.velocity);
699 float _speed = vlen(self.velocity);
700 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
701 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
703 self.velocity = new_vel;
705 self.nextthink = time;
708 void W_Nexball_Touch(void)
710 entity ball, attacker;
711 attacker = self.owner;
712 //self.think = func_null;
713 //self.enemy = world;
716 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
717 if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
719 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
720 other.flags &= ~FL_ONGROUND;
721 if(!attacker.ballcarried)
723 LogNB("stole", attacker);
724 _sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
726 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
728 attacker.teamkill_complain = time + 5;
729 attacker.teamkill_soundtime = time + 0.4;
730 attacker.teamkill_soundsource = other;
733 GiveBall(attacker, other.ballcarried);
739 void W_Nexball_Attack(float t)
743 if(!(ball = self.ballcarried))
746 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
747 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
751 self.metertime = 0; // Shot failed, hide the power meter
755 //Calculate multiplier
760 mi = autocvar_g_nexball_basketball_meter_minpower;
761 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
762 //One triangle wave period with 1 as max
763 mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
766 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
769 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
772 //TODO: use the speed_up cvar too ??
775 void W_Nexball_Attack2(void)
777 if(self.ballcarried.enemy)
779 entity _ball = self.ballcarried;
780 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
781 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
782 _ball.think = W_Nexball_Think;
783 _ball.nextthink = time;
787 if(!autocvar_g_nexball_tackling)
790 W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
791 entity missile = spawn();
793 missile.owner = self;
794 missile.classname = "ballstealer";
796 missile.movetype = MOVETYPE_FLY;
797 PROJECTILE_MAKETRIGGER(missile);
799 //setmodel(missile, "models/elaser.mdl"); // precision set below
800 setsize(missile, '0 0 0', '0 0 0');
801 setorigin(missile, w_shotorg);
803 W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
804 missile.angles = vectoangles(missile.velocity);
805 missile.touch = W_Nexball_Touch;
806 missile.think = SUB_Remove;
807 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
809 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
810 missile.flags = FL_PROJECTILE;
812 CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
815 float ball_customize()
819 self.effects &= ~EF_FLAME;
821 self.customizeentityforclient = func_null;
825 if(other == self.owner)
827 self.scale = autocvar_g_nexball_viewmodel_scale;
829 self.effects |= EF_FLAME;
831 self.effects &= ~EF_FLAME;
835 self.effects &= ~EF_FLAME;
842 METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2))
845 if(weapon_prepareattack(thiswep, actor, false, autocvar_g_balance_nexball_primary_refire))
846 if(autocvar_g_nexball_basketball_meter)
848 if(self.ballcarried && !self.metertime)
849 self.metertime = time;
851 weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
855 W_Nexball_Attack(-1);
856 weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
859 if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_nexball_secondary_refire))
862 weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
865 if(!fire1 && self.metertime && self.ballcarried)
867 W_Nexball_Attack(time - self.metertime);
868 // DropBall or stealing will set metertime back to 0
869 weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
872 METHOD(BallStealer, wr_setup, void(BallStealer thiswep))
874 //weapon_setup(WEP_PORTO.m_id);
876 METHOD(BallStealer, wr_checkammo1, bool(BallStealer thiswep))
880 METHOD(BallStealer, wr_checkammo2, bool(BallStealer thiswep))
885 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
887 if(self.ballcarried && g_nexball)
888 DropBall(self.ballcarried, self.origin, self.velocity);
893 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
895 makevectors(self.v_angle);
896 if(nexball_mode & NBM_BASKETBALL)
901 self.ballcarried.velocity = self.velocity;
902 self.ballcarried.customizeentityforclient = ball_customize;
904 setorigin(self.ballcarried, self.origin + self.view_ofs +
905 v_forward * autocvar_g_nexball_viewmodel_offset.x +
906 v_right * autocvar_g_nexball_viewmodel_offset.y +
907 v_up * autocvar_g_nexball_viewmodel_offset.z);
910 if(autocvar_g_nexball_safepass_maxdist)
912 if(self.ballcarried.wait < time && self.ballcarried.enemy)
914 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
915 self.ballcarried.enemy = world;
919 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
920 crosshair_trace(self);
922 IS_CLIENT(trace_ent) &&
923 trace_ent.deadflag == DEAD_NO &&
924 trace_ent.team == self.team &&
925 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
928 //if(self.ballcarried.enemy != trace_ent)
929 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
930 self.ballcarried.enemy = trace_ent;
931 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
939 if(self.weaponentity.weapons)
941 self.weapons = self.weaponentity.weapons;
942 Weapon w = WEP_NEXBALL;
944 self.switchweapon = self.weaponentity.switchweapon;
945 W_SwitchWeapon(self.switchweapon);
947 self.weaponentity.weapons = '0 0 0';
958 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
960 self.weaponentity.weapons = '0 0 0';
962 if(nexball_mode & NBM_BASKETBALL)
963 self.weapons |= WEPSET(NEXBALL);
965 self.weapons = '0 0 0';
970 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
974 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
975 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
980 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
982 if(self.weapon == WEP_NEXBALL.m_id)
988 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
990 if(self.classname == "droppedweapon")
991 if(self.weapon == WEP_NEXBALL.m_id)
997 MUTATOR_DEFINITION(gamemode_nexball)
999 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
1000 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
1001 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
1002 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
1003 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
1004 MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
1005 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
1006 MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
1010 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1011 if(g_nexball_meter_period <= 0)
1012 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1013 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1014 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
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);
1026 WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
1029 MUTATOR_ONROLLBACK_OR_REMOVE
1031 WEP_NEXBALL.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
1032 // we actually cannot roll back nb_delayedinit here
1033 // BUT: we don't need to! If this gets called, adding always
1039 LOG_INFO("This is a game type and it cannot be removed at runtime.");