tweaks and wasm build for w3

This commit is contained in:
Llywelwyn 2023-07-25 17:08:11 +01:00
parent 1c956cdf58
commit 1b4d0c2c4b
9 changed files with 96 additions and 42 deletions

View file

@ -50,7 +50,7 @@
}, },
{ {
"id": "scroll_magicmap_cursed", "id": "scroll_magicmap_cursed",
"name": { "name": "scroll of magic mapping", "plural": "scrolls of magic mapping" }, "name": { "name": "cursed scroll of magic mapping", "plural": "cursed scrolls of magic mapping" },
"renderable": { "glyph": "?", "fg": "#00FFFF", "bg": "#000000", "order": 2 }, "renderable": { "glyph": "?", "fg": "#00FFFF", "bg": "#000000", "order": 2 },
"flags": ["CONSUMABLE", "DESTRUCTIBLE", "CURSED"], "flags": ["CONSUMABLE", "DESTRUCTIBLE", "CURSED"],
"effects": { "magicmapper": "" } "effects": { "magicmapper": "" }
@ -69,6 +69,13 @@
"flags": ["EQUIP_MELEE"], "flags": ["EQUIP_MELEE"],
"effects": { "melee_power_bonus": "2" } "effects": { "melee_power_bonus": "2" }
}, },
{
"id": "equip_longsword",
"name": { "name": "longsword", "plural": "longswords" },
"renderable": { "glyph": ")", "fg": "#FFF8DC", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_MELEE"],
"effects": { "melee_power_bonus": "3" }
},
{ {
"id": "equip_smallshield", "id": "equip_smallshield",
"name": { "name": "buckler", "plural": "bucklers" }, "name": { "name": "buckler", "plural": "bucklers" },
@ -78,11 +85,18 @@
}, },
{ {
"id": "equip_mediumshield", "id": "equip_mediumshield",
"name": { "name": "medium shield", "plural": "medium shield" }, "name": { "name": "medium shield", "plural": "medium shields" },
"renderable": { "glyph": "[", "fg": "#C0C0C0", "bg": "#000000", "order": 2 }, "renderable": { "glyph": "[", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_SHIELD"], "flags": ["EQUIP_SHIELD"],
"effects": { "defence_bonus": "2", "melee_power_bonus": "-1" } "effects": { "defence_bonus": "2", "melee_power_bonus": "-1" }
}, },
{
"id": "equip_largeshield",
"name": { "name": "large shield", "plural": "large shields" },
"renderable": { "glyph": "[", "fg": "#FFF8DC", "bg": "#000000", "order": 2 },
"flags": ["EQUIP_SHIELD"],
"effects": { "defence_bonus": "4", "melee_power_bonus": "-2" }
},
{ {
"id": "wand_magicmissile", "id": "wand_magicmissile",
"name": { "name": "wand of magic missile", "plural": "wands of magic missile" }, "name": { "name": "wand of magic missile", "plural": "wands of magic missile" },
@ -120,7 +134,7 @@
{ {
"id": "food_apple", "id": "food_apple",
"name": { "name": "apple", "plural": "apples" }, "name": { "name": "apple", "plural": "apples" },
"renderable": { "glyph": "%", "fg": "#008000", "bg": "#000000", "order": 2 }, "renderable": { "glyph": "%", "fg": "#00FF00", "bg": "#000000", "order": 2 },
"flags": ["FOOD", "CONSUMABLE"] "flags": ["FOOD", "CONSUMABLE"]
} }
] ]

View file

@ -1,12 +1,4 @@
[ [
{
"id": "orc",
"name": "orc",
"renderable": { "glyph": "o", "fg": "#00FF00", "bg": "#000000", "order": 1 },
"flags": ["BLOCKS_TILE"],
"stats": { "max_hp": 8, "hp": 8, "defence": 0, "power": 3 },
"vision_range": 12
},
{ {
"id": "goblin", "id": "goblin",
"name": "goblin", "name": "goblin",
@ -15,12 +7,44 @@
"stats": { "max_hp": 6, "hp": 6, "defence": 0, "power": 2 }, "stats": { "max_hp": 6, "hp": 6, "defence": 0, "power": 2 },
"vision_range": 12 "vision_range": 12
}, },
{
"id": "kobold",
"name": "kobold",
"renderable": { "glyph": "k", "fg": "#FF7F50", "bg": "#000000", "order": 1 },
"flags": ["BLOCKS_TILE"],
"stats": { "max_hp": 6, "hp": 6, "defence": 0, "power": 1 },
"vision_range": 8
},
{ {
"id": "goblin_chieftain", "id": "goblin_chieftain",
"name": "goblin chieftain", "name": "goblin chieftain",
"renderable": { "glyph": "G", "fg": "#00FF00", "bg": "#000000", "order": 1 }, "renderable": { "glyph": "G", "fg": "#00FF00", "bg": "#000000", "order": 1 },
"flags": ["BLOCKS_TILE"], "flags": ["BLOCKS_TILE"],
"stats": { "max_hp": 8, "hp": 8, "defence": 1, "power": 2 },
"vision_range": 12
},
{
"id": "orc",
"name": "orc",
"renderable": { "glyph": "o", "fg": "#00FF00", "bg": "#000000", "order": 1 },
"flags": ["BLOCKS_TILE"],
"stats": { "max_hp": 8, "hp": 8, "defence": 0, "power": 3 }, "stats": { "max_hp": 8, "hp": 8, "defence": 0, "power": 3 },
"vision_range": 12 "vision_range": 12
},
{
"id": "orc_large",
"name": "large orc",
"renderable": { "glyph": "o", "fg": "#008000", "bg": "#000000", "order": 1 },
"flags": ["BLOCKS_TILE"],
"stats": { "max_hp": 12, "hp": 12, "defence": 1, "power": 3 },
"vision_range": 12
},
{
"id": "ogre",
"name": "ogre",
"renderable": { "glyph": "O", "fg": "#00FF00", "bg": "#000000", "order": 1 },
"flags": ["BLOCKS_TILE"],
"stats": { "max_hp": 12, "hp": 12, "defence": 3, "power": 3 },
"vision_range": 8
} }
] ]

View file

@ -12,6 +12,13 @@
"flags": ["HIDDEN", "ENTRY_TRIGGER", "SINGLE_ACTIVATION"], "flags": ["HIDDEN", "ENTRY_TRIGGER", "SINGLE_ACTIVATION"],
"effects": { "damage": "6" } "effects": { "damage": "6" }
}, },
{
"id": "trap_stonefall",
"name": "stonefall trap",
"renderable": { "glyph": "^", "fg": "#C0C0C0", "bg": "#000000", "order": 2 },
"flags": ["HIDDEN", "ENTRY_TRIGGER", "SINGLE_ACTIVATION"],
"effects": { "damage": "12" }
},
{ {
"id": "trap_confusion", "id": "trap_confusion",
"name": "magic trap", "name": "magic trap",

View file

@ -4,8 +4,10 @@
"table": [ "table": [
{ "id": "equip_dagger", "weight": 4, "min": 0, "max": 100 }, { "id": "equip_dagger", "weight": 4, "min": 0, "max": 100 },
{ "id": "equip_shortsword", "weight": 2, "min": 0, "max": 100 }, { "id": "equip_shortsword", "weight": 2, "min": 0, "max": 100 },
{ "id": "equip_longsword", "weight": 1, "min": 2, "max": 100 },
{ "id": "equip_smallshield", "weight": 4, "min": 0, "max": 100 }, { "id": "equip_smallshield", "weight": 4, "min": 0, "max": 100 },
{ "id": "equip_mediumshield", "weight": 2, "min": 0, "max": 100 } { "id": "equip_mediumshield", "weight": 2, "min": 0, "max": 100 },
{ "id": "equip_largeshield", "weight": 1, "min": 2, "max": 100 }
] ]
}, },
{ {
@ -18,8 +20,10 @@
{ {
"id": "scrolls", "id": "scrolls",
"table": [ "table": [
{ "id": "scroll_fireball", "weight": 2, "min": 0, "max": 100 }, { "id": "scroll_fireball", "weight": 2, "min": 2, "max": 100 },
{ "id": "scroll_fireball_cursed", "weight": 2, "min": 2, "max": 100 },
{ "id": "scroll_confusion", "weight": 2, "min": 0, "max": 100 }, { "id": "scroll_confusion", "weight": 2, "min": 0, "max": 100 },
{ "id": "scroll_magicmap_cursed", "weight": 2, "min": 0, "max": 100 },
{ "id": "scroll_magicmap", "weight": 2, "min": 0, "max": 100 } { "id": "scroll_magicmap", "weight": 2, "min": 0, "max": 100 }
] ]
}, },
@ -27,7 +31,7 @@
"id": "wands", "id": "wands",
"table": [ "table": [
{ "id": "wand_magicmissile", "weight": 1, "min": 0, "max": 100 }, { "id": "wand_magicmissile", "weight": 1, "min": 0, "max": 100 },
{ "id": "wand_fireball", "weight": 1, "min": 0, "max": 100 }, { "id": "wand_fireball", "weight": 1, "min": 2, "max": 100 },
{ "id": "wand_confusion", "weight": 1, "min": 0, "max": 100 }, { "id": "wand_confusion", "weight": 1, "min": 0, "max": 100 },
{ "id": "wand_digging", "weight": 1, "min": 0, "max": 100 } { "id": "wand_digging", "weight": 1, "min": 0, "max": 100 }
] ]
@ -42,16 +46,20 @@
{ {
"id": "mobs", "id": "mobs",
"table": [ "table": [
{ "id": "goblin", "weight": 6, "min": 0, "max": 100 }, { "id": "goblin", "weight": 10, "min": 0, "max": 100 },
{ "id": "orc", "weight": 2, "min": 0, "max": 100 }, { "id": "kobold", "weight": 10, "min": 0, "max": 3 },
{ "id": "goblin_chieftain", "weight": 1, "min": 0, "max": 100 } { "id": "orc", "weight": 4, "min": 1, "max": 100 },
{ "id": "orc_large", "weight": 1, "min": 3, "max": 100 },
{ "id": "goblin_chieftain", "weight": 1, "min": 3, "max": 100 },
{ "id": "ogre", "weight": 1, "min": 4, "max": 100 }
] ]
}, },
{ {
"id": "traps", "id": "traps",
"table": [ "table": [
{ "id": "trap_bear", "weight": 2, "min": 0, "max": 100 }, { "id": "trap_bear", "weight": 2, "min": 0, "max": 100 },
{ "id": "trap_confusion", "weight": 1, "min": 0, "max": 100 } { "id": "trap_confusion", "weight": 1, "min": 0, "max": 100 },
{ "id": "trap_stonefall", "weight": 1, "min": 3, "max": 100 }
] ]
} }
] ]

