Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ok, here is my full code. I have problems with line 42, I will indicate where it is at the end. I am basically trying to code a text based rpg. I've got the main functions but how can I make a combat system? I mean that I can ecounter an enemy, attack but how can I repeat that sequence without any errors?
- import random
- myhp = 50
- mo_basichp = 20
- mo_mediumhp = 50
- mo_hardhp = 100
- bosshp = 120
- mydmg = random.randrange(1,10)
- mo_basicdmg = random.randrange(1,5)
- mo_mediumdmg = random.randrange(2,12)
- mo_harddmg = random.randrange(5,20)
- bossdmg = random.randrange(5,30)
- mo_basic = ["Orc", "Skeleton", "Warrior", "Dwarf"]
- print("The Legend of King's College")
- import time
- time.sleep(2)
- print("Start" + " " + "Exit")
- gameop = input()
- if gameop == "Start" or "start":
- import sys
- from time import sleep
- words = "Once upon a time, in a far away land known as Murcia, there was a castle, that castle was King's College. There lived a mighty hero; Lucas. Now, he must face what destiny has to offer."
- for char in words:
- sleep(0.1)
- sys.stdout.write(char)
- sys.stdout.flush()
- time.sleep(2)
- //Down here are the problems
- mo_basic2 = random.choice(mo_basic)
- player_inbattle = False
- player_action = [" running around.", " in a cave.", " eating lunch.", " leveling up.", " fighting goblins."]
- while True:
- print ("Lucas has encountered a " + random.choice(mo_basic))
- print ("Fight or Flight?")
- answer1 = input()
- if answer1 == "Fight":
- player_inbattle = True
- print ("Attack" + "Defend")
- answerat = input()
- if answerat == "Attack" or "attack":
- while mo_basichp > 0:
- print ("Monster has " + mo_basichp - mydmg + " hp left")
- print ("The monster attacked you!")
- print ("You have " + myhp - mo_basicdmg + " hp left.")
- break
- else:
- print ("Lucas is" + random.choice(player_action))
- time.sleep(6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement