[Head] Type=Script Version=2.0 [Settings] Origin=0.000n 0.000w 0.00a 0.0° Run [Script] ################################### # The InGZ Bot # # a Xelagot script # # (c) 1999 Alex Grigny de Castro # ################################### #================================== # In and out of gz detection # Change parameters in Sub Settings # to suit your needs # the bot should be in GZ #================================== var @gz_NW, @gz_SE var %EventType, %EventTypeAv var &Chatter, $Chatline, $Chatname, $BotName, $Say var &Av var @InGZ, %InGZ var %BotName, %Chatline var /t_inGZ, /t_outGZ var $ID var $TextAnnounce, $TextIn, $TextOut, $TextOnDuty Gosub Settings OnWorldEnterEvent WorldEnter # re-enter the bot into the world to clear its avatar list Enter Label Start Goto Start End Sub Settings # GZ coordinates # the coordinates are those of the North-West and South-East corners # altitude and rotation are not used @gz_NW = 2.050n 1.560w 0a 0 @gz_SE = 0.950s 1.460e 0a 0 $TextAnnounce = "Welcome here, {p}" $TextIn = "You are in GZ, {p}" $TextOut = "You are outside GZ, {p}" $TextOnDuty = "{p}, I am on duty, don't disturb me!" WhisperControl 1 OnChatEvent Chat1 OnAvatarAddEvent Add1 OnAvatarChangeEvent Change1 OnAvatarDeleteEvent Delete1 EndSub Event WorldEnter # sets the announce text on entering the world WhisperAnnounce $TextAnnounce EndEvent Sub GuardChat # analises the parameters retrieved in the chat event @InGZ = &Chatter %InGZ = -1 $Say = "" Length %BotName $BotName Length %Chatline $Chatline IntAdd %L %BotName 2 IfString "who is here" IsIn $Chatline Concat $Say "I am here, " $Chatname Else IfString "where am I" IsIn $Chatline Gosub DetermineInGZ Else IfInt %Chatline <= %L Gosub SayOnDuty IfInt %InGZ = 1 Concat $Say $TextIn Else IfInt %InGZ = 0 Concat $Say $TextOut Gosub SayWhisper EndSub Sub DetermineInGZ # actual checking of position of avatar # to see if it is in the GZ square IfLoc @InGZ IsInSquare @gz_NW @gz_SE %InGZ = 1 Else %InGZ = 0 EndSub Sub SayOnDuty Concat $Say $TextOnDuty Gosub SayWhisper EndSub Sub SayWhisper Whisper &Chatter $Say $Say = "" EndSub Event Chat1 # chat event ChatImpair 3 GetEventType %EventType GetChatPerson &Chatter GetChatline $Chatline Trim $Chatline $Chatline GetName $Chatname &Chatter GetName $BotName Pos %u $BotName $Chatline IfInt %u = 1 Gosub GuardChat EndEvent Event Add1 # avatar add event GetEventType %EventTypeAv GetAvatarPerson &Av Gosub CheckGZ EndEvent Event Change1 # avatar change event GetEventType %EventTypeAv GetAvatarPerson &Av Gosub CheckGZ EndEvent Event Delete1 # avatar delete event GetEventType %EventTypeAv GetAvatarPerson &Av @InGZ = &Av %InGZ = -1 Gosub DetermineInGZ GetID $ID &Av GetName $n &Av IfInt %InGZ = 1 TItemSetTimeout /t_InGZ $ID 2 Else IfInt %InGZ = 0 TItemSetTimeout /t_OutGZ $ID 2 EndEvent Sub CheckGZ # check if avatar is in or out of GZ @InGZ = &Av %InGZ = -1 Gosub DetermineInGZ GetID $ID &Av GetName $n &Av IfInt %InGZ = 1 Goto IsInGZ Else Goto IsOutGZ Label IsInGZ TItemGet /t_InGz $ID $i %x &Av IfInt %x = 0 Whisper &Av $TextIn TItemSetTimeout /t_InGZ $ID 3600 TItemRemove /t_OutGZ $ID EndSub Label IsOutGZ TItemGet /t_OutGz $ID $i %x &Av IfInt %x = 0 Whisper &Av $TextOut TItemSetTimeout /t_OutGZ $ID 3600 TItemRemove /t_InGZ $ID EndSub EndSub |