Skip to content

Commit

Permalink
Range adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
fungamer2-2 committed Jan 5, 2024
1 parent 2539e60 commit 514edb3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 14 deletions.
3 changes: 3 additions & 0 deletions entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ def ranged_evasion(self):
mod -= 5

return ev + mod

def apply_armor(self, dam):
return apply_armor(dam, self.get_armor())

def shoot_projectile_at(self, target_pos, proj):
g = self.g
Expand Down
6 changes: 6 additions & 0 deletions game_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ def place_items(self):
if one_in(5):
pos = board.random_passable()
board.place_item_at(pos, Shield())

if one_in(2):
for _ in range(triangular_roll(1, 9)):
if one_in(2):
pos = board.random_passable()
board.place_item_at(pos, Dart())

def place_monsters(self):
eligible_types = {}
Expand Down
5 changes: 4 additions & 1 deletion inventory_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ def display_item(g, item):
if isinstance(item, Weapon):
use_text = "Wield"
can_throw = item.thrown != False
elif isinstance(item, ThrownItem):
can_throw = True
elif isinstance(item, Armor):
use_text = "Wear"

menu.add_text(f"U - {use_text}")
menu.add_text("D - Drop")
if can_throw:
menu.add_text("T - Throw")
menu.add_text("D - Drop")

menu.add_text("Enter - cancel")
menu.display()

Expand Down
32 changes: 30 additions & 2 deletions items.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def display_color(self):
return 0

def use(self, player):
self.add_msg("There isn't much of a use for your {item.name}.")
return ItemUseResult.NOT_USED

class Potion(Item):
Expand Down Expand Up @@ -207,16 +208,44 @@ def scroll_effect(self, player):


player.use_energy(100)

class ThrownItem(Item):

def __init__(self, name):
super().__init__()
self.name = name
self.damage = Dice(1, 1)
self.finesse = False
self.thrown = [6, 18]

def roll_damage(self):
return self.damage.roll()

def use(self, player):
if player.throw_item(self):
return ItemUseResult.USED
return ItemUseResult.NOT_USED

class Dart(ThrownItem):

def __init__(self):
super().__init__("dart")
self.damage = Dice(1, 4)
self.finesse = True
self.symbol = ";"

def display_color(self):
return curses.color_pair(COLOR_DODGER_BLUE2) | curses.A_REVERSE


class Weapon(Item):
description = "A weapon that can be used in combat."

def __init__(self):
super().__init__()
self.type = None
self.name = "weapon"
self.damage = Dice(0, 0, 1)
self.damage = Dice(1, 1)
self.dmg_type = "bludgeon"
self.finesse = False
self.heavy = False
Expand Down Expand Up @@ -252,7 +281,6 @@ class NullWeapon(Weapon):
def __init__(self):
super().__init__()
self.name = "unarmed"
self.damage = Dice(1, 1, 0)

def roll_damage(self):
return 1 + one_in(3)
Expand Down
11 changes: 5 additions & 6 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def xp_to_next_level(self):
amount = 100 * self.xp_level ** 1.5
return round(amount/10)*10


def inc_random_stat(self):
rand = rng(1, 6)

Expand Down Expand Up @@ -428,7 +427,6 @@ def attack_pos(self, pos):

mon_shield_bonus = 0
if mon.is_aware() and mon.shield:
self.add_msg("Defender is aware and using shield")
mon_shield_bonus = SHIELD_BONUS

att_roll -= mon_shield_bonus
Expand Down Expand Up @@ -506,7 +504,7 @@ def attack_pos(self, pos):

def on_defeat_monster(self, mon):
g = self.g
xp_gain = 15 * mon.get_diff_level()**1.7
xp_gain = 10 * mon.get_diff_level()**1.7
xp_gain = round(xp_gain/5)*5
self.gain_xp(xp_gain)

Expand Down Expand Up @@ -677,8 +675,7 @@ def throw_item(self, item):

mon = g.select_monster(mons_in_range, f"Throw the {item.name} at which monster?")
if not mon:
return None

return False

proj = Projectile(accuracy=self.attack_accuracy(True), name=item.name, can_crit=True)
proj.short_range = short_range
Expand Down Expand Up @@ -706,4 +703,6 @@ def throw_item(self, item):

self.shoot_projectile_at(mon.pos, proj)
board.place_item_at(proj.final_pos, item)
self.use_energy(100)
self.use_energy(100)

return True
5 changes: 3 additions & 2 deletions projectile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ def on_hit(self, attacker, defender, margin):
crit = one_in(9)

damage = self.roll_damage(crit)
damage = defender.apply_armor(damage)
attacker.add_msg_if_u_see(defender, f"The {self.name} hits {defender.get_name()}.")
if crit:
if damage > 0 and crit:
attacker.add_msg("Critical hit!", "good")

defender.take_damage(damage, attacker)
if defende.is_alive() and defender.is_monster():
if defender.is_alive() and defender.is_monster():
if attacker.is_player():
attacker.alerted()
6 changes: 3 additions & 3 deletions weapons.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"base_damage": "1d4",
"damage_type": "pierce",
"finesse": true,
"thrown": [4, 12]
"thrown": [6, 18]
},
{
"id": "greatclub",
Expand All @@ -28,7 +28,7 @@
"symbol": "h",
"base_damage": "1d6",
"damage_type": "slash",
"thrown": [4, 12]
"thrown": [6, 18]
},
{
"id": "scimitar",
Expand Down Expand Up @@ -67,6 +67,6 @@
"symbol": "¥",
"base_damage": "1d7",
"damage_type": "pierce",
"thrown": [4, 12]
"thrown": [6, 18]
}
]

0 comments on commit 514edb3

Please sign in to comment.