initial commit

This commit is contained in:
TotallyNot 2023-12-31 21:26:43 +01:00
commit 86f9333aec
21 changed files with 6449 additions and 0 deletions

405
src/passives.rs Normal file
View file

@ -0,0 +1,405 @@
use bevy_ecs::prelude::*;
use crate::{
effect::Effects,
player::stats::{
AdditiveBonus, CritRate, Defence, Dexterity, SimpleStatBonus, Speed, Strength,
},
Stages,
};
#[derive(Component, Default)]
#[cfg_attr(feature = "json", derive(serde::Deserialize))]
pub struct Merits {
pub life: u16,
pub crits: u16,
pub brawn: u16,
pub protection: u16,
pub sharpness: u16,
pub evasion: u16,
pub heavy_artillery_mastery: u16,
pub machine_gun_mastery: u16,
pub rifle_mastery: u16,
pub smg_mastery: u16,
pub shotgun_mastery: u16,
pub pistol_mastery: u16,
pub club_mastery: u16,
pub piercing_mastery: u16,
pub slashing_mastery: u16,
pub mechanical_mastery: u16,
pub temporary_mastery: u16,
}
#[derive(Component)]
#[cfg_attr(feature = "json", derive(serde::Deserialize))]
pub struct Education {
/// Gain a 1% damage bonus to all weapons
pub bio2350: bool,
/// Gain a 10% damage increase when hitting an opponent's throat
pub bio2380: bool,
/// Gain a 3% chance increase of achieving a critical hit
pub bio2410: bool,
/// Gain a 1% passive bonus to speed
pub cbt2790: bool,
/// Gain a +1.00 accuracy increase with Machine Guns
pub cbt2820: bool,
/// Gain a +1.00 accuracy increase with Submachine guns
pub cbt2830: bool,
/// Gain a +1.00 accuracy increase with Pistols
pub cbt2840: bool,
/// Gain a +1.00 accuracy increase with Rifles
pub cbt2850: bool,
/// Gain a +1.00 accuracy increase with Heavy Artillery
pub cbt2860: bool,
/// Gain a +1.00 accuracy increase with Shotguns
pub cbt2125: bool,
/// Gain a +1.00 accuracy increase with Temporary weapons
pub gen2116: bool,
/// Gain a 5% damage increase with Temporary weapons
pub gen2119: bool,
/// Gain a 1% passive bonus to dexterity
pub haf2104: bool,
/// Gain a 1% passive bonus to speed
pub haf2105: bool,
/// Gain a 1% passive bonus to strength
pub haf2106: bool,
/// Gain a 2% passive bonus to strength
pub haf2107: bool,
/// Gain a 1% passive bonus to dexterity
pub haf2108: bool,
/// Gain a 3% passive bonus to speed
pub haf2109: bool,
/// Gain a 10% damage increase with Japanese blade weapons
pub his2160: bool,
/// Gain a 2% bonus to all melee damage
pub his2170: bool,
/// Gain a 1% passive bonus to speed
pub mth2240: bool,
/// Gain a 1% passive bonus to speed
pub mth2250: bool,
/// Gain a 1% passive bonus to defense
pub mth2260: bool,
/// Gain a 2% passive bonus to defense
pub mth2320: bool,
/// Gain a 5% bonus to ammo conservation
pub mth2310: bool,
/// Gain a 20% bonus to ammo conservation
pub mth3330: bool,
/// Gain a 1% passive bonus to dexterity
pub psy2640: bool,
/// Gain a 2% passive bonus to dexterity
pub psy2650: bool,
/// Gain a 4% passive bonus to dexterity
pub psy2660: bool,
/// Gain an 8% passive bonus to dexterity
pub psy2670: bool,
/// Gain a 1% passive bonus to defense
pub def2710: bool,
/// Gain a 2% passive bonus to defense
pub def2730: bool,
/// Gain a 3% passive bonus to defense
pub def2740: bool,
/// Gain a 2% passive bonus to speed
pub def2750: bool,
/// Gain a 3% passive bonus to speed
pub def2760: bool,
/// Gain a 100% increase in damage dealt when using fists alone
pub def3770: bool,
/// Gain a 10% increase in steroid effectiveness
// NOTE: this effect is additive with the strip club perks
pub spt2480: bool,
/// Gain a 2% passive bonus to speed and strength
pub spt2490: bool,
/// Gain a 2% passive bonus to defense and dexterity
pub spt2500: bool,
}
impl Default for Education {
fn default() -> Self {
Self {
bio2350: true,
bio2380: true,
bio2410: true,
cbt2790: true,
cbt2820: true,
cbt2830: true,
cbt2840: true,
cbt2850: true,
cbt2860: true,
cbt2125: true,
gen2116: true,
gen2119: true,
haf2104: true,
haf2105: true,
haf2106: true,
haf2107: true,
haf2108: true,
haf2109: true,
his2160: true,
his2170: true,
mth2240: true,
mth2250: true,
mth2260: true,
mth2320: true,
mth2310: true,
mth3330: true,
psy2640: true,
psy2650: true,
psy2660: true,
psy2670: true,
def2710: true,
def2730: true,
def2740: true,
def2750: true,
def2760: true,
def3770: true,
spt2480: true,
spt2490: true,
spt2500: true,
}
}
}
#[derive(Component, Default)]
#[cfg_attr(feature = "json", derive(serde::Deserialize))]
pub struct FactionUpgrades {
pub str: u16,
pub spd: u16,
pub def: u16,
pub dex: u16,
pub life: u16,
pub acc: u16,
pub dmg: u16,
pub side_effects: u16,
}
#[derive(Component)]
#[cfg_attr(feature = "json", derive(serde::Deserialize))]
pub enum DrugCooldown {
Xanax,
Vicodin,
}
#[derive(Bundle, Default)]
pub(crate) struct PassiveBundle {
pub merits: Merits,
pub education: Education,
pub faction: FactionUpgrades,
}
fn spawn_permanent_effects(
merit_q: Query<(
Entity,
&Merits,
&Education,
&FactionUpgrades,
Option<&DrugCooldown>,
)>,
mut effects: Effects,
) {
for (player, merits, edu, faction, drug_cd) in merit_q.iter() {
if merits.brawn > 0 {
effects.spawn(
AdditiveBonus::<Strength>::new("brawn", (merits.brawn as f32) * 0.03),
player,
);
}
if merits.protection > 0 {
effects.spawn(
AdditiveBonus::<Defence>::new("protection", (merits.protection as f32) * 0.03),
player,
);
}
if merits.sharpness > 0 {
effects.spawn(
AdditiveBonus::<Speed>::new("sharpness", (merits.sharpness as f32) * 0.03),
player,
);
}
if merits.evasion > 0 {
effects.spawn(
AdditiveBonus::<Dexterity>::new("evasion", (merits.evasion as f32) * 0.03),
player,
);
}
if merits.crits > 0 {
effects.spawn(
SimpleStatBonus::<CritRate>::new("merits", merits.crits),
player,
);
}
if faction.spd > 0 {
effects.spawn(
AdditiveBonus::<Speed>::new("faction", (faction.spd as f32) * 0.01),
player,
);
}
if faction.str > 0 {
effects.spawn(
AdditiveBonus::<Strength>::new("faction", (faction.str as f32) * 0.01),
player,
);
}
if faction.def > 0 {
effects.spawn(
AdditiveBonus::<Defence>::new("faction", (faction.def as f32) * 0.01),
player,
);
}
if faction.dex > 0 {
effects.spawn(
AdditiveBonus::<Dexterity>::new("faction", (faction.dex as f32) * 0.01),
player,
);
}
#[allow(clippy::too_many_arguments)]
fn spawn_drug_bonuses(
label: &'static str,
player: Entity,
effects: &mut Effects,
str: f32,
def: f32,
spd: f32,
dex: f32,
mit: f32,
) {
fn mitigate(val: f32, mit: f32) -> f32 {
if val.is_sign_negative() {
// NOTE: The rounding here is pure speculation
(val * mit).floor() / 100.0
} else {
val / 100.0
}
}
effects.spawn(
AdditiveBonus::<Strength>::new(label, mitigate(str, mit)),
player,
);
effects.spawn(
AdditiveBonus::<Defence>::new(label, mitigate(def, mit)),
player,
);
effects.spawn(
AdditiveBonus::<Speed>::new(label, mitigate(spd, mit)),
player,
);
effects.spawn(
AdditiveBonus::<Dexterity>::new(label, mitigate(dex, mit)),
player,
);
}
let mit = 1.0 - (faction.side_effects as f32) * 0.03;
match drug_cd {
Some(DrugCooldown::Xanax) => {
spawn_drug_bonuses(
"xanax",
player,
&mut effects,
-35.0,
-35.0,
-35.0,
-35.0,
mit,
);
}
Some(DrugCooldown::Vicodin) => {
spawn_drug_bonuses("vicodin", player, &mut effects, 25.0, 25.0, 25.0, 25.0, mit);
}
_ => (),
}
if edu.bio2410 {
effects.spawn(SimpleStatBonus::<CritRate>::new("BIO2410", 6), player);
}
if edu.cbt2790 {
effects.spawn(AdditiveBonus::<Speed>::new("CBT2790", 0.01), player);
}
if edu.haf2104 {
effects.spawn(AdditiveBonus::<Dexterity>::new("HAF2104", 0.01), player);
}
if edu.haf2105 {
effects.spawn(AdditiveBonus::<Speed>::new("HAF2105", 0.01), player);
}
if edu.haf2106 {
effects.spawn(AdditiveBonus::<Strength>::new("HAF2106", 0.01), player);
}
if edu.haf2107 {
effects.spawn(AdditiveBonus::<Strength>::new("HAF2107", 0.02), player);
}
if edu.haf2108 {
effects.spawn(AdditiveBonus::<Dexterity>::new("HAF2108", 0.01), player);
}
if edu.haf2109 {
effects.spawn(AdditiveBonus::<Speed>::new("HAF2109", 0.03), player);
}
if edu.mth2240 {
effects.spawn(AdditiveBonus::<Speed>::new("MTH2240", 0.01), player);
}
if edu.mth2250 {
effects.spawn(AdditiveBonus::<Speed>::new("MTH2250", 0.01), player);
}
if edu.mth2260 {
effects.spawn(AdditiveBonus::<Defence>::new("MTH2260", 0.01), player);
}
if edu.mth2320 {
effects.spawn(AdditiveBonus::<Defence>::new("MTH2320", 0.02), player);
}
if edu.psy2640 {
effects.spawn(AdditiveBonus::<Dexterity>::new("PSY2640", 0.01), player);
}
if edu.psy2650 {
effects.spawn(AdditiveBonus::<Dexterity>::new("PSY2650", 0.02), player);
}
if edu.psy2660 {
effects.spawn(AdditiveBonus::<Dexterity>::new("PSY2660", 0.04), player);
}
if edu.psy2670 {
effects.spawn(AdditiveBonus::<Dexterity>::new("PSY2670", 0.08), player);
}
if edu.def2710 {
effects.spawn(AdditiveBonus::<Defence>::new("DEF2710", 0.01), player);
}
if edu.def2730 {
effects.spawn(AdditiveBonus::<Defence>::new("DEF2730", 0.02), player);
}
if edu.def2740 {
effects.spawn(AdditiveBonus::<Defence>::new("DEF2740", 0.03), player);
}
if edu.def2750 {
effects.spawn(AdditiveBonus::<Speed>::new("DEF2750", 0.02), player);
}
if edu.def2760 {
effects.spawn(AdditiveBonus::<Speed>::new("DEF2760", 0.03), player);
}
if edu.spt2490 {
effects.spawn(AdditiveBonus::<Speed>::new("SPT2490", 0.02), player);
effects.spawn(AdditiveBonus::<Strength>::new("SPT2490", 0.02), player);
}
if edu.spt2500 {
effects.spawn(AdditiveBonus::<Defence>::new("SPT2500", 0.02), player);
effects.spawn(AdditiveBonus::<Dexterity>::new("SPT2500", 0.02), player);
}
}
}
pub(crate) fn configure(stages: &mut Stages) {
stages.equip.add_systems(spawn_permanent_effects);
}