Disable shooting with spawn protection, lower default spawn protection

This commit is contained in:
Sofia 2026-08-03 19:57:16 +03:00
parent e0fd2cf804
commit d28ba31d74
4 changed files with 16 additions and 3 deletions

View File

@ -15,7 +15,7 @@ impl Default for GameOptions {
opts.insert(GameOption::FriendlyFire, GameOptionValue::Boolean(true));
opts.insert(GameOption::GoalsNeededToWin, GameOptionValue::Number(5.));
opts.insert(GameOption::RespawnTimer, GameOptionValue::Number(5.));
opts.insert(GameOption::SpawnProtection, GameOptionValue::Number(5.));
opts.insert(GameOption::SpawnProtection, GameOptionValue::Number(3.));
opts.insert(
GameOption::TelegrenadesAllowed,
GameOptionValue::Boolean(true),

View File

@ -45,6 +45,15 @@ impl Buffs {
true
}
pub fn can_shoot(&self) -> bool {
for buff in &self.buffs {
match buff.kind {
BuffKind::SpawnProtection => return false,
}
}
true
}
pub fn new_buff(&mut self, buff: Buff) {
self.buffs.push(buff);
}

View File

@ -203,7 +203,7 @@ impl IPlayer for LocalPlayer {
}
fn try_shoot(&mut self, to: Vector3, deal_damage: bool) -> bool {
if self.try_shoot_common(to, deal_damage) {
if self.buffs.can_shoot() && self.try_shoot_common(to, deal_damage) {
if let Some(weapon) = &mut self.weapon {
weapon.set_position(-Vector3::FORWARD);
weapon.set_rotation(Vector3::RIGHT * 0.5);

View File

@ -148,7 +148,11 @@ impl IPlayer for RemotePlayer {
}
fn try_shoot(&mut self, to: Vector3, deal_damage: bool) -> bool {
self.try_shoot_common(to, deal_damage)
if self.buffs.can_shoot() {
self.try_shoot_common(to, deal_damage)
} else {
false
}
}
fn try_throw_telegrenade(&mut self, to: Vector3) -> bool {