#ifdef IMPLEMENTATION
#ifdef SVQC
+.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;
GameLogEcho(s);
}
-void ball_restart(void)
-{SELFPARAM();
- if(self.owner)
- DropBall(self, self.owner.origin, '0 0 0');
+void ball_restart(entity this)
+{
+ if(this.owner)
+ DropBall(this, this.owner.origin, '0 0 0');
ResetBall();
}
-void nexball_setstatus(void)
+void nexball_setstatus()
{SELFPARAM();
self.items &= ~IT_KEY1;
if(self.ballcarried)
}
}
-void relocate_nexball(void)
+void relocate_nexball()
{SELFPARAM();
tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
if(trace_startsolid)
}
}
-void DropOwner(void)
+void DropOwner()
{SELFPARAM();
entity ownr;
ownr = self.owner;
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)
{SELFPARAM();
- entity ownr;
-
- if((ownr = ball.owner))
+ .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
+ entity ownr = ball.owner;
+ if(ownr)
{
ownr.effects &= ~autocvar_g_nexball_basketball_effects_default;
ownr.ballcarried = world;
if(ownr.metertime)
{
ownr.metertime = 0;
- ownr.weaponentity.state = WS_READY;
+ ownr.(weaponentity).state = WS_READY;
}
WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
}
ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
}
- plyr.weaponentity.weapons = plyr.weapons;
- plyr.weaponentity.switchweapon = plyr.weapon;
+ plyr.(weaponentity).weapons = plyr.weapons;
+ 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;
if(ball.owner.metertime)
{
ball.owner.metertime = 0;
- ball.owner.weaponentity.state = WS_READY;
+ .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
+ ball.owner.(weaponentity).state = WS_READY;
}
WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
ball.owner = world;
}
-void InitBall(void)
+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;
LogNB("init", world);
}
-void ResetBall(void)
+void ResetBall()
{SELFPARAM();
if(self.cnt < 2) // step 1
{
}
}
-void football_touch(void)
+void football_touch()
{SELFPARAM();
if(other.solid == SOLID_BSP)
{
self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
}
-void basketball_touch(void)
+void basketball_touch()
{SELFPARAM();
if(other.ballcarried)
{
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 GoalTouch(void)
+void GoalTouch()
{SELFPARAM();
entity ball;
float isclient, pscore, otherteam;
void nb_spawnteam(string teamname, float teamcolor)
{
LOG_TRACE("^2spawned team ", teamname, "\n");
- entity e;
- e = spawn();
- e.classname = "nexball_team";
+ entity e = new(nexball_team);
e.netname = teamname;
e.cnt = teamcolor;
e.team = e.cnt + 1;
nb_teams += 1;
}
-void nb_spawnteams(void)
+void nb_spawnteams()
{
bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
entity e;
}
}
-void nb_delayedinit(void)
+void nb_delayedinit(entity this)
{
if(find(world, classname, "nexball_team") == world)
nb_spawnteams();
// spawnfuncs //
//=======================//
-void SpawnBall(void)
+void SpawnBall()
{SELFPARAM();
if(!g_nexball) { remove(self); return; }
if(!autocvar_g_nexball_sound_bounce)
self.noise = "";
else if(self.noise == "")
- self.noise = SND(NB_BOUNCE);
+ self.noise = strzone(SND(NB_BOUNCE));
//bounce sound placeholder (FIXME)
if(self.noise1 == "")
- self.noise1 = SND(NB_DROP);
+ self.noise1 = strzone(SND(NB_DROP));
//ball drop sound placeholder (FIXME)
if(self.noise2 == "")
- self.noise2 = SND(NB_STEAL);
+ self.noise2 = strzone(SND(NB_STEAL));
//stealing sound placeholder (FIXME)
if(self.noise) precache_sound(self.noise);
precache_sound(self.noise1);
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();
return true;
}
-void SpawnGoal(void)
+void SpawnGoal()
{SELFPARAM();
if(!g_nexball) { remove(self); return; }
{
self.team = GOAL_FAULT;
if(self.noise == "")
- self.noise = SND(TYPEHIT);
+ self.noise = strzone(SND(TYPEHIT));
SpawnGoal();
}
{
self.team = GOAL_OUT;
if(self.noise == "")
- self.noise = SND(TYPEHIT);
+ self.noise = strzone(SND(TYPEHIT));
SpawnGoal();
}
self.nextthink = time;
}
-void W_Nexball_Touch(void)
+void W_Nexball_Touch()
{SELFPARAM();
entity ball, attacker;
attacker = self.owner;
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)
{
vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
-void W_Nexball_Attack2(void)
+void W_Nexball_Attack2()
{SELFPARAM();
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);
- entity missile = spawn();
+ W_SetupShot(self, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
+ entity missile = new(ballstealer);
missile.owner = self;
- missile.classname = "ballstealer";
missile.movetype = MOVETYPE_FLY;
PROJECTILE_MAKETRIGGER(missile);
W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
missile.angles = vectoangles(missile.velocity);
missile.touch = W_Nexball_Touch;
- missile.think = SUB_Remove;
+ missile.think = SUB_Remove_self;
missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
return true;
}
- METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2))
- {
- if(fire1)
- if(weapon_prepareattack(thiswep, actor, 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, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
- }
- else
- {
- W_Nexball_Attack(-1);
- weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
- }
- if(fire2)
- if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_nexball_secondary_refire))
- {
- W_Nexball_Attack2();
- weapon_thinkf(actor, 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(!fire1 && self.metertime && self.ballcarried)
- {
- W_Nexball_Attack(time - self.metertime);
- // DropBall or stealing will set metertime back to 0
- weapon_thinkf(actor, 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 )
{
}
else
{
- if(self.weaponentity.weapons)
+ .entity weaponentity = weaponentities[0]; // TODO
+ if(self.(weaponentity).weapons)
{
- self.weapons = self.weaponentity.weapons;
+ 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';
+ self.(weaponentity).weapons = '0 0 0';
}
}
return false;
}
+MUTATOR_HOOKFUNCTION(nb, SpectateCopy)
+{
+ SELFPARAM();
+ this.metertime = other.metertime;
+}
+
MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
-{SELFPARAM();
- self.weaponentity.weapons = '0 0 0';
+{
+ SELFPARAM();
+ this.metertime = 0;
+ .entity weaponentity = weaponentities[0];
+ this.(weaponentity).weapons = '0 0 0';
- if(nexball_mode & NBM_BASKETBALL)
- self.weapons |= WEPSET(NEXBALL);
+ if (nexball_mode & NBM_BASKETBALL)
+ this.weapons |= WEPSET(NEXBALL);
else
- self.weapons = '0 0 0';
+ this.weapons = '0 0 0';
return false;
}
MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
{SELFPARAM();
- if(self.weapon == WEP_NEXBALL.m_id)
- return true;
+ return PS(self).m_weapon == WEP_NEXBALL;
+}
- return false;
+MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
+{SELFPARAM();
+ return PS(self).m_weapon == WEP_MORTAR; // TODO: what is this for?
}
MUTATOR_HOOKFUNCTION(nb, FilterItem)
REGISTER_MUTATOR(nb, g_nexball)
{
- ActivateTeamplay();
- SetLimits(autocvar_g_nexball_goallimit, autocvar_g_nexball_goalleadlimit, -1, -1);
- have_team_spawns = -1; // request team spawns
-
MUTATOR_ONADD
{
g_nexball_meter_period = autocvar_g_nexball_meter_period;
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
/*
InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE);
WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+
+ ActivateTeamplay();
+ SetLimits(autocvar_g_nexball_goallimit, autocvar_g_nexball_goalleadlimit, autocvar_timelimit_override, -1);
+ have_team_spawns = -1; // request team spawns
}
MUTATOR_ONROLLBACK_OR_REMOVE