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");
25 #define ST_NEXBALL_GOALS 1
26 #define SP_NEXBALL_GOALS 4
27 #define SP_NEXBALL_FAULTS 5
28 void nb_ScoreRules(float teams)
30 ScoreRules_basics(teams, 0, 0, TRUE);
31 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
32 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
33 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
34 ScoreRules_basics_end();
37 void LogNB(string mode, entity actor)
40 if(!autocvar_sv_eventlog)
42 s = strcat(":nexball:", mode);
44 s = strcat(s, ":", ftos(actor.playerid));
48 void ball_restart(void)
51 DropBall(self, self.owner.origin, '0 0 0');
55 void nexball_setstatus(void)
58 self.items &= ~IT_KEY1;
61 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
63 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
65 self = self.ballcarried;
66 DropBall(self, self.owner.origin, '0 0 0');
71 self.items |= IT_KEY1;
75 void relocate_nexball(void)
77 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, TRUE, self);
82 if(!move_out_of_solid(self))
83 objerror("could not get out of solid at all!");
84 print("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
85 print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x));
86 print(" ", ftos(self.origin_y - o_y));
87 print(" ", ftos(self.origin_z - o_z), "'\n");
96 DropBall(self, ownr.origin, ownr.velocity);
97 makevectors(ownr.v_angle_y * '0 1 0');
98 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
99 ownr.flags &= ~FL_ONGROUND;
102 void GiveBall(entity plyr, entity ball)
106 if((ownr = ball.owner))
108 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
109 ownr.ballcarried = world;
113 ownr.weaponentity.state = WS_READY;
115 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
119 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
122 //setattachment(ball, plyr, "");
123 setorigin(ball, plyr.origin + plyr.view_ofs);
125 if(ball.team != plyr.team)
126 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
128 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
129 ball.team = plyr.team;
130 plyr.ballcarried = ball;
131 ball.nb_dropper = plyr;
133 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
134 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
136 ball.velocity = '0 0 0';
137 ball.movetype = MOVETYPE_NONE;
138 ball.touch = func_null;
139 ball.effects |= EF_NOSHADOW;
140 ball.scale = 1; // scale down.
142 WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
143 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
145 if(autocvar_g_nexball_basketball_delay_hold)
147 ball.think = DropOwner;
148 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
153 self.weaponentity.weapons = self.weapons;
154 self.weaponentity.switchweapon = self.weapon;
155 self.weapons = WEPSET_PORTO;
156 WEP_ACTION(WEP_PORTO, WR_RESETPLAYER);
157 self.switchweapon = WEP_PORTO;
158 W_SwitchWeapon(WEP_PORTO);
162 void DropBall(entity ball, vector org, vector vel)
164 ball.effects |= autocvar_g_nexball_basketball_effects_default;
165 ball.effects &= ~EF_NOSHADOW;
166 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
168 setattachment(ball, world, "");
169 setorigin(ball, org);
170 ball.movetype = MOVETYPE_BOUNCE;
171 ball.flags &= ~FL_ONGROUND;
172 ball.scale = ball_scale;
174 ball.nb_droptime = time;
175 ball.touch = basketball_touch;
176 ball.think = ResetBall;
177 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
179 if(ball.owner.metertime)
181 ball.owner.metertime = 0;
182 ball.owner.weaponentity.state = WS_READY;
185 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
186 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
187 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
189 ball.owner.ballcarried = world;
196 self.flags &= ~FL_ONGROUND;
197 self.movetype = MOVETYPE_BOUNCE;
198 if(self.classname == "nexball_basketball")
199 self.touch = basketball_touch;
200 else if(self.classname == "nexball_football")
201 self.touch = football_touch;
203 self.think = ResetBall;
204 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
208 sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
209 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
210 LogNB("init", world);
215 if(self.cnt < 2) // step 1
217 if(time == self.teamtime)
218 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
220 self.touch = func_null;
221 self.movetype = MOVETYPE_NOCLIP;
222 self.velocity = '0 0 0'; // just in case?
224 LogNB("resetidle", world);
226 self.nextthink = time;
228 else if(self.cnt < 4) // step 2 and 3
230 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
231 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
232 self.nextthink = time + 0.5;
237 // dprint("Step 4: time: ", ftos(time), "\n");
238 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
239 dprint("The ball moved too far away from its spawn origin.\nOffset: ",
240 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
241 self.velocity = '0 0 0';
242 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
243 self.movetype = MOVETYPE_NONE;
244 self.think = InitBall;
245 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
249 void football_touch(void)
251 if(other.solid == SOLID_BSP)
253 if(time > self.lastground + 0.1)
255 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
256 self.lastground = time;
258 if(vlen(self.velocity) && !self.cnt)
259 self.nextthink = time + autocvar_g_nexball_delay_idle;
262 if (!IS_PLAYER(other))
267 self.nextthink = time + autocvar_g_nexball_delay_idle;
270 self.team = other.team;
272 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
274 if(vlen(other.velocity))
275 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
277 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
279 makevectors(other.v_angle);
280 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
282 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
284 makevectors(other.v_angle_y * '0 1 0');
285 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
287 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
289 makevectors(other.v_angle);
290 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
292 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
295 void basketball_touch(void)
297 if(other.ballcarried)
302 if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
304 if(other.health <= 0)
306 LogNB("caught", other);
307 GiveBall(other, self);
309 else if(other.solid == SOLID_BSP)
311 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
312 if(vlen(self.velocity) && !self.cnt)
313 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
320 float isclient, pscore, otherteam;
324 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
325 ball = other.ballcarried;
328 if(ball.classname != "nexball_basketball")
329 if(ball.classname != "nexball_football")
331 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
337 otherteam = OtherTeam(ball.team);
341 if((isclient = IS_CLIENT(ball.pusher)))
342 pname = ball.pusher.netname;
344 pname = "Someone (?)";
346 if(ball.team == self.team) //owngoal (regular goals)
348 LogNB("owngoal", ball.pusher);
349 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
352 else if(self.team == GOAL_FAULT)
354 LogNB("fault", ball.pusher);
356 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
358 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
361 else if(self.team == GOAL_OUT)
363 LogNB("out", ball.pusher);
364 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
365 bprint(pname, "^7 went out of bounds.\n");
367 bprint("The ball was returned.\n");
372 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
373 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
377 sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
379 if(ball.team && pscore)
381 if(nb_teams == 2 && pscore < 0)
382 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
384 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
389 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
391 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
394 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
395 DropBall(ball, ball.owner.origin, ball.owner.velocity);
397 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
400 ball.think = ResetBall;
401 if(ball.classname == "nexball_basketball")
402 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
403 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
406 //=======================//
408 //=======================//
409 void spawnfunc_nexball_team(void)
416 self.team = self.cnt + 1;
419 void nb_spawnteam(string teamname, float teamcolor)
421 dprint("^2spawned team ", teamname, "\n");
424 e.classname = "nexball_team";
425 e.netname = teamname;
431 void nb_spawnteams(void)
433 float t_r = 0, t_b = 0, t_y = 0, t_p = 0;
435 for(e = world; (e = find(e, classname, "nexball_goal"));)
442 nb_spawnteam("Red", e.team-1) ;
449 nb_spawnteam("Blue", e.team-1) ;
456 nb_spawnteam("Yellow", e.team-1);
463 nb_spawnteam("Pink", e.team-1) ;
471 void nb_delayedinit(void)
473 if(find(world, classname, "nexball_team") == world)
475 nb_ScoreRules(nb_teams);
479 //=======================//
481 //=======================//
485 if(!g_nexball) { remove(self); return; }
487 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
491 self.model = "models/nexball/ball.md3";
495 precache_model(self.model);
496 setmodel(self, self.model);
497 setsize(self, BALL_MINS, BALL_MAXS);
498 ball_scale = self.scale;
501 self.spawnorigin = self.origin;
503 self.effects = self.effects | EF_LOWPRECISION;
505 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
507 self.glow_color = autocvar_g_nexball_trail_color;
508 self.glow_trail = TRUE;
511 self.movetype = MOVETYPE_FLY;
513 if(!autocvar_g_nexball_sound_bounce)
515 else if(self.noise == "")
516 self.noise = "sound/nexball/bounce.wav";
517 //bounce sound placeholder (FIXME)
518 if(self.noise1 == "")
519 self.noise1 = "sound/nexball/drop.wav";
520 //ball drop sound placeholder (FIXME)
521 if(self.noise2 == "")
522 self.noise2 = "sound/nexball/steal.wav";
523 //stealing sound placeholder (FIXME)
524 if(self.noise) precache_sound(self.noise);
525 precache_sound(self.noise1);
526 precache_sound(self.noise2);
528 WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
530 self.reset = ball_restart;
531 self.think = InitBall;
532 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
535 void spawnfunc_nexball_basketball(void)
537 nexball_mode |= NBM_BASKETBALL;
538 self.classname = "nexball_basketball";
539 if (!(balls & BALL_BASKET))
542 CVTOV(g_nexball_basketball_effects_default);
543 CVTOV(g_nexball_basketball_delay_hold);
544 CVTOV(g_nexball_basketball_delay_hold_forteam);
545 CVTOV(g_nexball_basketball_teamsteal);
547 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
550 self.effects = autocvar_g_nexball_basketball_effects_default;
551 self.solid = SOLID_TRIGGER;
552 balls |= BALL_BASKET;
553 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
554 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
558 void spawnfunc_nexball_football(void)
560 nexball_mode |= NBM_FOOTBALL;
561 self.classname = "nexball_football";
562 self.solid = SOLID_TRIGGER;
564 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
565 self.bouncestop = autocvar_g_nexball_football_bouncestop;
569 float nb_Goal_Customize()
572 e = WaypointSprite_getviewentity(other);
573 wp_owner = self.owner;
574 if(SAME_TEAM(e, wp_owner)) { return FALSE; }
581 if(!g_nexball) { remove(self); return; }
585 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
587 WaypointSprite_SpawnFixed("goal", (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE, ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0'));
588 self.sprite.customizeentityforclient = nb_Goal_Customize;
591 self.classname = "nexball_goal";
593 self.noise = "ctf/respawn.wav";
594 precache_sound(self.noise);
595 self.touch = GoalTouch;
598 void spawnfunc_nexball_redgoal(void)
600 self.team = NUM_TEAM_1;
603 void spawnfunc_nexball_bluegoal(void)
605 self.team = NUM_TEAM_2;
608 void spawnfunc_nexball_yellowgoal(void)
610 self.team = NUM_TEAM_3;
613 void spawnfunc_nexball_pinkgoal(void)
615 self.team = NUM_TEAM_4;
619 void spawnfunc_nexball_fault(void)
621 self.team = GOAL_FAULT;
623 self.noise = "misc/typehit.wav";
627 void spawnfunc_nexball_out(void)
629 self.team = GOAL_OUT;
631 self.noise = "misc/typehit.wav";
636 //Spawnfuncs preserved for compatibility
639 void spawnfunc_ball(void)
641 spawnfunc_nexball_football();
643 void spawnfunc_ball_football(void)
645 spawnfunc_nexball_football();
647 void spawnfunc_ball_basketball(void)
649 spawnfunc_nexball_basketball();
651 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
652 void spawnfunc_ball_redgoal(void)
654 spawnfunc_nexball_bluegoal(); // I blame Revenant
656 void spawnfunc_ball_bluegoal(void)
658 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
660 void spawnfunc_ball_fault(void)
662 spawnfunc_nexball_fault();
664 void spawnfunc_ball_bound(void)
666 spawnfunc_nexball_out();
669 //=======================//
671 //=======================//
674 void W_Nexball_Think()
676 //dprint("W_Nexball_Think\n");
677 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
678 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
679 vector old_dir = normalize(self.velocity);
680 float _speed = vlen(self.velocity);
681 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
682 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
684 self.velocity = new_vel;
686 self.nextthink = time;
689 void W_Nexball_Touch(void)
691 entity ball, attacker;
692 attacker = self.owner;
693 //self.think = func_null;
694 //self.enemy = world;
697 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
698 if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
700 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
701 other.flags &= ~FL_ONGROUND;
702 if(!attacker.ballcarried)
704 LogNB("stole", attacker);
705 sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
707 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
709 attacker.teamkill_complain = time + 5;
710 attacker.teamkill_soundtime = time + 0.4;
711 attacker.teamkill_soundsource = other;
714 GiveBall(attacker, other.ballcarried);
720 void W_Nexball_Attack(float t)
724 if(!(ball = self.ballcarried))
727 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
728 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
732 self.metertime = 0; // Shot failed, hide the power meter
736 //Calculate multiplier
741 mi = autocvar_g_nexball_basketball_meter_minpower;
742 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
743 //One triangle wave period with 1 as max
744 mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
747 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
750 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE));
753 //TODO: use the speed_up cvar too ??
756 void W_Nexball_Attack2(void)
758 if(self.ballcarried.enemy)
760 entity _ball = self.ballcarried;
761 W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
762 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
763 _ball.think = W_Nexball_Think;
764 _ball.nextthink = time;
768 if(!autocvar_g_nexball_tackling)
772 if(!(balls & BALL_BASKET))
774 W_SetupShot(self, FALSE, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
775 // pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
778 missile.owner = self;
779 missile.classname = "ballstealer";
781 missile.movetype = MOVETYPE_FLY;
782 PROJECTILE_MAKETRIGGER(missile);
784 //setmodel(missile, "models/elaser.mdl"); // precision set below
785 setsize(missile, '0 0 0', '0 0 0');
786 setorigin(missile, w_shotorg);
788 W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
789 missile.angles = vectoangles(missile.velocity);
790 missile.touch = W_Nexball_Touch;
791 missile.think = SUB_Remove;
792 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
794 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
795 missile.flags = FL_PROJECTILE;
797 CSQCProjectile(missile, TRUE, PROJECTILE_ELECTRO, TRUE);
800 float ball_customize()
804 self.effects &= ~EF_FLAME;
806 self.customizeentityforclient = func_null;
810 if(other == self.owner)
812 self.scale = autocvar_g_nexball_viewmodel_scale;
814 self.effects |= EF_FLAME;
816 self.effects &= ~EF_FLAME;
820 self.effects &= ~EF_FLAME;
827 float w_nexball_weapon(float req)
832 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
833 if(autocvar_g_nexball_basketball_meter)
835 if(self.ballcarried && !self.metertime)
836 self.metertime = time;
838 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
842 W_Nexball_Attack(-1);
843 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
845 if(self.BUTTON_ATCK2)
846 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
849 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
852 if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
854 W_Nexball_Attack(time - self.metertime);
855 // DropBall or stealing will set metertime back to 0
856 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
859 else if(req == WR_INIT)
861 precache_model("models/weapons/g_porto.md3");
862 precache_model("models/weapons/v_porto.md3");
863 precache_model("models/weapons/h_porto.iqm");
864 precache_model("models/elaser.mdl");
865 precache_sound("nexball/shoot1.wav");
866 precache_sound("nexball/shoot2.wav");
867 precache_sound("misc/typehit.wav");
869 else if(req == WR_SETUP)
871 //weapon_setup(WEP_PORTO);
873 // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE
877 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
879 if(self.ballcarried && g_nexball)
880 DropBall(self.ballcarried, self.origin, self.velocity);
885 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
887 makevectors(self.v_angle);
888 if(nexball_mode & NBM_BASKETBALL)
893 self.ballcarried.velocity = self.velocity;
894 self.ballcarried.customizeentityforclient = ball_customize;
896 setorigin(self.ballcarried, self.origin + self.view_ofs +
897 v_forward * autocvar_g_nexball_viewmodel_offset_x +
898 v_right * autocvar_g_nexball_viewmodel_offset_y +
899 v_up * autocvar_g_nexball_viewmodel_offset_z);
902 if(autocvar_g_nexball_safepass_maxdist)
904 if(self.ballcarried.wait < time && self.ballcarried.enemy)
906 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
907 self.ballcarried.enemy = world;
911 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
912 crosshair_trace(self);
914 IS_CLIENT(trace_ent) &&
915 trace_ent.deadflag == DEAD_NO &&
916 trace_ent.team == self.team &&
917 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
920 //if(self.ballcarried.enemy != trace_ent)
921 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
922 self.ballcarried.enemy = trace_ent;
923 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
931 if(self.weaponentity.weapons)
933 self.weapons = self.weaponentity.weapons;
934 WEP_ACTION(WEP_PORTO, WR_RESETPLAYER);
935 self.switchweapon = self.weaponentity.switchweapon;
936 W_SwitchWeapon(self.switchweapon);
938 self.weaponentity.weapons = '0 0 0';
949 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
951 self.weaponentity.weapons = '0 0 0';
953 if(nexball_mode & NBM_BASKETBALL)
954 self.weapons |= WEPSET_PORTO;
956 self.weapons = '0 0 0';
961 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
965 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
966 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
971 MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
973 start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
978 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
980 if(self.weapon == WEP_MORTAR)
986 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
988 if(self.classname == "droppedweapon")
989 if(self.weapon == WEP_MORTAR)
995 MUTATOR_DEFINITION(gamemode_nexball)
997 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
998 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
999 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
1000 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
1001 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
1002 MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
1003 MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
1004 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
1005 MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
1009 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1010 if(g_nexball_meter_period <= 0)
1011 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1012 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1013 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
1017 CVTOV(g_nexball_football_boost_forward); //100
1018 CVTOV(g_nexball_football_boost_up); //200
1019 CVTOV(g_nexball_delay_idle); //10
1020 CVTOV(g_nexball_football_physics); //0
1022 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
1024 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
1027 MUTATOR_ONROLLBACK_OR_REMOVE
1029 // we actually cannot roll back nb_delayedinit here
1030 // BUT: we don't need to! If this gets called, adding always
1036 print("This is a game type and it cannot be removed at runtime.");