Advertisement
Vaeb

Swordburst Online Fight Simulator

Dec 6th, 2015
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.96 KB | None | 0 0
  1. print("\nTest Starting")
  2.  
  3. --Created by Vaeb
  4. --Purpose: Viewing which armor/sword combinations are more likely to win in a battle
  5. --Important: Only change lines with a comment saying [CHANGE] following them
  6.  
  7. local HealthNum = 350 --[CHANGE] Your estimated character health (Level 30 is around 350)
  8. local AttackTime = 1.2
  9. local RegenTime = 9
  10. local WaitSpeed = 0.5
  11.  
  12. local DivideNum = 1/WaitSpeed
  13. local RegensToAttack = RegenTime/AttackTime
  14.  
  15. local BaseRegen = math.ceil(HealthNum/6)
  16.  
  17. --Get armor stats from:
  18.    --http://saob.wikia.com/wiki/Armor
  19.    --http://saob.wikia.com/wiki/Armor_Extension
  20.  
  21. --Get sword stats from:
  22.    --http://saob.wikia.com/wiki/Weapons
  23.    --http://saob.wikia.com/wiki/Weapons_V0.4.1
  24.  
  25. local Armors = {
  26.    [1] = { --Player 1
  27.       ["Name"] = "Rapier"; --[CHANGE] Choose a name
  28.       ["Damage"] = (29+29); --[CHANGE] Total damage in swords
  29.       ["Health"] = HealthNum + (70+0+0); --[CHANGE] Total health in character, armor and swords
  30.       ["Regen"] = BaseRegen + (25+0+0); --[CHANGE] Total health regen in character, armor and swords
  31.       ["Died"] = false;
  32.    };
  33.    [2] = { --Player 2
  34.       ["Name"] = "LastWish"; --[CHANGE] Choose a name
  35.       ["Damage"] = (28+28); --[CHANGE] Total damage in swords
  36.       ["Health"] = HealthNum + (70+0+0); --[CHANGE] Total health in character, armor and swords
  37.       ["Regen"] = BaseRegen + (25+45+45); --[CHANGE] Total health regen in character, armor and swords
  38.       ["Died"] = false;
  39.    };
  40. }
  41.  
  42. for i,v in pairs(Armors) do
  43.    Armors[i]["OrigHealth"] = Armors[i]["Health"]
  44. end
  45.  
  46. local StartTime = tick()
  47. local RegenNum = 0
  48. local TestDone = #Armors
  49.  
  50. coroutine.resume(coroutine.create(function()
  51.    while true do
  52.       wait(WaitSpeed*RegensToAttack)
  53.       if TestDone <= 1 then
  54.          break
  55.       end
  56.       for i,v in pairs(Armors) do
  57.          Armors[i]["Health"] = Armors[i]["Health"] + (Armors[i]["Regen"])
  58.          print("Regened " .. Armors[i]["Name"] .. " +" .. tostring(Armors[i]["Regen"]) .. " : Health: " .. tostring(Armors[i]["Health"]))
  59.       end
  60.       print("")
  61.    end
  62. end))
  63.  
  64. while true do
  65.    for i,v in pairs(Armors) do
  66.       local OtherNum = (((i == 1) and 2) or 1)
  67.       Armors[i]["Health"] = math.max(Armors[i]["Health"] - Armors[OtherNum]["Damage"], 0)
  68.       print(Armors[i]["Name"] .. " Was Damaged : Health: " .. tostring(Armors[i]["Health"]))
  69.       if Armors[i]["Health"] <= 0 then
  70.          print("/// [" .. tostring(math.floor((tick()-StartTime)*DivideNum)) .. "s] " .. Armors[i]["Name"] .. " Died \\\\\\")
  71.          TestDone = TestDone - 1
  72.          Armors[i]["Died"] = true
  73.       end
  74.       print("")
  75.    end
  76.  
  77.    print("-----------------------------\n")
  78.  
  79.    if TestDone == 1 then
  80.       for i,v in pairs(Armors) do
  81.          if Armors[i]["Died"] == false then
  82.             print("Test Complete : Winner: " .. Armors[i]["Name"])
  83.          end
  84.       end
  85.       break
  86.    elseif TestDone == 0 then
  87.       print("Test Complete : Tie")
  88.       break
  89.    end
  90.  
  91.    wait(WaitSpeed)
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement