From 608918af8174e9afb761cdd2ad46e489b21c5f4e Mon Sep 17 00:00:00 2001 From: troido Date: Thu, 16 Apr 2020 22:11:00 +0200 Subject: don't spread stones dropped from destroyed walls --- content/encyclopediae/default_encyclopedia.json | 12 ++++++------ src/components/mod.rs | 1 + src/componentwrapper.rs | 4 ++-- src/systems/droploot.rs | 4 +++- todo.md | 5 ++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/content/encyclopediae/default_encyclopedia.json b/content/encyclopediae/default_encyclopedia.json index 065db97..b4007d5 100644 --- a/content/encyclopediae/default_encyclopedia.json +++ b/content/encyclopediae/default_encyclopedia.json @@ -101,7 +101,7 @@ "arguments": [["health", "int", 100]], "components": [ ["Health", {"health": ["arg", "health"], "maxhealth": 100}], - ["Loot", {"loot": ["list", [{"type": "stone"}]]}] + ["Loot", {"spread": false, "loot": ["list", [{"type": "stone"}]]}] ], "sprite": "builtwall", "height": 2, @@ -140,7 +140,7 @@ ["Fighter", {"damage": 2, "cooldown": 6}], ["Movable", {"cooldown": 3}], ["Faction", {"faction": "evil"}], - ["Loot", {"loot": ["list", [ + ["Loot", {"spread": true, "loot": ["list", [ ["list", [{"type": "radishseed"}, 1.0]] ]]}] ] @@ -158,7 +158,7 @@ ["Fighter", {"damage": 5, "cooldown": 8}], ["Movable", {"cooldown": 4}], ["Faction", {"faction": "evil"}], - ["Loot", {"loot": ["list", [ + ["Loot", {"spread": true, "loot": ["list", [ ["list", [{"type": "sword"}, 0.05]], ["list", [{"type": "club"}, 0.1]], ["list", [{"type": "radish"}, 0.25]] @@ -178,7 +178,7 @@ ["Fighter", {"damage": 15, "cooldown": 10}], ["Movable", {"cooldown": 5}], ["Faction", {"faction": "evil"}], - ["Loot", {"loot": ["list", [ + ["Loot", {"spread": true, "loot": ["list", [ ["list", [{"type": "stone"}, 1.0]], ["list", [{"type": "stone"}, 0.3]], ["list", [{"type": "pebble"}, 0.5]], @@ -231,7 +231,7 @@ "height": 0.5, "components": [ ["Interactable", {"action": ["interaction", ["trigger", "die"]]}], - ["Loot", {"loot": ["list", [ + ["Loot", {"spread": true, "loot": ["list", [ ["list", [{"type": "radishseed"}, 0.92]], ["list", [{"type": "radishseed"}, 0.20]], ["list", [{"type": "radish"}, 0.8]], @@ -407,7 +407,7 @@ "height": 1.0, "components": [ ["Interactable", {"action": ["interaction", ["trigger", "die"]]}], - ["Loot", {"loot": ["list", [ + ["Loot", {"spread": true, "loot": ["list", [ ["list", [{"type": "carrotseed"}, 1.0]], ["list", [{"type": "carrot"}, 1.0]] ]]}] diff --git a/src/components/mod.rs b/src/components/mod.rs index 176f97a..64fa717 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -197,6 +197,7 @@ pub struct Clan { #[derive(Component, Debug, Clone)] #[storage(HashMapStorage)] pub struct Loot { + pub spread: bool, pub loot: Vec<(Template, f64)> } diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index d677cb2..ecc8227 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -182,8 +182,8 @@ components!(all: Home (home: Pos); Faction (faction: String) {Faction::from_str(faction.as_str()).ok_or(aerr!("invalid faction name"))?}; Interactable (action: Interaction) {action}; - Loot (loot: List) { - Loot { loot: + Loot (loot: List, spread: Bool) { + Loot {spread, loot: loot .iter() .map(|param| {match param { diff --git a/src/systems/droploot.rs b/src/systems/droploot.rs index fcd104b..604f29f 100644 --- a/src/systems/droploot.rs +++ b/src/systems/droploot.rs @@ -39,8 +39,10 @@ impl <'a> System<'a> for DropLoot{ if triggerbox.has_message(&[Trigger::Die, Trigger::Loot]) { for (template, chance) in &loot.loot { if *chance > rand::thread_rng().gen_range(0.0, 1.0) { + let pos = if loot.spread { + pick_position(position.pos, &ground, &flags) + } else {position.pos}; // todo: better error handling - let pos = pick_position(position.pos, &ground, &flags); new.create(pos, &template).unwrap(); } } diff --git a/todo.md b/todo.md index 1317ee4..a27c30c 100644 --- a/todo.md +++ b/todo.md @@ -3,9 +3,12 @@ - document assemblage and room definition - more tests -- visitors - improved tutorial - timer resource? - improve error handling - update drawing when migration fails - data encapsulation +- secure login +- bot connection +- interactions that take more than one try + -- cgit