29
29
MAX_ROOMS = 30
30
30
31
31
# Game
32
- # Monsters
33
- MAX_ROOM_MONSTERS = 3
34
- # chances: 80% orc, 20% troll
35
- monster_chances = {'orc' : 80 , 'troll' : 20 }
36
- # Items
37
- MAX_ROOM_ITEMS = 2
38
- # chances: 70% healing potion, 10% lightning bolt scroll, 10% fireball scroll, 10% confusion scroll
39
- item_chances = {'heal' : 70 , 'lightning' : 10 , 'fireball' : 10 , 'confuse' : 10 }
40
- # Healing potion
41
- HEAL_AMOUNT = 4
42
- # Lightning bolt scroll
43
- LIGHTNING_DAMAGE = 20
32
+ # Healing potion
33
+ HEAL_AMOUNT = 40
34
+ # Lightning bolt scroll
35
+ LIGHTNING_DAMAGE = 40
44
36
LIGHTNING_RANGE = 5
45
- # Confusion
37
+ # Confusion
46
38
CONFUSE_NUM_TURNS = 10
47
39
CONFUSE_RANGE = 8
48
- # Fireball
40
+ # Fireball
49
41
FIREBALL_RADIUS = 3
50
- FIREBALL_DAMAGE = 12
42
+ FIREBALL_DAMAGE = 25
51
43
# Experience and level-ups
52
44
LEVEL_UP_BASE = 200
53
45
LEVEL_UP_FACTOR = 150
@@ -333,6 +325,16 @@ def random_choice(chances_dict):
333
325
334
326
return strings [random_choice_index (chances )]
335
327
328
+ # Returns a value that depends on level. The table specifies what
329
+ # value occurs after each level, default is 0.
330
+ def from_dungeon_level (table ):
331
+ global dungeon_level
332
+
333
+ for (value , level ) in reversed (table ):
334
+ if dungeon_level >= level :
335
+ return value
336
+ return 0
337
+
336
338
# Fighters
337
339
# Handle player death
338
340
def player_death (player ):
@@ -500,9 +502,30 @@ def closest_monster(max_range):
500
502
# Place objects in some room
501
503
def place_objects (room ):
502
504
global objects
505
+
506
+ # maximum number of monsters per room
507
+ max_monsters = from_dungeon_level ([[2 ,1 ], [3 ,4 ], [5 ,6 ]])
508
+
509
+ # chance for each monster
510
+ monster_chances = {}
511
+ monster_chances ['orc' ] = 80 # orc always shows up, even if all
512
+ # other monsters have 0 chance
513
+ monster_chances ['troll' ] = from_dungeon_level ([[15 ,3 ], [30 ,5 ], [60 ,7 ]])
514
+
515
+ # maximum number of items per room
516
+ max_items = from_dungeon_level ([[1 ,1 ], [2 ,4 ]])
517
+
518
+ # chance of each item (by default they have a chance of 0 at level
519
+ # 1, which then goes up)
520
+ item_chances = {}
521
+ item_chances ['heal' ] = 35 # healing potion always shows up, even
522
+ # if all other items have 0 chance
523
+ item_chances ['lightning' ] = from_dungeon_level ([[25 ,4 ]])
524
+ item_chances ['fireball' ] = from_dungeon_level ([[25 ,6 ]])
525
+ item_chances ['confuse' ] = from_dungeon_level ([[10 ,2 ]])
503
526
504
527
# choose random number of monsters
505
- num_monsters = libtcod .random_get_int (0 , 0 , MAX_ROOM_MONSTERS )
528
+ num_monsters = libtcod .random_get_int (0 , 0 , max_monsters )
506
529
507
530
for i in range (num_monsters ):
508
531
# choose random spot for this monster
@@ -514,21 +537,21 @@ def place_objects(room):
514
537
choice = random_choice (monster_chances )
515
538
if choice == 'orc' :
516
539
# create an orc
517
- fighter_component = Fighter (hp = 10 , defense = 0 , power = 3 , xp = 35 , death_function = monster_death )
540
+ fighter_component = Fighter (hp = 20 , defense = 0 , power = 4 , xp = 35 , death_function = monster_death )
518
541
ai_component = BasicMonster ()
519
542
monster = Object (x , y , 'o' , 'orc' , libtcod .desaturated_green ,
520
543
blocks = True , fighter = fighter_component , ai = ai_component )
521
544
elif choice == 'troll' :
522
545
# create a troll
523
- fighter_component = Fighter (hp = 16 , defense = 1 , power = 4 , xp = 100 , death_function = monster_death )
546
+ fighter_component = Fighter (hp = 30 , defense = 2 , power = 8 , xp = 100 , death_function = monster_death )
524
547
ai_component = BasicMonster ()
525
548
monster = Object (x , y , 'T' , 'troll' , libtcod .darker_green ,
526
549
blocks = True , fighter = fighter_component , ai = ai_component )
527
550
528
551
objects .append (monster )
529
552
530
553
# choose random number of items
531
- num_items = libtcod .random_get_int (0 , 0 , MAX_ROOM_ITEMS )
554
+ num_items = libtcod .random_get_int (0 , 0 , max_items )
532
555
533
556
for i in range (num_items ):
534
557
# choose random spot for this item
@@ -982,7 +1005,7 @@ def new_game():
982
1005
983
1006
# Player init
984
1007
# create object representing the player
985
- fighter_component = Fighter (hp = 30 , defense = 2 , power = 5 , xp = 0 , death_function = player_death )
1008
+ fighter_component = Fighter (hp = 100 , defense = 1 , power = 4 , xp = 0 , death_function = player_death )
986
1009
player = Object (0 , 0 , '@' , 'player' , libtcod .white , blocks = True , fighter = fighter_component )
987
1010
player .level = 1
988
1011
0 commit comments