1 float autocvar_g_nexball_safepass_turnrate;
2 float autocvar_g_nexball_safepass_maxdist;
3 float autocvar_g_nexball_safepass_holdtime;
4 float autocvar_g_nexball_viewmodel_scale;
5 float autocvar_g_nexball_tackling;
6 vector autocvar_g_nexball_viewmodel_offset;
8 void basketball_touch();
12 #define NBM_FOOTBALL 2
13 #define NBM_BASKETBALL 4
16 float OtherTeam(float t) //works only if there are two teams on the map!
19 e = find(world, classname, "nexball_team");
21 e = find(e, classname, "nexball_team");
26 void LogNB(string mode, entity actor)
29 if(!autocvar_sv_eventlog)
31 s = strcat(":nexball:", mode);
33 s = strcat(s, ":", ftos(actor.playerid));
37 void ball_restart(void)
40 DropBall(self, self.owner.origin, '0 0 0');
44 void nexball_setstatus(void)
47 self.items &~= IT_KEY1;
50 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
52 bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n");
54 self = self.ballcarried;
55 DropBall(self, self.owner.origin, '0 0 0');
60 self.items |= IT_KEY1;
64 void relocate_nexball(void)
66 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, TRUE, self);
71 if(!move_out_of_solid(self))
72 objerror("could not get out of solid at all!");
73 print("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
74 print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x));
75 print(" ", ftos(self.origin_y - o_y));
76 print(" ", ftos(self.origin_z - o_z), "'\n");
85 DropBall(self, ownr.origin, ownr.velocity);
86 makevectors(ownr.v_angle_y * '0 1 0');
87 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
88 ownr.flags &~= FL_ONGROUND;
91 void GiveBall(entity plyr, entity ball)
95 if((ownr = ball.owner))
97 ownr.effects &~= autocvar_g_nexball_basketball_effects_default;
98 ownr.ballcarried = world;
102 ownr.weaponentity.state = WS_READY;
104 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
108 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
111 //setattachment(ball, plyr, "");
112 setorigin(ball, plyr.origin + plyr.view_ofs);
114 if(ball.team != plyr.team)
115 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
117 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
118 ball.team = plyr.team;
119 plyr.ballcarried = ball;
120 ball.dropperid = plyr.playerid;
122 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
123 ball.effects &~= autocvar_g_nexball_basketball_effects_default;
125 ball.velocity = '0 0 0';
126 ball.movetype = MOVETYPE_NONE;
127 ball.touch = SUB_Null;
128 ball.effects |= EF_NOSHADOW;
129 ball.scale = 1; // scale down.
131 WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
132 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
134 if(autocvar_g_nexball_basketball_delay_hold)
136 ball.think = DropOwner;
137 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
142 self.weaponentity.weapons = self.weapons;
143 self.weaponentity.switchweapon = self.weapon;
144 self.weapons = W_WeaponBit(WEP_PORTO);
145 weapon_action(WEP_PORTO, WR_RESETPLAYER);
146 self.switchweapon = WEP_PORTO;
147 W_SwitchWeapon(WEP_PORTO);
151 void DropBall(entity ball, vector org, vector vel)
153 ball.effects |= autocvar_g_nexball_basketball_effects_default;
154 ball.effects &~= EF_NOSHADOW;
155 ball.owner.effects &~= autocvar_g_nexball_basketball_effects_default;
157 setattachment(ball, world, "");
158 setorigin(ball, org);
159 ball.movetype = MOVETYPE_BOUNCE;
160 ball.flags &~= FL_ONGROUND;
161 ball.scale = ball_scale;
163 ball.ctf_droptime = time;
164 ball.touch = basketball_touch;
165 ball.think = ResetBall;
166 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
168 if(ball.owner.metertime)
170 ball.owner.metertime = 0;
171 ball.owner.weaponentity.state = WS_READY;
174 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
175 WaypointSprite_Spawn("nb-ball", 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // no health bar please
176 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
178 ball.owner.ballcarried = world;
185 self.flags &~= FL_ONGROUND;
186 self.movetype = MOVETYPE_BOUNCE;
187 if(self.classname == "nexball_basketball")
188 self.touch = basketball_touch;
189 else if(self.classname == "nexball_football")
190 self.touch = football_touch;
192 self.think = ResetBall;
193 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
197 sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
198 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
199 LogNB("init", world);
204 if(self.cnt < 2) // step 1
206 if(time == self.teamtime)
207 bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n");
208 self.touch = SUB_Null;
209 self.movetype = MOVETYPE_NOCLIP;
210 self.velocity = '0 0 0'; // just in case?
212 LogNB("resetidle", world);
214 self.nextthink = time;
216 else if(self.cnt < 4) // step 2 and 3
218 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
219 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
220 self.nextthink = time + 0.5;
225 // dprint("Step 4: time: ", ftos(time), "\n");
226 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
227 dprint("The ball moved too far away from its spawn origin.\nOffset: ",
228 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
229 self.velocity = '0 0 0';
230 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
231 self.movetype = MOVETYPE_NONE;
232 self.think = InitBall;
233 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
237 void football_touch(void)
239 if(other.solid == SOLID_BSP)
241 if(time > self.lastground + 0.1)
243 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
244 self.lastground = time;
246 if(vlen(self.velocity) && !self.cnt)
247 self.nextthink = time + autocvar_g_nexball_delay_idle;
250 if(other.classname != "player")
255 self.nextthink = time + autocvar_g_nexball_delay_idle;
258 self.team = other.team;
260 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
262 if(vlen(other.velocity))
263 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
265 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
267 makevectors(other.v_angle);
268 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
270 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
272 makevectors(other.v_angle_y * '0 1 0');
273 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
275 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
277 makevectors(other.v_angle);
278 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
280 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
283 void basketball_touch(void)
285 if(other.ballcarried)
290 if(!self.cnt && other.classname == "player" && (other.playerid != self.dropperid || time > self.ctf_droptime + autocvar_g_nexball_delay_collect))
292 if(other.health <= 0)
294 LogNB("caught", other);
295 GiveBall(other, self);
297 else if(other.solid == SOLID_BSP)
299 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
300 if(vlen(self.velocity) && !self.cnt)
301 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
308 float isclient, pscore, otherteam;
312 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
313 ball = other.ballcarried;
316 if(ball.classname != "nexball_basketball")
317 if(ball.classname != "nexball_football")
319 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
325 otherteam = OtherTeam(ball.team);
327 if((isclient = ball.pusher.flags & FL_CLIENT))
328 pname = ball.pusher.netname;
330 pname = "Someone (?)";
332 if(ball.team == self.team) //owngoal (regular goals)
334 LogNB("owngoal", ball.pusher);
335 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
338 else if(self.team == GOAL_FAULT)
340 LogNB("fault", ball.pusher);
342 bprint(ColoredTeamName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
344 bprint(ColoredTeamName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
347 else if(self.team == GOAL_OUT)
349 LogNB("out", ball.pusher);
350 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
351 bprint(pname, "^7 went out of bounds.\n");
353 bprint("The ball was returned.\n");
358 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
359 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", ColoredTeamName(ball.team), ".\n");
363 sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NONE);
365 if(ball.team && pscore)
367 if(nb_teams == 2 && pscore < 0)
368 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
370 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
375 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
377 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
380 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
381 DropBall(ball, ball.owner.origin, ball.owner.velocity);
383 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
386 ball.think = ResetBall;
387 if(ball.classname == "nexball_basketball")
388 ball.touch = football_touch; // better than SUB_Null: football control until the ball gets reset
389 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
392 //=======================//
394 //=======================//
395 void spawnfunc_nexball_team(void)
402 self.team = self.cnt + 1;
405 void nb_spawnteam(string teamname, float teamcolor)
407 dprint("^2spawned team ", teamname, "\n");
410 e.classname = "nexball_team";
411 e.netname = teamname;
417 void nb_spawnteams(void)
419 float t_r, t_b, t_y, t_p;
421 for(e = world; (e = find(e, classname, "nexball_goal"));)
428 nb_spawnteam("Red", e.team-1) ;
435 nb_spawnteam("Blue", e.team-1) ;
442 nb_spawnteam("Yellow", e.team-1);
449 nb_spawnteam("Pink", e.team-1) ;
457 void nb_delayedinit(void)
459 if(find(world, classname, "nexball_team") == world)
461 ScoreRules_nexball(nb_teams);
465 //=======================//
467 //=======================//
477 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
481 self.model = "models/nexball/ball.md3";
485 precache_model(self.model);
486 setmodel(self, self.model);
487 setsize(self, BALL_MINS, BALL_MAXS);
488 ball_scale = self.scale;
491 self.spawnorigin = self.origin;
493 self.effects = self.effects | EF_LOWPRECISION;
495 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
497 self.glow_color = autocvar_g_nexball_trail_color;
498 self.glow_trail = TRUE;
501 self.movetype = MOVETYPE_FLY;
503 if(!autocvar_g_nexball_sound_bounce)
506 self.noise = "sound/nexball/bounce.wav";
507 //bounce sound placeholder (FIXME)
509 self.noise1 = "sound/nexball/drop.wav";
510 //ball drop sound placeholder (FIXME)
512 self.noise2 = "sound/nexball/steal.wav";
513 //stealing sound placeholder (FIXME)
514 if(self.noise) precache_sound(self.noise);
515 precache_sound(self.noise1);
516 precache_sound(self.noise2);
518 WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
520 self.reset = ball_restart;
521 self.think = InitBall;
522 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
525 void spawnfunc_nexball_basketball(void)
527 nexball_mode |= NBM_BASKETBALL;
528 self.classname = "nexball_basketball";
529 if not(balls & BALL_BASKET)
532 CVTOV(g_nexball_basketball_effects_default);
533 CVTOV(g_nexball_basketball_delay_hold);
534 CVTOV(g_nexball_basketball_delay_hold_forteam);
535 CVTOV(g_nexball_basketball_teamsteal);
537 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
540 self.effects = autocvar_g_nexball_basketball_effects_default;
541 self.solid = SOLID_TRIGGER;
542 balls |= BALL_BASKET;
543 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
544 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
548 void spawnfunc_nexball_football(void)
550 nexball_mode |= NBM_FOOTBALL;
551 self.classname = "nexball_football";
552 self.solid = SOLID_TRIGGER;
554 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
555 self.bouncestop = autocvar_g_nexball_football_bouncestop;
567 self.classname = "nexball_goal";
569 self.noise = "ctf/respawn.wav";
570 precache_sound(self.noise);
571 self.touch = GoalTouch;
574 void spawnfunc_nexball_redgoal(void)
576 self.team = COLOR_TEAM1;
579 void spawnfunc_nexball_bluegoal(void)
581 self.team = COLOR_TEAM2;
584 void spawnfunc_nexball_yellowgoal(void)
586 self.team = COLOR_TEAM3;
589 void spawnfunc_nexball_pinkgoal(void)
591 self.team = COLOR_TEAM4;
595 void spawnfunc_nexball_fault(void)
597 self.team = GOAL_FAULT;
599 self.noise = "misc/typehit.wav";
603 void spawnfunc_nexball_out(void)
605 self.team = GOAL_OUT;
607 self.noise = "misc/typehit.wav";
612 //Spawnfuncs preserved for compatibility
615 void spawnfunc_ball(void)
617 spawnfunc_nexball_football();
619 void spawnfunc_ball_football(void)
621 spawnfunc_nexball_football();
623 void spawnfunc_ball_basketball(void)
625 spawnfunc_nexball_basketball();
627 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
628 void spawnfunc_ball_redgoal(void)
630 spawnfunc_nexball_bluegoal(); // I blame Revenant
632 void spawnfunc_ball_bluegoal(void)
634 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
636 void spawnfunc_ball_fault(void)
638 spawnfunc_nexball_fault();
640 void spawnfunc_ball_bound(void)
642 spawnfunc_nexball_out();
645 //=======================//
647 //=======================//
650 void W_Nexball_Think()
652 dprint("W_Nexball_Think\n");
653 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
654 vector new_dir = steerlib_pull(self.enemy.origin);
655 vector old_dir = normalize(self.velocity);
656 float _speed = vlen(self.velocity);
658 vector new_vel = (old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
659 self.velocity = new_vel;
661 self.nextthink = time;
664 void W_Nexball_Touch(void)
666 entity ball, attacker;
667 attacker = self.owner;
668 //self.think = SUB_Null;
669 //self.enemy = world;
672 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
673 if((ball = other.ballcarried) && (attacker.classname == "player"))
675 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
676 other.flags &~= FL_ONGROUND;
677 if(!attacker.ballcarried)
679 LogNB("stole", attacker);
680 sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTN_NORM);
682 if(attacker.team == other.team && time > attacker.teamkill_complain)
684 attacker.teamkill_complain = time + 5;
685 attacker.teamkill_soundtime = time + 0.4;
686 attacker.teamkill_soundsource = other;
689 GiveBall(attacker, other.ballcarried);
695 void W_Nexball_Attack(float t)
699 if(!(ball = self.ballcarried))
702 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
703 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
707 self.metertime = 0; // Shot failed, hide the power meter
711 //Calculate multiplier
716 mi = autocvar_g_nexball_basketball_meter_minpower;
717 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
718 //One triangle wave period with 1 as max
719 mul = 2 * mod(t, g_nexball_meter_period) / g_nexball_meter_period;
722 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
725 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE));
728 //TODO: use the speed_up cvar too ??
731 void W_Nexball_Attack2(void)
733 if(self.ballcarried.enemy)
735 self.ballcarried.think = W_Nexball_Think;
736 self.ballcarried.nextthink = time;
737 DropBall(self.ballcarried, w_shotorg, trigger_push_calculatevelocity(self.ballcarried.origin, self.ballcarried.enemy, 32));
741 if(!autocvar_g_nexball_tackling)
745 if(!(balls & BALL_BASKET))
747 W_SetupShot(self, FALSE, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
748 // pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
751 missile.owner = self;
752 missile.classname = "ballstealer";
754 missile.movetype = MOVETYPE_FLY;
755 PROJECTILE_MAKETRIGGER(missile);
757 setmodel(missile, "models/elaser.mdl"); // precision set below
758 setsize(missile, '0 0 0', '0 0 0');
759 setorigin(missile, w_shotorg);
761 W_SetupProjectileVelocity(missile, autocvar_g_balance_nexball_secondary_speed, 0);
762 missile.angles = vectoangles(missile.velocity);
763 missile.touch = W_Nexball_Touch;
764 missile.think = SUB_Remove;
765 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
767 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
768 missile.flags = FL_PROJECTILE;
771 var const float() nullfunc;
772 float ball_customize()
776 self.effects &~= EF_FLAME;
778 self.customizeentityforclient = nullfunc;
782 if(other == self.owner)
784 self.scale = autocvar_g_nexball_viewmodel_scale;
786 self.effects |= EF_FLAME;
788 self.effects &~= EF_FLAME;
792 self.effects &~= EF_FLAME;
799 float w_nexball_weapon(float req)
804 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
805 if(autocvar_g_nexball_basketball_meter)
807 if(self.ballcarried && !self.metertime)
808 self.metertime = time;
810 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
814 W_Nexball_Attack(-1);
815 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
817 if(self.BUTTON_ATCK2)
818 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
821 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
824 if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
826 W_Nexball_Attack(time - self.metertime);
827 // DropBall or stealing will set metertime back to 0
828 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
831 else if(req == WR_PRECACHE)
833 precache_model("models/weapons/g_porto.md3");
834 precache_model("models/weapons/v_porto.md3");
835 precache_model("models/weapons/h_porto.iqm");
836 precache_model("models/elaser.mdl");
837 precache_sound("nexball/shoot1.wav");
838 precache_sound("nexball/shoot2.wav");
839 precache_sound("misc/typehit.wav");
841 else if(req == WR_SETUP)
842 weapon_setup(WEP_PORTO);
843 else if(req == WR_SUICIDEMESSAGE)
845 w_deathtypestring = "is a weirdo";
847 else if(req == WR_KILLMESSAGE)
849 w_deathtypestring = "got killed by #'s black magic";
851 // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE
855 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
857 if(self.ballcarried && g_nexball)
858 DropBall(self.ballcarried, self.origin, self.velocity);
863 MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsString)
865 ret_string = strcat(ret_string, ":NB");
869 MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsPrettyString)
871 ret_string = strcat(ret_string, ", NexBall");
875 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
877 makevectors(self.v_angle);
878 if(nexball_mode & NBM_BASKETBALL)
883 self.ballcarried.velocity = self.velocity;
884 self.ballcarried.customizeentityforclient = ball_customize;
886 setorigin(self.ballcarried, self.origin + self.view_ofs +
887 v_forward * autocvar_g_nexball_viewmodel_offset_x +
888 v_right * autocvar_g_nexball_viewmodel_offset_y +
889 v_up * autocvar_g_nexball_viewmodel_offset_z);
892 if(autocvar_g_nexball_safepass_maxdist)
894 if(self.ballcarried.wait < time && self.ballcarried.enemy)
896 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
897 self.ballcarried.enemy = world;
901 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
902 crosshair_trace(self);
904 trace_ent.flags & FL_CLIENT &&
905 trace_ent.deadflag == DEAD_NO &&
906 trace_ent.team == self.team &&
907 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
910 //if(self.ballcarried.enemy != trace_ent)
911 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
912 self.ballcarried.enemy = trace_ent;
913 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
921 if(self.weaponentity.weapons)
923 self.weapons = self.weaponentity.weapons;
924 weapon_action(WEP_PORTO, WR_RESETPLAYER);
925 self.switchweapon = self.weaponentity.switchweapon;
926 W_SwitchWeapon(self.switchweapon);
928 self.weaponentity.weapons = 0;
937 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
939 self.weaponentity.weapons = 0;
941 if(nexball_mode & NBM_BASKETBALL)
944 if(autocvar_g_weapon_stay)
951 MUTATOR_DEFINITION(gamemode_nexball)
953 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
954 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
955 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
956 MUTATOR_HOOK(BuildMutatorsPrettyString, nexball_BuildMutatorsPrettyString, CBC_ORDER_ANY);
957 MUTATOR_HOOK(BuildMutatorsString, nexball_BuildMutatorsString, CBC_ORDER_ANY);
958 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
959 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
964 g_nexball_meter_period = autocvar_g_nexball_meter_period;
965 if(g_nexball_meter_period <= 0)
966 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
967 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
968 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
972 CVTOV(g_nexball_football_boost_forward); //100
973 CVTOV(g_nexball_football_boost_up); //200
974 CVTOV(g_nexball_delay_idle); //10
975 CVTOV(g_nexball_football_physics); //0
977 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
979 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);