From 9046218155aefff2e8c67ce7802512f4a90ec59c Mon Sep 17 00:00:00 2001 From: Condorra Date: Mon, 20 Feb 2023 15:23:36 +1100 Subject: [PATCH] Fixups for attack after attacker leaves. --- .../src/message_handler/user_commands/look.rs | 4 +++- .../src/message_handler/user_commands/movement.rs | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/blastmud_game/src/message_handler/user_commands/look.rs b/blastmud_game/src/message_handler/user_commands/look.rs index 113280b..4f894ff 100644 --- a/blastmud_game/src/message_handler/user_commands/look.rs +++ b/blastmud_game/src/message_handler/user_commands/look.rs @@ -117,7 +117,9 @@ async fn list_item_contents<'l>(ctx: &'l VerbContext<'_>, item: &'l Item) -> URe Subattack::Wrestling => buf.push_str(", wrestling "), _ => buf.push_str(", attacking ") } - match &head.presence_target { + match &head.active_combat.as_ref() + .and_then(|ac| ac.attacking.clone()) + .or_else(|| head.presence_target.clone()) { None => buf.push_str("someone"), Some(who) => match who.split_once("/") { None => buf.push_str("someone"), diff --git a/blastmud_game/src/message_handler/user_commands/movement.rs b/blastmud_game/src/message_handler/user_commands/movement.rs index 02d2683..345ba35 100644 --- a/blastmud_game/src/message_handler/user_commands/movement.rs +++ b/blastmud_game/src/message_handler/user_commands/movement.rs @@ -21,7 +21,7 @@ use crate::{ services::{ broadcast_to_room, skills::skill_check_and_grind, - combat::stop_attacking, + combat::stop_attacking_mut, combat::handle_resurrect, } }; @@ -97,7 +97,9 @@ pub async fn attempt_move_immediate( Some(old_victim) => { if let Some((vcode, vtype)) = old_victim.split_once("/") { if let Some(vitem) = trans.find_item_by_type_code(vcode, vtype).await? { - stop_attacking(trans, &mover, &vitem).await?; + let mut vitem_mut = (*vitem).clone(); + stop_attacking_mut(trans, &mut mover, &mut vitem_mut, false).await?; + trans.save_item_model(&vitem_mut).await? } } } @@ -126,7 +128,9 @@ pub async fn attempt_move_immediate( &attacker_names_str))).await?; } for item in &attacker_items[..] { - stop_attacking(trans, &item, &mover).await?; + let mut item_mut = (**item).clone(); + stop_attacking_mut(trans, &mut item_mut, &mut mover, true).await?; + trans.save_item_model(&item_mut).await?; } } else { if let Some(ctx) = player_ctx.as_ref() {