Facebook
From Scribby Hog, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 211
  1. -- A basic encounter script skeleton you can copy and modify for your own creations.
  2. difficulty = 2
  3. DET = 0
  4. music = "Justice" --Always OGG. Extension is added automatically. Remove the first two lines for custom music.
  5. encountertext = "There You Are =)"
  6. nextwaves = {"nowave"}
  7. wavetimer = 6.0
  8. arenasize = {205, 200}
  9.  
  10. enemies = {
  11. "poseur"
  12. }
  13.  
  14. enemypositions = {
  15. {0, 0}
  16. }
  17.  
  18.  
  19.  
  20. introtimer = 0
  21. introphase = 0
  22.  
  23. function Update()
  24.         if introtimer ~= nil and introtimer < 901 then
  25.                 introtimer = introtimer + 1
  26.         end
  27.         if introtimer ~= nil and introtimer < 360 and introphase == 0 then
  28.                 dog.sprite.rotation = dog.sprite.rotation + 1
  29.         elseif introtimer ~= nil and introtimer == 360 and introphase == 0 then
  30.                 introphase = 1
  31.                 dog.sprite.rotation = 0
  32.                 error.sprite.Set("crack_1")
  33.                 dog.sprite.Set("dogscared")
  34.                 Audio.PlaySound("break_1")
  35.         elseif introphase == 1 and introtimer < 440 then
  36.                 error.sprite.MoveTo(320 - (((80 - (introtimer - 360)) / 7)*math.sin(introtimer)),240 + (((80 - (introtimer - 360)) / 5)*math.sin(introtimer)))
  37.                 dog.sprite.MoveTo(580 + (((80 - (introtimer - 360)) / 2)*math.sin(introtimer)),60 - (((80 - (introtimer - 360)) / 1)*math.sin(introtimer)))
  38.         elseif introphase == 1 and introtimer == 480 then
  39.                 introphase = 2
  40.                 Audio.PlaySound("break_2")
  41.                 error.sprite.Set("crack_2")
  42.         elseif introphase == 2 and introtimer < 570 then
  43.                 error.sprite.MoveTo(320 - (((80 - (introtimer - 480)) / 14)*math.sin(introtimer)),240 + (((80 - (introtimer - 480)) / 7)*math.sin(introtimer)))
  44.                 dog.sprite.MoveTo(580 + (((80 - (introtimer - 480)) / 4)*math.sin(introtimer)),60 - (((80 - (introtimer - 480)) / 2.5)*math.sin(introtimer)))
  45.         elseif introphase == 2 and introtimer == 600 then
  46.                 introphase = 3
  47.                 Audio.PlaySound("break_3")
  48.                 error.sprite.Set("crack_3")
  49.         elseif introphase == 3 and introtimer < 680 then
  50.                 error.sprite.MoveTo(320 - (((80 - (introtimer - 600)) / 20)*math.sin(introtimer)),240 + (((80 - (introtimer - 600)) / 10)*math.sin(introtimer)))
  51.                 dog.sprite.MoveTo(580 + (((80 - (introtimer - 600)) / 5)*math.sin(introtimer)),60 - (((80 - (introtimer - 600)) / 3)*math.sin(introtimer)))
  52.         elseif introphase == 3 and introtimer == 740 then
  53.                 introphase = 4
  54.                 Audio.PlaySound("explode")
  55.         elseif introphase == 4 and introtimer == 750 then
  56.                 error.Remove()
  57.                 dog.sprite.Set("dogfall")
  58.                 dog.SetVar("velx",0)
  59.                 dog.SetVar("vely",1)
  60.                 SetGlobal("bit1",CreateProjectileAbs("bit_1",138.5,249))
  61.                 GetGlobal("bit1").SetVar("velx",0)
  62.                 GetGlobal("bit1").SetVar("vely",0)
  63.                 SetGlobal("bit2",CreateProjectileAbs("bit_2",200,400))
  64.                 GetGlobal("bit2").SetVar("velx",0)
  65.                 GetGlobal("bit2").SetVar("vely",1)
  66.                 SetGlobal("bit3",CreateProjectileAbs("bit_3",479,389.5))
  67.                 GetGlobal("bit3").SetVar("velx",1)
  68.                 GetGlobal("bit3").SetVar("vely",2)
  69.                 SetGlobal("bit4",CreateProjectileAbs("bit_4",515,196))
  70.                 GetGlobal("bit4").SetVar("velx",2)
  71.                 GetGlobal("bit4").SetVar("vely",3)
  72.                 SetGlobal("bit5",CreateProjectileAbs("bit_5",485,112))
  73.                 GetGlobal("bit5").SetVar("velx",1)
  74.                 GetGlobal("bit5").SetVar("vely",2)
  75.                 SetGlobal("bit6",CreateProjectileAbs("bit_6",144,126))
  76.                 GetGlobal("bit6").SetVar("velx",-1)
  77.                 GetGlobal("bit6").SetVar("vely",1)
  78.                 dog.SendToTop()
  79.         elseif introphase == 4 and introtimer ~= nil and introtimer >= 750 and introtimer < 900 then
  80.                 if dog ~= nil and GetGlobal("bit1") ~= nil and GetGlobal("bit2") ~= nil and GetGlobal("bit3") ~= nil and GetGlobal("bit4") ~= nil then
  81.                         if GetGlobal("bit5") ~= nil and GetGlobal("bit6") ~= nil then
  82.                                 dog.SetVar("velx",dog.GetVar("velx") + 0.04)
  83.                                 dog.SetVar("vely",dog.GetVar("vely") - 0.12)
  84.                                 dog.Move(dog.GetVar("velx"),dog.GetVar("vely"))
  85.                                 if introtimer%2 == 0 then
  86.                                         dog.sprite.rotation = dog.sprite.rotation - 1
  87.                                 end
  88.                                 GetGlobal("bit1").SetVar("velx",GetGlobal("bit1").GetVar("velx") - 0.04)
  89.                                 GetGlobal("bit1").SetVar("vely",GetGlobal("bit1").GetVar("vely") - 0.12)
  90.                                 GetGlobal("bit1").Move(GetGlobal("bit1").GetVar("velx"),GetGlobal("bit1").GetVar("vely"))
  91.                                 if introtimer%2 == 0 then
  92.                                         GetGlobal("bit1").sprite.rotation = GetGlobal("bit1").sprite.rotation + 1
  93.                                 end
  94.                                 GetGlobal("bit2").SetVar("velx",GetGlobal("bit2").GetVar("velx") + 0.02)
  95.                                 GetGlobal("bit2").SetVar("vely",GetGlobal("bit2").GetVar("vely") - 0.12)
  96.                                 GetGlobal("bit2").Move(GetGlobal("bit2").GetVar("velx"),GetGlobal("bit2").GetVar("vely"))
  97.                                 if introtimer%3 == 0 then
  98.                                         GetGlobal("bit2").sprite.rotation = GetGlobal("bit2").sprite.rotation + 1
  99.                                 end
  100.                                 GetGlobal("bit3").SetVar("velx",GetGlobal("bit3").GetVar("velx") + 0.02)
  101.                                 GetGlobal("bit3").SetVar("vely",GetGlobal("bit3").GetVar("vely") - 0.12)
  102.                                 GetGlobal("bit3").Move(GetGlobal("bit3").GetVar("velx"),GetGlobal("bit3").GetVar("vely"))
  103.                                 if introtimer%2 == 0 then
  104.                                         GetGlobal("bit3").sprite.rotation = GetGlobal("bit3").sprite.rotation - 1
  105.                                 end
  106.                                 GetGlobal("bit4").SetVar("velx",GetGlobal("bit4").GetVar("velx") - 0.04)
  107.                                 GetGlobal("bit4").SetVar("vely",GetGlobal("bit4").GetVar("vely") - 0.12)
  108.                                 GetGlobal("bit4").Move(GetGlobal("bit4").GetVar("velx"),GetGlobal("bit3").GetVar("vely"))
  109.                                 if introtimer%1 == 0 then
  110.                                         GetGlobal("bit4").sprite.rotation = GetGlobal("bit4").sprite.rotation - 1
  111.                                 end
  112.                                 GetGlobal("bit5").SetVar("velx",GetGlobal("bit5").GetVar("velx") - 0.04)
  113.                                 GetGlobal("bit5").SetVar("vely",GetGlobal("bit5").GetVar("vely") - 0.12)
  114.                                 GetGlobal("bit5").Move(GetGlobal("bit5").GetVar("velx"),GetGlobal("bit5").GetVar("vely"))
  115.                                 if introtimer%3 == 0 then
  116.                                         GetGlobal("bit5").sprite.rotation = GetGlobal("bit5").sprite.rotation + 1
  117.                                 end
  118.                                 GetGlobal("bit6").SetVar("velx",GetGlobal("bit6").GetVar("velx") - 0.04)
  119.                                 GetGlobal("bit6").SetVar("vely",GetGlobal("bit6").GetVar("vely") - 0.12)
  120.                                 GetGlobal("bit6").Move(GetGlobal("bit5").GetVar("velx"),GetGlobal("bit6").GetVar("vely"))
  121.                                 if introtimer%2 == 0 then
  122.                                         GetGlobal("bit6").sprite.rotation = GetGlobal("bit6").sprite.rotation + 1
  123.                                 end
  124.                         end
  125.                 end
  126.         elseif introtimer == 901 then
  127.                 introtimer = 902
  128.         end
  129.         if introtimer ~= nil and introtimer%5 == 0 then
  130.                         State("DIALOGRESULT")
  131.         end
  132.         if introtimer == 902 then
  133.                 dog.Remove()
  134.                 GetGlobal("bit1").Remove()
  135.                 GetGlobal("bit2").Remove()
  136.                 GetGlobal("bit3").Remove()
  137.                 GetGlobal("bit4").Remove()
  138.                 GetGlobal("bit5").Remove()
  139.                 GetGlobal("bit6").Remove()
  140.                
  141.                 introtimer = nil
  142.                 --BattleDialog({"[starcolor:000000][noskip][next]"})
  143.                
  144.                 State("ENEMYDIALOGUE")
  145.         end
  146. end
  147.  
  148. function OnHit(bullet)
  149. Audio.Play()
  150. end
  151.  
  152. function EncounterStarting()
  153.        
  154.         Player.name = "MC"
  155.         Player.lv = 20
  156.         Player.hp = 99
  157.         Audio.Stop()
  158.         error = CreateProjectileAbs("fake_error",320,240)
  159.         dog = CreateProjectileAbs("dog",580,60)
  160.        
  161.  Inventory.AddCustomItems({"Starfait"}, {0})
  162.     Inventory.SetInventory({"Starfait"})
  163.    
  164. end
  165.  
  166.  
  167. SetGlobal("intro",true)
  168.  
  169. function EnemyDialogueStarting()
  170.  
  171.     local intro = GetGlobal("intro") --updates the variable "intro" everytime the EnemyDialogueStarting() function is triggered
  172.     if intro == true then
  173.       enemies[1].SetVar('currentdialogue', {"[effect:none]*Monika smiles \nsweetly to you*", "Heya...","[effect:none]You've been \npretty busy \nwith those girls, \nhuh?","[effect:none]Can't believe \nabout you didn't \neven spare  \nyour childchood \nfriend,Sayori.","What kind of \nmonster are \nyou MC?","[effect:none]You killed all \nof them with \ncold blood.","[effect:none]And now you \nare sitting and \nplaying this \ngame to see \nmy death \ntoo?", "[effect:none]That's Pretty  \nsick if you ask \nme.","...","[effect:none]Anyways...","[noskip][effect:none]Here's the tip \nof the day.","[effect:none]Don't forget to \nsave your game!" ,"[noskip][effect:none][novoice][waitall:5]This could get... \nReally... \n[color:ff0000]frustrating [w:10][next]"})
  174.       SetGlobal("intro", false) -- sets the variable "intro" to false so that this line of dialogue only plays once
  175.     end
  176. end
  177.  
  178. function EnemyDialogueEnding()
  179.  
  180.     -- Good location to fill the 'nextwaves' table with the attacks you want to have simultaneously.
  181.     -- This example line below takes a random attack from 'possible_attacks'.
  182.    
  183. end
  184.  
  185. function DefenseEnding() --This built-in function fires after the defense round ends.
  186.  
  187.    encountertext = RandomEncounterText()
  188.         if (GetGlobal("rage") > 0 and ShowedDialog == false) then
  189.                 ShowedDialog = true
  190.                 encountertext = "Looks like Monika let his\rdefense down."
  191.         end    
  192.        
  193.        
  194. end
  195.  
  196. function HandleSpare()
  197.            State("ENEMYDIALOGUE")
  198.     if GetGlobal("rage") > 0 then
  199.                 BattleDialog({"Trump won't let you go until\ryou've payed for your sins."})
  200.         elseif GetGlobal("spareable") == 1 then
  201.                 BattleDialog({"This is where you'd spare him.\nGood job."})
  202.         else
  203.                 BattleDialog({"[color:ff0000]Finish Your Job."})
  204.         if GetGlobal("rage") > 3 then  
  205.             nextwaves = {"dunkedon"}
  206.             BattleDialog({"Im glad you did it."})
  207. end
  208.  
  209.  
  210. function HandleItem(ItemID)
  211.         if ItemID == "STARFAIT" then
  212.         Player.Heal(14)
  213.         BattleDialog({"You eat the Starfait. \nYou recovered 14 HP!"})
  214.         end
  215. end
  216. end
  217. end