float autocvar_g_balance_nexball_secondary_refire;
float autocvar_g_balance_nexball_secondary_speed;
-void basketball_touch();
-void football_touch();
-void ResetBall();
+void basketball_touch(entity this);
+void football_touch(entity this);
+void ResetBall(entity this);
const int NBM_NONE = 0;
const int NBM_FOOTBALL = 2;
const int NBM_BASKETBALL = 4;
{
if(this.owner)
DropBall(this, this.owner.origin, '0 0 0');
- ResetBall();
+ ResetBall(this);
}
void nexball_setstatus()
{SELFPARAM();
- self.items &= ~IT_KEY1;
- if(self.ballcarried)
+ this.items &= ~IT_KEY1;
+ if(this.ballcarried)
{
- if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
+ if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
{
- bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
- setself(self.ballcarried);
- DropBall(self, self.owner.origin, '0 0 0');
- ResetBall();
- setself(this);
+ bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
+ DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
+ entity e = this.ballcarried;
+ WITHSELF(e, ResetBall(e));
}
else
- self.items |= IT_KEY1;
+ this.items |= IT_KEY1;
}
}
}
}
-void DropOwner()
-{SELFPARAM();
+void DropOwner(entity this)
+{
entity ownr;
ownr = this.owner;
DropBall(this, ownr.origin, ownr.velocity);
}
void GiveBall(entity plyr, entity ball)
-{SELFPARAM();
+{
.entity weaponentity = weaponentities[0]; // TODO: find ballstealer
entity ownr = ball.owner;
if(ownr)
ball.velocity = '0 0 0';
ball.movetype = MOVETYPE_NONE;
- ball.touch = func_null;
+ settouch(ball, func_null);
ball.effects |= EF_NOSHADOW;
ball.scale = 1; // scale down.
if(autocvar_g_nexball_basketball_delay_hold)
{
- ball.think = DropOwner;
+ setthink(ball, DropOwner);
ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
}
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);
+ WITHSELF(plyr, w.wr_resetplayer(w, plyr));
PS(plyr).m_switchweapon = WEP_NEXBALL;
- W_SwitchWeapon(plyr, WEP_NEXBALL);
- setself(this);
+ WITHSELF(plyr, W_SwitchWeapon(plyr, WEP_NEXBALL));
}
void DropBall(entity ball, vector org, vector vel)
ball.scale = ball_scale;
ball.velocity = vel;
ball.nb_droptime = time;
- ball.touch = basketball_touch;
- ball.think = ResetBall;
+ settouch(ball, basketball_touch);
+ setthink(ball, ResetBall);
ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
if(ball.owner.metertime)
ball.owner = world;
}
-void InitBall()
-{SELFPARAM();
+void InitBall(entity this)
+{
if(gameover) return;
UNSET_ONGROUND(this);
this.movetype = MOVETYPE_BOUNCE;
if(this.classname == "nexball_basketball")
- this.touch = basketball_touch;
+ settouch(this, basketball_touch);
else if(this.classname == "nexball_football")
- this.touch = football_touch;
+ settouch(this, football_touch);
this.cnt = 0;
- this.think = ResetBall;
+ setthink(this, ResetBall);
this.nextthink = time + autocvar_g_nexball_delay_idle + 3;
this.teamtime = 0;
this.pusher = world;
LogNB("init", world);
}
-void ResetBall()
-{SELFPARAM();
+void ResetBall(entity this)
+{
if(this.cnt < 2) // step 1
{
if(time == this.teamtime)
bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
- this.touch = func_null;
+ settouch(this, func_null);
this.movetype = MOVETYPE_NOCLIP;
this.velocity = '0 0 0'; // just in case?
if(!this.cnt)
this.velocity = '0 0 0';
setorigin(this, this.spawnorigin); // make sure it's positioned correctly anyway
this.movetype = MOVETYPE_NONE;
- this.think = InitBall;
+ setthink(this, InitBall);
this.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
}
}
-void football_touch()
-{SELFPARAM();
+void football_touch(entity this)
+{
if(other.solid == SOLID_BSP)
{
if(time > self.lastground + 0.1)
self.avelocity = -250 * v_forward; // maybe there is a way to make it look better?
}
-void basketball_touch()
-{SELFPARAM();
+void basketball_touch(entity this)
+{
if(other.ballcarried)
{
- football_touch();
+ football_touch(this);
return;
}
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))
}
}
-void GoalTouch()
-{SELFPARAM();
+void GoalTouch(entity this)
+{
entity ball;
float isclient, pscore, otherteam;
string pname;
WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
ball.cnt = 1;
- ball.think = ResetBall;
+ setthink(ball, ResetBall);
if(ball.classname == "nexball_basketball")
- ball.touch = football_touch; // better than func_null: football control until the ball gets reset
+ settouch(ball, football_touch); // better than func_null: football control until the ball gets reset
ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
}
WaypointSprite_AttachCarrier(WP_NbBall, this, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
this.reset = ball_restart;
- this.think = InitBall;
+ setthink(this, InitBall);
this.nextthink = game_starttime + autocvar_g_nexball_delay_start;
}
if(this.noise == "")
this.noise = "ctf/respawn.wav";
precache_sound(this.noise);
- this.touch = GoalTouch;
+ settouch(this, GoalTouch);
}
spawnfunc(nexball_redgoal)
//=======================//
-void W_Nexball_Think()
-{SELFPARAM();
+void W_Nexball_Think(entity this)
+{
//dprint("W_Nexball_Think\n");
//vector new_dir = steerlib_arrive(this.enemy.origin, 2500);
vector new_dir = normalize(this.enemy.origin + '0 0 50' - this.origin);
this.nextthink = time;
}
-void W_Nexball_Touch()
-{SELFPARAM();
+void W_Nexball_Touch(entity this)
+{
entity ball, attacker;
attacker = self.owner;
//self.think = func_null;
entity _ball = self.ballcarried;
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;
+ setthink(_ball, W_Nexball_Think);
_ball.nextthink = time;
return;
}
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_self;
+ settouch(missile, W_Nexball_Touch);
+ setthink(missile, SUB_Remove);
missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
}
}
-METHOD(BallStealer, wr_setup, void(BallStealer this))
+METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor))
{
TC(BallStealer, this);
//weapon_setup(WEP_PORTO.m_id);
{
self.weapons = self.(weaponentity).weapons;
Weapon w = WEP_NEXBALL;
- w.wr_resetplayer(w);
+ w.wr_resetplayer(w, self);
PS(self).m_switchweapon = self.(weaponentity).m_switchweapon;
W_SwitchWeapon(self, PS(self).m_switchweapon);