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
- Pets no longer aggro on pet owners after being healed
- 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

View File

@ -86,7 +86,6 @@ impl BehaviorTree {
do_hostile_tree_if_hostile,
do_pet_tree_if_owned,
do_pickup_loot,
untarget,
do_idle_tree,
],
}
@ -339,6 +338,7 @@ fn do_pickup_loot(bdata: &mut BehaviorData) -> bool {
.controller
.push_event(ControlEvent::InventoryEvent(InventoryEvent::Pickup(*uid)));
}
bdata.agent.target = None;
} else if let Some((bearing, speed)) = bdata.agent.chaser.chase(
&*bdata.read_data.terrain,
bdata.agent_data.pos.0,
@ -362,14 +362,6 @@ fn do_pickup_loot(bdata: &mut BehaviorData) -> bool {
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
fn follow_if_far_away(bdata: &mut BehaviorData) -> bool {
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.target = None;
}
}
true
@ -559,6 +560,7 @@ pub fn handle_inbox_update_pending_trade(bdata: &mut BehaviorData) -> bool {
if pending.phase != TradePhase::Mutate {
// we got into the review phase but without balanced goods, decline
agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
event_emitter.emit(ServerEvent::ProcessTradeAction(
*agent_data.entity,
tradeid,
@ -601,6 +603,7 @@ pub fn handle_inbox_update_pending_trade(bdata: &mut BehaviorData) -> bool {
},
TradingBehavior::None => {
agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
event_emitter.emit(ServerEvent::ProcessTradeAction(
*agent_data.entity,
tradeid,
@ -691,6 +694,7 @@ pub fn handle_inbox_cancel_interactions(bdata: &mut BehaviorData) -> bool {
},
}
agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
}
true
},
@ -698,6 +702,7 @@ pub fn handle_inbox_cancel_interactions(bdata: &mut BehaviorData) -> bool {
// immediately cancel the trade
let (tradeid, _pending, _prices, _inventories) = &**boxval;
agent.behavior.unset(BehaviorState::TRADING);
agent.target = None;
event_emitter.emit(ServerEvent::ProcessTradeAction(
*agent_data.entity,
*tradeid,