View file

@ -30,7 +30,7 @@ impl DoorPlacement {
// There are no corridors - scan for possible places // There are no corridors - scan for possible places
let tiles = build_data.map.tiles.clone(); let tiles = build_data.map.tiles.clone();
for (i, tile) in tiles.iter().enumerate() { for (i, tile) in tiles.iter().enumerate() {
if *tile == TileType::Floor && self.door_possible(build_data, i) && rng.roll_dice(1, 3) == 1 { if *tile == TileType::Floor && self.door_possible(build_data, i) && rng.roll_dice(1, 6) == 1 {
build_data.spawn_list.push((i, "door".to_string())); build_data.spawn_list.push((i, "door".to_string()));
} }
} }

View file

@ -302,11 +302,11 @@ pub fn random_builder(new_depth: i32, rng: &mut rltk::RandomNumberGenerator, wid
} }
*/ */
builder.with(DoorPlacement::new());
if rng.roll_dice(1, 20) == 1 { if rng.roll_dice(1, 20) == 1 {
builder.with(PrefabBuilder::sectional(prefab_builder::prefab_sections::UNDERGROUND_FORT)); builder.with(PrefabBuilder::sectional(prefab_builder::prefab_sections::UNDERGROUND_FORT));
} }
builder.with(DoorPlacement::new());
builder.with(PrefabBuilder::vaults()); builder.with(PrefabBuilder::vaults());
// Regardless of anything else, fill the edges back in with walls. We can't walk // Regardless of anything else, fill the edges back in with walls. We can't walk
// there anyway, and we don't want an open line of sight into the unmapped void. // there anyway, and we don't want an open line of sight into the unmapped void.

