backExamples

Xelagot action script

RandomTeleport Bot

You can download this script: click here.

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0

[Script]
                         ###################################
                         #     The RandomTeleport Bot      #
                         #        a Xelagot script         #
                         # (c) 1999 Alex Grigny de Castro  #
                         ###################################

# Look at the begining of the script for the following data,
# which may be changed to suit your needs:
#   @Centre = 0n 0w 0a 0
#   %Radius = 370
#   $TportName = "name rantport"
# You must mark an object which will serve as random teleport
# by putting in its action field:
# 'create name rantport'
# as specified in the statement
#   $TportName = "name rantport"
# The bot must be near this object.
# When the script is run, the bot scans the area, finds the object,
# and adds a 'bump teleport' to the action field of the object,
# according to what has been specified
# by %Radius and @Centre.
# @Centre can be anywhere, it is the centre of a circumference
# of radius %Radius metres, where the person will be teleported to.
# The bot will sense if someone clicks on the teleport object:
# as soon as that happens and the person
# gets teleported by the object, 
# the bot changes the 'bump teleport' part
# of the action field in the object to a random value
# %Radius metres away from @Centre, for the next victim :)

var $Error
var @QueryPos, %IsQuerying
var $TportName, ~Tport, %Tport
var ~TportNew, $TportDes, $TportAct
var %TportNum, %clicked
var @Centre, %Radius

Label Top

   ################# DATA ##################
   
   @Centre = 0n 0w 0a 0
   %Radius = 370
   $TportName = "name rantport"
   
   #########################################
   
   ClearLists
   %IsQuerying = 0
   %clicked = 0
   %TportNum = 0
   OnWorldReconnectEvent Reconnect
   OnQueryCompleteEvent QueryComplete
   Say Installing random teleport. Scanning...
   Gosub ScanArea
   Label WaitForQuery
   IfInt %IsQuerying = 1 Goto WaitForQuery
   Say Scanning done... Searching for teleport object...
   # calculate tport
   Gosub FindTport
   $Error = "not found"
   IfInt %TportNum <> 0 Gosub ChangeTport
   Else Goto End
   Say Random teleport installed
   OnObjectClickEvent ObjectClick
   Label WaitForClick
      IfInt %clicked = 1 Gosub ChangeTport
   IfInt %TportNum <> 0 Goto WaitForClick
   $Error = ""
Label End
   Concat $a "Aborting script... " $Error
   Say $a
End

Sub ScanArea
   %IsQuerying = 1
   QueryAt @Centre
EndSub

Event Reconnect
   Say Got disconnected...
   IfInt %IsQuerying = 1 Gosub ScanArea
   Else ResetTo Top 
EndEvent

Event QueryComplete
   %IsQuerying = 0
EndEvent

Sub FindTport
   Concat $Error "Teleport object not found in this area. "
   Concat $Error $Error "Please include in Action 'create " $TportName "'"
   FilterClear
   ResClear
   FilterAction $TportName
   ResFromSurveyFilter
   IfGetResObjectItem ~Tport 1 GetObjectNumber %TportNum ~Tport
   Else %TportNum = 0
EndSub

Sub ChangeTport
   # may NOT be called from an event handler
   Gosub ClearConfirmed
   Gosub CalculateTport
   ~TportNew = ~Tport
   GetAction ~TportNew $TportAct
   ObjectModify ~Tport ~TportNew
   ~Tport = ~TportNew
   GetObjectNumber %TportNum ~Tport
   %clicked = 0
EndSub

Sub CalculateTport
   Random %a 0 360
   @t = @Centre
   LocMove3d @t %Radius %a 0
   LocTurn @t @Centre
   GetRotation %t @t
   IntDiv %t %t 10
   IntMul %t %t 10
   GetRotation @t %t
   GetTeleport $t @t
   Concat $TportAct "create " $TportName "; activate teleport " $t
EndSub

Event ObjectClick
   GetTargetObject ~z
   GetObjectNumber %z ~z
   IfInt %z = %TportNum %clicked = 1
   Else %clicked = 0
EndEvent

Sub ClearConfirmed
  ClearListAS
  ClearListAF
  ClearListDS
  ClearListDF
EndSub



backExamples