Do more cleanup of recloned NPCs, but wait 10 minutes instead of 2.
This commit is contained in:
parent
f0aa3d1d08
commit
067d9383ac
@ -41,7 +41,10 @@ use rand::{prelude::IteratorRandom, thread_rng, Rng};
|
||||
use rand_distr::{Distribution, Normal};
|
||||
use std::{sync::Arc, time};
|
||||
|
||||
use super::effect::{cancel_effect, default_effects_for_type, run_effects};
|
||||
use super::{
|
||||
effect::{cancel_effect, default_effects_for_type, run_effects},
|
||||
sharing::stop_conversation_mut,
|
||||
};
|
||||
|
||||
pub async fn soak_damage<DamageDist: DamageDistribution>(
|
||||
trans: &DBTrans,
|
||||
@ -701,7 +704,7 @@ pub async fn handle_death(trans: &DBTrans, whom: &mut Item) -> DResult<()> {
|
||||
.upsert_task(&Task {
|
||||
meta: TaskMeta {
|
||||
task_code: whom.item_code.clone(),
|
||||
next_scheduled: Utc::now() + chrono::Duration::seconds(120),
|
||||
next_scheduled: Utc::now() + chrono::Duration::seconds(600),
|
||||
..Default::default()
|
||||
},
|
||||
details: TaskDetails::RecloneNPC {
|
||||
@ -751,6 +754,10 @@ pub async fn handle_resurrect(trans: &DBTrans, player: &mut Item) -> DResult<boo
|
||||
for effect in &player.active_effects {
|
||||
cancel_effect(trans, player, effect).await?;
|
||||
}
|
||||
player.active_climb = None;
|
||||
if player.active_conversation.is_some() {
|
||||
stop_conversation_mut(trans, player, "stops talking on account of being dead").await?;
|
||||
}
|
||||
player.active_effects = vec![];
|
||||
calculate_total_stats_skills_for_user(player, &user);
|
||||
recalculate_urge_growth(trans, player).await?;
|
||||
@ -1174,37 +1181,6 @@ pub async fn switch_to_feint(ctx: &VerbContext<'_>, who: &Arc<Item>) -> UResult<
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct NPCRecloneTaskHandler;
|
||||
#[async_trait]
|
||||
impl TaskHandler for NPCRecloneTaskHandler {
|
||||
async fn do_task(&self, ctx: &mut TaskRunContext) -> DResult<Option<time::Duration>> {
|
||||
let npc_code = match &ctx.task.details {
|
||||
TaskDetails::RecloneNPC { npc_code } => npc_code.clone(),
|
||||
_ => Err("Expected RecloneNPC type")?,
|
||||
};
|
||||
let mut npc_item = match ctx.trans.find_item_by_type_code("npc", &npc_code).await? {
|
||||
None => return Ok(None),
|
||||
Some(r) => (*r).clone(),
|
||||
};
|
||||
|
||||
let npc = match npc_by_code().get(npc_code.as_str()) {
|
||||
None => return Ok(None),
|
||||
Some(r) => r,
|
||||
};
|
||||
|
||||
if npc_item.death_data.is_none() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
corpsify_item(ctx.trans, &npc_item).await?;
|
||||
|
||||
npc_item.death_data = None;
|
||||
npc_item.health = max_health(&npc_item);
|
||||
npc_item.location = npc.spawn_location.to_owned();
|
||||
ctx.trans.save_item_model(&npc_item).await?;
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
pub struct RotCorpseTaskHandler;
|
||||
#[async_trait]
|
||||
impl TaskHandler for RotCorpseTaskHandler {
|
||||
|
@ -20,7 +20,10 @@ use crate::{
|
||||
queued_command::{queue_command_for_npc_and_save, MovementSource, QueueCommand},
|
||||
TaskHandler, TaskRunContext,
|
||||
},
|
||||
services::combat::{corpsify_item, start_attack, start_attack_mut},
|
||||
services::{
|
||||
combat::{corpsify_item, start_attack, start_attack_mut},
|
||||
effect::cancel_effect,
|
||||
},
|
||||
DResult,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
@ -619,6 +622,12 @@ impl TaskHandler for NPCRecloneTaskHandler {
|
||||
corpsify_item(ctx.trans, &npc_item).await?;
|
||||
|
||||
npc_item.death_data = None;
|
||||
npc_item.active_climb = None;
|
||||
npc_item.active_combat = None;
|
||||
for effect in &npc_item.active_effects.clone() {
|
||||
cancel_effect(ctx.trans, &mut npc_item, effect).await?;
|
||||
}
|
||||
npc_item.active_effects = vec![];
|
||||
npc_item.health = npc.max_health;
|
||||
npc_item.location = npc.spawn_location.to_owned();
|
||||
ctx.trans.save_item_model(&npc_item).await?;
|
||||
|
Loading…
Reference in New Issue
Block a user