M_ARGV(0, float) *= autocvar_g_buffs_disability_weaponspeed;
}
+MUTATOR_HOOKFUNCTION(buffs, SetPlayerAlpha)
+{
+ entity player = M_ARGV(0, entity);
+
+ if(STAT(BUFFS, player) & BUFF_INVISIBLE.m_itemid)
+ {
+ float alph = ((autocvar_g_buffs_invisible_alpha) ? autocvar_g_buffs_invisible_alpha : -1);
+ M_ARGV(1, float) = alph; // player_alpha
+ M_ARGV(2, float) = alph; // weapon_alpha
+ }
+}
+
.bool buff_flight_crouchheld;
MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
}
}
- if((STAT(BUFFS, player) & BUFF_INVISIBLE.m_itemid) && (player.oldbuffs & BUFF_INVISIBLE.m_itemid))
- player.alpha = ((autocvar_g_buffs_invisible_alpha) ? autocvar_g_buffs_invisible_alpha : -1); // powerups reset alpha, so we must enforce this (TODO)
-
if(STAT(BUFFS, player) & BUFF_MEDIC.m_itemid)
if(time >= player.buff_medic_healtime)
{
}
}
- BUFF_ONADD(BUFF_INVISIBLE)
- {
- if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
- player.buff_invisible_prev_alpha = default_player_alpha; // we don't want to save the powerup's alpha, as player may lose the powerup while holding the buff
- else
- player.buff_invisible_prev_alpha = player.alpha;
- player.alpha = autocvar_g_buffs_invisible_alpha;
- }
-
- BUFF_ONREM(BUFF_INVISIBLE)
- {
- if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
- player.alpha = autocvar_g_instagib_invis_alpha;
- else
- player.alpha = player.buff_invisible_prev_alpha;
- }
-
BUFF_ONADD(BUFF_FLIGHT)
{
player.buff_flight_oldgravity = player.gravity;
return true;
}
+MUTATOR_HOOKFUNCTION(mutator_instagib, SetPlayerAlpha)
+{
+ entity player = M_ARGV(0, entity);
+
+ if(time < player.strength_finished)
+ {
+ M_ARGV(1, float) = autocvar_g_instagib_invis_alpha; // player_alpha
+ M_ARGV(2, float) = autocvar_g_instagib_invis_alpha; // weapon_alpha
+ }
+}
+
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
{
entity player = M_ARGV(0, entity);
play_countdown(player, player.strength_finished, SND_POWEROFF);
if (time > player.strength_finished)
{
- player.alpha = default_player_alpha;
- player.exteriorweaponentity.alpha = default_weapon_alpha;
player.items &= ~ITEM_Invisibility.m_itemid;
Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
}
{
if (time < player.strength_finished)
{
- player.alpha = autocvar_g_instagib_invis_alpha;
- player.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
player.items |= ITEM_Invisibility.m_itemid;
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_INVISIBILITY, player.netname);
Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
void nade_veil_touch(entity this, entity toucher)
{
- if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
+ if ( IS_PLAYER(toucher) || (IS_VEHICLE(toucher) && toucher.owner) )
{
entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
float tint_alpha = 0.75;
- if(SAME_TEAM(toucher, this.realowner))
- {
+ if(SAME_TEAM(show_tint, this.realowner))
tint_alpha = 0.45;
- if(!STAT(VEIL_ORB, show_tint))
- {
- toucher.nade_veil_prevalpha = toucher.alpha;
- toucher.alpha = -1;
- }
- }
+
STAT(VEIL_ORB, show_tint) = time + 0.1;
STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
}
(it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \
&& boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
+MUTATOR_HOOKFUNCTION(nades, SetPlayerAlpha)
+{
+ entity player = M_ARGV(0, entity);
+
+ if(STAT(VEIL_ORB, player) > time)
+ {
+ M_ARGV(1, float) = -1; // player_alpha
+ M_ARGV(2, float) = -1; // weapon_alpha
+ }
+}
+
MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
{
entity player = M_ARGV(0, entity);
if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
{
STAT(VEIL_ORB, player) = 0;
- if(player.vehicle)
- player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
- else
- player.alpha = player.nade_veil_prevalpha;
}
}
M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
}
-
- if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
- {
- mon.alpha = mon.nade_veil_prevalpha;
- STAT(VEIL_ORB, mon) = 0;
- }
}
MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
sound (this, CH_INFO, samp, VOL_BASE, ATTEN_NORM);
}
+void SetPlayerAlpha(entity this)
+{
+ if(IS_DEAD(this) || this.vehicle)
+ return;
+
+ float player_alpha = default_player_alpha;
+ float weapon_alpha = default_weapon_alpha;
+ MUTATOR_CALLHOOK(SetPlayerAlpha, this, player_alpha, weapon_alpha);
+ player_alpha = M_ARGV(1, float);
+ weapon_alpha = M_ARGV(2, float);
+ this.alpha = player_alpha;
+ this.exteriorweaponentity.alpha = weapon_alpha;
+}
+
void player_powerups(entity this)
{
+ SetPlayerAlpha(this);
+
// add a way to see what the items were BEFORE all of these checks for the mutator hook
int items_prev = this.items;
/** targ */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(Unfreeze, EV_Unfreeze);
+
+/** Called when setting the player's alpha, useful for powerups */
+#define EV_SetPlayerAlpha(i, o) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** player alpha */ i(float, MUTATOR_ARGV_1_float) \
+ /**/ o(float, MUTATOR_ARGV_1_float) \
+ /** weapon alpha */ i(float, MUTATOR_ARGV_2_float) \
+ /**/ o(float, MUTATOR_ARGV_2_float) \
+ /**/
+MUTATOR_HOOKABLE(SetPlayerAlpha, EV_SetPlayerAlpha);