Advertisement
daixso

updated Fight.py 8/5/12

Aug 5th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.06 KB | None | 0 0
  1. import random
  2.  
  3. #player stats
  4. playerLevel = 1
  5. playerHp = 85+15*playerLevel
  6. playerMana = 130 + 20*playerLevel
  7. playerExp = 75.0
  8. ressurects = 3
  9.  
  10.  
  11.  
  12. #experience calculations
  13. playerExpForLevel = playerLevel*100
  14. playerExpToLevel = playerExpForLevel - playerExp
  15. playerExpPerc = playerExp/playerExpForLevel
  16. playerExpPercent = playerExpPerc*100
  17.  
  18.  
  19.  
  20.  
  21.  
  22. #boss or regular mob
  23. randNum=8 #random.randint(1,10)
  24.  
  25. if randNum >= 7:
  26.     print "A boss has appeared!\n"
  27.     bossHp=random.randint(200,500)*playerLevel
  28.     while bossHp > 0:
  29.         print "The boss has " + `bossHp` + " HP!\n"
  30.         print "You are level " + `playerLevel` + "!\nYour HP: " + `playerHp` + "!\nYour Mana: " + `playerMana`
  31.         print "You are " + `playerExpPercent` + "% through this level, and need " + `playerExpToLevel` + " more exp!\n"
  32.         print "Choose an attack...\n1. Fireball (50% hit, 50 mana)\n2. Melee (80% hit, 0 mana)"
  33.         attack=raw_input("Attack: ")
  34.         if attack == 1:
  35.            
  36.             hitChance = random.randint(1,10)
  37.             if hitChance >= 5:
  38.                 critChance = random.randint(1,10)
  39.                 if critChance >= 8:
  40.                     playerMana-=50
  41.                     #player does critical hit, adding 10 damage, plus an additional 5 per level
  42.                     fireballHit = random.randint(35,85)*playerLevel
  43.                     bossDamage = fireballHit + 5*playerLevel
  44.                     bossHp-=bossDamage
  45.                     print "You crit the boss for " + `bossDamage` + " HP!\n\n"
  46.                 else:
  47.                     #player does regular hit
  48.                     fireballHit = random.randint(25,75)*playerLevel
  49.                     bossHp-= fireballHit
  50.                     print "You hit the boss for " + `fireballHit` + " HP!\n\n"
  51.             else:
  52.                 print "You miss the boss, and deal no damage!\n\n"
  53.         else:
  54.             #melee attack, no mana consumption
  55.             hitChance = random.randint(1,10)
  56.             if hitChance <= 8:
  57.                 #player will hit
  58.                 critChance = random.randint(1,10)
  59.                 if critChance >= 8:
  60.                     #player does critical hit, adding10 damage, plus an additional 5 per level
  61.                     meleeHit=random.randint(30,60)*playerLevel
  62.                     bossDamage = meleeHit + 4*playerLevel
  63.                     bossHp-=bossDamage
  64.                     print "You crit the boss for " + `bossDamage` + " HP!\n\n"
  65.                 else:
  66.                     #player does normal hit
  67.                     meleeHit=random.randint(20,50)*playerLevel
  68.                     bossHp-=meleeHit
  69.                     print "You crit the boss for " + `meleeHit` + " HP!\n\n"
  70.             else:
  71.                 print "You miss the boss, and deal no damage!\n\n"
  72.                
  73.     print "You have slain the boss! And have been rewarded 150 exp!"
  74.     playerExp+=150
  75.     if playerExp >= playerExpForLevel:
  76.         difference = playerExp - playerExpForLevel
  77.         playerExp = difference
  78.         playerLevel+=1
  79.  
  80. else:
  81.     print "A mob has appeared!\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement