global levelimport timeimport randomglobal expglobal streglobal agiglobal long_swordglobal long_sword_strglobal goldglobal exp_cglobal nameglobal fistglobal fist_strglobal healthglobal fireballglobal fireball_dmghealth = 10stre = 1fist = 1fist_str = 1 + strelevel = 1exp = 0agi = 1long_sword = 1long_sword_str = 4 + stregold = 5exp_c = 10fireball = 0fireball_dmg = 10name = "Rahovart"def intro(): global name print "Ultima Story" name = raw_input("Your name: ") print "Welcome to Ultima Story", name,"." print "If you need any help during the game, type help."def room_A_1(): global level global exp global stre global agi global long_sword global long_sword_str global gold global exp_c global name level_up() print "You awaken in a large room to the sound of your name" print "You have nothing to defend yourself but your fists" print "Would you like to explore or fight", name,"?" option = raw_input("Command:") if option=="fight": room_A_1_fight() if option=="explore": print "You look around the room and find only a door." choice = raw_input("Would you like to enter?: ") if choice == "Y": room_A_2() else: room_A_1() else: room_A_1()def room_A_1_fight(): global level global exp global stre global agi global long_sword global long_sword_str global gold global exp_c global name global fist global fist_str global health gob_str = 1 gob_level = 1 print "You're searching for something to kill." time.sleep(1) print "You've found something!" gob_health = 5 while gob_health > 0: choice = raw_input("Would you like to fight the goblin? Y/N:") if choice == "Y": choice = raw_input("Pick your weapon:") if choice == "fist" and fist > 0: print "You engage the goblin." print "The goblin has", gob_health,"health." time.sleep(1) dynamic = random.random() if dynamic > 0.1: print "You hit the goblin!" print "He lost" ,gob_health - fist_str, "health!" gob_health = gob_health - fist_str else: print "You missed!" if dynamic < 0.1: random_hit = random.random() if random_hit > 0.7: print "You lost 2 health!" health = health - gob_str*2 else: print "You lost 1 health!" health = health - gob_str if choice == "long sword" and long_sword > 0: print "You engage the goblin." print "The goblin has", gob_health,"health." time.sleep(1) dynamic = random.random() if dynamic > 0.3: print "You slashed the goblin!" print "He lost", long_sword_str, "health!" gob_health = gob_health - long_sword_str else: print "You missed!" if dynamic < 0.3: random_hit = random.random() if random_hit > 0.7: print "You lost 2 health!" health = health - gob_str*2 else: print "You lost 1 health!" health = health - gob_str else: print "You ran away!" room_A_1() print "You felled the goblin!" exp = exp + 1 print "You gained 1 experience point." if long_sword == 0: print "You acquired a Long Sword!" long_sword = long_sword + 1 room_A_1()def room_A_2(): global level global exp global stre global agi global long_sword global long_sword_str global gold global exp_c global name global health level_up() lock = 0 print "This room contains two levers (left and right) and a locked door" option = raw_input("Command:") if option=="pull left lever": room_A_2_fight() if option=="pull right lever": print "You pull the right lever." print "The bars raise and the door is unlocked." lock = lock + 1 choice = raw_input("Would you like to enter?: ") if choice == "Y" and lock == 1: room_A_3() else: room_A_2()def room_A_2_fight(): global level global exp global stre global agi global long_sword global long_sword_str global gold global exp_c global name global health global fireball print "A zombie approaches you!" time.sleep(1) zom_health = 10 zom_str = 3 while zom_health > 0: choice = raw_input("Fight?: ") if choice == "Y": choice = raw_input("Pick your weapon:") if choice == "long sword" and long_sword > 0: print "You engage the zombie." print "The zombie has", zom_health,"health." time.sleep(1) dynamic = random.random() if dynamic > 0.3: print "You slashed the zombie!" print "He lost", long_sword_str, "health!" zom_health = zom_health - long_sword_str else: print "You missed!" if dynamic < 0.3: random_hit = random.random() if random_hit > 0.7: print "You lost", zom_str*2, "health!" health = health - zom_str*2 else: print "You lost", zom_str, "health!" health = health - zom_str print "You felled the zombie!" exp = exp + 2 print "You gained 2 experience points." fireball = fireball + 1 print "You acquired Tome of Fireball!" room_A_2()def room_A_3(): print "Upon entering the room you hear a sinister laughter from above you" print "The exit is on the other side of the room" choice = raw_input("Proceed?: ") if choice == "Y": room_A_3_fight() else: print "Come on you coward!" room_A_3()def room_A_3_fight(): global level global exp global stre global agi global long_sword global long_sword_str global gold global exp_c global name global health global fireball global fireball_dmg global name print "???: You thought you could escape that easily?" time.sleep(1) print name, ":Who are you?" time.sleep(1) print "???: You're a lot more messed up than I thought, buahaha" time.sleep(2) print "???: This should be quite fun!" time.sleep(1) print name, ":..." time.sleep(1) print "???: Time to die!" time.sleep(1) print "The mysterious man approaches you!" time.sleep(1) boss_health = 20 boss_str = 5 while boss_health > 0: choice = raw_input("Pick your weapon:") if choice == "long sword" and long_sword > 0: print "You engage the mysterious man!" print "He has", boss_health,"health." time.sleep(1) dynamic = random.random() if dynamic > 0.3: print "You slashed him!" print "He lost", long_sword_str, "health!" boss_health = boss_health - long_sword_str elif dynamic < 0.3: print "The mysterious man strikes!" random_hit = random.random() if random_hit > 0.9: print "You lost", boss_str*2, "health!" health = health - boss_str*2 else: print "You lost", boss_str, "health!" health = health - boss_str if choice == "fireball" and fireball > 0: print "You begin to channel energy!" print "The mysterious man has", boss_health,"health." time.sleep(1) dynamic = random.random() if dynamic > 0: print "You launch a ball of fire at the mysterious man!" print "He lost", fireball_dmg, "health!" boss_health = boss_health - fireball_dmg print "You felled the mysterious man!" exp = exp + 6 print "You gained 6 experience points." dungeon_exit()def dungeon_exit(): level_up() global name print "???: You win this round, I'm too weak to continue fighting..." print "???: But good luck getting around town with that bounty on your head! Buahaha" print name, "What's your name?" print "???: It's Lucid. I'm the town jailor. You should get out of here..." print "Lucid: You have a lot to learn about your past..." print "Lucid faints. You proceed to the exit and open the door." print "The sunlight blinds you as you venture forth into the open." print "The world awaits you", name,"go forth and fulfill your destiny!" world_map()def world_map():def level_up(): global level global stre global agi global health global exp if level == 1 and exp == 2: level = level + 1 print "You have reached Level 2!" stre = stre + 1 print "You have gained 1 strength!" agi = agi + 1 print "You have gained 1 agility!" health = health + 5 print "You have gained 5 hit points!" elif level == 2 and exp == 10: level = level + 1 print "You have reached level 3!" stre = stre + 2 print "You have gained 2 strength!" health = health + 5 "You have gained 5 hit points!"intro()room_A_1()