From fcb0f8d8f044f2477594fea9c908251609f26e86 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 2 Feb 2022 20:45:43 -0500 Subject: [PATCH] Wood golem attacks and ai --- .../common/abilities/ability_set_manifest.ron | 7 +++ .../abilities/custom/beastclaws/basic.ron | 1 + .../abilities/custom/claygolem/strike.ron | 1 + .../abilities/custom/harvester/scythe.ron | 1 + .../abilities/custom/mandragora/basic.ron | 1 + .../custom/minotaur/cripplingstrike.ron | 1 + .../abilities/custom/quadmedhoof/basic.ron | 1 + .../abilities/custom/tidalwarrior/pincer.ron | 1 + .../abilities/custom/woodgolem/shockwave.ron | 17 ++++++ .../abilities/custom/woodgolem/spin.ron | 22 ++++++++ .../abilities/custom/woodgolem/strike.ron | 17 ++++++ .../common/abilities/custom/yeti/strike.ron | 1 + assets/common/abilities/dagger/tempbasic.ron | 1 + assets/common/abilities/empty/basic.ron | 1 + assets/common/abilities/farming/basic.ron | 1 + assets/common/abilities/gnarling/axe/chop.ron | 1 + .../common/abilities/gnarling/dagger/stab.ron | 1 + assets/common/abilities/pick/swing.ron | 1 + assets/common/abilities/shield/tempbasic.ron | 1 + .../items/npc_armor/golem/woodgolem.ron | 13 +++++ .../npc_weapons/unique/wood_golem_fist.ron | 21 ++++++++ common/src/comp/ability.rs | 5 ++ common/src/comp/inventory/loadout_builder.rs | 4 ++ common/src/states/basic_melee.rs | 4 +- server/src/sys/agent.rs | 4 ++ server/src/sys/agent/attack.rs | 54 +++++++++++++++++++ server/src/sys/agent/data.rs | 1 + .../audio/sfx/event_mapper/combat/tests.rs | 1 + 28 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 assets/common/abilities/custom/woodgolem/shockwave.ron create mode 100644 assets/common/abilities/custom/woodgolem/spin.ron create mode 100644 assets/common/abilities/custom/woodgolem/strike.ron create mode 100644 assets/common/items/npc_armor/golem/woodgolem.ron create mode 100644 assets/common/items/npc_weapons/unique/wood_golem_fist.ron diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 161fb4f37d..7cd5af3ee0 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -89,6 +89,13 @@ secondary: "common.abilities.custom.mandragora.scream", abilities: [], ), + Custom("Wood Golem"): ( + primary: "common.abilities.custom.woodgolem.strike", + secondary: "common.abilities.custom.woodgolem.spin", + abilities: [ + (None, "common.abilities.custom.woodgolem.shockwave") + ], + ), Custom("Sword Simple"): ( primary: "common.abilities.swordsimple.doublestrike", secondary: "common.abilities.swordsimple.dash", diff --git a/assets/common/abilities/custom/beastclaws/basic.ron b/assets/common/abilities/custom/beastclaws/basic.ron index f7c5ce98be..22a98bfc32 100644 --- a/assets/common/abilities/custom/beastclaws/basic.ron +++ b/assets/common/abilities/custom/beastclaws/basic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 5.0, angle: 120.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/claygolem/strike.ron b/assets/common/abilities/custom/claygolem/strike.ron index dd4829a4fc..c49c68b75f 100644 --- a/assets/common/abilities/custom/claygolem/strike.ron +++ b/assets/common/abilities/custom/claygolem/strike.ron @@ -13,4 +13,5 @@ BasicMelee( range: 4.0, angle: 45.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/harvester/scythe.ron b/assets/common/abilities/custom/harvester/scythe.ron index 423f136dc5..d47ee5c838 100644 --- a/assets/common/abilities/custom/harvester/scythe.ron +++ b/assets/common/abilities/custom/harvester/scythe.ron @@ -13,4 +13,5 @@ BasicMelee( range: 4.0, angle: 60.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/mandragora/basic.ron b/assets/common/abilities/custom/mandragora/basic.ron index 1ffb653d5f..cf44dd6b25 100644 --- a/assets/common/abilities/custom/mandragora/basic.ron +++ b/assets/common/abilities/custom/mandragora/basic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 3, angle: 30, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/minotaur/cripplingstrike.ron b/assets/common/abilities/custom/minotaur/cripplingstrike.ron index 868984e356..75889c0937 100644 --- a/assets/common/abilities/custom/minotaur/cripplingstrike.ron +++ b/assets/common/abilities/custom/minotaur/cripplingstrike.ron @@ -13,4 +13,5 @@ BasicMelee( range: 5.0, angle: 60.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/quadmedhoof/basic.ron b/assets/common/abilities/custom/quadmedhoof/basic.ron index bc35fc17d6..86baf681b0 100644 --- a/assets/common/abilities/custom/quadmedhoof/basic.ron +++ b/assets/common/abilities/custom/quadmedhoof/basic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 0.8, angle: 50.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/tidalwarrior/pincer.ron b/assets/common/abilities/custom/tidalwarrior/pincer.ron index 1a165b2b5a..8b52b39ed2 100644 --- a/assets/common/abilities/custom/tidalwarrior/pincer.ron +++ b/assets/common/abilities/custom/tidalwarrior/pincer.ron @@ -13,4 +13,5 @@ BasicMelee( range: 5.0, angle: 60.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/custom/woodgolem/shockwave.ron b/assets/common/abilities/custom/woodgolem/shockwave.ron new file mode 100644 index 0000000000..45e34c9b48 --- /dev/null +++ b/assets/common/abilities/custom/woodgolem/shockwave.ron @@ -0,0 +1,17 @@ +Shockwave( + energy_cost: 0, + buildup_duration: 1.5, + swing_duration: 0.12, + recover_duration: 1.2, + damage: 20.0, + poise_damage: 30, + knockback: (strength: 30.0, direction: TowardsUp), + shockwave_angle: 90.0, + shockwave_vertical_angle: 90.0, + shockwave_speed: 15.0, + shockwave_duration: 2.0, + requires_ground: true, + move_efficiency: 0.0, + damage_kind: Crushing, + specifier: Ground, +) diff --git a/assets/common/abilities/custom/woodgolem/spin.ron b/assets/common/abilities/custom/woodgolem/spin.ron new file mode 100644 index 0000000000..0acd740d55 --- /dev/null +++ b/assets/common/abilities/custom/woodgolem/spin.ron @@ -0,0 +1,22 @@ +SpinMelee( + buildup_duration: 0.1, + swing_duration: 0.3, + recover_duration: 0.1, + melee_constructor: ( + kind: Bash( + damage: 15.0, + poise: 30.0, + knockback: 20.0, + energy_regen: 0.0, + ), + range: 7.5, + angle: 360.0, + ), + energy_cost: 0, + is_infinite: false, + movement_behavior: Stationary, + is_interruptible: false, + forward_speed: 0.0, + num_spins: 1, + specifier: None, +) diff --git a/assets/common/abilities/custom/woodgolem/strike.ron b/assets/common/abilities/custom/woodgolem/strike.ron new file mode 100644 index 0000000000..5dd0dd6715 --- /dev/null +++ b/assets/common/abilities/custom/woodgolem/strike.ron @@ -0,0 +1,17 @@ +BasicMelee( + energy_cost: 0, + buildup_duration: 0.8, + swing_duration: 0.1, + recover_duration: 0.5, + melee_constructor: ( + kind: Bash( + damage: 10.0, + poise: 25.0, + knockback: 15.0, + energy_regen: 0.0, + ), + range: 4.0, + angle: 45.0, + ), + ori_modifier: 0.4, +) diff --git a/assets/common/abilities/custom/yeti/strike.ron b/assets/common/abilities/custom/yeti/strike.ron index fbd0fb6dec..20fcb6ce98 100644 --- a/assets/common/abilities/custom/yeti/strike.ron +++ b/assets/common/abilities/custom/yeti/strike.ron @@ -13,4 +13,5 @@ BasicMelee( range: 4.0, angle: 20.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/dagger/tempbasic.ron b/assets/common/abilities/dagger/tempbasic.ron index 7ef4502d09..91c60c050b 100644 --- a/assets/common/abilities/dagger/tempbasic.ron +++ b/assets/common/abilities/dagger/tempbasic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 3.5, angle: 20.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/empty/basic.ron b/assets/common/abilities/empty/basic.ron index b96f4cf0bd..c4c9226ad4 100644 --- a/assets/common/abilities/empty/basic.ron +++ b/assets/common/abilities/empty/basic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 3.5, angle: 15.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/farming/basic.ron b/assets/common/abilities/farming/basic.ron index 44419919c7..25fa0ba93b 100644 --- a/assets/common/abilities/farming/basic.ron +++ b/assets/common/abilities/farming/basic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 3.5, angle: 20.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/gnarling/axe/chop.ron b/assets/common/abilities/gnarling/axe/chop.ron index 833977ec9b..9b8c9e8c06 100644 --- a/assets/common/abilities/gnarling/axe/chop.ron +++ b/assets/common/abilities/gnarling/axe/chop.ron @@ -13,4 +13,5 @@ BasicMelee( range: 3, angle: 30, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/gnarling/dagger/stab.ron b/assets/common/abilities/gnarling/dagger/stab.ron index 7c786aa313..59e77ff8a4 100644 --- a/assets/common/abilities/gnarling/dagger/stab.ron +++ b/assets/common/abilities/gnarling/dagger/stab.ron @@ -13,4 +13,5 @@ BasicMelee( range: 2, angle: 15, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/pick/swing.ron b/assets/common/abilities/pick/swing.ron index d51a64d7e0..dd1c02be5c 100644 --- a/assets/common/abilities/pick/swing.ron +++ b/assets/common/abilities/pick/swing.ron @@ -13,4 +13,5 @@ BasicMelee( range: 4.5, angle: 20.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/abilities/shield/tempbasic.ron b/assets/common/abilities/shield/tempbasic.ron index f1f746580f..7793bb5b1b 100644 --- a/assets/common/abilities/shield/tempbasic.ron +++ b/assets/common/abilities/shield/tempbasic.ron @@ -13,4 +13,5 @@ BasicMelee( range: 3.0, angle: 90.0, ), + ori_modifier: 1.0, ) diff --git a/assets/common/items/npc_armor/golem/woodgolem.ron b/assets/common/items/npc_armor/golem/woodgolem.ron new file mode 100644 index 0000000000..6f97bc29ea --- /dev/null +++ b/assets/common/items/npc_armor/golem/woodgolem.ron @@ -0,0 +1,13 @@ +ItemDef( + name: "Wood Golem Armor", + description: "Yeet", + kind: Armor(( + kind: Chest("Wood Golem"), + stats: ( + protection: Some(Normal(60.0)), + poise_resilience: Some(Normal(60.0)), + ), + )), + quality: Common, + tags: [], +) \ No newline at end of file diff --git a/assets/common/items/npc_weapons/unique/wood_golem_fist.ron b/assets/common/items/npc_weapons/unique/wood_golem_fist.ron new file mode 100644 index 0000000000..5567ac650c --- /dev/null +++ b/assets/common/items/npc_weapons/unique/wood_golem_fist.ron @@ -0,0 +1,21 @@ +ItemDef( + name: "Wood Golem Fists", + description: "Yeet", + kind: Tool(( + kind: Natural, + hands: Two, + stats: Direct(( + equip_time_secs: 0.001, + power: 1.0, + effect_power: 1.0, + speed: 1.0, + crit_chance: 0.1, + range: 1.0, + energy_efficiency: 1.0, + buff_strength: 1.0, + )), + )), + quality: Low, + tags: [], + ability_spec: Some(Custom("Wood Golem")), +) \ No newline at end of file diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 32efaa0611..8ad672aba0 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -394,6 +394,7 @@ pub enum CharacterAbility { swing_duration: f32, recover_duration: f32, melee_constructor: MeleeConstructor, + ori_modifier: f32, }, BasicRanged { energy_cost: f32, @@ -610,6 +611,7 @@ impl Default for CharacterAbility { angle: 15.0, damage_effect: None, }, + ori_modifier: 1.0, } } } @@ -697,6 +699,7 @@ impl CharacterAbility { ref mut swing_duration, ref mut recover_duration, ref mut melee_constructor, + ori_modifier: _, } => { *buildup_duration /= stats.speed; *swing_duration /= stats.speed; @@ -1696,6 +1699,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { swing_duration, recover_duration, melee_constructor, + ori_modifier, energy_cost: _, } => CharacterState::BasicMelee(basic_melee::Data { static_data: basic_melee::StaticData { @@ -1703,6 +1707,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { swing_duration: Duration::from_secs_f32(*swing_duration), recover_duration: Duration::from_secs_f32(*recover_duration), melee_constructor: *melee_constructor, + ori_modifier: *ori_modifier, ability_info, }, timer: Duration::default(), diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 7bd3e03e4f..84c8c9873b 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -180,6 +180,9 @@ fn default_main_tool(body: &Body) -> Item { golem::Species::ClayGolem => Some(Item::new_from_asset_expect( "common.items.npc_weapons.unique.clay_golem_fist", )), + golem::Species::WoodGolem => Some(Item::new_from_asset_expect( + "common.items.npc_weapons.unique.wood_golem_fist", + )), _ => None, }, Body::QuadrupedMedium(quadruped_medium) => match quadruped_medium.species { @@ -465,6 +468,7 @@ impl LoadoutBuilder { }, Body::Golem(body) => match body.species { golem::Species::ClayGolem => Some("common.items.npc_armor.golem.claygolem"), + golem::Species::WoodGolem => Some("common.items.npc_armor.golem.woodgolem"), _ => None, }, Body::QuadrupedLow(body) => match body.species { diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 7161a6ac36..534c969aeb 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -23,6 +23,8 @@ pub struct StaticData { pub recover_duration: Duration, /// Used to construct the Melee attack pub melee_constructor: MeleeConstructor, + /// Adjusts turning rate during the attack + pub ori_modifier: f32, /// What key is used to press ability pub ability_info: AbilityInfo, } @@ -44,7 +46,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_orientation(data, &mut update, 1.0, None); + handle_orientation(data, &mut update, self.static_data.ori_modifier, None); handle_move(data, &mut update, 0.7); handle_jump(data, output_events, &mut update, 1.0); diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 2c36f98b0a..dccf1799b6 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -1749,6 +1749,7 @@ impl<'a> AgentData<'a> { "Gnarling Blowgun" => Tactic::ElevatedRanged, "Deadwood" => Tactic::Deadwood, "Mandragora" => Tactic::Mandragora, + "Wood Golem" => Tactic::WoodGolem, _ => Tactic::SimpleMelee, }, AbilitySpec::Tool(tool_kind) => tool_tactic(*tool_kind), @@ -2132,6 +2133,9 @@ impl<'a> AgentData<'a> { Tactic::Mandragora => { self.handle_mandragora(agent, controller, &attack_data, tgt_data, read_data) }, + Tactic::WoodGolem => { + self.handle_wood_golem(agent, controller, &attack_data, tgt_data, read_data) + }, } } diff --git a/server/src/sys/agent/attack.rs b/server/src/sys/agent/attack.rs index 1e4424f038..a2ac4f7c81 100644 --- a/server/src/sys/agent/attack.rs +++ b/server/src/sys/agent/attack.rs @@ -2192,4 +2192,58 @@ impl<'a> AgentData<'a> { } } } + + pub fn handle_wood_golem( + &self, + agent: &mut Agent, + controller: &mut Controller, + attack_data: &AttackData, + tgt_data: &TargetData, + read_data: &ReadData, + ) { + const SHOCKWAVE_RANGE: f32 = 25.0; + const SHOCKWAVE_WAIT_TIME: f32 = 7.5; + const SPIN_WAIT_TIME: f32 = 3.0; + + // After spinning, reset timer + if matches!(self.char_state, CharacterState::SpinMelee(s) if s.stage_section == StageSection::Recover) + { + agent.action_state.timer = 0.0; + } + + if attack_data.in_min_range() { + // If in minimum range + if agent.action_state.timer > SPIN_WAIT_TIME { + // If it's been too long since able to hit target, spin + controller.push_basic_input(InputKind::Secondary); + } else if attack_data.angle < 30.0 { + // Else if in angle to strike, strike + controller.push_basic_input(InputKind::Primary); + } else { + // Else increment spin timer + agent.action_state.timer += read_data.dt.0; + // If not in angle, apply slight movement so golem orients itself correctly + controller.inputs.move_dir = (tgt_data.pos.0 - self.pos.0) + .xy() + .try_normalized() + .unwrap_or_else(Vec2::zero) + * 0.01; + } + } else { + // Else if too far for melee + if attack_data.dist_sqrd < SHOCKWAVE_RANGE.powi(2) && attack_data.angle < 45.0 { + // Shockwave if close enough and haven't shockwaved too recently + if agent.action_state.counter > SHOCKWAVE_WAIT_TIME { + controller.push_basic_input(InputKind::Ability(0)); + } + if matches!(self.char_state, CharacterState::Shockwave(_)) { + agent.action_state.counter = 0.0; + } else { + agent.action_state.counter += read_data.dt.0; + } + } + // And always try to path towards target + self.path_toward_target(agent, controller, tgt_data, read_data, false, false, None); + } + } } diff --git a/server/src/sys/agent/data.rs b/server/src/sys/agent/data.rs index 57dfbef116..d294067ff7 100644 --- a/server/src/sys/agent/data.rs +++ b/server/src/sys/agent/data.rs @@ -116,6 +116,7 @@ pub enum Tactic { StoneGolem, Deadwood, Mandragora, + WoodGolem, } #[derive(SystemData)] diff --git a/voxygen/src/audio/sfx/event_mapper/combat/tests.rs b/voxygen/src/audio/sfx/event_mapper/combat/tests.rs index c38844cebb..6495771f27 100644 --- a/voxygen/src/audio/sfx/event_mapper/combat/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/combat/tests.rs @@ -87,6 +87,7 @@ fn maps_basic_melee() { angle: 15.0, damage_effect: None, }, + ori_modifier: 1.0, ability_info: empty_ability_info(), }, timer: Duration::default(),