#ifdef IMPLEMENTATION
#ifdef SVQC
-.float metertime;
+.float metertime = _STAT(NB_METERSTART);
int autocvar_g_nexball_goalleadlimit;
#define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
+bool autocvar_g_nexball_basketball_jumppad = true;
float autocvar_g_nexball_basketball_bouncefactor;
float autocvar_g_nexball_basketball_bouncestop;
float autocvar_g_nexball_basketball_carrier_highspeed;
float autocvar_g_nexball_delay_collect;
float autocvar_g_nexball_delay_goal;
float autocvar_g_nexball_delay_start;
+bool autocvar_g_nexball_football_jumppad = true;
float autocvar_g_nexball_football_bouncefactor;
float autocvar_g_nexball_football_bouncestop;
bool autocvar_g_nexball_radar_showallplayers;
DropBall(self, ownr.origin, ownr.velocity);
makevectors(ownr.v_angle.y * '0 1 0');
ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
- ownr.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(ownr);
}
void GiveBall(entity plyr, entity ball)
}
plyr.(weaponentity).weapons = plyr.weapons;
- plyr.(weaponentity).switchweapon = plyr.weapon;
+ plyr.(weaponentity).m_switchweapon = PS(plyr).m_weapon;
plyr.weapons = WEPSET(NEXBALL);
setself(plyr);
Weapon w = WEP_NEXBALL;
w.wr_resetplayer(w);
- plyr.switchweapon = WEP_NEXBALL.m_id;
- W_SwitchWeapon(WEP_NEXBALL.m_id);
+ PS(plyr).m_switchweapon = WEP_NEXBALL;
+ W_SwitchWeapon(WEP_NEXBALL);
setself(this);
}
setattachment(ball, world, "");
setorigin(ball, org);
ball.movetype = MOVETYPE_BOUNCE;
- ball.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(ball);
ball.scale = ball_scale;
ball.velocity = vel;
ball.nb_droptime = time;
void InitBall()
{SELFPARAM();
if(gameover) return;
- self.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(self);
self.movetype = MOVETYPE_BOUNCE;
if(self.classname == "nexball_basketball")
self.touch = basketball_touch;
football_touch();
return;
}
- if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
+ if(!self.cnt && IS_PLAYER(other) && !STAT(FROZEN, other) && !IS_DEAD(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
{
if(other.health <= 0)
return;
}
}
-void nb_delayedinit()
+void nb_delayedinit(entity this)
{
if(find(world, classname, "nexball_team") == world)
nb_spawnteams();
if(!self.effects)
self.effects = autocvar_g_nexball_basketball_effects_default;
self.solid = SOLID_TRIGGER;
+ self.pushable = autocvar_g_nexball_basketball_jumppad;
balls |= BALL_BASKET;
self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
self.classname = "nexball_football";
self.solid = SOLID_TRIGGER;
balls |= BALL_FOOT;
+ self.pushable = autocvar_g_nexball_football_jumppad;
self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
self.bouncestop = autocvar_g_nexball_football_bouncestop;
SpawnBall();
PROJECTILE_TOUCH;
if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
- if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
+ if((ball = other.ballcarried) && !STAT(FROZEN, other) && !IS_DEAD(other) && (IS_PLAYER(attacker)))
{
other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
- other.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(other);
if(!attacker.ballcarried)
{
LogNB("stole", attacker);
if(!(ball = self.ballcarried))
return;
- W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
+ W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
if(trace_startsolid)
{
if(self.ballcarried.enemy)
{
entity _ball = self.ballcarried;
- W_SetupShot(self, false, 4, SND(NB_SHOOT1), CH_WEAPON_A, 0);
+ W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
_ball.think = W_Nexball_Think;
_ball.nextthink = time;
if(!autocvar_g_nexball_tackling)
return;
- W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
+ W_SetupShot(self, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
entity missile = new(ballstealer);
missile.owner = self;
return true;
}
- METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
- {
- if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire))
- if(autocvar_g_nexball_basketball_meter)
- {
- if(self.ballcarried && !self.metertime)
- self.metertime = time;
- else
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
- }
- else
- {
- W_Nexball_Attack(-1);
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
- }
- if(fire & 2)
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
- {
- W_Nexball_Attack2();
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
- }
+METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
+{
+ SELFPARAM();
+ TC(BallStealer, thiswep);
+ if(fire & 1)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire))
+ if(autocvar_g_nexball_basketball_meter)
+ {
+ if(self.ballcarried && !self.metertime)
+ self.metertime = time;
+ else
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+ }
+ else
+ {
+ W_Nexball_Attack(-1);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+ }
+ if(fire & 2)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
+ {
+ W_Nexball_Attack2();
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
+ }
+
+ if(!(fire & 1) && self.metertime && self.ballcarried)
+ {
+ W_Nexball_Attack(time - self.metertime);
+ // DropBall or stealing will set metertime back to 0
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+ }
+}
- if(!(fire & 1) && self.metertime && self.ballcarried)
- {
- W_Nexball_Attack(time - self.metertime);
- // DropBall or stealing will set metertime back to 0
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
- }
- }
- METHOD(BallStealer, wr_setup, void(BallStealer thiswep))
- {
- //weapon_setup(WEP_PORTO.m_id);
- }
- METHOD(BallStealer, wr_checkammo1, bool(BallStealer thiswep))
- {
- return true;
- }
- METHOD(BallStealer, wr_checkammo2, bool(BallStealer thiswep))
- {
- return true;
- }
+METHOD(BallStealer, wr_setup, void(BallStealer this))
+{
+ TC(BallStealer, this);
+ //weapon_setup(WEP_PORTO.m_id);
+}
+
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this))
+{
+ TC(BallStealer, this);
+ return true;
+}
+
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this))
+{
+ TC(BallStealer, this);
+ return true;
+}
void nb_DropBall(entity player)
{
}
MUTATOR_HOOKFUNCTION(nb, PlayerDies)
-{SELFPARAM();
- nb_DropBall(self);
+{
+ nb_DropBall(frag_target);
return false;
}
self.ballcarried.velocity = self.velocity;
self.ballcarried.customizeentityforclient = ball_customize;
- setorigin(self.ballcarried, self.origin + self.view_ofs +
+ vector org = self.origin + self.view_ofs +
v_forward * autocvar_g_nexball_viewmodel_offset.x +
v_right * autocvar_g_nexball_viewmodel_offset.y +
- v_up * autocvar_g_nexball_viewmodel_offset.z);
+ v_up * autocvar_g_nexball_viewmodel_offset.z;
+ setorigin(self.ballcarried, org);
// 'safe passing'
if(autocvar_g_nexball_safepass_maxdist)
crosshair_trace(self);
if( trace_ent &&
IS_CLIENT(trace_ent) &&
- trace_ent.deadflag == DEAD_NO &&
+ !IS_DEAD(trace_ent) &&
trace_ent.team == self.team &&
vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist )
{
self.weapons = self.(weaponentity).weapons;
Weapon w = WEP_NEXBALL;
w.wr_resetplayer(w);
- self.switchweapon = self.(weaponentity).switchweapon;
- W_SwitchWeapon(self.switchweapon);
+ PS(self).m_switchweapon = self.(weaponentity).m_switchweapon;
+ W_SwitchWeapon(PS(self).m_switchweapon);
self.(weaponentity).weapons = '0 0 0';
}
MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
{SELFPARAM();
- return self.weapon == WEP_NEXBALL.m_id;
+ return PS(self).m_weapon == WEP_NEXBALL;
}
MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
{SELFPARAM();
- return self.weapon == WEP_MORTAR.m_id; // TODO: what is this for?
+ return PS(self).m_weapon == WEP_MORTAR; // TODO: what is this for?
}
MUTATOR_HOOKFUNCTION(nb, FilterItem)
if(g_nexball_meter_period <= 0)
g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users
g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32
- addstat(STAT_NB_METERSTART, AS_FLOAT, metertime);
// General settings
/*
WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
ActivateTeamplay();
- SetLimits(autocvar_g_nexball_goallimit, autocvar_g_nexball_goalleadlimit, -1, -1);
+ SetLimits(autocvar_g_nexball_goallimit, autocvar_g_nexball_goalleadlimit, autocvar_timelimit_override, -1);
have_team_spawns = -1; // request team spawns
}