Skip to content

Commit

Permalink
Full weapon list now implemented!
Browse files Browse the repository at this point in the history
The full range of random H&H weapons is now available to the player.

The only remaining thing is to implement actual ranged combat for the
guns.
  • Loading branch information
jarcane committed Jul 14, 2014
1 parent 5b2967c commit 921f425
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 15 deletions.
18 changes: 5 additions & 13 deletions handhrl.py
Expand Up @@ -1052,19 +1052,11 @@ def get_item(x, y):
return item

def get_weapon(x, y):
choice = 'laser_sword'

if choice == 'laser_sword':
# create a sword
# determine sword bonus, if any.
sword_bonus = rolldice(1, 3) - 1
if sword_bonus > 0:
sword_name = '+' + str(sword_bonus) + ' laser sword'
else:
sword_name = 'laser sword'
equipment_component = Equipment(slot='right hand', damage_roll=[2, 10, 1], to_hit_bonus=sword_bonus,
damage_bonus=sword_bonus)
item = Object(x, y, '/', sword_name, libtcod.sky, equipment=equipment_component)
weapon = hhtable.make_weapon()

equipment_component = Equipment(slot='right hand', damage_roll=weapon['damage'], to_hit_bonus=weapon['bonus'],
damage_bonus=weapon['bonus'])
item = Object(x, y, weapon['char'], weapon['name'], libtcod.brass, equipment=equipment_component)

return item

Expand Down
92 changes: 90 additions & 2 deletions hhtable.py
Expand Up @@ -5,8 +5,8 @@
'''


import libtcodpy as libtcod
import random


def make_monster_table(dungeon_level):
Expand Down Expand Up @@ -41,4 +41,92 @@ def make_monster_table(dungeon_level):

adjust_table = {k: v for k, v in monster_table.iteritems() if v[0] <= dungeon_level}

return adjust_table
return adjust_table


def make_weapon():
# generate a weapon name and damage

# table entries for modern are lists: character, name, rolldice tuple (or list if Highest X)

modern_weapon = [['-', 'shiv', (1, 3)],
['-', 'combat knife', (1, 4)],
['-', 'vibro-blade', (1, 6)],
['/', 'cutlass', (1, 8)],
['/', 'vibro-sword', (1, 10)],
['/', 'laser sword', [2, 10, 1]],
[')', 'laser pistol', [2, 6, 1]],
[')', 'slug pistol', (1, 8)],
[')', 'particle beamer', (1, 10)],
['}', 'pulse rifle', [3, 6, 2]],
['}', 'plasma rifle', (2, 6)],
['}', 'bolt rifle', (2, 10)],
['=', 'naval pumpgun', (2, 6)],
['=', 'sonic wavegun', (2, 8)],
['=', 'plasma burster', (2, 12)],
['&', 'minigun', [4, 6, 3]],
['&', 'flamethrower', [1, 8]],
['&', 'microrocket gun', (3, 8)]]

ancient_types = ['dagger', 'sword', 'pistol', 'rifle', 'shotgun', 'heavy']

ancient_names = {'dagger': ['monomolecular', 'phasic', 'plasma', 'hard light', 'synthdiamond', 'chitin'],
'sword': ['monomolecular', 'phasic', 'plasma', 'hard light', 'synthdiamond', 'chitin'],
'pistol': ['neutron slug', 'disintegrator', 'electric arc', 'quark accelerator',
'pain ray', 'dark matter beam'],
'rifle': ['neutron slug', 'disintegrator', 'electric arc', 'quark accelerator',
'pain ray', 'dark matter beam'],
'shotgun': ['graviton wave gun', 'spatial distruptor', 'field projector', 'waveform collapser',
'superfluid blast emitter', 'molecular vibrator'],
'heavy': ['existential dequantifier', 'remote fusion launcher', 'antimatter pod launcher',
'matter melter', 'uncertainty resolver', 'polarity reverser']}

ancient_char = {'dagger': '-',
'sword': '/',
'pistol': ')',
'rifle': '}',
'shotgun': '=',
'heavy': '&'}

ancient_damage = {'dagger': [(1, 4), (1, 6), (1, 8), (1, 10), [2, 10, 1]],
'sword': [(1, 8), (1, 10), (1, 12), [2, 12, 1], [3, 12, 1]],
'pistol': [(1, 8), (1, 10), (1, 12), (2, 8), (2, 10)],
'rifle': [(2, 8), (2, 10), [3, 10, 2], (2, 12), (3, 6)],
'shotgun': [(2, 6), (2, 8), (2, 10), (2, 12), [3, 10, 2]],
'heavy': [(3, 8), (3, 10), (3, 12), (4, 8), (4, 10)]}

# determine if ancient or modern
age = libtcod.random_get_int(0, 1, 4)
if age < 4:
# return modern weapon
char, name, damage = random.choice(modern_weapon)
else:
# choose type of ancient weapon
type = random.choice(ancient_types)

# get the weapon's character
char = ancient_char[type]

# name the weapon
if type == 'heavy' or type == 'shotgun':
name = random.choice(ancient_names[type])
else:
name = random.choice(ancient_names[type]) + type

# get the weapon's damage
damage = random.choice(ancient_damage[type])

# roll bonus
bonus = libtcod.random_get_int(0, 1, 3) - 1

# append bonus to name if non-zero
if bonus > 0:
name = name + ' +' + str(bonus)

# put it together
weapon = {'char': char,
'name': name,
'damage': damage,
'bonus': bonus}

return weapon

0 comments on commit 921f425

Please sign in to comment.