View file

@ -21,7 +21,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
.with(Player {}) .with(Player {})
.with(Viewshed { visible_tiles: Vec::new(), range: 12, dirty: true }) .with(Viewshed { visible_tiles: Vec::new(), range: 12, dirty: true })
.with(Name { name: "wanderer".to_string(), plural: "wanderers".to_string() }) .with(Name { name: "wanderer".to_string(), plural: "wanderers".to_string() })
.with(CombatStats { max_hp: 8, hp: 8, defence: 0, power: 4 }) .with(CombatStats { max_hp: 12, hp: 12, defence: 0, power: 4 })
.with(HungerClock { state: HungerState::Satiated, duration: 50 }) .with(HungerClock { state: HungerState::Satiated, duration: 50 })
.with(Attributes { .with(Attributes {
strength: Attribute { base: 10, modifiers: 0, bonus: 0 }, strength: Attribute { base: 10, modifiers: 0, bonus: 0 },
@ -82,7 +82,16 @@ pub fn spawn_region(
let spawn_table; let spawn_table;
match category.as_ref() { match category.as_ref() {
"mob" => spawn_table = mob_table(map_depth), "mob" => spawn_table = mob_table(map_depth),
"item" => spawn_table = item_table(map_depth), "item" => {
let item_category = item_category_table().roll(rng);
match item_category.as_ref() {
"equipment" => spawn_table = equipment_table(map_depth),
"potion" => spawn_table = potion_table(map_depth),
"scroll" => spawn_table = scroll_table(map_depth),
"wand" => spawn_table = wand_table(map_depth),
_ => spawn_table = debug_table(),
}
}
"food" => spawn_table = food_table(map_depth), "food" => spawn_table = food_table(map_depth),
"trap" => spawn_table = trap_table(map_depth), "trap" => spawn_table = trap_table(map_depth),
_ => spawn_table = debug_table(), _ => spawn_table = debug_table(),
@ -125,21 +134,13 @@ fn category_table() -> RandomTable {
return RandomTable::new().add("mob", 12).add("item", 6).add("food", 2).add("trap", 1); return RandomTable::new().add("mob", 12).add("item", 6).add("food", 2).add("trap", 1);
} }
fn debug_table() -> RandomTable { // 3 scrolls : 3 potions : 1 equipment : 1 wand?
return RandomTable::new().add("debug", 1); fn item_category_table() -> RandomTable {
return RandomTable::new().add("equipment", 1).add("potion", 3).add("scroll", 3).add("wand", 1);
} }
// 6 equipment : 10 potions : 10 scrolls : 2 cursed scrolls fn debug_table() -> RandomTable {
fn item_table(map_depth: i32) -> RandomTable { return RandomTable::new().add("debug", 1);
return RandomTable::new()
// Equipment
.add_table(equipment_table(map_depth))
// Potions
.add_table(potion_table(map_depth))
// Scrolls
.add_table(scroll_table(map_depth))
// Wands
.add_table(wand_table(map_depth));
} }
pub fn equipment_table(map_depth: i32) -> RandomTable { pub fn equipment_table(map_depth: i32) -> RandomTable {

View file

@ -801,16 +801,16 @@ function __wbg_get_imports() {
const ret = wasm.memory; const ret = wasm.memory;
return addHeapObject(ret); return addHeapObject(ret);
}; };
imports.wbg.__wbindgen_closure_wrapper702 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper718 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 116, __wbg_adapter_20); const ret = makeMutClosure(arg0, arg1, 155, __wbg_adapter_20);
return addHeapObject(ret); return addHeapObject(ret);
}; };
imports.wbg.__wbindgen_closure_wrapper1684 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper1688 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 357, __wbg_adapter_23); const ret = makeMutClosure(arg0, arg1, 359, __wbg_adapter_23);
return addHeapObject(ret); return addHeapObject(ret);
}; };
imports.wbg.__wbindgen_closure_wrapper1686 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper1690 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 357, __wbg_adapter_23); const ret = makeMutClosure(arg0, arg1, 359, __wbg_adapter_23);
return addHeapObject(ret); return addHeapObject(ret);
}; };

Binary file not shown.