Add friendly fire option
This commit is contained in:
parent
d3e082084a
commit
f732472f7c
@ -91,6 +91,7 @@ impl Default for GameOptions {
|
|||||||
let mut opts = HashMap::new();
|
let mut opts = HashMap::new();
|
||||||
opts.insert(GameOption::AllowAnyMap, GameOptionValue::Boolean(false));
|
opts.insert(GameOption::AllowAnyMap, GameOptionValue::Boolean(false));
|
||||||
opts.insert(GameOption::AllowAnyTeam, GameOptionValue::Boolean(false));
|
opts.insert(GameOption::AllowAnyTeam, GameOptionValue::Boolean(false));
|
||||||
|
opts.insert(GameOption::FriendlyFire, GameOptionValue::Boolean(true));
|
||||||
Self { values: opts }
|
Self { values: opts }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +116,8 @@ pub enum GameOption {
|
|||||||
AllowAnyMap,
|
AllowAnyMap,
|
||||||
/// Allow anyone to select anyone's team, not just themselves and the host
|
/// Allow anyone to select anyone's team, not just themselves and the host
|
||||||
AllowAnyTeam,
|
AllowAnyTeam,
|
||||||
|
/// Allow anyone to shoot anyone, not just other team's members
|
||||||
|
FriendlyFire,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for GameOption {
|
impl ToString for GameOption {
|
||||||
@ -122,6 +125,7 @@ impl ToString for GameOption {
|
|||||||
match self {
|
match self {
|
||||||
GameOption::AllowAnyMap => "Allow anyone to select the map",
|
GameOption::AllowAnyMap => "Allow anyone to select the map",
|
||||||
GameOption::AllowAnyTeam => "Allow anyone to select any teams",
|
GameOption::AllowAnyTeam => "Allow anyone to select any teams",
|
||||||
|
GameOption::FriendlyFire => "Friendly fire",
|
||||||
}
|
}
|
||||||
.to_owned()
|
.to_owned()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use godot::{classes::AudioStreamPlayer3D, prelude::*};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game_manager::Game,
|
game_manager::{Game, GameOption},
|
||||||
net::util::cast_ray,
|
net::util::cast_ray,
|
||||||
player::{DamageSource, IPlayer},
|
player::{DamageSource, IPlayer},
|
||||||
};
|
};
|
||||||
@ -69,9 +69,17 @@ impl Weapon for Raygun {
|
|||||||
|
|
||||||
if deal_damage && let Some(target) = target {
|
if deal_damage && let Some(target) = target {
|
||||||
if let Ok(mut player) = target.collider.try_dynify::<dyn IPlayer>() {
|
if let Ok(mut player) = target.collider.try_dynify::<dyn IPlayer>() {
|
||||||
player
|
self.run_deferred(move |_| {
|
||||||
.dyn_bind_mut()
|
if let Some(game) = Game::singleton()
|
||||||
.take_damage(DamageSource::Player(player_id), 100, true);
|
&& game.bind().opts.is_true(GameOption::FriendlyFire)
|
||||||
|
{
|
||||||
|
player.dyn_bind_mut().take_damage(
|
||||||
|
DamageSource::Player(player_id),
|
||||||
|
100,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user