if(!STAT(FROZEN, player))
if(!PHYS_INPUT_BUTTON_CHAT(player))
if(IS_REAL_CLIENT(player)) // bots may camp, but that's no reason to constantly kill them
- if(!forbidWeaponUse(player))
+ if(!weaponLocked(player))
{
// calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
vector dist = vec2(player.campcheck_prevorigin - player.origin);
if (!autocvar_g_nades)
return false; // allow turning them off mid match
- if(forbidWeaponUse(this))
+ if (weaponLocked(this))
return false;
if (!IS_PLAYER(this))
{
return;
}
- if (!PHYS_INPUT_BUTTON_ATCK2(player) || forbidWeaponUse(player) ||
+ if (!PHYS_INPUT_BUTTON_ATCK2(player) || weaponLocked(player) ||
!(round_handler_IsActive() && !round_handler_IsRoundStarted()))
{
return;
if (IS_DEAD(it)) continue;
if (time < it.msnt_timer) continue;
if (time < it.spawnshieldtime) continue;
- if (forbidWeaponUse(it)) continue;
+ if (weaponLocked(it)) continue;
if (it == player) continue;
tested++; // i consider a teammate to be available when he passes the checks above
// Vehicle currently in use
if(this.owner)
{
- if(!forbidWeaponUse(this.owner))
+ if(!weaponLocked(this.owner))
if(toucher != NULL)
if((this.origin_z + this.maxs_z) > (toucher.origin_z))
if(vehicles_crushable(toucher))
autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
_out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed, dt);
- if(!forbidWeaponUse(this))
+ if(!weaponLocked(this))
if(PHYS_INPUT_BUTTON_ATCK(this))
if(time > gun.attack_finished_single[0])
if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1, autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides, autocvar_g_vehicle_bumblebee_raygun_turnspeed, dt);
- if(!forbidWeaponUse(this))
+ if(!weaponLocked(this))
if((PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this)) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * PHYS_INPUT_FRAMETIME || autocvar_g_vehicle_bumblebee_raygun == 0))
{
vehic.gun3.enemy.realowner = this;
Weapon wep1 = WEP_RACER;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
- if (!forbidWeaponUse(player))
+ if (!weaponLocked(player))
if (PHYS_INPUT_BUTTON_ATCK(player))
if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
{
}
}
- if(!forbidWeaponUse(player))
+ if(!weaponLocked(player))
if(time > vehic.delay)
if(PHYS_INPUT_BUTTON_ATCK2(player))
{
Weapon wep1 = WEP_RAPTOR;
.entity weaponentity = weaponentities[0];
- if(!forbidWeaponUse(this))
+ if(!weaponLocked(this))
if(PHYS_INPUT_BUTTON_ATCK(this))
if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
{
vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false);
Weapon wep2a = WEP_RAPTOR_BOMB;
- if(!forbidWeaponUse(this))
+ if(!weaponLocked(this))
if(STAT(VEHICLESTAT_W2MODE, vehic) == RSM_BOMB)
{
if(time > vehic.lip + autocvar_g_vehicle_raptor_bombs_refire)
vehic.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
vehic.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
- if(!forbidWeaponUse(this))
+ if(!weaponLocked(this))
if(PHYS_INPUT_BUTTON_ATCK(this))
{
vehic.cnt = time;
if(!PHYS_INPUT_BUTTON_ATCK2(this.owner))
return;
- if(forbidWeaponUse(this.owner))
+ if(weaponLocked(this.owner))
return;
v = gettaginfo(this.tur_head,gettagindex(this.tur_head,"tag_fire"));
// loadable hagar secondary attack, must always run each frame
if(time < game_starttime || time < actor.race_penalty || timeout_status == TIMEOUT_ACTIVE)
return;
- if (round_handler_IsActive() && !round_handler_IsRoundStarted())
+ if (weaponUseForbidden(actor))
return;
bool loaded = actor.(weaponentity).hagar_load >= WEP_CVAR_SEC(hagar, load_max);
} else if(WEP_CVAR(vaporizer, reload_ammo) && actor.(weaponentity).clip_load < vaporizer_ammo) { // forced reload
thiswep.wr_reload(thiswep, actor, weaponentity);
}
- if((fire & 1) && (GetResource(actor, RES_CELLS) || !autocvar_g_rm) && !forbidWeaponUse(actor))
+ if((fire & 1) && (GetResource(actor, RES_CELLS) || !autocvar_g_rm) && !weaponLocked(actor))
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
{
void FireGrapplingHook(entity actor, .entity weaponentity)
{
- if(forbidWeaponUse(actor)) return;
+ if(weaponLocked(actor)) return;
if(actor.vehicle) return;
// TODO: offhand hook shoots from eye
{
if (this.vehicle) return;
if (IS_DEAD(this)) return;
- if (forbidWeaponUse(this)) return;
+ if (weaponLocked(this)) return;
entity actor = this;
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
/** id */ i(float, MUTATOR_ARGV_0_float) \
/** status */ i(float, MUTATOR_ARGV_1_float) \
/** data */ i(string, MUTATOR_ARGV_2_string) \
- /**/
+ /**/
MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
+/**
+ * return true to lock weapon (can't be used nor changed) for a player
+ */
+#define EV_LockWeapon(i, o) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /**/
+MUTATOR_HOOKABLE(LockWeapon, EV_LockWeapon);
+
/**
* return true to prevent weapon use for a player
*/
- #define EV_ForbidWeaponUse(i, o) \
- /** player */ i(entity, MUTATOR_ARGV_0_entity) \
- /**/
+#define EV_ForbidWeaponUse(i, o) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /**/
MUTATOR_HOOKABLE(ForbidWeaponUse, EV_ForbidWeaponUse);
/** called when creating a clone of the player (usually for corpses that stay after the player has re-spawned) */
return false;
}
}
- else if(!forbidWeaponUse(this) && CS(this).cvar_cl_weapon_switch_reload)
+ else if(!weaponLocked(this) && CS(this).cvar_cl_weapon_switch_reload)
{
entity actor = this;
w.wr_reload(w, actor, weaponentity);
}
}
-bool forbidWeaponUse(entity player)
+bool weaponUseForbidden(entity player)
+{
+ if (round_handler_IsActive() && !round_handler_IsRoundStarted()) return true;
+ if (MUTATOR_CALLHOOK(ForbidWeaponUse, player)) return true;
+ return false;
+}
+
+bool weaponLocked(entity player)
{
if (time < game_starttime && !sv_ready_restart_after_countdown) return true;
if (player.player_blocked) return true;
if (game_stopped) return true;
if (STAT(FROZEN, player)) return true;
- if (MUTATOR_CALLHOOK(ForbidWeaponUse, player)) return true;
+ if (MUTATOR_CALLHOOK(LockWeapon, player)) return true;
return false;
}
int button_atck = PHYS_INPUT_BUTTON_ATCK(actor);
int button_atck2 = PHYS_INPUT_BUTTON_ATCK2(actor);
- if (round_handler_IsActive() && !round_handler_IsRoundStarted())
+ if (weaponUseForbidden(actor))
button_atck = button_atck2 = 0; // forbid primary and secondary fire, switching is allowed
- if (forbidWeaponUse(actor))
+ if (weaponLocked(actor))
{
if (this.state != WS_CLEAR)
{
bool block_weapon = false;
{
bool key_pressed = PHYS_INPUT_BUTTON_HOOK(actor) && !actor.vehicle;
- if (round_handler_IsActive() && !round_handler_IsRoundStarted())
+ if (weaponUseForbidden(actor))
key_pressed = false;
Weapon off = actor.offhand;
vector CL_Weapon_GetShotOrg(float wpn);
-bool forbidWeaponUse(entity player);
+bool weaponUseForbidden(entity player);
+bool weaponLocked(entity player);
void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset);