.float buff_time = _STAT(BUFF_TIME);
void buffs_DelayedInit(entity this);
-AUTOCVAR(g_buffs, int, -1, _("Enable buffs, -1: enabled but no auto location or replacing powerups, 1: enabled and can replace them"));
+AUTOCVAR(g_buffs, int, -1, "Enable buffs, -1: enabled but no auto location or replacing powerups, 1: enabled and can replace them");
REGISTER_MUTATOR(buffs, autocvar_g_buffs)
{
void buff_Respawn(entity this)
{
- if(gameover) { return; }
+ if(game_stopped) return;
vector oldbufforigin = this.origin;
this.velocity = '0 0 200';
void buff_Touch(entity this, entity toucher)
{
- if(gameover) { return; }
+ if(game_stopped) return;
if(ITEM_TOUCH_NEEDKILL())
{
this.oldbuffs = this.buffs;
}
- if(!gameover)
+ if(!game_stopped)
if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime)
if(!this.buff_activetime_updated)
{
}
if(this.buff_activetime)
- if(!gameover)
+ if(!game_stopped)
if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime)
{
this.buff_activetime = max(0, this.buff_activetime - frametime);
entity buff = buff_FirstFromFlags(this.buffs);
- if(!this.buffs || buff_Available(buff))
+ if(!this.buffs || !buff_Available(buff))
buff_NewType(this, 0);
this.classname = "item_buff";
this.solid = SOLID_TRIGGER;
this.flags = FL_ITEM;
this.bot_pickup = true;
- this.bot_pickupevalfunc = commodity_pickupevalfunc;
+ this.bot_pickupevalfunc = generic_pickupevalfunc;
this.bot_pickupbasevalue = 1000;
IL_PUSH(g_items, this);
setthink(this, buff_Think);
}
}
-MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate)
+MUTATOR_HOOKFUNCTION(buffs, Damage_Calculate)
{
entity frag_attacker = M_ARGV(1, entity);
entity frag_target = M_ARGV(2, entity);
if(player.buffs & BUFF_JUMP.m_itemid)
M_ARGV(1, float) = autocvar_g_buffs_jump_height;
-
- if(player.buffs & BUFF_FLIGHT.m_itemid)
- if(!IS_JUMP_HELD(player) && PHYS_INPUT_BUTTON_CROUCH(player))
- player.gravity *= -1;
}
MUTATOR_HOOKFUNCTION(buffs, MonsterMove)
MUTATOR_HOOKFUNCTION(buffs, PlayerUseKey, CBC_ORDER_FIRST)
{
- if(MUTATOR_RETURNVALUE || gameover) { return; }
+ if(MUTATOR_RETURNVALUE || game_stopped) return;
entity player = M_ARGV(0, entity);
MUTATOR_HOOKFUNCTION(buffs, ForbidThrowCurrentWeapon)
{
- if(MUTATOR_RETURNVALUE || gameover) { return; }
+ if(MUTATOR_RETURNVALUE || game_stopped) return;
entity player = M_ARGV(0, entity);
if(player.buffs & BUFF_SWAPPER.m_itemid)
M_ARGV(0, float) *= autocvar_g_buffs_disability_weaponspeed;
}
+.bool buff_flight_crouchheld;
+
MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
{
entity player = M_ARGV(0, entity);
- if(gameover || IS_DEAD(player)) { return; }
+ if(game_stopped || IS_DEAD(player)) return;
+
+ if(player.buffs & BUFF_FLIGHT.m_itemid)
+ {
+ if(!PHYS_INPUT_BUTTON_CROUCH(player))
+ player.buff_flight_crouchheld = false;
+ else if(!player.buff_flight_crouchheld)
+ {
+ player.buff_flight_crouchheld = true;
+ player.gravity *= -1;
+ }
+ }
if(time < player.buff_disability_time)
if(time >= player.buff_disability_effect_time)
}
if(player.buffs & BUFF_AMMO.m_itemid)
- if(player.clip_size)
- player.clip_load = player.(weapon_load[PS(player).m_switchweapon.m_id]) = player.clip_size;
+ {
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if(player.(weaponentity).clip_size)
+ player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
+ }
+ }
if((player.buffs & BUFF_INVISIBLE.m_itemid) && (player.oldbuffs & BUFF_INVISIBLE.m_itemid))
if(player.alpha != autocvar_g_buffs_invisible_alpha)
player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_WEAPON_AMMO);
player.items |= IT_UNLIMITED_WEAPON_AMMO;
- if(player.clip_load)
- player.buff_ammo_prev_clipload = player.clip_load;
- player.clip_load = player.(weapon_load[PS(player).m_switchweapon.m_id]) = player.clip_size;
+ if(player.buffs & BUFF_AMMO.m_itemid)
+ {
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if(player.(weaponentity).clip_load)
+ player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load;
+ if(player.(weaponentity).clip_size)
+ player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
+ }
+ }
}
BUFF_ONREM(BUFF_AMMO)
else
player.items &= ~IT_UNLIMITED_WEAPON_AMMO;
- if(player.buff_ammo_prev_clipload)
- player.clip_load = player.buff_ammo_prev_clipload;
+ if(player.buffs & BUFF_AMMO.m_itemid)
+ {
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if(player.(weaponentity).buff_ammo_prev_clipload)
+ player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload;
+ }
+ }
}
BUFF_ONADD(BUFF_INVISIBLE)