1 #include "gamemode_nexball.qh"
6 #include "../t_jumppads.qh"
8 float autocvar_g_nexball_safepass_turnrate;
9 float autocvar_g_nexball_safepass_maxdist;
10 float autocvar_g_nexball_safepass_holdtime;
11 float autocvar_g_nexball_viewmodel_scale;
12 float autocvar_g_nexball_tackling;
13 vector autocvar_g_nexball_viewmodel_offset;
15 void basketball_touch();
16 void football_touch();
18 const float NBM_NONE = 0;
19 const float NBM_FOOTBALL = 2;
20 const float NBM_BASKETBALL = 4;
23 float OtherTeam(float t) //works only if there are two teams on the map!
26 e = find(world, classname, "nexball_team");
28 e = find(e, classname, "nexball_team");
32 const float ST_NEXBALL_GOALS = 1;
33 const float SP_NEXBALL_GOALS = 4;
34 const float SP_NEXBALL_FAULTS = 5;
35 void nb_ScoreRules(float teams)
37 ScoreRules_basics(teams, 0, 0, true);
38 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
39 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
40 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
41 ScoreRules_basics_end();
44 void LogNB(string mode, entity actor)
47 if(!autocvar_sv_eventlog)
49 s = strcat(":nexball:", mode);
51 s = strcat(s, ":", ftos(actor.playerid));
55 void ball_restart(void)
58 DropBall(self, self.owner.origin, '0 0 0');
62 void nexball_setstatus(void)
65 self.items &= ~IT_KEY1;
68 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
70 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
72 self = self.ballcarried;
73 DropBall(self, self.owner.origin, '0 0 0');
78 self.items |= IT_KEY1;
82 void relocate_nexball(void)
84 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
89 if(!move_out_of_solid(self))
90 objerror("could not get out of solid at all!");
91 print("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
92 print(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
93 print(" ", ftos(self.origin.y - o.y));
94 print(" ", ftos(self.origin.z - o.z), "'\n");
103 DropBall(self, ownr.origin, ownr.velocity);
104 makevectors(ownr.v_angle.y * '0 1 0');
105 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
106 ownr.flags &= ~FL_ONGROUND;
109 void GiveBall(entity plyr, entity ball)
113 if((ownr = ball.owner))
115 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
116 ownr.ballcarried = world;
120 ownr.weaponentity.state = WS_READY;
122 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
126 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
129 //setattachment(ball, plyr, "");
130 setorigin(ball, plyr.origin + plyr.view_ofs);
132 if(ball.team != plyr.team)
133 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
135 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
136 ball.team = plyr.team;
137 plyr.ballcarried = ball;
138 ball.nb_dropper = plyr;
140 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
141 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
143 ball.velocity = '0 0 0';
144 ball.movetype = MOVETYPE_NONE;
145 ball.touch = func_null;
146 ball.effects |= EF_NOSHADOW;
147 ball.scale = 1; // scale down.
149 WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
150 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
152 if(autocvar_g_nexball_basketball_delay_hold)
154 ball.think = DropOwner;
155 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
160 self.weaponentity.weapons = self.weapons;
161 self.weaponentity.switchweapon = self.weapon;
162 self.weapons = WEPSET_PORTO;
163 WEP_ACTION(WEP_PORTO, WR_RESETPLAYER);
164 self.switchweapon = WEP_PORTO;
165 W_SwitchWeapon(WEP_PORTO);
169 void DropBall(entity ball, vector org, vector vel)
171 ball.effects |= autocvar_g_nexball_basketball_effects_default;
172 ball.effects &= ~EF_NOSHADOW;
173 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
175 setattachment(ball, world, "");
176 setorigin(ball, org);
177 ball.movetype = MOVETYPE_BOUNCE;
178 ball.flags &= ~FL_ONGROUND;
179 ball.scale = ball_scale;
181 ball.nb_droptime = time;
182 ball.touch = basketball_touch;
183 ball.think = ResetBall;
184 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
186 if(ball.owner.metertime)
188 ball.owner.metertime = 0;
189 ball.owner.weaponentity.state = WS_READY;
192 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
193 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
194 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
196 ball.owner.ballcarried = world;
203 self.flags &= ~FL_ONGROUND;
204 self.movetype = MOVETYPE_BOUNCE;
205 if(self.classname == "nexball_basketball")
206 self.touch = basketball_touch;
207 else if(self.classname == "nexball_football")
208 self.touch = football_touch;
210 self.think = ResetBall;
211 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
215 sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
216 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
217 LogNB("init", world);
222 if(self.cnt < 2) // step 1
224 if(time == self.teamtime)
225 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
227 self.touch = func_null;
228 self.movetype = MOVETYPE_NOCLIP;
229 self.velocity = '0 0 0'; // just in case?
231 LogNB("resetidle", world);
233 self.nextthink = time;
235 else if(self.cnt < 4) // step 2 and 3
237 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
238 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
239 self.nextthink = time + 0.5;
244 // dprint("Step 4: time: ", ftos(time), "\n");
245 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
246 dprint("The ball moved too far away from its spawn origin.\nOffset: ",
247 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
248 self.velocity = '0 0 0';
249 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
250 self.movetype = MOVETYPE_NONE;
251 self.think = InitBall;
252 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
256 void football_touch(void)
258 if(other.solid == SOLID_BSP)
260 if(time > self.lastground + 0.1)
262 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
263 self.lastground = time;
265 if(vlen(self.velocity) && !self.cnt)
266 self.nextthink = time + autocvar_g_nexball_delay_idle;
269 if (!IS_PLAYER(other))
274 self.nextthink = time + autocvar_g_nexball_delay_idle;
277 self.team = other.team;
279 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
281 if(vlen(other.velocity))
282 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
284 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
286 makevectors(other.v_angle);
287 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
289 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
291 makevectors(other.v_angle.y * '0 1 0');
292 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
294 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
296 makevectors(other.v_angle);
297 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
299 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
302 void basketball_touch(void)
304 if(other.ballcarried)
309 if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
311 if(other.health <= 0)
313 LogNB("caught", other);
314 GiveBall(other, self);
316 else if(other.solid == SOLID_BSP)
318 sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
319 if(vlen(self.velocity) && !self.cnt)
320 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
327 float isclient, pscore, otherteam;
331 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
332 ball = other.ballcarried;
335 if(ball.classname != "nexball_basketball")
336 if(ball.classname != "nexball_football")
338 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
344 otherteam = OtherTeam(ball.team);
348 if((isclient = IS_CLIENT(ball.pusher)))
349 pname = ball.pusher.netname;
351 pname = "Someone (?)";
353 if(ball.team == self.team) //owngoal (regular goals)
355 LogNB("owngoal", ball.pusher);
356 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
359 else if(self.team == GOAL_FAULT)
361 LogNB("fault", ball.pusher);
363 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
365 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
368 else if(self.team == GOAL_OUT)
370 LogNB("out", ball.pusher);
371 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
372 bprint(pname, "^7 went out of bounds.\n");
374 bprint("The ball was returned.\n");
379 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
380 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
384 sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
386 if(ball.team && pscore)
388 if(nb_teams == 2 && pscore < 0)
389 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
391 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
396 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
398 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
401 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
402 DropBall(ball, ball.owner.origin, ball.owner.velocity);
404 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
407 ball.think = ResetBall;
408 if(ball.classname == "nexball_basketball")
409 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
410 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
413 //=======================//
415 //=======================//
416 void spawnfunc_nexball_team(void)
423 self.team = self.cnt + 1;
426 void nb_spawnteam(string teamname, float teamcolor)
428 dprint("^2spawned team ", teamname, "\n");
431 e.classname = "nexball_team";
432 e.netname = teamname;
438 void nb_spawnteams(void)
440 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
442 for(e = world; (e = find(e, classname, "nexball_goal"));)
449 nb_spawnteam("Red", e.team-1) ;
456 nb_spawnteam("Blue", e.team-1) ;
463 nb_spawnteam("Yellow", e.team-1);
470 nb_spawnteam("Pink", e.team-1) ;
478 void nb_delayedinit(void)
480 if(find(world, classname, "nexball_team") == world)
482 nb_ScoreRules(nb_teams);
486 //=======================//
488 //=======================//
492 if(!g_nexball) { remove(self); return; }
494 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
498 self.model = "models/nexball/ball.md3";
502 precache_model(self.model);
503 setmodel(self, self.model);
504 setsize(self, BALL_MINS, BALL_MAXS);
505 ball_scale = self.scale;
508 self.spawnorigin = self.origin;
510 self.effects = self.effects | EF_LOWPRECISION;
512 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
514 self.glow_color = autocvar_g_nexball_trail_color;
515 self.glow_trail = true;
518 self.movetype = MOVETYPE_FLY;
520 if(!autocvar_g_nexball_sound_bounce)
522 else if(self.noise == "")
523 self.noise = "sound/nexball/bounce.wav";
524 //bounce sound placeholder (FIXME)
525 if(self.noise1 == "")
526 self.noise1 = "sound/nexball/drop.wav";
527 //ball drop sound placeholder (FIXME)
528 if(self.noise2 == "")
529 self.noise2 = "sound/nexball/steal.wav";
530 //stealing sound placeholder (FIXME)
531 if(self.noise) precache_sound(self.noise);
532 precache_sound(self.noise1);
533 precache_sound(self.noise2);
535 WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
537 self.reset = ball_restart;
538 self.think = InitBall;
539 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
542 void spawnfunc_nexball_basketball(void)
544 nexball_mode |= NBM_BASKETBALL;
545 self.classname = "nexball_basketball";
546 if (!(balls & BALL_BASKET))
549 CVTOV(g_nexball_basketball_effects_default);
550 CVTOV(g_nexball_basketball_delay_hold);
551 CVTOV(g_nexball_basketball_delay_hold_forteam);
552 CVTOV(g_nexball_basketball_teamsteal);
554 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
557 self.effects = autocvar_g_nexball_basketball_effects_default;
558 self.solid = SOLID_TRIGGER;
559 balls |= BALL_BASKET;
560 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
561 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
565 void spawnfunc_nexball_football(void)
567 nexball_mode |= NBM_FOOTBALL;
568 self.classname = "nexball_football";
569 self.solid = SOLID_TRIGGER;
571 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
572 self.bouncestop = autocvar_g_nexball_football_bouncestop;
576 float nb_Goal_Customize()
579 e = WaypointSprite_getviewentity(other);
580 wp_owner = self.owner;
581 if(SAME_TEAM(e, wp_owner)) { return false; }
588 if(!g_nexball) { remove(self); return; }
592 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
594 WaypointSprite_SpawnFixed("goal", (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE, ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0'));
595 self.sprite.customizeentityforclient = nb_Goal_Customize;
598 self.classname = "nexball_goal";
600 self.noise = "ctf/respawn.wav";
601 precache_sound(self.noise);
602 self.touch = GoalTouch;
605 void spawnfunc_nexball_redgoal(void)
607 self.team = NUM_TEAM_1;
610 void spawnfunc_nexball_bluegoal(void)
612 self.team = NUM_TEAM_2;
615 void spawnfunc_nexball_yellowgoal(void)
617 self.team = NUM_TEAM_3;
620 void spawnfunc_nexball_pinkgoal(void)
622 self.team = NUM_TEAM_4;
626 void spawnfunc_nexball_fault(void)
628 self.team = GOAL_FAULT;
630 self.noise = "misc/typehit.wav";
634 void spawnfunc_nexball_out(void)
636 self.team = GOAL_OUT;
638 self.noise = "misc/typehit.wav";
643 //Spawnfuncs preserved for compatibility
646 void spawnfunc_ball(void)
648 spawnfunc_nexball_football();
650 void spawnfunc_ball_football(void)
652 spawnfunc_nexball_football();
654 void spawnfunc_ball_basketball(void)
656 spawnfunc_nexball_basketball();
658 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
659 void spawnfunc_ball_redgoal(void)
661 spawnfunc_nexball_bluegoal(); // I blame Revenant
663 void spawnfunc_ball_bluegoal(void)
665 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
667 void spawnfunc_ball_fault(void)
669 spawnfunc_nexball_fault();
671 void spawnfunc_ball_bound(void)
673 spawnfunc_nexball_out();
676 //=======================//
678 //=======================//
681 void W_Nexball_Think()
683 //dprint("W_Nexball_Think\n");
684 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
685 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
686 vector old_dir = normalize(self.velocity);
687 float _speed = vlen(self.velocity);
688 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
689 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
691 self.velocity = new_vel;
693 self.nextthink = time;
696 void W_Nexball_Touch(void)
698 entity ball, attacker;
699 attacker = self.owner;
700 //self.think = func_null;
701 //self.enemy = world;
704 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
705 if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
707 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
708 other.flags &= ~FL_ONGROUND;
709 if(!attacker.ballcarried)
711 LogNB("stole", attacker);
712 sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
714 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
716 attacker.teamkill_complain = time + 5;
717 attacker.teamkill_soundtime = time + 0.4;
718 attacker.teamkill_soundsource = other;
721 GiveBall(attacker, other.ballcarried);
727 void W_Nexball_Attack(float t)
731 if(!(ball = self.ballcarried))
734 W_SetupShot(self, false, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
735 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
739 self.metertime = 0; // Shot failed, hide the power meter
743 //Calculate multiplier
748 mi = autocvar_g_nexball_basketball_meter_minpower;
749 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
750 //One triangle wave period with 1 as max
751 mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
754 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
757 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
760 //TODO: use the speed_up cvar too ??
763 void W_Nexball_Attack2(void)
765 if(self.ballcarried.enemy)
767 entity _ball = self.ballcarried;
768 W_SetupShot(self, false, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
769 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
770 _ball.think = W_Nexball_Think;
771 _ball.nextthink = time;
775 if(!autocvar_g_nexball_tackling)
779 if(!(balls & BALL_BASKET))
781 W_SetupShot(self, false, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
782 // pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
785 missile.owner = self;
786 missile.classname = "ballstealer";
788 missile.movetype = MOVETYPE_FLY;
789 PROJECTILE_MAKETRIGGER(missile);
791 //setmodel(missile, "models/elaser.mdl"); // precision set below
792 setsize(missile, '0 0 0', '0 0 0');
793 setorigin(missile, w_shotorg);
795 W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
796 missile.angles = vectoangles(missile.velocity);
797 missile.touch = W_Nexball_Touch;
798 missile.think = SUB_Remove;
799 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
801 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
802 missile.flags = FL_PROJECTILE;
804 CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
807 float ball_customize()
811 self.effects &= ~EF_FLAME;
813 self.customizeentityforclient = func_null;
817 if(other == self.owner)
819 self.scale = autocvar_g_nexball_viewmodel_scale;
821 self.effects |= EF_FLAME;
823 self.effects &= ~EF_FLAME;
827 self.effects &= ~EF_FLAME;
834 float w_nexball_weapon(float req)
839 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
840 if(autocvar_g_nexball_basketball_meter)
842 if(self.ballcarried && !self.metertime)
843 self.metertime = time;
845 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
849 W_Nexball_Attack(-1);
850 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
852 if(self.BUTTON_ATCK2)
853 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
856 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
859 if(!self.BUTTON_ATCK && self.metertime && self.ballcarried)
861 W_Nexball_Attack(time - self.metertime);
862 // DropBall or stealing will set metertime back to 0
863 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
866 else if(req == WR_INIT)
868 precache_model("models/weapons/g_porto.md3");
869 precache_model("models/weapons/v_porto.md3");
870 precache_model("models/weapons/h_porto.iqm");
871 precache_model("models/elaser.mdl");
872 precache_sound("nexball/shoot1.wav");
873 precache_sound("nexball/shoot2.wav");
874 precache_sound("misc/typehit.wav");
876 else if(req == WR_SETUP)
878 //weapon_setup(WEP_PORTO);
880 // No need to check WR_CHECKAMMO* or WR_AIM, it should always return true
884 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
886 if(self.ballcarried && g_nexball)
887 DropBall(self.ballcarried, self.origin, self.velocity);
892 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
894 makevectors(self.v_angle);
895 if(nexball_mode & NBM_BASKETBALL)
900 self.ballcarried.velocity = self.velocity;
901 self.ballcarried.customizeentityforclient = ball_customize;
903 setorigin(self.ballcarried, self.origin + self.view_ofs +
904 v_forward * autocvar_g_nexball_viewmodel_offset.x +
905 v_right * autocvar_g_nexball_viewmodel_offset.y +
906 v_up * autocvar_g_nexball_viewmodel_offset.z);
909 if(autocvar_g_nexball_safepass_maxdist)
911 if(self.ballcarried.wait < time && self.ballcarried.enemy)
913 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
914 self.ballcarried.enemy = world;
918 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
919 crosshair_trace(self);
921 IS_CLIENT(trace_ent) &&
922 trace_ent.deadflag == DEAD_NO &&
923 trace_ent.team == self.team &&
924 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
927 //if(self.ballcarried.enemy != trace_ent)
928 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
929 self.ballcarried.enemy = trace_ent;
930 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
938 if(self.weaponentity.weapons)
940 self.weapons = self.weaponentity.weapons;
941 WEP_ACTION(WEP_PORTO, WR_RESETPLAYER);
942 self.switchweapon = self.weaponentity.switchweapon;
943 W_SwitchWeapon(self.switchweapon);
945 self.weaponentity.weapons = '0 0 0';
956 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
958 self.weaponentity.weapons = '0 0 0';
960 if(nexball_mode & NBM_BASKETBALL)
961 self.weapons |= WEPSET_PORTO;
963 self.weapons = '0 0 0';
968 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
972 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
973 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
978 MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
980 start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
985 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
987 if(self.weapon == WEP_MORTAR)
993 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
995 if(self.classname == "droppedweapon")
996 if(self.weapon == WEP_MORTAR)
1002 MUTATOR_DEFINITION(gamemode_nexball)
1004 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
1005 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
1006 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
1007 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
1008 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
1009 MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
1010 MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
1011 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
1012 MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
1016 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1017 if(g_nexball_meter_period <= 0)
1018 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1019 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1020 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
1024 CVTOV(g_nexball_football_boost_forward); //100
1025 CVTOV(g_nexball_football_boost_up); //200
1026 CVTOV(g_nexball_delay_idle); //10
1027 CVTOV(g_nexball_football_physics); //0
1029 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
1031 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
1034 MUTATOR_ONROLLBACK_OR_REMOVE
1036 // we actually cannot roll back nb_delayedinit here
1037 // BUT: we don't need to! If this gets called, adding always
1043 print("This is a game type and it cannot be removed at runtime.");