Fix npcs untargeting trade partner while in trade

This commit is contained in:
Tavo Annus 2022-10-06 21:52:09 +03:00
parent d4f5a18bd0
commit fcd7447991
3 changed files with 7 additions and 9 deletions

View File

@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- FXAA now behaves correctly at non-1.0x internal resolutions - FXAA now behaves correctly at non-1.0x internal resolutions
- Pets no longer aggro on pet owners after being healed - Pets no longer aggro on pet owners after being healed
- Pets no longer lose their intrinsic weapons/armour when loaded on login. - Pets no longer lose their intrinsic weapons/armour when loaded on login.
- Fixed npcs using `/say` instead of `/tell`
## [0.13.0] - 2022-07-23 ## [0.13.0] - 2022-07-23

View File

@ -86,7 +86,6 @@ impl BehaviorTree {
do_hostile_tree_if_hostile, do_hostile_tree_if_hostile,
do_pet_tree_if_owned, do_pet_tree_if_owned,
do_pickup_loot, do_pickup_loot,
untarget,
do_idle_tree, do_idle_tree,
], ],
} }
@ -339,6 +338,7 @@ fn do_pickup_loot(bdata: &mut BehaviorData) -> bool {
.controller .controller
.push_event(ControlEvent::InventoryEvent(InventoryEvent::Pickup(*uid))); .push_event(ControlEvent::InventoryEvent(InventoryEvent::Pickup(*uid)));
} }
bdata.agent.target = None;
} else if let Some((bearing, speed)) = bdata.agent.chaser.chase( } else if let Some((bearing, speed)) = bdata.agent.chaser.chase(
&*bdata.read_data.terrain, &*bdata.read_data.terrain,
bdata.agent_data.pos.0, bdata.agent_data.pos.0,
@ -362,14 +362,6 @@ fn do_pickup_loot(bdata: &mut BehaviorData) -> bool {
false false
} }
/// Reset the agent's target
///
/// This function will never stop the BehaviorTree
fn untarget(bdata: &mut BehaviorData) -> bool {
bdata.agent.target = None;
false
}
// If too far away, then follow the target // If too far away, then follow the target
fn follow_if_far_away(bdata: &mut BehaviorData) -> bool { fn follow_if_far_away(bdata: &mut BehaviorData) -> bool {
if let Some(Target { target, .. }) = bdata.agent.target { if let Some(Target { target, .. }) = bdata.agent.target {

View File

@ -489,6 +489,7 @@ pub fn handle_inbox_finished_trade(bdata: &mut BehaviorData) -> bool {
}, },
} }
agent.behavior.unset(BehaviorState::TRADING); agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
} }
} }
true true
@ -559,6 +560,7 @@ pub fn handle_inbox_update_pending_trade(bdata: &mut BehaviorData) -> bool {
if pending.phase != TradePhase::Mutate { if pending.phase != TradePhase::Mutate {
// we got into the review phase but without balanced goods, decline // we got into the review phase but without balanced goods, decline
agent.behavior.unset(BehaviorState::TRADING); agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
event_emitter.emit(ServerEvent::ProcessTradeAction( event_emitter.emit(ServerEvent::ProcessTradeAction(
*agent_data.entity, *agent_data.entity,
tradeid, tradeid,
@ -601,6 +603,7 @@ pub fn handle_inbox_update_pending_trade(bdata: &mut BehaviorData) -> bool {
}, },
TradingBehavior::None => { TradingBehavior::None => {
agent.behavior.unset(BehaviorState::TRADING); agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
event_emitter.emit(ServerEvent::ProcessTradeAction( event_emitter.emit(ServerEvent::ProcessTradeAction(
*agent_data.entity, *agent_data.entity,
tradeid, tradeid,
@ -691,6 +694,7 @@ pub fn handle_inbox_cancel_interactions(bdata: &mut BehaviorData) -> bool {
}, },
} }
agent.behavior.unset(BehaviorState::TRADING); agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
} }
true true
}, },
@ -698,6 +702,7 @@ pub fn handle_inbox_cancel_interactions(bdata: &mut BehaviorData) -> bool {
// immediately cancel the trade // immediately cancel the trade
let (tradeid, _pending, _prices, _inventories) = &**boxval; let (tradeid, _pending, _prices, _inventories) = &**boxval;
agent.behavior.unset(BehaviorState::TRADING); agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
event_emitter.emit(ServerEvent::ProcessTradeAction( event_emitter.emit(ServerEvent::ProcessTradeAction(
*agent_data.entity, *agent_data.entity,
*tradeid, *tradeid,