1 #include "gamemode_nexball.qh"
6 float autocvar_g_nexball_safepass_turnrate;
7 float autocvar_g_nexball_safepass_maxdist;
8 float autocvar_g_nexball_safepass_holdtime;
9 float autocvar_g_nexball_viewmodel_scale;
10 float autocvar_g_nexball_tackling;
11 vector autocvar_g_nexball_viewmodel_offset;
13 void basketball_touch();
14 void football_touch();
16 const float NBM_NONE = 0;
17 const float NBM_FOOTBALL = 2;
18 const float NBM_BASKETBALL = 4;
21 float OtherTeam(float t) //works only if there are two teams on the map!
24 e = find(world, classname, "nexball_team");
26 e = find(e, classname, "nexball_team");
30 const float ST_NEXBALL_GOALS = 1;
31 const float SP_NEXBALL_GOALS = 4;
32 const float SP_NEXBALL_FAULTS = 5;
33 void nb_ScoreRules(float teams)
35 ScoreRules_basics(teams, 0, 0, true);
36 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
37 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
38 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
39 ScoreRules_basics_end();
42 void LogNB(string mode, entity actor)
45 if(!autocvar_sv_eventlog)
47 s = strcat(":nexball:", mode);
49 s = strcat(s, ":", ftos(actor.playerid));
53 void ball_restart(void)
56 DropBall(self, self.owner.origin, '0 0 0');
60 void nexball_setstatus(void)
62 self.items &= ~IT_KEY1;
65 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
67 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
68 setself(self.ballcarried);
69 DropBall(self, self.owner.origin, '0 0 0');
74 self.items |= IT_KEY1;
78 void relocate_nexball(void)
80 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
85 if(!move_out_of_solid(self))
86 objerror("could not get out of solid at all!");
87 LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
88 LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
89 LOG_INFO(" ", ftos(self.origin.y - o.y));
90 LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
99 DropBall(self, ownr.origin, ownr.velocity);
100 makevectors(ownr.v_angle.y * '0 1 0');
101 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
102 ownr.flags &= ~FL_ONGROUND;
105 void GiveBall(entity plyr, entity ball)
109 if((ownr = ball.owner))
111 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
112 ownr.ballcarried = world;
116 ownr.weaponentity.state = WS_READY;
118 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
122 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
125 //setattachment(ball, plyr, "");
126 setorigin(ball, plyr.origin + plyr.view_ofs);
128 if(ball.team != plyr.team)
129 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
131 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
132 ball.team = plyr.team;
133 plyr.ballcarried = ball;
134 ball.nb_dropper = plyr;
136 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
137 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
139 ball.velocity = '0 0 0';
140 ball.movetype = MOVETYPE_NONE;
141 ball.touch = func_null;
142 ball.effects |= EF_NOSHADOW;
143 ball.scale = 1; // scale down.
145 WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
146 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
148 if(autocvar_g_nexball_basketball_delay_hold)
150 ball.think = DropOwner;
151 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
154 plyr.weaponentity.weapons = plyr.weapons;
155 plyr.weaponentity.switchweapon = plyr.weapon;
156 plyr.weapons = WEPSET_PORTO;
158 WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
159 plyr.switchweapon = WEP_PORTO.m_id;
160 W_SwitchWeapon(WEP_PORTO.m_id);
164 void DropBall(entity ball, vector org, vector vel)
166 ball.effects |= autocvar_g_nexball_basketball_effects_default;
167 ball.effects &= ~EF_NOSHADOW;
168 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
170 setattachment(ball, world, "");
171 setorigin(ball, org);
172 ball.movetype = MOVETYPE_BOUNCE;
173 ball.flags &= ~FL_ONGROUND;
174 ball.scale = ball_scale;
176 ball.nb_droptime = time;
177 ball.touch = basketball_touch;
178 ball.think = ResetBall;
179 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
181 if(ball.owner.metertime)
183 ball.owner.metertime = 0;
184 ball.owner.weaponentity.state = WS_READY;
187 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
188 WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
189 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
191 ball.owner.ballcarried = world;
198 self.flags &= ~FL_ONGROUND;
199 self.movetype = MOVETYPE_BOUNCE;
200 if(self.classname == "nexball_basketball")
201 self.touch = basketball_touch;
202 else if(self.classname == "nexball_football")
203 self.touch = football_touch;
205 self.think = ResetBall;
206 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
210 _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
211 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
212 LogNB("init", world);
217 if(self.cnt < 2) // step 1
219 if(time == self.teamtime)
220 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
222 self.touch = func_null;
223 self.movetype = MOVETYPE_NOCLIP;
224 self.velocity = '0 0 0'; // just in case?
226 LogNB("resetidle", world);
228 self.nextthink = time;
230 else if(self.cnt < 4) // step 2 and 3
232 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
233 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
234 self.nextthink = time + 0.5;
239 // dprint("Step 4: time: ", ftos(time), "\n");
240 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
241 LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
242 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
243 self.velocity = '0 0 0';
244 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
245 self.movetype = MOVETYPE_NONE;
246 self.think = InitBall;
247 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
251 void football_touch(void)
253 if(other.solid == SOLID_BSP)
255 if(time > self.lastground + 0.1)
257 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
258 self.lastground = time;
260 if(vlen(self.velocity) && !self.cnt)
261 self.nextthink = time + autocvar_g_nexball_delay_idle;
264 if (!IS_PLAYER(other))
269 self.nextthink = time + autocvar_g_nexball_delay_idle;
272 self.team = other.team;
274 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
276 if(vlen(other.velocity))
277 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
279 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
281 makevectors(other.v_angle);
282 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
284 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
286 makevectors(other.v_angle.y * '0 1 0');
287 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
289 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
291 makevectors(other.v_angle);
292 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
294 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
297 void basketball_touch(void)
299 if(other.ballcarried)
304 if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
306 if(other.health <= 0)
308 LogNB("caught", other);
309 GiveBall(other, self);
311 else if(other.solid == SOLID_BSP)
313 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
314 if(vlen(self.velocity) && !self.cnt)
315 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
322 float isclient, pscore, otherteam;
326 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
327 ball = other.ballcarried;
330 if(ball.classname != "nexball_basketball")
331 if(ball.classname != "nexball_football")
333 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
339 otherteam = OtherTeam(ball.team);
343 if((isclient = IS_CLIENT(ball.pusher)))
344 pname = ball.pusher.netname;
346 pname = "Someone (?)";
348 if(ball.team == self.team) //owngoal (regular goals)
350 LogNB("owngoal", ball.pusher);
351 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
354 else if(self.team == GOAL_FAULT)
356 LogNB("fault", ball.pusher);
358 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
360 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
363 else if(self.team == GOAL_OUT)
365 LogNB("out", ball.pusher);
366 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
367 bprint(pname, "^7 went out of bounds.\n");
369 bprint("The ball was returned.\n");
374 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
375 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
379 _sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
381 if(ball.team && pscore)
383 if(nb_teams == 2 && pscore < 0)
384 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
386 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
391 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
393 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
396 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
397 DropBall(ball, ball.owner.origin, ball.owner.velocity);
399 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
402 ball.think = ResetBall;
403 if(ball.classname == "nexball_basketball")
404 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
405 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
408 //=======================//
410 //=======================//
411 void spawnfunc_nexball_team(void)
418 self.team = self.cnt + 1;
421 void nb_spawnteam(string teamname, float teamcolor)
423 LOG_TRACE("^2spawned team ", teamname, "\n");
426 e.classname = "nexball_team";
427 e.netname = teamname;
433 void nb_spawnteams(void)
435 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
437 for(e = world; (e = find(e, classname, "nexball_goal"));)
444 nb_spawnteam("Red", e.team-1) ;
451 nb_spawnteam("Blue", e.team-1) ;
458 nb_spawnteam("Yellow", e.team-1);
465 nb_spawnteam("Pink", e.team-1) ;
473 void nb_delayedinit(void)
475 if(find(world, classname, "nexball_team") == world)
477 nb_ScoreRules(nb_teams);
481 //=======================//
483 //=======================//
487 if(!g_nexball) { remove(self); return; }
489 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
493 self.model = "models/nexball/ball.md3";
497 precache_model(self.model);
498 _setmodel(self, self.model);
499 setsize(self, BALL_MINS, BALL_MAXS);
500 ball_scale = self.scale;
503 self.spawnorigin = self.origin;
505 self.effects = self.effects | EF_LOWPRECISION;
507 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
509 self.glow_color = autocvar_g_nexball_trail_color;
510 self.glow_trail = true;
513 self.movetype = MOVETYPE_FLY;
515 if(!autocvar_g_nexball_sound_bounce)
517 else if(self.noise == "")
518 self.noise = SND(NB_BOUNCE);
519 //bounce sound placeholder (FIXME)
520 if(self.noise1 == "")
521 self.noise1 = SND(NB_DROP);
522 //ball drop sound placeholder (FIXME)
523 if(self.noise2 == "")
524 self.noise2 = SND(NB_STEAL);
525 //stealing sound placeholder (FIXME)
526 if(self.noise) precache_sound(self.noise);
527 precache_sound(self.noise1);
528 precache_sound(self.noise2);
530 WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
532 self.reset = ball_restart;
533 self.think = InitBall;
534 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
537 void spawnfunc_nexball_basketball(void)
539 nexball_mode |= NBM_BASKETBALL;
540 self.classname = "nexball_basketball";
541 if (!(balls & BALL_BASKET))
544 CVTOV(g_nexball_basketball_effects_default);
545 CVTOV(g_nexball_basketball_delay_hold);
546 CVTOV(g_nexball_basketball_delay_hold_forteam);
547 CVTOV(g_nexball_basketball_teamsteal);
549 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
552 self.effects = autocvar_g_nexball_basketball_effects_default;
553 self.solid = SOLID_TRIGGER;
554 balls |= BALL_BASKET;
555 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
556 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
560 void spawnfunc_nexball_football(void)
562 nexball_mode |= NBM_FOOTBALL;
563 self.classname = "nexball_football";
564 self.solid = SOLID_TRIGGER;
566 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
567 self.bouncestop = autocvar_g_nexball_football_bouncestop;
571 float nb_Goal_Customize()
574 e = WaypointSprite_getviewentity(other);
575 wp_owner = self.owner;
576 if(SAME_TEAM(e, wp_owner)) { return false; }
583 if(!g_nexball) { remove(self); return; }
587 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
589 entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
590 wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
591 self.sprite.customizeentityforclient = nb_Goal_Customize;
594 self.classname = "nexball_goal";
596 self.noise = "ctf/respawn.wav";
597 precache_sound(self.noise);
598 self.touch = GoalTouch;
601 void spawnfunc_nexball_redgoal(void)
603 self.team = NUM_TEAM_1;
606 void spawnfunc_nexball_bluegoal(void)
608 self.team = NUM_TEAM_2;
611 void spawnfunc_nexball_yellowgoal(void)
613 self.team = NUM_TEAM_3;
616 void spawnfunc_nexball_pinkgoal(void)
618 self.team = NUM_TEAM_4;
622 void spawnfunc_nexball_fault(void)
624 self.team = GOAL_FAULT;
626 self.noise = SND(TYPEHIT);
630 void spawnfunc_nexball_out(void)
632 self.team = GOAL_OUT;
634 self.noise = SND(TYPEHIT);
639 //Spawnfuncs preserved for compatibility
642 void spawnfunc_ball(void)
644 spawnfunc_nexball_football();
646 void spawnfunc_ball_football(void)
648 spawnfunc_nexball_football();
650 void spawnfunc_ball_basketball(void)
652 spawnfunc_nexball_basketball();
654 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
655 void spawnfunc_ball_redgoal(void)
657 spawnfunc_nexball_bluegoal(); // I blame Revenant
659 void spawnfunc_ball_bluegoal(void)
661 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
663 void spawnfunc_ball_fault(void)
665 spawnfunc_nexball_fault();
667 void spawnfunc_ball_bound(void)
669 spawnfunc_nexball_out();
672 //=======================//
674 //=======================//
677 void W_Nexball_Think()
679 //dprint("W_Nexball_Think\n");
680 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
681 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
682 vector old_dir = normalize(self.velocity);
683 float _speed = vlen(self.velocity);
684 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
685 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
687 self.velocity = new_vel;
689 self.nextthink = time;
692 void W_Nexball_Touch(void)
694 entity ball, attacker;
695 attacker = self.owner;
696 //self.think = func_null;
697 //self.enemy = world;
700 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
701 if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
703 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
704 other.flags &= ~FL_ONGROUND;
705 if(!attacker.ballcarried)
707 LogNB("stole", attacker);
708 _sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
710 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
712 attacker.teamkill_complain = time + 5;
713 attacker.teamkill_soundtime = time + 0.4;
714 attacker.teamkill_soundsource = other;
717 GiveBall(attacker, other.ballcarried);
723 void W_Nexball_Attack(float t)
727 if(!(ball = self.ballcarried))
730 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
731 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
735 self.metertime = 0; // Shot failed, hide the power meter
739 //Calculate multiplier
744 mi = autocvar_g_nexball_basketball_meter_minpower;
745 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
746 //One triangle wave period with 1 as max
747 mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
750 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
753 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
756 //TODO: use the speed_up cvar too ??
759 void W_Nexball_Attack2(void)
761 if(self.ballcarried.enemy)
763 entity _ball = self.ballcarried;
764 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
765 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
766 _ball.think = W_Nexball_Think;
767 _ball.nextthink = time;
771 if(!autocvar_g_nexball_tackling)
775 if(!(balls & BALL_BASKET))
777 W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
780 missile.owner = self;
781 missile.classname = "ballstealer";
783 missile.movetype = MOVETYPE_FLY;
784 PROJECTILE_MAKETRIGGER(missile);
786 //setmodel(missile, "models/elaser.mdl"); // precision set below
787 setsize(missile, '0 0 0', '0 0 0');
788 setorigin(missile, w_shotorg);
790 W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
791 missile.angles = vectoangles(missile.velocity);
792 missile.touch = W_Nexball_Touch;
793 missile.think = SUB_Remove;
794 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
796 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
797 missile.flags = FL_PROJECTILE;
799 CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
802 float ball_customize()
806 self.effects &= ~EF_FLAME;
808 self.customizeentityforclient = func_null;
812 if(other == self.owner)
814 self.scale = autocvar_g_nexball_viewmodel_scale;
816 self.effects |= EF_FLAME;
818 self.effects &= ~EF_FLAME;
822 self.effects &= ~EF_FLAME;
829 float w_nexball_weapon(float req)
834 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
835 if(autocvar_g_nexball_basketball_meter)
837 if(self.ballcarried && !self.metertime)
838 self.metertime = time;
840 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
844 W_Nexball_Attack(-1);
845 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
847 if(self.BUTTON_ATCK2)
848 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
851 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
854 if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
856 W_Nexball_Attack(time - self.metertime);
857 // DropBall or stealing will set metertime back to 0
858 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
861 else if(req == WR_INIT)
864 else if(req == WR_SETUP)
866 //weapon_setup(WEP_PORTO.m_id);
868 // No need to check WR_CHECKAMMO* or WR_AIM, it should always return true
872 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
874 if(self.ballcarried && g_nexball)
875 DropBall(self.ballcarried, self.origin, self.velocity);
880 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
882 makevectors(self.v_angle);
883 if(nexball_mode & NBM_BASKETBALL)
888 self.ballcarried.velocity = self.velocity;
889 self.ballcarried.customizeentityforclient = ball_customize;
891 setorigin(self.ballcarried, self.origin + self.view_ofs +
892 v_forward * autocvar_g_nexball_viewmodel_offset.x +
893 v_right * autocvar_g_nexball_viewmodel_offset.y +
894 v_up * autocvar_g_nexball_viewmodel_offset.z);
897 if(autocvar_g_nexball_safepass_maxdist)
899 if(self.ballcarried.wait < time && self.ballcarried.enemy)
901 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
902 self.ballcarried.enemy = world;
906 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
907 crosshair_trace(self);
909 IS_CLIENT(trace_ent) &&
910 trace_ent.deadflag == DEAD_NO &&
911 trace_ent.team == self.team &&
912 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
915 //if(self.ballcarried.enemy != trace_ent)
916 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
917 self.ballcarried.enemy = trace_ent;
918 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
926 if(self.weaponentity.weapons)
928 self.weapons = self.weaponentity.weapons;
929 WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
930 self.switchweapon = self.weaponentity.switchweapon;
931 W_SwitchWeapon(self.switchweapon);
933 self.weaponentity.weapons = '0 0 0';
944 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
946 self.weaponentity.weapons = '0 0 0';
948 if(nexball_mode & NBM_BASKETBALL)
949 self.weapons |= WEPSET_PORTO;
951 self.weapons = '0 0 0';
956 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
960 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
961 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
966 MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
968 start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
973 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
975 if(self.weapon == WEP_MORTAR.m_id)
981 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
983 if(self.classname == "droppedweapon")
984 if(self.weapon == WEP_MORTAR.m_id)
990 MUTATOR_DEFINITION(gamemode_nexball)
992 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
993 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
994 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
995 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
996 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
997 MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
998 MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
999 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
1000 MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
1004 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1005 if(g_nexball_meter_period <= 0)
1006 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1007 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1008 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
1012 CVTOV(g_nexball_football_boost_forward); //100
1013 CVTOV(g_nexball_football_boost_up); //200
1014 CVTOV(g_nexball_delay_idle); //10
1015 CVTOV(g_nexball_football_physics); //0
1017 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
1019 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
1022 MUTATOR_ONROLLBACK_OR_REMOVE
1024 // we actually cannot roll back nb_delayedinit here
1025 // BUT: we don't need to! If this gets called, adding always
1031 LOG_INFO("This is a game type and it cannot be removed at runtime.");