f
s
o

s
c
r
i
p
t
i
n
g

index tutorials scripts links closetpacifist

The battle warp script does the following:

  1. Allows an immortal to give the NPC Krista a Fishle to toggle the system on/off.
  2. Allows a player to type 'battlewarp to be warped to the designated location.


Making It Work

  1. First, add the global variables BattleWarpIsOn, BattleTimer, and EveryTenTicks to the needed files by adding the following line to the top of the Dispatcher.ls, quests.ls, Timers.ls and GlobalScripts.ls files.
    global BattleWarpIsOn, BattleTimer, EveryTenTicks


  2. Then, add the initilization of the variables into the initialize function in Dispatcher.ls, after the line gDispatcher.name = "Dispatcher".
      set BattleWarpIsOn = FALSE
      set BattleTimer = 0
      set EveryTenTicks = 0


  3. Then, in quests.ls, after the set Exchanger = FALSE line, add the following block of code which detects when the Fishle is given to Krista, checks that the player in an IMM, toggles the value of BattleWarpIsOn, and displays an message saying so to the IMM.
      if NPCsName = "Krista" then
        if ItemToGive = "Fishle" then
          set FilName = string(Path) & "SETTINGS" & string(FoldDelim) & "immortals.txt"
          set IMMMs = file(FilName).read
    
          set CheckName = "*" & string(user.name) & "*"
          if IMMMs contains CheckName then set IsIMM = TRUE
    
          set CheckName = "+" & string(user.name) & "+"
          if IMMMs contains CheckName then set IsIMM = TRUE
          
          if IsIMM = TRUE then
            if BattleWarpIsOn = TRUE then 
              set BattleWarpIsOn = FALSE
              set OnOff = "off"
    
              set BattleTimer = 0
              set EveryTenTicks = 0
    
              set TalkDat = "[BATTLE] The battle has ended - thanks for participating!"
    
              movie.sendMessage("@AllUsers", "Broadcast", TalkDat)
    
              grp = movie.serverGroup("@x1000y992")
              if not voidP(grp) then
                -- Loop through all users in each group
                nuser = grp.serverUserCount
                repeat with iu = 1 to nuser
                  user = grp.serverUser(iu)
                  if not voidP(user) then
                      set TheName = string(user.name)
    
                      movie.sendMessage(TheName, "Warp", "!!! !!! x500y500 10 10")
                  end if
                end repeat
              end if
            else
              set BattleWarpIsOn = TRUE
              set OnOff = "on"
    
              set BattleTimer = 1
              set EveryTenTicks = 1
    
              set TalkDat = "[BATTLE] A battle has been started"&\
                " - broadcast 'battlewarp' to be transported."
    
              movie.sendMessage("@AllUsers", "Broadcast", TalkDat)
             end if
            set TalkDat = "Krista says " & QUOTE &\
               "The battlewarp function has been turned " & OnOff & "." & QUOTE
    
            movie.sendMessage(string(user.name), "sqa", TalkDat)
            exit
    
          end if
        end if
      end if
  4. In GlobalScripts.ls, after the line set TheBCast = string(fullmsg.content), add the following code, which checks if the message is the text 'battlewarp', checks that the battlewarp is on, and then warps the player to the designated location, after which it displays a message to the effect to the player.
       if TheBCast = "battlewarp" then
         if BattleWarpIsOn = TRUE then
           movie.sendMessage(TheName, "Warp", "!!! !!! x1000y992 11 11")
           set TalkDat = "You have been battle warped."
    
           movie.sendMessage(TheName, "sqa", TalkDat)
           exit
         end if
       end if
    
  5. In Timers.ls, after the line on TimeOutRun, add the following code, which increments the ticker, anounces the ticks left every 30 ticks, and then teleports everyone out with a message at the end of the battle.
    if BattleTimer > 0 then -- {*}{*}
      if BattleTimer < 101 then -- 100 being the number of ticks for the battle to last
        set BattleTimer = BattleTimer + 1
        set EveryTenTicks = EveryTenTicks + 1
        
        if EveryTenTicks = 10 then 
          set TalkDat = "[BATTLE] " & BattleTimer & " ticks left in the battle!"
    
          myPMovie.sendMessage("@AllUsers", "Broadcast", TalkDat)
          set EveryTenTicks = 0
        end if
      else
        set BattleTimer = 0
        set EveryTenTicks = 0
    
        set TalkDat = "[BATTLE] The battle has ended - thanks for participating!"
    
        myPMovie.sendMessage("@AllUsers", "Broadcast", TalkDat)
        myPMovie.sendMessage("@x1000y992", "Warp", "!!! !!! x500y500 10 10")
         -- warps all players in x1000y992
      end if
    end if