if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
{
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;
+ DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
ResetBall(e);
}
else
ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
+ ball.weaponentity_fld = weaponentity;
ball.team = plyr.team;
plyr.ballcarried = ball;
ball.nb_dropper = plyr;
if(ball.owner.metertime)
{
ball.owner.metertime = 0;
- .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
+ .entity weaponentity = ball.weaponentity_fld;
ball.owner.(weaponentity).state = WS_READY;
}
}
else
{
- .entity weaponentity = weaponentities[0]; // TODO
- if(player.(weaponentity).weapons)
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- player.weapons = player.(weaponentity).weapons;
- Weapon w = WEP_NEXBALL;
- w.wr_resetplayer(w, player);
- player.(weaponentity).m_switchweapon = player.m_switchweapon;
- W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
+ .entity weaponentity = weaponentities[slot];
+
+ if(player.(weaponentity).weapons)
+ {
+ player.weapons = player.(weaponentity).weapons;
+ Weapon w = WEP_NEXBALL;
+ w.wr_resetplayer(w, player);
+ player.(weaponentity).m_switchweapon = player.m_switchweapon;
+ W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
- player.(weaponentity).weapons = '0 0 0';
+ player.(weaponentity).weapons = '0 0 0';
+ }
}
}
MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
{
- entity player = M_ARGV(0, entity);
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+ //entity player = M_ARGV(0, entity);
+ entity wepent = M_ARGV(1, entity);
- return player.(weaponentity).m_weapon == WEP_NEXBALL;
+ return wepent.m_weapon == WEP_NEXBALL;
}
MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
{
- entity player = M_ARGV(0, entity);
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+ //entity player = M_ARGV(0, entity);
+ int wep = M_ARGV(1, int);
- return player.(weaponentity).m_weapon == WEP_MORTAR; // TODO: what is this for?
+ return wep == WEP_MORTAR.m_id; // TODO: what is this for?
}
MUTATOR_HOOKFUNCTION(nb, FilterItem)
/** returns true if throwing the current weapon shall not be allowed */
#define EV_ForbidThrowCurrentWeapon(i, o) \
/** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \
/**/
MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
/** returns true if dropping the current weapon shall not be allowed at any time including death */
#define EV_ForbidDropCurrentWeapon(i, o) \
- /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** weapon id */ i(int, MUTATOR_ARGV_1_int) \
/**/
MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
bool W_IsWeaponThrowable(entity this, int w)
{
- if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this))
+ if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this, w))
return false;
if (!autocvar_g_pickup_items)
return false;
Weapon w = this.(weaponentity).m_weapon;
if (w == WEP_Null)
return; // just in case
- if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this))
+ if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this, this.(weaponentity)))
return;
if(!autocvar_g_weapon_throwable)
return;
void SpawnThrownWeapon(entity this, vector org, float w, .entity weaponentity)
{
- if(this.weapons & WepSet_FromWeapon(this.(weaponentity).m_weapon))
- if(W_IsWeaponThrowable(this, this.(weaponentity).m_weapon.m_id))
- W_ThrowNewWeapon(this, this.(weaponentity).m_weapon.m_id, false, org, randomvec() * 125 + '0 0 200', weaponentity);
+ entity wep = this.(weaponentity).m_weapon;
+
+ if(this.weapons & WepSet_FromWeapon(wep))
+ if(W_IsWeaponThrowable(this, wep.m_id))
+ W_ThrowNewWeapon(this, wep.m_id, false, org, randomvec() * 125 + '0 0 200', weaponentity);
}