Implement tick-based game loop, combat overhaul, and attack-any-NPC
Replace immediate combat with a 3-second tick engine that resolves actions, NPC AI, status effects, respawns, and passive regeneration. Players queue combat actions (attack/defend/flee/use) that resolve on the next tick. Any NPC can now be attacked — non-hostile targets incur attitude penalties instead of being blocked. Status effects persist in the database and continue ticking while players are offline. Made-with: Cursor
This commit is contained in:
@@ -49,7 +49,7 @@ impl Attitude {
|
||||
matches!(self, Attitude::Hostile)
|
||||
}
|
||||
|
||||
pub fn can_be_attacked(self) -> bool {
|
||||
pub fn is_hostile(self) -> bool {
|
||||
matches!(self, Attitude::Hostile | Attitude::Aggressive)
|
||||
}
|
||||
|
||||
@@ -315,7 +315,8 @@ impl World {
|
||||
|
||||
load_entities_from_dir(®ion_path.join("npcs"), ®ion_name, &mut |id, content| {
|
||||
let nf: NpcFile = toml::from_str(content).map_err(|e| format!("Bad npc {id}: {e}"))?;
|
||||
let combat = nf.combat.map(|c| NpcCombatStats { max_hp: c.max_hp, attack: c.attack, defense: c.defense, xp_reward: c.xp_reward });
|
||||
let combat = Some(nf.combat.map(|c| NpcCombatStats { max_hp: c.max_hp, attack: c.attack, defense: c.defense, xp_reward: c.xp_reward })
|
||||
.unwrap_or(NpcCombatStats { max_hp: 20, attack: 4, defense: 2, xp_reward: 5 }));
|
||||
let greeting = nf.dialogue.and_then(|d| d.greeting);
|
||||
npcs.insert(id.clone(), Npc { id: id.clone(), name: nf.name, description: nf.description, room: nf.room, base_attitude: nf.base_attitude, faction: nf.faction, respawn_secs: nf.respawn_secs, greeting, combat });
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user