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 ", Team_ColoredFullName(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.nb_dropper = plyr;
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 = func_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 = WEPSET_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.nb_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, ATTEN_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 ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
209 self.touch = func_null;
210 self.movetype = MOVETYPE_NOCLIP;
211 self.velocity = '0 0 0'; // just in case?
213 LogNB("resetidle", world);
215 self.nextthink = time;
217 else if(self.cnt < 4) // step 2 and 3
219 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
220 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
221 self.nextthink = time + 0.5;
226 // dprint("Step 4: time: ", ftos(time), "\n");
227 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
228 dprint("The ball moved too far away from its spawn origin.\nOffset: ",
229 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
230 self.velocity = '0 0 0';
231 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
232 self.movetype = MOVETYPE_NONE;
233 self.think = InitBall;
234 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
238 void football_touch(void)
240 if(other.solid == SOLID_BSP)
242 if(time > self.lastground + 0.1)
244 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
245 self.lastground = time;
247 if(vlen(self.velocity) && !self.cnt)
248 self.nextthink = time + autocvar_g_nexball_delay_idle;
251 if (!IS_PLAYER(other))
256 self.nextthink = time + autocvar_g_nexball_delay_idle;
259 self.team = other.team;
261 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
263 if(vlen(other.velocity))
264 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
266 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
268 makevectors(other.v_angle);
269 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
271 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
273 makevectors(other.v_angle_y * '0 1 0');
274 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
276 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
278 makevectors(other.v_angle);
279 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
281 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
284 void basketball_touch(void)
286 if(other.ballcarried)
291 if(!self.cnt && IS_PLAYER(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
293 if(other.health <= 0)
295 LogNB("caught", other);
296 GiveBall(other, self);
298 else if(other.solid == SOLID_BSP)
300 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
301 if(vlen(self.velocity) && !self.cnt)
302 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
309 float isclient, pscore, otherteam;
313 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
314 ball = other.ballcarried;
317 if(ball.classname != "nexball_basketball")
318 if(ball.classname != "nexball_football")
320 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
326 otherteam = OtherTeam(ball.team);
330 if((isclient = IS_CLIENT(ball.pusher)))
331 pname = ball.pusher.netname;
333 pname = "Someone (?)";
335 if(ball.team == self.team) //owngoal (regular goals)
337 LogNB("owngoal", ball.pusher);
338 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
341 else if(self.team == GOAL_FAULT)
343 LogNB("fault", ball.pusher);
345 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
347 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
350 else if(self.team == GOAL_OUT)
352 LogNB("out", ball.pusher);
353 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
354 bprint(pname, "^7 went out of bounds.\n");
356 bprint("The ball was returned.\n");
361 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
362 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
366 sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
368 if(ball.team && pscore)
370 if(nb_teams == 2 && pscore < 0)
371 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
373 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
378 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
380 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
383 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
384 DropBall(ball, ball.owner.origin, ball.owner.velocity);
386 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
389 ball.think = ResetBall;
390 if(ball.classname == "nexball_basketball")
391 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
392 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
395 //=======================//
397 //=======================//
398 void spawnfunc_nexball_team(void)
405 self.team = self.cnt + 1;
408 void nb_spawnteam(string teamname, float teamcolor)
410 dprint("^2spawned team ", teamname, "\n");
413 e.classname = "nexball_team";
414 e.netname = teamname;
420 void nb_spawnteams(void)
422 float t_r = 0, t_b = 0, t_y = 0, t_p = 0;
424 for(e = world; (e = find(e, classname, "nexball_goal"));)
431 nb_spawnteam("Red", e.team-1) ;
438 nb_spawnteam("Blue", e.team-1) ;
445 nb_spawnteam("Yellow", e.team-1);
452 nb_spawnteam("Pink", e.team-1) ;
460 void nb_delayedinit(void)
462 if(find(world, classname, "nexball_team") == world)
464 ScoreRules_nexball(nb_teams);
468 //=======================//
470 //=======================//
480 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
484 self.model = "models/nexball/ball.md3";
488 precache_model(self.model);
489 setmodel(self, self.model);
490 setsize(self, BALL_MINS, BALL_MAXS);
491 ball_scale = self.scale;
494 self.spawnorigin = self.origin;
496 self.effects = self.effects | EF_LOWPRECISION;
498 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
500 self.glow_color = autocvar_g_nexball_trail_color;
501 self.glow_trail = TRUE;
504 self.movetype = MOVETYPE_FLY;
506 if(!autocvar_g_nexball_sound_bounce)
508 else if(self.noise == "")
509 self.noise = "sound/nexball/bounce.wav";
510 //bounce sound placeholder (FIXME)
511 if(self.noise1 == "")
512 self.noise1 = "sound/nexball/drop.wav";
513 //ball drop sound placeholder (FIXME)
514 if(self.noise2 == "")
515 self.noise2 = "sound/nexball/steal.wav";
516 //stealing sound placeholder (FIXME)
517 if(self.noise) precache_sound(self.noise);
518 precache_sound(self.noise1);
519 precache_sound(self.noise2);
521 WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
523 self.reset = ball_restart;
524 self.think = InitBall;
525 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
528 void spawnfunc_nexball_basketball(void)
530 nexball_mode |= NBM_BASKETBALL;
531 self.classname = "nexball_basketball";
532 if (!(balls & BALL_BASKET))
535 CVTOV(g_nexball_basketball_effects_default);
536 CVTOV(g_nexball_basketball_delay_hold);
537 CVTOV(g_nexball_basketball_delay_hold_forteam);
538 CVTOV(g_nexball_basketball_teamsteal);
540 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
543 self.effects = autocvar_g_nexball_basketball_effects_default;
544 self.solid = SOLID_TRIGGER;
545 balls |= BALL_BASKET;
546 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
547 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
551 void spawnfunc_nexball_football(void)
553 nexball_mode |= NBM_FOOTBALL;
554 self.classname = "nexball_football";
555 self.solid = SOLID_TRIGGER;
557 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
558 self.bouncestop = autocvar_g_nexball_football_bouncestop;
570 self.classname = "nexball_goal";
572 self.noise = "ctf/respawn.wav";
573 precache_sound(self.noise);
574 self.touch = GoalTouch;
577 void spawnfunc_nexball_redgoal(void)
579 self.team = NUM_TEAM_1;
582 void spawnfunc_nexball_bluegoal(void)
584 self.team = NUM_TEAM_2;
587 void spawnfunc_nexball_yellowgoal(void)
589 self.team = NUM_TEAM_3;
592 void spawnfunc_nexball_pinkgoal(void)
594 self.team = NUM_TEAM_4;
598 void spawnfunc_nexball_fault(void)
600 self.team = GOAL_FAULT;
602 self.noise = "misc/typehit.wav";
606 void spawnfunc_nexball_out(void)
608 self.team = GOAL_OUT;
610 self.noise = "misc/typehit.wav";
615 //Spawnfuncs preserved for compatibility
618 void spawnfunc_ball(void)
620 spawnfunc_nexball_football();
622 void spawnfunc_ball_football(void)
624 spawnfunc_nexball_football();
626 void spawnfunc_ball_basketball(void)
628 spawnfunc_nexball_basketball();
630 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
631 void spawnfunc_ball_redgoal(void)
633 spawnfunc_nexball_bluegoal(); // I blame Revenant
635 void spawnfunc_ball_bluegoal(void)
637 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
639 void spawnfunc_ball_fault(void)
641 spawnfunc_nexball_fault();
643 void spawnfunc_ball_bound(void)
645 spawnfunc_nexball_out();
648 //=======================//
650 //=======================//
653 void W_Nexball_Think()
655 //dprint("W_Nexball_Think\n");
656 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
657 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
658 vector old_dir = normalize(self.velocity);
659 float _speed = vlen(self.velocity);
660 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
661 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
663 self.velocity = new_vel;
665 self.nextthink = time;
668 void W_Nexball_Touch(void)
670 entity ball, attacker;
671 attacker = self.owner;
672 //self.think = func_null;
673 //self.enemy = world;
676 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
677 if((ball = other.ballcarried) && (IS_PLAYER(attacker)))
679 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
680 other.flags &= ~FL_ONGROUND;
681 if(!attacker.ballcarried)
683 LogNB("stole", attacker);
684 sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
686 if(attacker.team == other.team && time > attacker.teamkill_complain)
688 attacker.teamkill_complain = time + 5;
689 attacker.teamkill_soundtime = time + 0.4;
690 attacker.teamkill_soundsource = other;
693 GiveBall(attacker, other.ballcarried);
699 void W_Nexball_Attack(float t)
703 if(!(ball = self.ballcarried))
706 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
707 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
711 self.metertime = 0; // Shot failed, hide the power meter
715 //Calculate multiplier
720 mi = autocvar_g_nexball_basketball_meter_minpower;
721 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
722 //One triangle wave period with 1 as max
723 mul = 2 * mod(t, g_nexball_meter_period) / g_nexball_meter_period;
726 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
729 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE));
732 //TODO: use the speed_up cvar too ??
735 void W_Nexball_Attack2(void)
737 if(self.ballcarried.enemy)
739 entity _ball = self.ballcarried;
740 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
741 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
742 _ball.think = W_Nexball_Think;
743 _ball.nextthink = time;
747 if(!autocvar_g_nexball_tackling)
751 if(!(balls & BALL_BASKET))
753 W_SetupShot(self, FALSE, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
754 // pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
757 missile.owner = self;
758 missile.classname = "ballstealer";
760 missile.movetype = MOVETYPE_FLY;
761 PROJECTILE_MAKETRIGGER(missile);
763 setmodel(missile, "models/elaser.mdl"); // precision set below
764 setsize(missile, '0 0 0', '0 0 0');
765 setorigin(missile, w_shotorg);
767 W_SetupProjectileVelocity(missile, autocvar_g_balance_nexball_secondary_speed, 0);
768 missile.angles = vectoangles(missile.velocity);
769 missile.touch = W_Nexball_Touch;
770 missile.think = SUB_Remove;
771 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
773 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
774 missile.flags = FL_PROJECTILE;
777 float ball_customize()
781 self.effects &= ~EF_FLAME;
783 self.customizeentityforclient = func_null;
787 if(other == self.owner)
789 self.scale = autocvar_g_nexball_viewmodel_scale;
791 self.effects |= EF_FLAME;
793 self.effects &= ~EF_FLAME;
797 self.effects &= ~EF_FLAME;
804 float w_nexball_weapon(float req)
809 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
810 if(autocvar_g_nexball_basketball_meter)
812 if(self.ballcarried && !self.metertime)
813 self.metertime = time;
815 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
819 W_Nexball_Attack(-1);
820 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
822 if(self.BUTTON_ATCK2)
823 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
826 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
829 if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
831 W_Nexball_Attack(time - self.metertime);
832 // DropBall or stealing will set metertime back to 0
833 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
836 else if(req == WR_PRECACHE)
838 precache_model("models/weapons/g_porto.md3");
839 precache_model("models/weapons/v_porto.md3");
840 precache_model("models/weapons/h_porto.iqm");
841 precache_model("models/elaser.mdl");
842 precache_sound("nexball/shoot1.wav");
843 precache_sound("nexball/shoot2.wav");
844 precache_sound("misc/typehit.wav");
846 else if(req == WR_SETUP)
848 weapon_setup(WEP_PORTO);
850 // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE
854 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
856 if(self.ballcarried && g_nexball)
857 DropBall(self.ballcarried, self.origin, self.velocity);
862 MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsString)
864 ret_string = strcat(ret_string, ":NB");
868 MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsPrettyString)
870 ret_string = strcat(ret_string, ", NexBall");
874 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
876 makevectors(self.v_angle);
877 if(nexball_mode & NBM_BASKETBALL)
882 self.ballcarried.velocity = self.velocity;
883 self.ballcarried.customizeentityforclient = ball_customize;
885 setorigin(self.ballcarried, self.origin + self.view_ofs +
886 v_forward * autocvar_g_nexball_viewmodel_offset_x +
887 v_right * autocvar_g_nexball_viewmodel_offset_y +
888 v_up * autocvar_g_nexball_viewmodel_offset_z);
891 if(autocvar_g_nexball_safepass_maxdist)
893 if(self.ballcarried.wait < time && self.ballcarried.enemy)
895 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
896 self.ballcarried.enemy = world;
900 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
901 crosshair_trace(self);
903 IS_CLIENT(trace_ent) &&
904 trace_ent.deadflag == DEAD_NO &&
905 trace_ent.team == self.team &&
906 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
909 //if(self.ballcarried.enemy != trace_ent)
910 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
911 self.ballcarried.enemy = trace_ent;
912 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
920 if(self.weaponentity.weapons)
922 self.weapons = self.weaponentity.weapons;
923 weapon_action(WEP_PORTO, WR_RESETPLAYER);
924 self.switchweapon = self.weaponentity.switchweapon;
925 W_SwitchWeapon(self.switchweapon);
927 self.weaponentity.weapons = '0 0 0';
938 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
940 self.weaponentity.weapons = '0 0 0';
942 if(nexball_mode & NBM_BASKETBALL)
943 self.weapons |= WEPSET_PORTO;
945 self.weapons = '0 0 0';
950 MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
952 start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
957 MUTATOR_DEFINITION(gamemode_nexball)
959 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
960 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
961 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
962 MUTATOR_HOOK(BuildMutatorsPrettyString, nexball_BuildMutatorsPrettyString, CBC_ORDER_ANY);
963 MUTATOR_HOOK(BuildMutatorsString, nexball_BuildMutatorsString, CBC_ORDER_ANY);
964 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
965 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
966 MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
970 g_nexball_meter_period = autocvar_g_nexball_meter_period;
971 if(g_nexball_meter_period <= 0)
972 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
973 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
974 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
978 CVTOV(g_nexball_football_boost_forward); //100
979 CVTOV(g_nexball_football_boost_up); //200
980 CVTOV(g_nexball_delay_idle); //10
981 CVTOV(g_nexball_football_physics); //0
983 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
985 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
988 MUTATOR_ONROLLBACK_OR_REMOVE
990 // we actually cannot roll back nb_delayedinit here
991 // BUT: we don't need to! If this gets called, adding always
997 print("This is a game type and it cannot be removed at runtime.");