Advertisement
Katchau01

Encounter.lua

Aug 18th, 2020 (edited)
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 KB | None | 0 0
  1. -- A basic encounter script skeleton you can copy and modify for your own creations.
  2.  
  3. music = "Terraria_Music_Boss_1" --Either OGG or WAV. Extension is added automatically. Uncomment for custom music.
  4. encountertext = "You feel an evil presence\rwatching you..." --Modify as necessary. It will only be read out in the action select screen.
  5. nextwaves = {"bullettest_chaserorb"}
  6. wavetimer = 4.0
  7. arenasize = {155, 130}
  8. autolinebreak = true
  9.  
  10. enemies = {
  11. "Eye of Cthulhu"
  12. }
  13.  
  14. enemypositions = {
  15. {0, 0}
  16. }
  17.  
  18.  
  19. SetGlobal("phase", 1)
  20. SetGlobal("SetSprite", 0)
  21.  
  22. require "Animations/EoC_Phase2_anim"
  23.  
  24. -- A custom list with attacks to choose from. Actual selection happens in EnemyDialogueEnding(). Put here in case you want to use it.
  25. possible_attacks = {"bullettest_chaserorb", "vertical", "bullet_purplewave"}
  26.  
  27. function EncounterStarting()
  28.     -- If you want to change the game state immediately, this is the place.
  29.     Player.lv = 2
  30.     Player.hp = 24
  31.     Player.name = "Marlon"
  32.     Player.atk = 150
  33.     Inventory.AddCustomItems({"Mushroom", "L. Healing P", "B. Honey", "Arkhalis", "Empty Gun"}, {0, 0, 0, 0, 1})
  34.     Inventory.SetInventory({"Mushroom", "Mushroom", "L. Healing P", "L. Healing P", "B. Honey", "B. Honey", "Arkhalis", "Empty Gun"})
  35.     eyeofcthulhu = CreateSprite("Eye_of_Cthulhu")
  36.     eyeofcthulhu.MoveTo(315,350)
  37.     eyeofcthulhu.SetAnimation({"Eye_of_Cthulhu", "Eye_of_Cthulhu2", "Eye_of_Cthulhu3"}, 1/7)
  38. end
  39.  
  40. function Arkhalis()
  41.     Player.atk = Player.atk + 200
  42. end
  43.  
  44. function Update()
  45.     --By calling the AnimateSans() function on the animation Lua file, we can create some movement!
  46.       if GetGlobal("phase") == 1 then
  47.       Animateeyeofcthulhu()
  48.       eyeofcthulhuphase2.alpha = 0
  49.      
  50.       else
  51.       Animateeyeofcthulhuphase2()
  52.       eyeofcthulhu.StopAnimation ()
  53.       eyeofcthulhu.Remove ()
  54.       eyeofcthulhuphase2.SendToTop ()
  55.       eyeofcthulhuphase2.alpha = 1
  56.       end
  57. end
  58.  
  59. function Animateeyeofcthulhu()
  60.     eyeofcthulhu.rotation = 10*math.sin(Time.time + 2)
  61. end
  62.  
  63. function EnemyDialogueStarting()
  64.     -- Good location for setting monster dialogue depending on how the battle is going.
  65. end
  66.  
  67. function EnemyDialogueEnding()
  68.     -- Good location to fill the 'nextwaves' table with the attacks you want to have simultaneously.
  69.     nextwaves = { possible_attacks[math.random(#possible_attacks)] }
  70. end
  71.  
  72. function DefenseEnding() --This built-in function fires after the defense round ends.
  73.    nextwaves = { possible_attacks[math.random(#possible_attacks)] } --This built-in function gets a random encounter text from a random enemy.
  74. end
  75.  
  76. function HandleSpare()
  77. end
  78.  
  79. function HandleItem(ItemID)
  80.     -- (ItemID is in all uppercase, LIKE THIS)
  81.     if ItemID == "MUSHROOM" then
  82.         Player.Heal(5)
  83.         BattleDialog({"You ate a Mushroom.\nIt didn't make you grow\nYou recovered 5 HP."})
  84.     elseif ItemID == "L. HEALING P" then
  85.         Player.Heal(10)
  86.         BattleDialog({"You drank the Potion.\nTastes like mushroom\nYou recovered 10 HP."})
  87.    elseif ItemID == "B. HONEY" then
  88.         Player.Heal(12)
  89.         BattleDialog({"You drank the Bottled Honey.\nThis honey is very sweet.\nYou recovered 12 HP."})
  90.    elseif ItemID == "ARKHALIS" then
  91.         BattleDialog({"You equipped the Arkhalis sword.[func:Arkhalis]", "Your ATTACK has increased!"})
  92.     elseif ItemID == "EMPTY GUN" then
  93.         Inventory.SetAmount(150) -- 12 weapon ATK
  94.         BattleDialog({"You equipped the Empty Gun."})
  95.     end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement