Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import exit
- from random import randint, randrange
- import math
- import time
- """
- A lot of these is inefficient and quite useless, i'l rewrite it later when it's functioning
- The mechanic is technically finished except the variable random part
- """
- #################################################################################################################
- # Player
- player_exp = 0
- exp_limit = 50
- player_level = 1
- player_maxhp = 100
- player_hp = 100
- player_atk = 0
- player_agi = 0
- player_misc = 0
- stat_limit = 8
- # Equipped
- eq_punch = True
- eq_sword1 = False
- eq_sword2 = False
- eq_rapier1 = False
- eq_rapier2 = False
- eq_axe1 = False
- eq_axe2 = False
- eq_shield = False
- eq_armor = False
- potion_count = 0
- potion_limit = 3
- weapon1_drop = randint(40, 60)
- weapon2_drop = randint(10, 30)
- potion_drop = randint(20, 50)
- # Weapon Stats
- punch_atk = 6
- punch_hitchance = 100
- punch_critchance = 0
- sword1_atk = 10
- sword1_hitchance = 40
- sword1_critchance = 10
- sword2_atk = 14
- sword2_hitchance = 50
- sword2_critchance = 10
- rapier1_atk = 8
- rapier1_hitchance = 50
- rapier1_critchance = 15
- rapier2_atk = 10
- rapier2_hitchance = 60
- rapier2_critchance = 7
- axe1_atk = 18
- axe1_hitchance = 30
- axe1_critchance = 20
- axe2_atk = 24
- axe2_hitchance = 40
- axe2_critchance = 25
- shield_red = 10
- armor_red = 20
- potion_count = 0
- potion_limit = 3
- # Trigger
- room1 = False
- mini_boss = False
- boss = False
- exit_key = False
- # Monsters
- name_rat = "Rat"
- rat_hp = randint(10, 15)
- rat_atk = randint(1, 2)
- rat_crit = 3
- rat_evade = 15
- rat_exp = randrange(1, 3)
- rat_chance = randint(60, 80)
- name_rat2 = "Giant Rat"
- rat2_hp = randint(20, 45)
- rat2_atk = randint(5, 10)
- rat2_crit = 5
- rat2_evade = 2
- rat2_exp = randint(5, 10)
- rat2_chance = randint(30, 50)
- name_goblin = "Goblin"
- goblin_hp = randint(20, 40)
- goblin_atk = randint(3, 7)
- goblin_crit = 15
- goblin_evade = 20
- goblin_exp = randint(7, 10)
- goblin_chance = randint(50, 70)
- name_slime = "Red Slime"
- slime_hp = randint(100, 200)
- slime_atk = randint(1, 2)
- slime_crit = 60
- slime_evade = 10
- slime_exp = randint(1, 5)
- slime_chance = randint(50, 60)
- name_slime2 = "Green Slime"
- slime2_hp = randint(40, 80)
- slime2_atk = randint(15, 20)
- slime2_crit = 5
- slime2_evade = 10
- slime2_exp = randint(10, 40)
- slime2_chance = randint(30, 50)
- name_slime3 = "Blue Slime"
- slime3_hp = randint(10, 15)
- slime3_atk = 0
- slime3_crit = 0
- slime3_evade = 0
- slime3_exp = randint(1, 2)
- slime3_chance = randint(10, 30)
- name_askeleton = "Armored Skeleton"
- skeleton_hp = randint(120, 180)
- skeleton_atk = randint(5, 10)
- skeleton_crit = 2
- skeleton_evade = 10
- skeleton_exp = randint(15, 25)
- skeleton_chance = randint(30, 45)
- name_askeleton2 = "Swordsman Skeleton"
- skeleton2_hp = randint(50, 80)
- skeleton2_atk = randint(10, 18)
- skeleton2_crit = 5
- skeleton2_evade = 10
- skeleton2_exp = randint(15, 25)
- skeleton2_chance = randint(30, 45)
- name_zombie = "A Lone Zombie"
- zombie_hp = randint(40, 80)
- zombie_atk = randint(10, 15)
- zombie_crit = 10
- zombie_evade = 10
- zombie_exp = randint(10, 20)
- zombie_chance = randint(30, 40)
- name_gargoyle = "Stone Gargoyle"
- gargoyle_hp = randint(100, 200)
- gargoyle_atk = randint(10, 20)
- gargoyle_crit = 5
- gargoyle_evade = 20
- gargoyle_exp = randint(20, 30)
- gargoyle_chance = randint(20, 40)
- name_minotaur = "Minotaur"
- minotaur_hp = randint(80, 120)
- minotaur_atk = randint(10, 20)
- minotaur_crit = 5
- minotaur_evade = 15
- minotaur_exp = randint(20, 40)
- minotaur_chance = randint(10, 20)
- name_boss = "Troglodyte"
- boss_hp = 800
- boss_atk = 25
- boss_crit = 10
- boss_evade = 10
- boss_exp = randint(50, 80)
- boss_chance = randint(1,3)
- #################################################################################################################
- def rng(): # RNG
- return randint(0, 100)
- def dead(reason): # End
- print(reason, "Restart?\n1. Yes\n2. No")
- choice = input("> ")
- if choice == "1":
- print("Do you wish to recreate your character?\n1. Yes\n2. No")
- choice = input("> ")
- if choice == "1":
- print("Recreating character...")
- time.sleep(1)
- char_create()
- else:
- print("Restarting...")
- time.sleep(1)
- start()
- else:
- print("Thank you for playing")
- exit(0)
- def exp_check(enemy_exp): # Check player exp for level up
- global exp_limit, player_level, player_exp, player_hp, player_maxhp, potion_limit
- player_exp += enemy_exp
- if player_level >= 15:
- player_exp = exp_limit
- print("Warning: Max Level Reached!")
- elif player_exp == exp_limit:
- player_exp -= exp_limit
- exp_limit += 25
- player_level += 1
- player_maxhp += 20
- player_hp = player_maxhp
- print("You are now Level:", player_level)
- if player_level % 4 == 0:
- potion_limit += 1
- print("Potion limit increased")
- print(f"You now can hold {potion_limit} potion")
- level_up()
- def level_up(): # Player level up
- global player_atk, player_agi, player_misc
- print("You gained a skill point!")
- print("What do you want to add ?")
- print(f"1.ATK: {player_atk}/{stat_limit} 2. AGI: {player_agi}/{stat_limit} 3. MISC: {player_misc}/{stat_limit}")
- choice = input("> ")
- if choice == "1":
- if player_atk >= 8:
- print("Error: Stat is already maxed")
- time.sleep(1)
- level_up()
- else:
- player_atk += 1
- elif choice == "2":
- if player_agi >= 8:
- print("Error: Stat is already maxed")
- time.sleep(1)
- level_up()
- else:
- player_agi += 1
- elif choice == "3":
- if player_misc >= 8:
- print("Error: Stat is already maxed")
- time.sleep(1)
- level_up()
- else:
- player_misc += 1
- else:
- print("Error: Not a number")
- level_up()
- def health_check(): # Checks player health
- if player_hp <= 0:
- dead("You ran out of health")
- def weapon_check(): # Check player weapon
- if eq_sword1 == True:
- return sword1_atk
- elif eq_sword2 == True:
- return sword2_atk
- elif eq_rapier1 == True:
- return rapier1_atk
- elif eq_rapier2 == True:
- return rapier2_atk
- elif eq_axe1 == True:
- return axe1_atk
- elif eq_axe2 == True:
- return axe2_atk
- else:
- return punch_atk
- def armor_check(): # Check player's armor
- if eq_shield and eq_armor == True:
- return shield_red + armor_red
- elif eq_shield == True:
- return shield_red
- elif eq_armor == True:
- return armor_red
- else:
- return 1
- def hit_chance(): # Player hit chance
- if eq_sword1 == True:
- return (sword1_hitchance + (player_atk * 5))
- elif eq_sword2 == True:
- return (sword2_hitchance + (player_atk * 5))
- elif eq_rapier1 == True:
- return (rapier1_hitchance + (player_atk * 5))
- elif eq_rapier2 == True:
- return (rapier2_hitchance + (player_atk * 5))
- elif eq_axe1 == True:
- return (axe1_hitchance + (player_atk * 5))
- elif eq_axe2 == True:
- return (axe2_hitchance + (player_atk * 5))
- else:
- return (punch_hitchance + (player_atk * 5))
- def crit_chance(): # Player crit chance
- if eq_sword1 == True:
- return (sword1_critchance + (player_misc * 2))
- elif eq_sword2 == True:
- return (sword2_critchance + (player_misc * 2))
- elif eq_rapier1 == True:
- return (rapier1_critchance + (player_misc * 2))
- elif eq_rapier2 == True:
- return (rapier2_critchance + (player_misc * 2))
- elif eq_axe1 == True:
- return (axe1_critchance + (player_misc * 2))
- elif eq_axe2 == True:
- return (axe2_critchance + (player_misc * 2))
- else:
- return (punch_critchance + (player_misc * 2))
- def battle(enemy_name, enemy_hp, enemy_atk, enemy_crit, enemy_evade, enemy_exp):# Battle sequence
- time.sleep(1)
- print("===============================================================================")
- while enemy_hp > 0:
- global player_hp, potion_count
- health_check()
- print("-------------------------------------------------------------------------------")
- print(f"{enemy_name}'s Stats:")
- print(f"HP: {enemy_hp} Power: {enemy_atk} Crit Chance: {enemy_crit}% Evade: {enemy_evade}%\n")
- print("Your Stats:")
- print(f"Level: {player_level} EXP: {player_exp}/{exp_limit} HP: {player_hp}/{player_maxhp} Power: {player_atk + weapon_check()} Potion: {potion_count}/{potion_limit}")
- print(f"Hit Chance: {hit_chance()}% Parry Chance: {player_agi * 8}% Crit Chance: {crit_chance()}% Evade Chance: {player_agi * 5}%")
- print("-------------------------------------------------------------------------------")
- print("Action:\n1. Attack\n2. Parry\n3. Use Potion")
- choice = input("> ")
- if choice == "1":
- if rng() <= enemy_evade or not rng() <= hit_chance():
- print("Miss!")
- elif rng() <= hit_chance() and rng() <= crit_chance():
- print("Critical Hit!")
- enemy_hp -= ((player_atk + weapon_check()) * 2)
- health_check()
- else:
- print("Succesful Hit!")
- enemy_hp -= player_atk + weapon_check()
- if rng() <= player_agi * 5:
- print("Hit Evaded!")
- elif rng() <= enemy_crit:
- print("Enemy Critical Hit!")
- player_hp -= math.ceil((armor_check() * 0.01) * (enemy_atk * 2))
- else:
- print("You are hit")
- player_hp -= math.ceil((armor_check() * 0.01) * enemy_atk)
- health_check()
- time.sleep(1)
- elif choice == "2":
- if rng() <= enemy_evade:
- print("Parry Evaded!")
- player_hp -= math.ceil((armor_check() * 0.01) * enemy_atk)
- elif rng() <= player_agi * 8 and rng() <= enemy_crit:
- print("Critical Parry!")
- enemy_hp -= math.ceil((enemy_atk * 2) * 0.8)
- elif rng() <= player_agi * 8:
- print("Parry Succesful!")
- enemy_hp -= math.ceil(enemy_atk * 0.8)
- player_hp -= math.ceil(((armor_check() * 0.01) * enemy_atk) * 0.1)
- else:
- print("Parry Failed")
- player_hp -= math.ceil((armor_check() * 0.01) * enemy_atk)
- if rng() <= player_agi * 5:
- print("Enemy Miss!")
- elif rng() <= enemy_crit:
- print("Enemy Critical Hit!")
- player_hp -= math.ceil((armor_check() * 0.01) * (enemy_atk * 2))
- else:
- print("You are hit!")
- player_hp -= math.ceil(((armor_check() * 0.01) * enemy_atk) * 0.1)
- health_check()
- time.sleep(1)
- elif choice == "3":
- if potion_count == 0:
- print("You don't have a potion")
- time.sleep(1)
- else:
- potion_count -= 1
- print(f"You used a potion, you have {potion_count} potion left.")
- player_hp += 30 + (player_misc * 15)
- time.sleep(1)
- else:
- print("Error: Not a number")
- print(f"{enemy_name} killed")
- print(f"You gained {enemy_exp} EXP")
- exp_check(enemy_exp)
- print(f"Your EXP is now {player_exp}/{exp_limit}")
- print("===================================================================================")
- time.sleep(2)
- def weapon_change(): # Change player weapon
- if eq_sword1 == True:
- return eq_sword1 == False
- elif eq_sword2 == True:
- return eq_sword2 == False
- elif eq_rapier1 == True:
- return eq_rapier1 == False
- elif eq_rapier2 == True:
- return eq_rapier2 == False
- elif eq_axe1 == True:
- return eq_axe1 == False
- elif eq_axe2 == True:
- return eq_axe2 == False
- else:
- return eq_punch == False
- ##########################################################################################################################
- def char_create():
- global player_atk, player_agi, player_misc
- stat_allocate = 10
- print("You have", stat_allocate, "Skill Points.")
- print("ATK affect your hit chance with weapon and the damage you dealt.")
- print("Each point will increase hit chance by '5%' and add point of damage")
- print("Enter a number between 0-8 for your ATK.")
- player_atk = int(input("> "))
- stat_allocate -= player_atk
- print("--------------------------------------------------------------------------------------------------------------")
- print("You have", stat_allocate, "Skill Point(s) remaining.")
- print("AGI affect your chance to parry enemy attack.")
- print("Each AGI point will increase parry chance by '8%' and evade by '5%'")
- print("A successful pary wil decrease damage received to '10%' and the enemy will receive '80%' of their own damage.")
- print("Enter a number between 0-8 for your AGI.")
- player_agi = int(input("> "))
- stat_allocate -= player_agi
- print("--------------------------------------------------------------------------------------------------------------")
- print("You have", stat_allocate, "Skill Point(s) remaining")
- print("MISC skill will affect your chances of landing a critical and increase potion effectiveness.")
- print("Each MISC point wil increase crit chances with weapon '2%' and potion effectiveness by 15 Points")
- print("Enter a number between 0-8 for your MISC")
- player_misc = int(input("> "))
- stat_allocate -= player_misc
- print("--------------------------------------------------------------------------------------------------------------")
- if stat_allocate > 0:
- print("You have", stat_allocate, "Skill points remaining. Do you want to restart?\n1. Yes\n2. No")
- choice = input("> ")
- if choice == "1":
- print("Restarting...")
- time.sleep(2)
- char_create()
- else:
- print("Starting...")
- time.sleep(2)
- start()
- elif stat_allocate < 0:
- print("Error: Stat exceed maximum")
- print("Restarting...")
- time.sleep(2)
- char_create()
- else:
- print("Starting...")
- time.sleep(3)
- start()
- def start():
- global eq_sword1, room1
- if start == False:
- print("You wake up in a dark room")
- print("You see an unfamiliar roof")
- print("You try to get a grasp of your surrounding")
- print("Only to be startled by a rat hissing at you")
- battle(name_rat, rat_hp, rat_atk, rat_crit, rat_evade, rat_exp)
- room1 = True
- if rng() < weapon1_drop:
- print("The enemy dropped a rusty sword")
- print("Rusty Sword Stats")
- print(f"ATK: {sword1_atk}, Hit Chance: {sword1_hitchance} Crit Chance: {sword1_critchance}")
- print("Do you wish to take it?\n1. Yes\n2. No")
- choice = input("> ")
- if choice == "1":
- weapon_change()
- eq_sword1 = True
- print("Rusty Sword equipped")
- time.sleep(1)
- else:
- print("You leave the Rusty Sword")
- time.sleep(1)
- else:
- if rng() < secret_chance:
- print("You saw a black slave")
- print("He's charging at you full speed")
- battle(name_secret, secret_hp, secret_atk, secret_crit, secret_evade, secret_exp)
- print("Suddenly, there are police siren")
- print("You are arrested for being racist")
- dead("You are racist")
- if rng() < rat_chance:
- print("You look around the room")
- print("Only to be startled by a rat hissing at you")
- battle(name_rat, rat_hp, rat_atk, rat_crit, rat2_evade, rat_exp)
- if rng() < weapon1_drop:
- print("The enemy dropped a rusty sword")
- print("Rusty Sword Stats:")
- print(f"ATK: {sword1_atk}, Hit Chance: {sword1_hitchance} Crit Chance: {sword1_critchance}")
- print("Do you wish to take it?\n1. Yes\n2. No")
- choice = input("> ")
- if choice == "1":
- weapon_change()
- eq_sword1 = True
- print("Rusty Sword equipped\n")
- time.sleep(1)
- else:
- print("You leave the Rusty Sword\n")
- time.sleep(1)
- print("The room is gloomy")
- print("The walls are cracked")
- print("There are shackles and cages along the wall")
- print("You see 2 door\n1. East Door\n2. South Door")
- choice = input("> ")
- if choice == "1":
- print("You entered the East Door")
- time.sleep(1)
- room2()
- elif choice == "2":
- print("You went through the South Door")
- time.sleep(1)
- room6()
- def room2():
- global potion_count
- if rng() <= slime3_chance:
- print("You encountered a blue slime")
- print("It have a pointy head")
- print("It's humping at you")
- print("You didn't feel anything")
- battle(name_slime3, slime3_hp, slime3_atk, slime3_atk, slime3_evade, slime3_exp)
- print("Maybe the slime isn't that bad?")
- if rng() < potion_drop:
- print("The enemy dropped a Health Potion")
- print(f"You have {potion_count}/{potion_limit} Health Potion")
- print("Do you wish to take it?\n1. Yes\n2. No")
- choice = input("> ")
- if choice == "1":
- if potion_count < potion_limit:
- potion_count += 1
- print("You took the Health Potion\n")
- else:
- print("Warning: Potion Limit Reached")
- else:
- print("You leave the Health Potion\n")
- elif rng() <= rat2_chance:
- print("A giant rat is blocking the hallway")
- print("You prepared yourself to attack it")
- battle(name_rat2, rat2_hp, rat2_atk, rat2_crit, rat2_evade, rat2_exp)
- print("You entered a hallway")
- print("Your surroundings is lit by torches on the walls")
- print("There are 2 doors\n1. South Door\n2. West Door")
- choice = input("> ")
- if choice == "1":
- print("You went through the South Door")
- time.sleep(1)
- room5()
- elif choice == "2":
- print("You chose to go through the West Door")
- time.sleep(1)
- start()
- else:
- print("Not a number")
- char_create()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement