#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")
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;
void GiveBall(entity plyr, entity ball)
{SELFPARAM();
- int slot = 0; // TODO: find ballstealer
+ .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
entity ownr = ball.owner;
if(ownr)
{
if(ownr.metertime)
{
ownr.metertime = 0;
- ownr.weaponentity[slot].state = WS_READY;
+ ownr.(weaponentity).state = WS_READY;
}
WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier);
}
ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
}
- plyr.weaponentity[slot].weapons = plyr.weapons;
- plyr.weaponentity[slot].switchweapon = plyr.weapon;
+ plyr.(weaponentity).weapons = plyr.weapons;
+ plyr.(weaponentity).switchweapon = plyr.weapon;
plyr.weapons = WEPSET(NEXBALL);
setself(plyr);
Weapon w = WEP_NEXBALL;
if(ball.owner.metertime)
{
ball.owner.metertime = 0;
- int slot = 0; // TODO: find ballstealer
- ball.owner.weaponentity[slot].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;
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)
{
}
}
-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()
{
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);
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;
vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
-void W_Nexball_Attack2(void)
+void W_Nexball_Attack2()
{SELFPARAM();
if(self.ballcarried.enemy)
{
return;
W_SetupShot(self, false, 2, SND(NB_SHOOT2), CH_WEAPON_A, 0);
- entity missile = spawn();
+ 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, int slot, int fire))
+ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
{
if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, slot, false, autocvar_g_balance_nexball_primary_refire))
+ 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, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
else
{
W_Nexball_Attack(-1);
- weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
if(fire & 2)
- if(weapon_prepareattack(thiswep, actor, slot, true, autocvar_g_balance_nexball_secondary_refire))
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
{
W_Nexball_Attack2();
- weapon_thinkf(actor, slot, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
+ 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, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
}
METHOD(BallStealer, wr_setup, void(BallStealer thiswep))
}
else
{
- int slot = 0; // TODO
- if(self.weaponentity[slot].weapons)
+ .entity weaponentity = weaponentities[0]; // TODO
+ if(self.(weaponentity).weapons)
{
- self.weapons = self.weaponentity[slot].weapons;
+ self.weapons = self.(weaponentity).weapons;
Weapon w = WEP_NEXBALL;
w.wr_resetplayer(w);
- self.switchweapon = self.weaponentity[slot].switchweapon;
+ self.switchweapon = self.(weaponentity).switchweapon;
W_SwitchWeapon(self.switchweapon);
- self.weaponentity[slot].weapons = '0 0 0';
+ self.(weaponentity).weapons = '0 0 0';
}
}
{
SELFPARAM();
this.metertime = 0;
- int slot = 0;
- this.weaponentity[slot].weapons = '0 0 0';
+ .entity weaponentity = weaponentities[0];
+ this.(weaponentity).weapons = '0 0 0';
if (nexball_mode & NBM_BASKETBALL)
this.weapons |= WEPSET(NEXBALL);
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
/*