adds mob ancestries, converts everything over to get_reactions()
This commit is contained in:
parent
614653e028
commit
9e26c41aad
5 changed files with 40 additions and 54 deletions
|
|
@ -1,22 +1,22 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id": "human",
|
"id": "human",
|
||||||
"allied": []
|
"allies": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "elf",
|
"id": "elf",
|
||||||
"allied": []
|
"allies": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "dwarf",
|
"id": "dwarf",
|
||||||
"allied": ["gnome"]
|
"allies": ["gnome"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "gnome",
|
"id": "gnome",
|
||||||
"allied": ["dwarf"]
|
"allies": ["dwarf"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "catfolk",
|
"id": "catfolk",
|
||||||
"allied": []
|
"allies": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"id": "npc_barkeep",
|
"id": "npc_barkeep",
|
||||||
"name": "barkeep",
|
"name": "barkeep",
|
||||||
"renderable": { "glyph": "@", "fg": "#EE82EE", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#EE82EE", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL"],
|
"flags": ["NEUTRAL", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"quips": ["Drink?", "Something to eat?", "Don't go out on an empty stomach."]
|
"quips": ["Drink?", "Something to eat?", "Don't go out on an empty stomach."]
|
||||||
},
|
},
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
"id": "npc_townsperson",
|
"id": "npc_townsperson",
|
||||||
"name": "townsperson",
|
"name": "townsperson",
|
||||||
"renderable": { "glyph": "@", "fg": "#9fa86c", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#9fa86c", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL", "RANDOM_PATH"],
|
"flags": ["NEUTRAL", "RANDOM_PATH", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"quips": ["Hello!", "Good morning.", "<a quiet complaint about chores>"]
|
"quips": ["Hello!", "Good morning.", "<a quiet complaint about chores>"]
|
||||||
},
|
},
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
"id": "npc_drunk",
|
"id": "npc_drunk",
|
||||||
"name": "drunk",
|
"name": "drunk",
|
||||||
"renderable": { "glyph": "@", "fg": "#a0a83c", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#a0a83c", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL"],
|
"flags": ["NEUTRAL", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"quips": ["Hic!", "H-Hic'.", "Get me 'nother, would you?"]
|
"quips": ["Hic!", "H-Hic'.", "Get me 'nother, would you?"]
|
||||||
},
|
},
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"id": "npc_fisher",
|
"id": "npc_fisher",
|
||||||
"name": "fisher",
|
"name": "fisher",
|
||||||
"renderable": { "glyph": "@", "fg": "#3ca3a8", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#3ca3a8", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL"],
|
"flags": ["NEUTRAL", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"quips": ["Hey."]
|
"quips": ["Hey."]
|
||||||
},
|
},
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
"id": "npc_dockworker",
|
"id": "npc_dockworker",
|
||||||
"name": "dock worker",
|
"name": "dock worker",
|
||||||
"renderable": { "glyph": "@", "fg": "#68d8de", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#68d8de", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL"],
|
"flags": ["NEUTRAL", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"quips": ["No boat for a few days.", "Not much for us to do."]
|
"quips": ["No boat for a few days.", "Not much for us to do."]
|
||||||
},
|
},
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
"id": "npc_priest",
|
"id": "npc_priest",
|
||||||
"name": "priest",
|
"name": "priest",
|
||||||
"renderable": { "glyph": "@", "fg": "#FFFFFF", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#FFFFFF", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL"],
|
"flags": ["NEUTRAL", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"quips": ["Light's givings.", "<a quiet prayer>", "Bless you."]
|
"quips": ["Light's givings.", "<a quiet prayer>", "Bless you."]
|
||||||
},
|
},
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
"id": "npc_miner",
|
"id": "npc_miner",
|
||||||
"name": "miner",
|
"name": "miner",
|
||||||
"renderable": { "glyph": "@", "fg": "#946123", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#946123", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL"],
|
"flags": ["NEUTRAL", "IS_HUMAN"],
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"attacks": [{ "name": "hits", "hit_bonus": 0, "damage": "1d8" }],
|
"attacks": [{ "name": "hits", "hit_bonus": 0, "damage": "1d8" }],
|
||||||
"quips": ["You're not borrowing my pick."]
|
"quips": ["You're not borrowing my pick."]
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
"id": "npc_guard",
|
"id": "npc_guard",
|
||||||
"name": "smalltown guard",
|
"name": "smalltown guard",
|
||||||
"renderable": { "glyph": "@", "fg": "#034efc", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "@", "fg": "#034efc", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["NEUTRAL", "RANDOM_PATH"],
|
"flags": ["NEUTRAL", "RANDOM_PATH", "IS_HUMAN"],
|
||||||
"level": 2,
|
"level": 2,
|
||||||
"vision_range": 4,
|
"vision_range": 4,
|
||||||
"attacks": [{ "name": "hits", "hit_bonus": 0, "damage": "1d8" }],
|
"attacks": [{ "name": "hits", "hit_bonus": 0, "damage": "1d8" }],
|
||||||
|
|
@ -205,7 +205,7 @@
|
||||||
"id": "gnome",
|
"id": "gnome",
|
||||||
"name": "gnome",
|
"name": "gnome",
|
||||||
"renderable": { "glyph": "G", "fg": "#AA5500", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "G", "fg": "#AA5500", "bg": "#000000", "order": 1 },
|
||||||
"flags": ["SMALL_GROUP"],
|
"flags": ["SMALL_GROUP", "IS_GNOME"],
|
||||||
"level": 1,
|
"level": 1,
|
||||||
"speed": 6,
|
"speed": 6,
|
||||||
"vision_range": 12,
|
"vision_range": 12,
|
||||||
|
|
@ -282,7 +282,7 @@
|
||||||
"id": "dwarf",
|
"id": "dwarf",
|
||||||
"name": "dwarf",
|
"name": "dwarf",
|
||||||
"renderable": { "glyph": "h", "fg": "#d61b1b", "bg": "#000000", "order": 1 },
|
"renderable": { "glyph": "h", "fg": "#d61b1b", "bg": "#000000", "order": 1 },
|
||||||
"flags": [],
|
"flags": ["IS_DWARF"],
|
||||||
"level": 2,
|
"level": 2,
|
||||||
"bac": 10,
|
"bac": 10,
|
||||||
"speed": 6,
|
"speed": 6,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl<'a> System<'a> for AdjacentAI {
|
||||||
let (mut turns, factions, ancestries, positions, map, mut want_melee, entities, player) = data;
|
let (mut turns, factions, ancestries, positions, map, mut want_melee, entities, player) = data;
|
||||||
|
|
||||||
let mut turn_done: Vec<Entity> = Vec::new();
|
let mut turn_done: Vec<Entity> = Vec::new();
|
||||||
for (entity, _turn, my_faction, pos) in (&entities, &turns, &factions, &positions).join() {
|
for (entity, _turn, pos) in (&entities, &turns, &positions).join() {
|
||||||
if entity != *player {
|
if entity != *player {
|
||||||
let mut reactions: Vec<(Entity, Reaction)> = Vec::new();
|
let mut reactions: Vec<(Entity, Reaction)> = Vec::new();
|
||||||
let idx = map.xy_idx(pos.x, pos.y);
|
let idx = map.xy_idx(pos.x, pos.y);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ impl<'a> System<'a> for VisibleAI {
|
||||||
mut chasing,
|
mut chasing,
|
||||||
) = data;
|
) = data;
|
||||||
|
|
||||||
for (entity, _turn, faction, pos, viewshed) in (&entities, &turns, &factions, &positions, &viewsheds).join() {
|
for (entity, _turn, pos, viewshed) in (&entities, &turns, &positions, &viewsheds).join() {
|
||||||
if entity == *player {
|
if entity == *player {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ impl<'a> System<'a> for VisibleAI {
|
||||||
for visible_tile in viewshed.visible_tiles.iter() {
|
for visible_tile in viewshed.visible_tiles.iter() {
|
||||||
let idx = map.xy_idx(visible_tile.x, visible_tile.y);
|
let idx = map.xy_idx(visible_tile.x, visible_tile.y);
|
||||||
if this_idx != idx {
|
if this_idx != idx {
|
||||||
evaluate(entity, idx, &ancestries, &factions, &faction.name, &mut reactions, None);
|
evaluate(entity, idx, &ancestries, &factions, &mut reactions, None);
|
||||||
idxs.insert(idx);
|
idxs.insert(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ impl<'a> System<'a> for VisibleAI {
|
||||||
// and it's not the idx we're standing on, then evaluate here w/ minds taken into
|
// and it's not the idx we're standing on, then evaluate here w/ minds taken into
|
||||||
// account.
|
// account.
|
||||||
if this_idx != idx && idxs.contains(&idx) {
|
if this_idx != idx && idxs.contains(&idx) {
|
||||||
evaluate(entity, idx, &ancestries, &factions, &faction.name, &mut reactions, Some(&minds));
|
evaluate(entity, idx, &ancestries, &factions, &mut reactions, Some(&minds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -96,46 +96,28 @@ fn evaluate(
|
||||||
idx: usize,
|
idx: usize,
|
||||||
ancestries: &ReadStorage<HasAncestry>,
|
ancestries: &ReadStorage<HasAncestry>,
|
||||||
factions: &ReadStorage<Faction>,
|
factions: &ReadStorage<Faction>,
|
||||||
this_faction: &str,
|
|
||||||
reactions: &mut Vec<(usize, Reaction, Entity)>,
|
reactions: &mut Vec<(usize, Reaction, Entity)>,
|
||||||
minds: Option<&ReadStorage<Mind>>,
|
minds: Option<&ReadStorage<Mind>>,
|
||||||
) {
|
) {
|
||||||
crate::spatial::for_each_tile_content(idx, |other_entity| {
|
crate::spatial::for_each_tile_content(idx, |other_entity| {
|
||||||
let mut shared_ancestry = false;
|
let mut check = true;
|
||||||
if let Some(this_ancestry) = ancestries.get(entity) {
|
if minds.is_some() {
|
||||||
if let Some(other_ancestry) = ancestries.get(other_entity) {
|
if minds.unwrap().get(other_entity).is_none() {
|
||||||
if this_ancestry.name == other_ancestry.name {
|
check = false;
|
||||||
reactions.push((idx, Reaction::Ignore, other_entity));
|
|
||||||
shared_ancestry = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !shared_ancestry {
|
if check {
|
||||||
// If minds are passed, we assume we're using telepathy here,
|
reactions.push((
|
||||||
// so if the other entity is mindless, we skip it.
|
idx,
|
||||||
if minds.is_some() {
|
crate::raws::get_reactions(
|
||||||
if minds.unwrap().get(other_entity).is_some() {
|
entity,
|
||||||
if let Some(faction) = factions.get(other_entity) {
|
other_entity,
|
||||||
reactions.push((
|
&factions,
|
||||||
idx,
|
&ancestries,
|
||||||
crate::raws::faction_reaction(
|
&crate::raws::RAWS.lock().unwrap(),
|
||||||
this_faction,
|
),
|
||||||
&faction.name,
|
other_entity,
|
||||||
&crate::raws::RAWS.lock().unwrap(),
|
));
|
||||||
),
|
|
||||||
other_entity,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if let Some(faction) = factions.get(other_entity) {
|
|
||||||
reactions.push((
|
|
||||||
idx,
|
|
||||||
crate::raws::faction_reaction(this_faction, &faction.name, &crate::raws::RAWS.lock().unwrap()),
|
|
||||||
other_entity,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,9 @@ impl RawMaster {
|
||||||
}
|
}
|
||||||
self.faction_index.insert(faction.id.clone(), reactions);
|
self.faction_index.insert(faction.id.clone(), reactions);
|
||||||
}
|
}
|
||||||
|
for ancestry in self.raws.ancestries.iter() {
|
||||||
|
self.ancestry_index.insert(ancestry.id.clone(), ancestry.allies.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -851,14 +854,15 @@ pub fn ancestry_reaction(this_ancestry: Ancestry, other_ancestry: Ancestry, raws
|
||||||
} else {
|
} else {
|
||||||
let this_ancestry = get_ancestry_string(this_ancestry);
|
let this_ancestry = get_ancestry_string(this_ancestry);
|
||||||
let other_ancestry = get_ancestry_string(other_ancestry);
|
let other_ancestry = get_ancestry_string(other_ancestry);
|
||||||
|
console::log(format!("{:?}", this_ancestry));
|
||||||
if raws.ancestry_index.contains_key(this_ancestry) {
|
if raws.ancestry_index.contains_key(this_ancestry) {
|
||||||
let mine = &raws.ancestry_index[this_ancestry];
|
let mine = &raws.ancestry_index[this_ancestry];
|
||||||
|
console::log(format!("{:?}", mine));
|
||||||
if mine.contains(other_ancestry) {
|
if mine.contains(other_ancestry) {
|
||||||
return Some(Reaction::Ignore);
|
return Some(Reaction::Ignore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue