diff --git a/entity.py b/entity.py index d8e7c1d..358886f 100644 --- a/entity.py +++ b/entity.py @@ -43,9 +43,18 @@ def calc_evasion(self): if not self.is_alive(): dex = 0 return 10 + (dex - 10) / 2 + + def base_speed(self): + return 100 def get_speed(self): - return 100 + return round(self.base_speed() * self.speed_mult()) + + def speed_mult(self): + mult = 1 + if self.has_status("Slowed"): + mult = 0.5 + return mult @abstractmethod def get_name(self, capitalize=False): diff --git a/game_inst.py b/game_inst.py index babc240..4e1c7d7 100644 --- a/game_inst.py +++ b/game_inst.py @@ -95,12 +95,17 @@ def generate_level(self): def place_items(self): board = self.get_board() + potions = [ + [HealingPotion, 120], + [EnlargementPotion, 25], + [ShrinkingPotion, 25], + [SpeedPotion, 35] + ] + for _ in range(rng(1, 5)): pos = board.random_passable() - typ = HealingPotion - if one_in(3): - typ = random.choice([EnlargementPotion, ShrinkingPotion, SpeedPotion]) + typ = random_weighted(potions) board.place_item_at(pos, typ()) def place_monsters(self): @@ -249,7 +254,6 @@ def do_turn(self): return self.refresh_mon_pos_cache() - player.do_turn() self.subtick_timer += used @@ -258,12 +262,12 @@ def do_turn(self): m.energy += used self.process_noise_events() + while self.subtick_timer >= 100: self.subtick_timer -= 100 self.tick += 1 for m in self.monsters: m.tick() - remaining = self.monsters.copy() random.shuffle(remaining) diff --git a/monster.py b/monster.py index 8a65ebf..15701f1 100644 --- a/monster.py +++ b/monster.py @@ -58,7 +58,7 @@ def get_skill(self, name): skills = self.type.skills return skills.get("name", 0) - def get_speed(self): + def base_speed(self): return self.type.speed def get_diff_level(self): diff --git a/monsters.json b/monsters.json index 0c22ff6..d462681 100644 --- a/monsters.json +++ b/monsters.json @@ -122,5 +122,25 @@ "pack_travel": true, "flags": [ "KEEN_SMELL" ], "attack_msg": " bites " + }, + { + "id": "giant_centipede", + "name": "giant centipede", + "symbol": "m", + "STR": 5, + "DEX": 14, + "CON": 12, + "INT": 1, + "WIS": 7, + "CHA": 3, + "HP": 5, + "to_hit": 4, + "level": 5, + "diff": 3, + "use_dex_melee": true, + "size": "small", + "speed": 90, + "base_damage": "1d4", + "attack_msg": " bites " } ] \ No newline at end of file diff --git a/player.py b/player.py index 34c3680..8c8b1cc 100644 --- a/player.py +++ b/player.py @@ -32,12 +32,11 @@ def calc_evasion(self): if self.has_status("Hasted"): bonus += 2 if self.has_status("Enlarged"): - bonus *= 0.75 + bonus *= 0.7 elif self.has_status("Reduced"): - bonus *= 1.25 + bonus *= 1.3 - - return bonus + return bonus + 5 def add_to_inventory(self, item): self.inventory.append(item) @@ -122,11 +121,11 @@ def visible_monsters(self): if (m := g.monster_at(pos)): yield m - def get_speed(self): - speed = 100 + def speed_mult(self): + mult = super().speed_mult() if self.has_status("Hasted"): - speed *= 2 - return speed + mult *= 2 + return mult def get_name(self, capitalize=False): return "You" if capitalize else "you" @@ -140,7 +139,7 @@ def calc_to_hit_bonus(self, mon): mod += 5 if self.has_status("Reduced"): - mod += 1 + mod += 1.5 return mod def regen_rate(self): @@ -154,7 +153,7 @@ def recalc_max_hp(self): if self.has_status("Enlarged"): val *= 1.5 elif self.has_status("Reduced"): - val *= 0.75 + val *= 0.7 oldhp = self.MAX_HP self.MAX_HP = round(val) @@ -192,7 +191,6 @@ def use_item(self): item = g.select_use_item() if not item: return False - self.add_msg(f"You have selected {item.name}") used = item.use(self) if used: self.inventory.remove(item) @@ -261,7 +259,7 @@ def attack_pos(self, pos): damage = dice(1, 6) + div_rand(self.STR - 10, 2) if self.has_status("Enlarged"): - damage += dice(1, 4) + damage += dice(1, 6) elif self.has_status("Reduced"): damage = (damage + 1) // 2 damage = max(damage, 1) @@ -277,7 +275,6 @@ def attack_pos(self, pos): noise = div_rand(noise, 2) self.make_noise(noise) - self.add_msg(f"Made combat sound of {noise}") self.add_msg(f"You hit {mon.get_name()} for {damage} damage.") mon.take_damage(damage) @@ -349,7 +346,7 @@ def do_turn(self): def stealth_roll(self): stealth = (self.DEX-10)/2 if self.has_status("Reduced"): - stealth += 2 + stealth += 3 elif self.has_status("Enlarged"): - stealth -= 2 + stealth -= 3 return gauss_roll(stealth) \ No newline at end of file diff --git a/utils.py b/utils.py index 8e18f12..125591a 100644 --- a/utils.py +++ b/utils.py @@ -52,6 +52,9 @@ def div_rand(x, y): mod = x % y return sign * (x//y + (rng(1, y) <= mod)) +def random_weighted(entries): + values, weights = list(zip(*entries)) + return random.choices(values, weights=weights)[0] def dice(num, sides): if sides == 1: