mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Switched to BasicMelee
This commit is contained in:
parent
b1026296cb
commit
b45df7fe10
@ -1,23 +1,11 @@
|
||||
ComboMelee(
|
||||
stage_data: [(
|
||||
stage: 1,
|
||||
base_damage: 150,
|
||||
damage_increase: 10,
|
||||
base_poise_damage: 40,
|
||||
poise_damage_increase: 0,
|
||||
knockback: 10.0,
|
||||
range: 4.5,
|
||||
angle: 50.0,
|
||||
base_buildup_duration: 0.4,
|
||||
base_swing_duration: 0.1,
|
||||
base_recover_duration: 0.25,
|
||||
forward_movement: 0.0,
|
||||
)],
|
||||
initial_energy_gain: 50,
|
||||
max_energy_gain: 150,
|
||||
energy_increase: 50,
|
||||
speed_increase: 0.1,
|
||||
max_speed_increase: 0.4,
|
||||
scales_from_combo: 2,
|
||||
is_interruptible: false,
|
||||
BasicMelee(
|
||||
energy_cost: 0,
|
||||
buildup_duration: 0.6,
|
||||
swing_duration: 0.1,
|
||||
recover_duration: 0.15,
|
||||
base_damage: 50,
|
||||
base_poise_damage: 0,
|
||||
knockback: 0.0,
|
||||
range: 3.5,
|
||||
max_angle: 20.0,
|
||||
)
|
||||
|
@ -9,8 +9,8 @@ ItemDef(
|
||||
power: 0.25,
|
||||
poise_strength: 0.25,
|
||||
speed: 0.5,
|
||||
crit_chance: 0.09375,
|
||||
crit_mult: 2.2190475,
|
||||
crit_chance: 0.0,
|
||||
crit_mult: 1.0,
|
||||
)),
|
||||
)),
|
||||
quality: Low,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
combat::Attack,
|
||||
comp::{Energy, InputKind, Ori, Pos, Vel},
|
||||
comp::{tool::ToolKind, Energy, InputAttr, InputKind, Ori, Pos, Vel},
|
||||
event::{LocalEvent, ServerEvent},
|
||||
states::{behavior::JoinData, *},
|
||||
};
|
||||
@ -10,11 +10,6 @@ use specs_idvs::IdvStorage;
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
use vek::*;
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct InputAttr {
|
||||
pub select_pos: Option<Vec3<f32>>,
|
||||
}
|
||||
|
||||
/// Data returned from character behavior fn's to Character Behavior System.
|
||||
pub struct StateUpdate {
|
||||
pub character: CharacterState,
|
||||
@ -200,7 +195,7 @@ pub struct Melee {
|
||||
pub max_angle: f32,
|
||||
pub applied: bool,
|
||||
pub hit_count: u32,
|
||||
pub break_block: Option<Vec3<i32>>,
|
||||
pub break_block: Option<(Vec3<i32>, Option<ToolKind>)>,
|
||||
}
|
||||
|
||||
impl Component for Melee {
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
comp::{
|
||||
inventory::slot::{EquipSlot, InvSlotId, Slot},
|
||||
invite::{InviteKind, InviteResponse},
|
||||
BuffKind, InputAttr,
|
||||
BuffKind,
|
||||
},
|
||||
trade::{TradeAction, TradeId},
|
||||
uid::Uid,
|
||||
@ -118,7 +118,7 @@ pub enum ControlAction {
|
||||
}
|
||||
|
||||
impl ControlAction {
|
||||
pub fn basic_start(input: InputKind) -> Self {
|
||||
pub fn basic_input(input: InputKind) -> Self {
|
||||
ControlAction::StartInput {
|
||||
input,
|
||||
target: None,
|
||||
@ -144,6 +144,11 @@ impl InputKind {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct InputAttr {
|
||||
pub select_pos: Option<Vec3<f32>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Climb {
|
||||
Up,
|
||||
|
@ -55,14 +55,14 @@ pub use self::{
|
||||
Buff, BuffCategory, BuffChange, BuffData, BuffEffect, BuffId, BuffKind, BuffSource, Buffs,
|
||||
ModifierKind,
|
||||
},
|
||||
character_state::{CharacterState, InputAttr, Melee, StateUpdate},
|
||||
character_state::{CharacterState, Melee, StateUpdate},
|
||||
chat::{
|
||||
ChatMode, ChatMsg, ChatType, Faction, SpeechBubble, SpeechBubbleType, UnresolvedChatMsg,
|
||||
},
|
||||
combo::Combo,
|
||||
controller::{
|
||||
Climb, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, InputKind,
|
||||
InventoryAction, InventoryEvent, InventoryManip, MountState, Mounting,
|
||||
Climb, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, InputAttr,
|
||||
InputKind, InventoryAction, InventoryEvent, InventoryManip, MountState, Mounting,
|
||||
},
|
||||
energy::{Energy, EnergyChange, EnergySource},
|
||||
group::Group,
|
||||
|
@ -152,6 +152,7 @@ pub enum ServerEvent {
|
||||
// Attempt to mine a block, turning it into an item
|
||||
MineBlock {
|
||||
pos: Vec3<i32>,
|
||||
tool: Option<comp::tool::ToolKind>,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -122,10 +122,17 @@ impl CharacterBehavior for Data {
|
||||
max_angle: self.static_data.max_angle,
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
break_block: update
|
||||
break_block: self
|
||||
.static_data
|
||||
.ability_info
|
||||
.select_pos
|
||||
.filter(|_| self.static_data.ability_info.tool == Some(ToolKind::Pick))
|
||||
.map(|p| p.map(|e| e.floor() as i32)),
|
||||
.map(|p| {
|
||||
(
|
||||
p.map(|e| e.floor() as i32),
|
||||
self.static_data.ability_info.tool,
|
||||
)
|
||||
})
|
||||
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
||||
});
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
|
@ -187,10 +187,17 @@ impl CharacterBehavior for Data {
|
||||
max_angle: self.static_data.max_angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
break_block: update
|
||||
break_block: self
|
||||
.static_data
|
||||
.ability_info
|
||||
.select_pos
|
||||
.filter(|_| self.static_data.ability_info.tool == Some(ToolKind::Pick))
|
||||
.map(|p| p.map(|e| e.floor() as i32)),
|
||||
.map(|p| {
|
||||
(
|
||||
p.map(|e| e.floor() as i32),
|
||||
self.static_data.ability_info.tool,
|
||||
)
|
||||
})
|
||||
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
||||
});
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
// Swings
|
||||
|
@ -217,8 +217,13 @@ impl CharacterBehavior for Data {
|
||||
.static_data
|
||||
.ability_info
|
||||
.select_pos
|
||||
.filter(|_| self.static_data.ability_info.tool == Some(ToolKind::Pick))
|
||||
.map(|p| p.map(|e| e.floor() as i32)),
|
||||
.map(|p| {
|
||||
(
|
||||
p.map(|e| e.floor() as i32),
|
||||
self.static_data.ability_info.tool,
|
||||
)
|
||||
})
|
||||
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -164,12 +164,17 @@ impl CharacterBehavior for Data {
|
||||
max_angle: self.static_data.angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
break_block: update
|
||||
break_block: self
|
||||
.static_data
|
||||
.ability_info
|
||||
.select_pos
|
||||
.filter(|_| {
|
||||
self.static_data.ability_info.tool == Some(ToolKind::Pick)
|
||||
.map(|p| {
|
||||
(
|
||||
p.map(|e| e.floor() as i32),
|
||||
self.static_data.ability_info.tool,
|
||||
)
|
||||
})
|
||||
.map(|p| p.map(|e| e.floor() as i32)),
|
||||
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
||||
});
|
||||
}
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
|
@ -177,10 +177,17 @@ impl CharacterBehavior for Data {
|
||||
max_angle: self.static_data.max_angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
break_block: update
|
||||
break_block: self
|
||||
.static_data
|
||||
.ability_info
|
||||
.select_pos
|
||||
.filter(|_| self.static_data.ability_info.tool == Some(ToolKind::Pick))
|
||||
.map(|p| p.map(|e| e.floor() as i32)),
|
||||
.map(|p| {
|
||||
(
|
||||
p.map(|e| e.floor() as i32),
|
||||
self.static_data.ability_info.tool,
|
||||
)
|
||||
})
|
||||
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
||||
});
|
||||
|
||||
update.character = CharacterState::LeapMelee(Data {
|
||||
|
@ -141,10 +141,17 @@ impl CharacterBehavior for Data {
|
||||
max_angle: 180_f32.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
break_block: update
|
||||
break_block: self
|
||||
.static_data
|
||||
.ability_info
|
||||
.select_pos
|
||||
.filter(|_| self.static_data.ability_info.tool == Some(ToolKind::Pick))
|
||||
.map(|p| p.map(|e| e.floor() as i32)),
|
||||
.map(|p| {
|
||||
(
|
||||
p.map(|e| e.floor() as i32),
|
||||
self.static_data.ability_info.tool,
|
||||
)
|
||||
})
|
||||
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
||||
});
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
if matches!(
|
||||
|
@ -69,12 +69,15 @@ impl<'a> System<'a> for Sys {
|
||||
let rad = body.radius() * scale;
|
||||
|
||||
// Mine blocks broken by the attack
|
||||
if let Some(block_pos) = melee_attack.break_block {
|
||||
if let Some((block_pos, tool)) = melee_attack.break_block {
|
||||
// Check distance to block
|
||||
if eye_pos.distance_squared(block_pos.map(|e| e as f32 + 0.5))
|
||||
< (rad + scale * melee_attack.range).powi(2)
|
||||
{
|
||||
server_emitter.emit(ServerEvent::MineBlock { pos: block_pos });
|
||||
server_emitter.emit(ServerEvent::MineBlock {
|
||||
pos: block_pos,
|
||||
tool,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,10 @@ use tracing::error;
|
||||
use vek::*;
|
||||
|
||||
use common::{
|
||||
comp::{self, agent::AgentEvent, inventory::slot::EquipSlot, item, slot::Slot, Inventory, Pos},
|
||||
comp::{
|
||||
self, agent::AgentEvent, inventory::slot::EquipSlot, item, slot::Slot, tool::ToolKind,
|
||||
Inventory, Pos,
|
||||
},
|
||||
consts::MAX_MOUNT_RANGE,
|
||||
uid::Uid,
|
||||
vol::ReadVol,
|
||||
@ -257,11 +260,11 @@ fn within_mounting_range(player_position: Option<&Pos>, mount_position: Option<&
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_mine_block(server: &mut Server, pos: Vec3<i32>) {
|
||||
pub fn handle_mine_block(server: &mut Server, pos: Vec3<i32>, tool: Option<ToolKind>) {
|
||||
let state = server.state_mut();
|
||||
if state.can_set_block(pos) {
|
||||
let block = state.terrain().get(pos).ok().copied();
|
||||
if let Some(block) = block {
|
||||
if let Some(block) = block.filter(|b| b.mine_tool().map_or(true, |t| Some(t) == tool)) {
|
||||
if let Some(item) = comp::Item::try_reclaim_from_block(block) {
|
||||
state
|
||||
.create_object(Default::default(), comp::object::Body::Pouch)
|
||||
|
@ -191,7 +191,7 @@ impl Server {
|
||||
handle_combo_change(&self, entity, change)
|
||||
},
|
||||
ServerEvent::RequestSiteInfo { entity, id } => handle_site_info(&self, entity, id),
|
||||
ServerEvent::MineBlock { pos } => handle_mine_block(self, pos),
|
||||
ServerEvent::MineBlock { pos, tool } => handle_mine_block(self, pos, tool),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ impl<'a> System<'a> for Sys {
|
||||
// every frame.
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Fly));
|
||||
.push(ControlAction::basic_input(InputKind::Fly));
|
||||
}
|
||||
|
||||
let flees = alignment
|
||||
@ -631,7 +631,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Fly));
|
||||
.push(ControlAction::basic_input(InputKind::Fly));
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
@ -1136,7 +1136,7 @@ impl<'a> AgentData<'a> {
|
||||
if condition {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Jump));
|
||||
.push(ControlAction::basic_input(InputKind::Jump));
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
@ -1258,7 +1258,7 @@ impl<'a> AgentData<'a> {
|
||||
if dist_sqrd < (min_attack_dist * self.scale).powi(2) {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
@ -1283,7 +1283,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
}
|
||||
} else {
|
||||
agent.target = None;
|
||||
@ -1300,7 +1300,7 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer > 4.0 && self.energy.current() > 10 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if self
|
||||
.stats
|
||||
@ -1311,12 +1311,12 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
@ -1341,7 +1341,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
}
|
||||
} else {
|
||||
agent.target = None;
|
||||
@ -1358,7 +1358,7 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer > 2.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if self
|
||||
.stats
|
||||
@ -1369,12 +1369,12 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
@ -1399,7 +1399,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
agent.action_timer = 0.0;
|
||||
} else {
|
||||
agent.action_timer += dt.0;
|
||||
@ -1417,7 +1417,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
}
|
||||
} else {
|
||||
agent.target = None;
|
||||
@ -1435,14 +1435,14 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer > 2.0 {
|
||||
agent.action_timer = 0.0;
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
@ -1462,7 +1462,7 @@ impl<'a> AgentData<'a> {
|
||||
if agent.action_timer > 4.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer = 0.0;
|
||||
} else {
|
||||
agent.action_timer += dt.0;
|
||||
@ -1480,7 +1480,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
}
|
||||
} else {
|
||||
agent.target = None;
|
||||
@ -1492,7 +1492,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
@ -1519,7 +1519,7 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer > 2.0 && self.energy.current() > 300 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if self
|
||||
.stats
|
||||
@ -1533,7 +1533,7 @@ impl<'a> AgentData<'a> {
|
||||
.push(ControlAction::CancelInput(InputKind::Secondary));
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller
|
||||
@ -1541,7 +1541,7 @@ impl<'a> AgentData<'a> {
|
||||
.push(ControlAction::CancelInput(InputKind::Secondary));
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
} else {
|
||||
@ -1557,7 +1557,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
}
|
||||
} else if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
@ -1585,7 +1585,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
} else if dist_sqrd < (5.0 * min_attack_dist * self.scale).powi(2) {
|
||||
if agent.action_timer < 1.5 {
|
||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||
@ -1613,15 +1613,15 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
} else if self.energy.current() > 10 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
}
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
@ -1643,7 +1643,7 @@ impl<'a> AgentData<'a> {
|
||||
* speed;
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else {
|
||||
controller.inputs.move_dir =
|
||||
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
||||
@ -1657,7 +1657,7 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Roll));
|
||||
.push(ControlAction::basic_input(InputKind::Roll));
|
||||
}
|
||||
} else if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
@ -1686,13 +1686,13 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
//controller.inputs.primary.set_state(true);
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if self.vel.0.is_approx_zero() {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
}
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
@ -1710,7 +1710,7 @@ impl<'a> AgentData<'a> {
|
||||
if agent.action_timer > 5.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer = 0.0;
|
||||
} else {
|
||||
agent.action_timer += dt.0;
|
||||
@ -1735,7 +1735,7 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else if dist_sqrd < (radius as f32 * min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = (self.pos.0 - tgt_pos.0)
|
||||
.xy()
|
||||
@ -1754,7 +1754,7 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer < circle_time as f32 + 0.5 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer < 2.0 * circle_time as f32 + 0.5 {
|
||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||
@ -1766,7 +1766,7 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer < 2.0 * circle_time as f32 + 1.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
agent.action_timer = 0.0;
|
||||
@ -1799,7 +1799,7 @@ impl<'a> AgentData<'a> {
|
||||
.unwrap_or_else(Vec2::unit_y);
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
@ -1833,7 +1833,7 @@ impl<'a> AgentData<'a> {
|
||||
}
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
self.jump_if(controller, bearing.z > 1.5);
|
||||
controller.inputs.move_z = bearing.z;
|
||||
} else {
|
||||
@ -1859,12 +1859,12 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer > 1.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||
@ -1897,13 +1897,13 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
} else if dist_sqrd < (3.0 * min_attack_dist * self.scale).powi(2)
|
||||
&& dist_sqrd > (2.0 * min_attack_dist * self.scale).powi(2)
|
||||
{
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||
.xy()
|
||||
.rotated_z(-0.47 * PI)
|
||||
@ -1937,12 +1937,12 @@ impl<'a> AgentData<'a> {
|
||||
} else if agent.action_timer > 2.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
@ -1970,11 +1970,11 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
} else if dist_sqrd < (5.0 * min_attack_dist * self.scale).powi(2) {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
@ -1989,7 +1989,7 @@ impl<'a> AgentData<'a> {
|
||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
controller.inputs.move_dir =
|
||||
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
||||
} else {
|
||||
@ -2009,12 +2009,12 @@ impl<'a> AgentData<'a> {
|
||||
if agent.action_timer < 2.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer < 3.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
agent.action_timer = 0.0;
|
||||
@ -2044,7 +2044,7 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Secondary));
|
||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||
} else if dist_sqrd < (7.0 * min_attack_dist * self.scale).powi(2) {
|
||||
if agent.action_timer < 2.0 {
|
||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||
@ -2054,7 +2054,7 @@ impl<'a> AgentData<'a> {
|
||||
.unwrap_or_else(Vec2::unit_y);
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer < 4.0 {
|
||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||
@ -2064,12 +2064,12 @@ impl<'a> AgentData<'a> {
|
||||
.unwrap_or_else(Vec2::unit_y);
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer < 6.0 {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Ability(0)));
|
||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
agent.action_timer = 0.0;
|
||||
@ -2099,7 +2099,7 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
@ -2124,7 +2124,7 @@ impl<'a> AgentData<'a> {
|
||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else {
|
||||
agent.target = None;
|
||||
}
|
||||
@ -2134,7 +2134,7 @@ impl<'a> AgentData<'a> {
|
||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else {
|
||||
agent.target = None;
|
||||
}
|
||||
@ -2150,7 +2150,7 @@ impl<'a> AgentData<'a> {
|
||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::basic_start(InputKind::Primary));
|
||||
.push(ControlAction::basic_input(InputKind::Primary));
|
||||
} else {
|
||||
agent.target = None;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user