1 #include "gamemode_nexball.qh"
6 float autocvar_g_nexball_basketball_bouncefactor;
7 float autocvar_g_nexball_basketball_bouncestop;
8 float autocvar_g_nexball_basketball_carrier_highspeed;
9 bool autocvar_g_nexball_basketball_meter;
10 float autocvar_g_nexball_basketball_meter_maxpower;
11 float autocvar_g_nexball_basketball_meter_minpower;
12 float autocvar_g_nexball_delay_collect;
13 float autocvar_g_nexball_delay_goal;
14 float autocvar_g_nexball_delay_start;
15 float autocvar_g_nexball_football_bouncefactor;
16 float autocvar_g_nexball_football_bouncestop;
17 bool autocvar_g_nexball_radar_showallplayers;
18 bool autocvar_g_nexball_sound_bounce;
19 int autocvar_g_nexball_trail_color;
21 float autocvar_g_nexball_safepass_turnrate;
22 float autocvar_g_nexball_safepass_maxdist;
23 float autocvar_g_nexball_safepass_holdtime;
24 float autocvar_g_nexball_viewmodel_scale;
25 float autocvar_g_nexball_tackling;
26 vector autocvar_g_nexball_viewmodel_offset;
28 void basketball_touch();
29 void football_touch();
31 const float NBM_NONE = 0;
32 const float NBM_FOOTBALL = 2;
33 const float NBM_BASKETBALL = 4;
36 float OtherTeam(float t) //works only if there are two teams on the map!
39 e = find(world, classname, "nexball_team");
41 e = find(e, classname, "nexball_team");
45 const float ST_NEXBALL_GOALS = 1;
46 const float SP_NEXBALL_GOALS = 4;
47 const float SP_NEXBALL_FAULTS = 5;
48 void nb_ScoreRules(float teams)
50 ScoreRules_basics(teams, 0, 0, true);
51 ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
52 ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
53 ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
54 ScoreRules_basics_end();
57 void LogNB(string mode, entity actor)
60 if(!autocvar_sv_eventlog)
62 s = strcat(":nexball:", mode);
64 s = strcat(s, ":", ftos(actor.playerid));
68 void ball_restart(void)
71 DropBall(self, self.owner.origin, '0 0 0');
75 void nexball_setstatus(void)
77 self.items &= ~IT_KEY1;
80 if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
82 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
83 setself(self.ballcarried);
84 DropBall(self, self.owner.origin, '0 0 0');
89 self.items |= IT_KEY1;
93 void relocate_nexball(void)
95 tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
100 if(!move_out_of_solid(self))
101 objerror("could not get out of solid at all!");
102 LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
103 LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
104 LOG_INFO(" ", ftos(self.origin.y - o.y));
105 LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
114 DropBall(self, ownr.origin, ownr.velocity);
115 makevectors(ownr.v_angle.y * '0 1 0');
116 ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
117 ownr.flags &= ~FL_ONGROUND;
120 void GiveBall(entity plyr, entity ball)
124 if((ownr = ball.owner))
126 ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
127 ownr.ballcarried = world;
131 ownr.weaponentity.state = WS_READY;
133 WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
137 WaypointSprite_Kill(ball.waypointsprite_attachedforcarrier);
140 //setattachment(ball, plyr, "");
141 setorigin(ball, plyr.origin + plyr.view_ofs);
143 if(ball.team != plyr.team)
144 ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
146 ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
147 ball.team = plyr.team;
148 plyr.ballcarried = ball;
149 ball.nb_dropper = plyr;
151 plyr.effects |= autocvar_g_nexball_basketball_effects_default;
152 ball.effects &= ~autocvar_g_nexball_basketball_effects_default;
154 ball.velocity = '0 0 0';
155 ball.movetype = MOVETYPE_NONE;
156 ball.touch = func_null;
157 ball.effects |= EF_NOSHADOW;
158 ball.scale = 1; // scale down.
160 WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
161 WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
163 if(autocvar_g_nexball_basketball_delay_hold)
165 ball.think = DropOwner;
166 ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
169 plyr.weaponentity.weapons = plyr.weapons;
170 plyr.weaponentity.switchweapon = plyr.weapon;
171 plyr.weapons = WEPSET_NEXBALL;
173 WEP_ACTION(WEP_NEXBALL, WR_RESETPLAYER);
174 plyr.switchweapon = WEP_NEXBALL.m_id;
175 W_SwitchWeapon(WEP_NEXBALL.m_id);
179 void DropBall(entity ball, vector org, vector vel)
181 ball.effects |= autocvar_g_nexball_basketball_effects_default;
182 ball.effects &= ~EF_NOSHADOW;
183 ball.owner.effects &= ~autocvar_g_nexball_basketball_effects_default;
185 setattachment(ball, world, "");
186 setorigin(ball, org);
187 ball.movetype = MOVETYPE_BOUNCE;
188 ball.flags &= ~FL_ONGROUND;
189 ball.scale = ball_scale;
191 ball.nb_droptime = time;
192 ball.touch = basketball_touch;
193 ball.think = ResetBall;
194 ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
196 if(ball.owner.metertime)
198 ball.owner.metertime = 0;
199 ball.owner.weaponentity.state = WS_READY;
202 WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
203 WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
204 WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
206 ball.owner.ballcarried = world;
213 self.flags &= ~FL_ONGROUND;
214 self.movetype = MOVETYPE_BOUNCE;
215 if(self.classname == "nexball_basketball")
216 self.touch = basketball_touch;
217 else if(self.classname == "nexball_football")
218 self.touch = football_touch;
220 self.think = ResetBall;
221 self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
225 _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
226 WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
227 LogNB("init", world);
232 if(self.cnt < 2) // step 1
234 if(time == self.teamtime)
235 bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
237 self.touch = func_null;
238 self.movetype = MOVETYPE_NOCLIP;
239 self.velocity = '0 0 0'; // just in case?
241 LogNB("resetidle", world);
243 self.nextthink = time;
245 else if(self.cnt < 4) // step 2 and 3
247 // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
248 self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
249 self.nextthink = time + 0.5;
254 // dprint("Step 4: time: ", ftos(time), "\n");
255 if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
256 LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
257 vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
258 self.velocity = '0 0 0';
259 setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
260 self.movetype = MOVETYPE_NONE;
261 self.think = InitBall;
262 self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
266 void football_touch(void)
268 if(other.solid == SOLID_BSP)
270 if(time > self.lastground + 0.1)
272 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
273 self.lastground = time;
275 if(vlen(self.velocity) && !self.cnt)
276 self.nextthink = time + autocvar_g_nexball_delay_idle;
279 if (!IS_PLAYER(other))
284 self.nextthink = time + autocvar_g_nexball_delay_idle;
287 self.team = other.team;
289 if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original
291 if(vlen(other.velocity))
292 self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
294 else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point
296 makevectors(other.v_angle);
297 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up;
299 else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
301 makevectors(other.v_angle.y * '0 1 0');
302 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
304 else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
306 makevectors(other.v_angle);
307 self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
309 self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
312 void basketball_touch(void)
314 if(other.ballcarried)
319 if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
321 if(other.health <= 0)
323 LogNB("caught", other);
324 GiveBall(other, self);
326 else if(other.solid == SOLID_BSP)
328 _sound(self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
329 if(vlen(self.velocity) && !self.cnt)
330 self.nextthink = min(time + autocvar_g_nexball_delay_idle, self.teamtime);
337 float isclient, pscore, otherteam;
341 if((self.spawnflags & GOAL_TOUCHPLAYER) && other.ballcarried)
342 ball = other.ballcarried;
345 if(ball.classname != "nexball_basketball")
346 if(ball.classname != "nexball_football")
348 if((!ball.pusher && self.team != GOAL_OUT) || ball.cnt)
354 otherteam = OtherTeam(ball.team);
358 if((isclient = IS_CLIENT(ball.pusher)))
359 pname = ball.pusher.netname;
361 pname = "Someone (?)";
363 if(ball.team == self.team) //owngoal (regular goals)
365 LogNB("owngoal", ball.pusher);
366 bprint("Boo! ", pname, "^7 scored a goal against their own team!\n");
369 else if(self.team == GOAL_FAULT)
371 LogNB("fault", ball.pusher);
373 bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n");
375 bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n");
378 else if(self.team == GOAL_OUT)
380 LogNB("out", ball.pusher);
381 if((self.spawnflags & GOAL_TOUCHPLAYER) && ball.owner)
382 bprint(pname, "^7 went out of bounds.\n");
384 bprint("The ball was returned.\n");
389 LogNB(strcat("goal:", ftos(self.team)), ball.pusher);
390 bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n");
394 _sound(ball, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NONE);
396 if(ball.team && pscore)
398 if(nb_teams == 2 && pscore < 0)
399 TeamScore_AddToTeam(otherteam, ST_NEXBALL_GOALS, -pscore);
401 TeamScore_AddToTeam(ball.team, ST_NEXBALL_GOALS, pscore);
406 PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
408 PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
411 if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
412 DropBall(ball, ball.owner.origin, ball.owner.velocity);
414 WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
417 ball.think = ResetBall;
418 if(ball.classname == "nexball_basketball")
419 ball.touch = football_touch; // better than func_null: football control until the ball gets reset
420 ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
423 //=======================//
425 //=======================//
426 void spawnfunc_nexball_team(void)
433 self.team = self.cnt + 1;
436 void nb_spawnteam(string teamname, float teamcolor)
438 LOG_TRACE("^2spawned team ", teamname, "\n");
441 e.classname = "nexball_team";
442 e.netname = teamname;
448 void nb_spawnteams(void)
450 bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
452 for(e = world; (e = find(e, classname, "nexball_goal"));)
459 nb_spawnteam("Red", e.team-1) ;
466 nb_spawnteam("Blue", e.team-1) ;
473 nb_spawnteam("Yellow", e.team-1);
480 nb_spawnteam("Pink", e.team-1) ;
488 void nb_delayedinit(void)
490 if(find(world, classname, "nexball_team") == world)
492 nb_ScoreRules(nb_teams);
496 //=======================//
498 //=======================//
502 if(!g_nexball) { remove(self); return; }
504 // balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
508 self.model = "models/nexball/ball.md3";
512 precache_model(self.model);
513 _setmodel(self, self.model);
514 setsize(self, BALL_MINS, BALL_MAXS);
515 ball_scale = self.scale;
518 self.spawnorigin = self.origin;
520 self.effects = self.effects | EF_LOWPRECISION;
522 if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
524 self.glow_color = autocvar_g_nexball_trail_color;
525 self.glow_trail = true;
528 self.movetype = MOVETYPE_FLY;
530 if(!autocvar_g_nexball_sound_bounce)
532 else if(self.noise == "")
533 self.noise = SND(NB_BOUNCE);
534 //bounce sound placeholder (FIXME)
535 if(self.noise1 == "")
536 self.noise1 = SND(NB_DROP);
537 //ball drop sound placeholder (FIXME)
538 if(self.noise2 == "")
539 self.noise2 = SND(NB_STEAL);
540 //stealing sound placeholder (FIXME)
541 if(self.noise) precache_sound(self.noise);
542 precache_sound(self.noise1);
543 precache_sound(self.noise2);
545 WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
547 self.reset = ball_restart;
548 self.think = InitBall;
549 self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
552 void spawnfunc_nexball_basketball(void)
554 nexball_mode |= NBM_BASKETBALL;
555 self.classname = "nexball_basketball";
556 if (!(balls & BALL_BASKET))
559 CVTOV(g_nexball_basketball_effects_default);
560 CVTOV(g_nexball_basketball_delay_hold);
561 CVTOV(g_nexball_basketball_delay_hold_forteam);
562 CVTOV(g_nexball_basketball_teamsteal);
564 autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
567 self.effects = autocvar_g_nexball_basketball_effects_default;
568 self.solid = SOLID_TRIGGER;
569 balls |= BALL_BASKET;
570 self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
571 self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
575 void spawnfunc_nexball_football(void)
577 nexball_mode |= NBM_FOOTBALL;
578 self.classname = "nexball_football";
579 self.solid = SOLID_TRIGGER;
581 self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
582 self.bouncestop = autocvar_g_nexball_football_bouncestop;
586 float nb_Goal_Customize()
589 e = WaypointSprite_getviewentity(other);
590 wp_owner = self.owner;
591 if(SAME_TEAM(e, wp_owner)) { return false; }
598 if(!g_nexball) { remove(self); return; }
602 if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
604 entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
605 wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
606 self.sprite.customizeentityforclient = nb_Goal_Customize;
609 self.classname = "nexball_goal";
611 self.noise = "ctf/respawn.wav";
612 precache_sound(self.noise);
613 self.touch = GoalTouch;
616 void spawnfunc_nexball_redgoal(void)
618 self.team = NUM_TEAM_1;
621 void spawnfunc_nexball_bluegoal(void)
623 self.team = NUM_TEAM_2;
626 void spawnfunc_nexball_yellowgoal(void)
628 self.team = NUM_TEAM_3;
631 void spawnfunc_nexball_pinkgoal(void)
633 self.team = NUM_TEAM_4;
637 void spawnfunc_nexball_fault(void)
639 self.team = GOAL_FAULT;
641 self.noise = SND(TYPEHIT);
645 void spawnfunc_nexball_out(void)
647 self.team = GOAL_OUT;
649 self.noise = SND(TYPEHIT);
654 //Spawnfuncs preserved for compatibility
657 void spawnfunc_ball(void)
659 spawnfunc_nexball_football();
661 void spawnfunc_ball_football(void)
663 spawnfunc_nexball_football();
665 void spawnfunc_ball_basketball(void)
667 spawnfunc_nexball_basketball();
669 // The "red goal" is defended by blue team. A ball in there counts as a point for red.
670 void spawnfunc_ball_redgoal(void)
672 spawnfunc_nexball_bluegoal(); // I blame Revenant
674 void spawnfunc_ball_bluegoal(void)
676 spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p
678 void spawnfunc_ball_fault(void)
680 spawnfunc_nexball_fault();
682 void spawnfunc_ball_bound(void)
684 spawnfunc_nexball_out();
687 //=======================//
689 //=======================//
692 void W_Nexball_Think()
694 //dprint("W_Nexball_Think\n");
695 //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
696 vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
697 vector old_dir = normalize(self.velocity);
698 float _speed = vlen(self.velocity);
699 vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
700 //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
702 self.velocity = new_vel;
704 self.nextthink = time;
707 void W_Nexball_Touch(void)
709 entity ball, attacker;
710 attacker = self.owner;
711 //self.think = func_null;
712 //self.enemy = world;
715 if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
716 if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
718 other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
719 other.flags &= ~FL_ONGROUND;
720 if(!attacker.ballcarried)
722 LogNB("stole", attacker);
723 _sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
725 if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
727 attacker.teamkill_complain = time + 5;
728 attacker.teamkill_soundtime = time + 0.4;
729 attacker.teamkill_soundsource = other;
732 GiveBall(attacker, other.ballcarried);
738 void W_Nexball_Attack(float t)
742 if(!(ball = self.ballcarried))
745 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
746 tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
750 self.metertime = 0; // Shot failed, hide the power meter
754 //Calculate multiplier
759 mi = autocvar_g_nexball_basketball_meter_minpower;
760 ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
761 //One triangle wave period with 1 as max
762 mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
765 mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
768 DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
771 //TODO: use the speed_up cvar too ??
774 void W_Nexball_Attack2(void)
776 if(self.ballcarried.enemy)
778 entity _ball = self.ballcarried;
779 W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
780 DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
781 _ball.think = W_Nexball_Think;
782 _ball.nextthink = time;
786 if(!autocvar_g_nexball_tackling)
790 if(!(balls & BALL_BASKET))
792 W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
795 missile.owner = self;
796 missile.classname = "ballstealer";
798 missile.movetype = MOVETYPE_FLY;
799 PROJECTILE_MAKETRIGGER(missile);
801 //setmodel(missile, "models/elaser.mdl"); // precision set below
802 setsize(missile, '0 0 0', '0 0 0');
803 setorigin(missile, w_shotorg);
805 W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
806 missile.angles = vectoangles(missile.velocity);
807 missile.touch = W_Nexball_Touch;
808 missile.think = SUB_Remove;
809 missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
811 missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
812 missile.flags = FL_PROJECTILE;
814 CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
817 float ball_customize()
821 self.effects &= ~EF_FLAME;
823 self.customizeentityforclient = func_null;
827 if(other == self.owner)
829 self.scale = autocvar_g_nexball_viewmodel_scale;
831 self.effects |= EF_FLAME;
833 self.effects &= ~EF_FLAME;
837 self.effects &= ~EF_FLAME;
844 METHOD(BallStealer, wr_think, bool(BallStealer thiswep, bool fire1, bool fire2))
847 if(weapon_prepareattack(0, autocvar_g_balance_nexball_primary_refire))
848 if(autocvar_g_nexball_basketball_meter)
850 if(self.ballcarried && !self.metertime)
851 self.metertime = time;
853 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
857 W_Nexball_Attack(-1);
858 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
861 if(weapon_prepareattack(1, autocvar_g_balance_nexball_secondary_refire))
864 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
867 if(!fire1 && self.metertime && self.ballcarried)
869 W_Nexball_Attack(time - self.metertime);
870 // DropBall or stealing will set metertime back to 0
871 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
875 METHOD(BallStealer, wr_init, bool(BallStealer thiswep))
879 METHOD(BallStealer, wr_setup, bool(BallStealer thiswep))
881 //weapon_setup(WEP_PORTO.m_id);
884 METHOD(BallStealer, wr_aim, bool(BallStealer thiswep))
888 METHOD(BallStealer, wr_checkammo1, bool(BallStealer thiswep))
892 METHOD(BallStealer, wr_checkammo2, bool(BallStealer thiswep))
897 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
899 if(self.ballcarried && g_nexball)
900 DropBall(self.ballcarried, self.origin, self.velocity);
905 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
907 makevectors(self.v_angle);
908 if(nexball_mode & NBM_BASKETBALL)
913 self.ballcarried.velocity = self.velocity;
914 self.ballcarried.customizeentityforclient = ball_customize;
916 setorigin(self.ballcarried, self.origin + self.view_ofs +
917 v_forward * autocvar_g_nexball_viewmodel_offset.x +
918 v_right * autocvar_g_nexball_viewmodel_offset.y +
919 v_up * autocvar_g_nexball_viewmodel_offset.z);
922 if(autocvar_g_nexball_safepass_maxdist)
924 if(self.ballcarried.wait < time && self.ballcarried.enemy)
926 //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname));
927 self.ballcarried.enemy = world;
931 //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist);
932 crosshair_trace(self);
934 IS_CLIENT(trace_ent) &&
935 trace_ent.deadflag == DEAD_NO &&
936 trace_ent.team == self.team &&
937 vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
940 //if(self.ballcarried.enemy != trace_ent)
941 // centerprint(self, sprintf("Locked to %s", trace_ent.netname));
942 self.ballcarried.enemy = trace_ent;
943 self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime;
951 if(self.weaponentity.weapons)
953 self.weapons = self.weaponentity.weapons;
954 WEP_ACTION(WEP_NEXBALL, WR_RESETPLAYER);
955 self.switchweapon = self.weaponentity.switchweapon;
956 W_SwitchWeapon(self.switchweapon);
958 self.weaponentity.weapons = '0 0 0';
969 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
971 self.weaponentity.weapons = '0 0 0';
973 if(nexball_mode & NBM_BASKETBALL)
974 self.weapons |= WEPSET_NEXBALL;
976 self.weapons = '0 0 0';
981 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
985 self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
986 self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
991 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
993 if(self.weapon == WEP_MORTAR.m_id)
999 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
1001 if(self.classname == "droppedweapon")
1002 if(self.weapon == WEP_MORTAR.m_id)
1008 MUTATOR_DEFINITION(gamemode_nexball)
1010 MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
1011 MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
1012 MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
1013 MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
1014 MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
1015 MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
1016 MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
1017 MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
1021 g_nexball_meter_period = autocvar_g_nexball_meter_period;
1022 if(g_nexball_meter_period <= 0)
1023 g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
1024 g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
1025 addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
1029 CVTOV(g_nexball_football_boost_forward); //100
1030 CVTOV(g_nexball_football_boost_up); //200
1031 CVTOV(g_nexball_delay_idle); //10
1032 CVTOV(g_nexball_football_physics); //0
1034 radar_showennemies = autocvar_g_nexball_radar_showallplayers;
1036 InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
1039 MUTATOR_ONROLLBACK_OR_REMOVE
1041 // we actually cannot roll back nb_delayedinit here
1042 // BUT: we don't need to! If this gets called, adding always
1048 LOG_INFO("This is a game type and it cannot be removed at runtime.");