From 5c49ded823165dd8f9bd23a1f268c935c8ee3407 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Jul 2021 00:37:54 +0000 Subject: [PATCH] add best quest. add rare monsters to quests. dont use the same seed for random numbers if you want different results --- data/quests.toml | 6 +++++- src/ship/map/enemy.rs | 8 ++------ src/ship/map/maps.rs | 5 +++-- src/ship/packet/handler/quest.rs | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/data/quests.toml b/data/quests.toml index a316475..d1d3298 100644 --- a/data/quests.toml +++ b/data/quests.toml @@ -32,4 +32,8 @@ dat = "q233-ext-bb.dat" [[Retrieval.quests]] bin = "q236-ext-bb.bin" dat = "q236-ext-bb.dat" -#drop_table = "q102-drops" \ No newline at end of file +#drop_table = "q102-drops" + +[[Retrieval.quests]] +bin = "q118-vr-bb.bin" +dat = "q118-vr-bb.dat" diff --git a/src/ship/map/enemy.rs b/src/ship/map/enemy.rs index 6ed160b..e66cca4 100644 --- a/src/ship/map/enemy.rs +++ b/src/ship/map/enemy.rs @@ -108,12 +108,8 @@ impl RareMonsterAppearTable { pub fn roll_appearance(&self, monster: &MonsterType) -> bool { 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::() < *self.appear_rate.get(monster).unwrap_or(&0.0f32) { + // let mut rng = rand_chacha::ChaChaRng::from_entropy(); + if rand_chacha::ChaChaRng::from_entropy().gen::() < *self.appear_rate.get(monster).unwrap_or(&0.0f32) { println!("its a rare!"); true } diff --git a/src/ship/map/maps.rs b/src/ship/map/maps.rs index 0bd34b7..ceebd65 100644 --- a/src/ship/map/maps.rs +++ b/src/ship/map/maps.rs @@ -398,9 +398,10 @@ impl Maps { }) } - pub fn set_quest_data(&mut self, enemies: Vec>, objects: Vec>) { - // pub fn set_quest_data(&mut self, enemies: Vec>, objects: Vec>, rare_monster_table: RareMonsterAppearTable) { + // pub fn set_quest_data(&mut self, enemies: Vec>, objects: Vec>) { + pub fn set_quest_data(&mut self, enemies: Vec>, objects: Vec>, rare_monster_appear_table: &RareMonsterAppearTable) { self.enemy_data = enemies; + self.roll_monster_appearance(rare_monster_appear_table); // self.enemy_data = enemies // .iter() diff --git a/src/ship/packet/handler/quest.rs b/src/ship/packet/handler/quest.rs index 90359c3..c993579 100644 --- a/src/ship/packet/handler/quest.rs +++ b/src/ship/packet/handler/quest.rs @@ -83,7 +83,8 @@ pub fn player_chose_quest(id: ClientId, questmenuselect: &QuestMenuSelect, quest let room = rooms.get_mut(room_id.0) .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?.as_mut() .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?; - room.maps.set_quest_data(quest.enemies.clone(), quest.objects.clone()); + // room.maps.set_quest_data(quest.enemies.clone(), quest.objects.clone()); + room.maps.set_quest_data(quest.enemies.clone(), quest.objects.clone(), &room.rare_monster_table); room.map_areas = quest.map_areas.clone(); let bin = quest::quest_header(questmenuselect, &quest.bin_blob, "bin");