Browse Source

more testing/debugging. align monster appearance between client and server.

pull/60/head
andy 3 years ago
parent
commit
14e14639c8
  1. 8
      data/battle_param/ep1_rare_monster.toml
  2. 68
      src/ship/map/enemy.rs
  3. 4
      src/ship/map/maps.rs

8
data/battle_param/ep1_rare_monster.toml

@ -3,7 +3,7 @@
# 1/256 = 0.00390625
# 1/512 = 0.001953125
Hildebear = 1.0
RagRappy = 0.1
PoisonLily = 0.1
PofuillySlime = 0.1
Hildebear = 0.1
RagRappy = 0.2
PoisonLily = 0.3
PofuillySlime = 0.4

68
src/ship/map/enemy.rs

@ -107,9 +107,13 @@ impl RareMonsterAppearTable {
}
pub fn roll_appearance(&self, monster: &MonsterType) -> bool {
let mut rng = rand_chacha::ChaChaRng::seed_from_u64(self.seed as u64); // TODO: figure out how to seed with a u32
println!("rolling for {:?} appearance", monster);
if rng.gen::<f32>() < *self.appear_rate.get(monster).unwrap_or(&0.0f32) {
println!("rolling appearance for {:?} with seed {:?}", monster, self.seed);
let mut rng = rand_chacha::ChaChaRng::from_entropy();
let roll: f32 = rng.gen();
let monster_rate = self.appear_rate.get(monster).unwrap_or(&0.0f32);
println!("rolled {:?} and {:?} has appear rate {:?}", roll, monster, monster_rate);
if roll < *monster_rate {
// if rng.gen::<f32>() < *self.appear_rate.get(monster).unwrap_or(&0.0f32) {
println!("its a rare!");
true
}
@ -349,42 +353,42 @@ impl MapEnemy {
}
}
// TODO: does `shiny` need to be set here?
// TODO: distinguish between a `random` rare monster and a `set/guaranteed` rare monster? (does any acceptable quest even have this?)
pub fn set_rare_appearance(self) -> MapEnemy {
match self.monster {
MonsterType::RagRappy | MonsterType::Hildebear |
MonsterType::PoisonLily | MonsterType::PofuillySlime |
MonsterType::SandRappyCrater | MonsterType::ZuCrater | MonsterType::Dorphon |
MonsterType::SandRappyDesert | MonsterType::ZuDesert | MonsterType::MerissaA |
MonsterType::SaintMillion | MonsterType::Shambertin => self.set_shiny(),
_ => self,
}
}
// // TODO: does `shiny` need to be set here?
// // TODO: distinguish between a `random` rare monster and a `set/guaranteed` rare monster? (does any acceptable quest even have this?)
// pub fn set_rare_appearance(self) -> MapEnemy {
// match (self.monster, self.map_area.to_episode()) {
// (MonsterType::RagRappy, Episode::One) => {MapEnemy {monster: MonsterType::AlRappy, ..self}},
// (MonsterType::RagRappy, Episode::Two) => {MapEnemy {monster: MonsterType::EventRappy, ..self}},
// (MonsterType::Hildebear, _) => {MapEnemy {monster: MonsterType::Hildeblue, ..self}},
// (MonsterType::PoisonLily, _) => {MapEnemy {monster: MonsterType::NarLily, ..self}},
// (MonsterType::PofuillySlime, _) => {MapEnemy {monster: MonsterType::PouillySlime, ..self}},
// (MonsterType::SandRappyCrater, _) => {MapEnemy {monster: MonsterType::DelRappyCrater, ..self}},
// (MonsterType::ZuCrater, _) => {MapEnemy {monster: MonsterType::PazuzuCrater, ..self}},
// (MonsterType::Dorphon, _) => {MapEnemy {monster: MonsterType::DorphonEclair, ..self}},
// (MonsterType::SandRappyDesert, _) => {MapEnemy {monster: MonsterType::DelRappyDesert, ..self}},
// (MonsterType::ZuDesert, _) => {MapEnemy {monster: MonsterType::PazuzuDesert, ..self}},
// (MonsterType::MerissaA, _) => {MapEnemy {monster: MonsterType::MerissaAA, ..self}},
// (MonsterType::SaintMillion, _) => {MapEnemy {monster: MonsterType::Kondrieu, ..self}},
// (MonsterType::Shambertin, _) => {MapEnemy {monster: MonsterType::Kondrieu, ..self}},
// _ => {self},
// match self.monster {
// MonsterType::RagRappy | MonsterType::Hildebear |
// MonsterType::PoisonLily | MonsterType::PofuillySlime |
// MonsterType::SandRappyCrater | MonsterType::ZuCrater | MonsterType::Dorphon |
// MonsterType::SandRappyDesert | MonsterType::ZuDesert | MonsterType::MerissaA |
// MonsterType::SaintMillion | MonsterType::Shambertin => self.set_shiny(),
// _ => self,
// }
// }
// TODO: does `shiny` need to be set here?
// TODO: distinguish between a `random` rare monster and a `set/guaranteed` rare monster? (does any acceptable quest even have this?)
pub fn set_rare_appearance(self) -> MapEnemy {
match (self.monster, self.map_area.to_episode()) {
(MonsterType::RagRappy, Episode::One) => {MapEnemy {monster: MonsterType::AlRappy, shiny:true, ..self}},
(MonsterType::RagRappy, Episode::Two) => {MapEnemy {monster: MonsterType::EventRappy, shiny:true, ..self}},
(MonsterType::Hildebear, _) => {MapEnemy {monster: MonsterType::Hildeblue, shiny:true, ..self}},
(MonsterType::PoisonLily, _) => {MapEnemy {monster: MonsterType::NarLily, shiny:true, ..self}},
(MonsterType::PofuillySlime, _) => {MapEnemy {monster: MonsterType::PouillySlime, shiny:true, ..self}},
(MonsterType::SandRappyCrater, _) => {MapEnemy {monster: MonsterType::DelRappyCrater, shiny:true, ..self}},
(MonsterType::ZuCrater, _) => {MapEnemy {monster: MonsterType::PazuzuCrater, shiny:true, ..self}},
(MonsterType::Dorphon, _) => {MapEnemy {monster: MonsterType::DorphonEclair, shiny:true, ..self}},
(MonsterType::SandRappyDesert, _) => {MapEnemy {monster: MonsterType::DelRappyDesert, shiny:true, ..self}},
(MonsterType::ZuDesert, _) => {MapEnemy {monster: MonsterType::PazuzuDesert, shiny:true, ..self}},
(MonsterType::MerissaA, _) => {MapEnemy {monster: MonsterType::MerissaAA, shiny:true, ..self}},
(MonsterType::SaintMillion, _) => {MapEnemy {monster: MonsterType::Kondrieu, shiny:true, ..self}},
(MonsterType::Shambertin, _) => {MapEnemy {monster: MonsterType::Kondrieu, shiny:true, ..self}},
_ => {self},
}
}
// in theory this should only be called on monsters we know can have rare types
pub fn roll_appearance_for_quest(self, rare_monster_table: &RareMonsterAppearTable) -> MapEnemy {
pub fn roll_appearance_for_mission(self, rare_monster_table: &RareMonsterAppearTable) -> MapEnemy {
if rare_monster_table.roll_appearance(&self.monster) {
return self.set_rare_appearance()
}

4
src/ship/map/maps.rs

@ -439,8 +439,8 @@ impl Maps {
pub fn roll_monster_appearance(&mut self, rare_monster_table: &RareMonsterAppearTable) {
self.enemy_data = self.enemy_data
.iter()
.map(|&x| if x.is_some() {
Some(x.unwrap().roll_appearance_for_quest(&rare_monster_table))
.map(|&x| if x.is_some() && x.unwrap().has_rare_appearance() {
Some(x.unwrap().roll_appearance_for_mission(&rare_monster_table))
} else {
x
})

Loading…
Cancel
Save