The script has 4 stages:
It needs two areas in the same zone of the world:
To play, team members must wear appropriate avatars, as specified in the file Avatar.txt. There, Red=0,MrTourist means red team members must wear avatar 0, which is called on the avatar list "MrTourist". You must edit this file and put the right avatar number and name for reds and greens.
The Settings.txt has more items:
LaserTag01.zip is for bots using Eminent Domain rights. They may change objects belonging to others (provided these others have build rights).
LaserTag02.zip is for other bots, they must log in with the citizen number of the owner of the objects they must modify.
Field=0.000n 0.000w 0.00a 0.0 GameLength=10 Red=Red Green=Green RedTitle=Reds GreenTitle=Greens NameNWTop=name NWTop NameSEBottom=name SEBottom NameRedBase=name RedBase NameGreenBase=name GreenBase NameRedEnergizer=name RedEnergizer NameGreenEnergizer=name GreenEnergizer NameRedBoard=name RedBoard NameGreenBoard=name GreenBoard NameNoJoin=name NoJoin NameRedJoin=name RedJoin NameGreenJoin=name GreenJoin NameRedNames=name RedNames NameGreenNames=name GreenNames NameLaserNotice=name LaserNotice ScoreHitAv=1 ScoreHitBase=10 ScoreHitOwnAv=-1 ScoreHitOwnBase=0 ScoreHitMiss=0 AvRecoverySec=10 BaseRecoverySec=10 MaxShots=10 JoinRedTeam=Click to join Read Team JoinGreenTeam=Click to join Green Team Withdraw=Click to withdraw BreakLength=3 RegMinimum=5 RegMaximum=10 |
Red=0,MrTourist Green=1,MrsTourist |
... IfLoc &Source IsInVCylinder @a 1.5 1.5 # Else Goto RedEnergizeNot ... IfLoc &Source IsInVCylinder @a 1.5 1.5 # Else Goto GreenEnergizeNot |
[Head]
Type=Script
Version=2.0
[Settings]
Origin=0.000n 0.000w 0.00a 0.0
[Script]
###################################
# The LaserTag Bot #
# a Xelagot script #
# (c) 1999 Alex Grigny de Castro #
# written with the help of #
# Killamo #
###################################
# does not use ED rights to change objects
# general
var %Stage
var /s_Menu, $Chatline, $Value, %Value, $BotName
var /s_MenuAll
var $Error, $Err, %Error
var @Field, @Seat, ~NWTSEB, %IsQuerying
var %GameLength, %GameSec, %WarnSec, %LastMinuteWarn
var /s_Avatar, $AvatarFile
var $Red, $Green, $NoJoin, $RedAv, %RedAv, $GreenAv, %GreenAv
var $JoinRedDes, $JoinGreenDes, $NoJoinDes
#
var $NoJoin, $RedJoin, $GreenJoin, $RedNames, $GreenNames
var $RedMembers, $GreenMembers
var %SourceColor, %TargetColor
var ~RedJoin, ~GreenJoin, ~NoJoin
var $LaserNotice, ~LaserNotice, $LaserNoticeDes
var ~RedBase, ~GreenBase, $RedBase, $GreenBase
var ~RedEnergizer, ~GreenEnergizer, $RedEnergizer, $GreenEnergizer
# boards
var $RedBoard, $GreenBoard
var %ScoreI, %ScoreC
var %ScoreRed, %ScoreGreen, $Score
# for Sub IsInField
var @WhereIs, @NWTop, @SEBottom, $NWTop, $SEBottom
var %IsInField
# TEAMS
var $RedTitle, $GreenTitle
var /s_REDS, /s_GREENS, $FReds, $FGreens
var /s_Settings, $FSettings
var /t_Recovering, /t_BaseHit
# Timeouts
var %RecoveryTime, %BaseHitTime
var %BreakLength, %RegMinimum, %RegMaximum
var %BreakSec, %RegMinSec, %RegMaxSec
# Players
var &Source, &Target, ~Target, $Source, $Target
var %SourceAv, %TargetAv
var %SourceIsInField, %TargetIsInField
var %HitAv, %HitBase, %HitOwnAv, %HitOwnBase, %Miss
var %TeamScore, %ShotsLeft, $Team, %acc, $acc
var %SShotsLeft, %SShots, %SHitAv, %SWasHit, %SHitBase
var %SHitOwnAv, %SHitOwnBase, %SScore, $SScoreCard
var %TShotsLeft, %TShots, %THitAv, %TWasHit, %THitBase
var %THitOwnAv, %THitOwnBase, %TScore, $TScoreCard
Label Start
%Stage = 0
Gosub Initialise
OnWorldReconnectEvent Reconnect
Gosub ScanField
Label Scanning
IfInt %IsQuerying = 1 Goto Scanning
%Error = 0
$Error = ""
Say Searching for notice board...
$LaserNoticeDes = "Initialising..."
Gosub SetLaserNotice
IfString $Error <> "" Goto Error
Say Found notice board
Say Searching for markers...
Gosub FindNWTSEB
IfString $Error <> "" Goto Error
Say Found field markers
Gosub BotPosition
Say Searching for registrars...
Gosub FindJoin
IfString $Error <> "" Goto Error
Say Found registrars
Gosub ClearJoin
Say Searching for bases...
Gosub FindBases
IfString $Error <> "" Goto Error
Say Found bases
Say Searching for energizers...
Gosub FindEnergizers
IfString $Error <> "" Goto Error
Say Found energizers
Say Searching for score boards...
Gosub SetScores
IfString $Error <> "" Goto Error
Say Found score boards
Say Searching for team boards...
Gosub SetNames
IfString $Error <> "" Goto Error
Say Found team boards
Say Ready!
Goto InitBreak2
Label InitRegister
$LaserNoticeDes = "Registering"
Gosub ClearConfirmed
Gosub SetLaserNotice
Gosub InitialiseRegister
GetDateTime !t
!v = !t
Label LoopRegister
GetDifSecond %s !t
IfInt %s > 5 Gosub CheckRegisters
GetDifSecond %s !v
IfInt %s < %RegMinSec Goto LoopRegister
OnObjectClickEvent ObjectClickRegister2
$LaserNoticeDes = "Click to start playing"
Gosub SetLaserNotice
Sbt %a %RegMaximum %RegMinimum
StringFromReal $b %a
Concat $a "Timeout for registering is in " $b " minutes. Click on sign to start playing"
Say $a
Label LoopRegister2
GetDifSecond %s !t
IfInt %s > 5 Gosub CheckRegisters
GetDifSecond %s !v
IfInt %s < %RegMaxSec Goto LoopRegister2
Say Timed out, sorry....
Goto InitBreak2
Label InitPlay
Gosub InitialisePlay
GetDateTime !t
!u = !t
Label LoopPlay
GetDifSecond %s !t
IfInt %s > %WarnSec IfInt %LastMinuteWarn <> 0 GoSub WarnLastMinute
Else Gosub CheckScores
IfInt %s < %GameSec Goto LoopPlay
Else Gosub TerminatePlay
Label InitBreak
Gosub InitialiseBreak
$LaserNoticeDes = "Game over"
Gosub SetLaserNotice
GetDateTime !v
Label LoopBreak
GetDifSecond %s !v
IfInt %s < %BreakSec Goto LoopBreak
OnObjectClickEvent ObjectClickBreak2
$LaserNoticeDes = "Click to start registering"
Gosub SetLaserNotice
Label LoopBreakA
Goto LoopBreakA
Label InitBreak2
Gosub InitialiseBreak
OnObjectClickEvent ObjectClickBreak2
$LaserNoticeDes = "Click to start registering"
Gosub SetLaserNotice
Label LoopBreak2
Goto LoopBreak2
End
Label Error
Say $Error
End
Sub Initialise
$FSettings = "Settings.txt"
$AvatarFile = "Avatar.txt"
$FReds = "Reds.txt"
$FGreens = "Greens.txt"
$NoJoin = "Withdraw"
Gosub LoadSettings
GetName $BotName
%IsQuerying = 0
%ScoreRed = 0
%ScoreGreen = 0
SListLoad /s_REDS $FReds %r
SListNameValueOnly /s_REDS
SListSave /s_REDS $Freds %r
SListLoad /s_GREENS $FGreens %r
SListNameValueOnly /s_GREENS
SListSave /s_GREENS $FGreens %r
Gosub LoadAvatar
Gosub SaveSettings
EndSub
Sub LoadSettings
SListLoad /s_Settings $FSettings %r
# scan position, middle of zone, altitude/rotation irrelevant
IfSlistGetValue /s_Settings "Field" $v @Field = $v
Else @Field = 0n 0w
# length of game in minutes
IfSlistGetValue /s_Settings "GameLength" $v %GameLength = $v
Else %GameLength = 20
Max %GameLength %GameLength 2
# length of break in minutes
IfSlistGetValue /s_Settings "BreakLength" $v %BreakLength = $v
Else %BreakLength = 3
Max %BreakLength %BreakLength 1
# minimum length of registration in minutes
IfSlistGetValue /s_Settings "RegMinimum" $v %RegMinimum = $v
Else %RegMinimum = 1
Max %RegMinimum %RegMinimum 1
# maximum length of registration in minutes
IfSlistGetValue /s_Settings "RegMaximum" $v %RegMaximum = $v
Else %RegMaximum = 2
Add %a %RegMinimum 1
Max %RegMaximum %RegMaximum %a
# change to seconds
Mul %GameSec %GameLength 60
Sbt %WarnSec %GameSec 60
Mul %BreakSec %BreakLength 60
Mul %RegMinSec %RegMinimum 60
Mul %RegMaxSec %RegMaximum 60
IfSlistGetValue /s_Settings "Red" $v $Red = $v
Else $Red = "Red"
IfSlistGetValue /s_Settings "Green" $v $Green = $v
Else $Green = "Green"
IfSlistGetValue /s_Settings "RedTitle" $v $RedTitle = $v
Else $RedTitle = "Reds"
IfSlistGetValue /s_Settings "GreenTitle" $v $GreenTitle = $v
Else $GreenTitle = "Greens"
IfSlistGetValue /s_Settings "NameNWTop" $v $NWTop = $v
Else $NWTop = "name NWTop"
IfSlistGetValue /s_Settings "NameSEBottom" $v $SEBottom = $v
Else $SEBottom = "name SEBottom"
IfSlistGetValue /s_Settings "NameRedBase" $v $RedBase = $v
Else $RedBase = "name RedBase"
IfSlistGetValue /s_Settings "NameGreenBase" $v $GreenBase = $v
Else $GreenBase = "name GreenBase"
IfSlistGetValue /s_Settings "NameRedEnergizer" $v $RedEnergizer = $v
Else $RedEnergizer = "name RedEnergizer"
IfSlistGetValue /s_Settings "NameGreenEnergizer" $v $GreenEnergizer = $v
Else $GreenEnergizer = "name GreenEnergizer"
IfSlistGetValue /s_Settings "NameRedBoard" $v $RedBoard = $v
Else $RedBoard = "name RedBoard"
IfSlistGetValue /s_Settings "NameGreenBoard" $v $GreenBoard = $v
Else $GreenBoard = "name GreenBoard"
IfSlistGetValue /s_Settings "NameNoJoin" $v $NoJoin = $v
Else $NoJoin = "name NoJoin"
IfSlistGetValue /s_Settings "NameRedJoin" $v $RedJoin = $v
Else $RedJoin = "name RedJoin"
IfSlistGetValue /s_Settings "NameGreenJoin" $v $GreenJoin = $v
Else $GreenJoin = "name GreenJoin"
IfSlistGetValue /s_Settings "NameRedNames" $v $RedNames = $v
Else $RedNames = "name RedNames"
IfSlistGetValue /s_Settings "NameGreenNames" $v $GreenNames = $v
Else $GreenNames = "name GreenNames"
IfSlistGetValue /s_Settings "JoinRedTeam" $v $JoinRedDes = $v
Else $JoinRedDes = "Click to join Read Team"
IfSlistGetValue /s_Settings "JoinGreenTeam" $v $JoinGreenDes = $v
Else $JoinGreenDes = "Click to join Green Team"
IfSlistGetValue /s_Settings "Withdraw" $v $NoJoinDes = $v
Else $NoJoinDes = "Click to withdraw"
IfSlistGetValue /s_Settings "NameLaserNotice" $v $LaserNotice = $v
Else $LaserNotice = "name LaserNotice"
IfSlistGetValue /s_Settings "ScoreHitAv" $v %HitAv = $v
Else %HitAv = 1
IfSlistGetValue /s_Settings "ScoreHitBase" $v %HitBase = $v
Else %HitBase = 10
IfSlistGetValue /s_Settings "ScoreHitOwnAv" $v %HitOwnAv = $v
Else %HitOwnAv = -1
IfSlistGetValue /s_Settings "ScoreHitOwnBase" $v %HitOwnBase = $v
Else %HitOwnBase = 0
IfSlistGetValue /s_Settings "ScoreHitMiss" $v %Miss = $v
Else %Miss = 0
IfSlistGetValue /s_Settings "AvRecoverySec" $v %RecoveryTime = $v
Else %RecoveryTime = 10
IfSlistGetValue /s_Settings "BaseRecoverySec" $v %BaseHitTime = $v
Else %BaseHitTime = 30
IfSlistGetValue /s_Settings "MaxShots" $v %ShotsLeft = $v
Else %ShotsLeft = 15
Max %ShotsLeft %ShotsLeft 10
EndSub
Sub SaveSettings
$v = @Field
SlistSetValue /s_Settings "Field" $v
$v = %GameLength
SlistSetValue /s_Settings "GameLength" $v
$v = %RegMinimum
SlistSetValue /s_Settings "RegMinimum" $v
$v = %RegMaximum
SlistSetValue /s_Settings "RegMaximum" $v
$v = %BreakLength
SlistSetValue /s_Settings "BreakLength" $v
SlistSetValue /s_Settings "Red" $Red
SlistSetValue /s_Settings "Green" $Green
SlistSetValue /s_Settings "RedTitle" $RedTitle
SlistSetValue /s_Settings "GreenTitle" $GreenTitle
SlistSetValue /s_Settings "NameNWTop" $NWTop
SlistSetValue /s_Settings "NameSEBottom" $SEBottom
SlistSetValue /s_Settings "NameRedBase" $RedBase
SlistSetValue /s_Settings "NameGreenBase" $GreenBase
SlistSetValue /s_Settings "NameRedEnergizer" $RedEnergizer
SlistSetValue /s_Settings "NameGreenEnergizer" $GreenEnergizer
SlistSetValue /s_Settings "NameRedBoard" $RedBoard
SlistSetValue /s_Settings "NameGreenBoard" $GreenBoard
SlistSetValue /s_Settings "NameNoJoin" $NoJoin
SlistSetValue /s_Settings "NameRedJoin" $RedJoin
SlistSetValue /s_Settings "NameGreenJoin" $GreenJoin
SlistSetValue /s_Settings "NameRedNames" $RedNames
SlistSetValue /s_Settings "NameGreenNames" $GreenNames
SlistSetValue /s_Settings "JoinRedTeam" $JoinRedDes
SlistSetValue /s_Settings "JoinGreenTeam" $JoinGreenDes
SlistSetValue /s_Settings "Withdraw" $NoJoinDes
SlistSetValue /s_Settings "NameLaserNotice" $LaserNotice
$v = %HitAv
SlistSetValue /s_Settings "ScoreHitAv" $v
$v = %HitBase
SlistSetValue /s_Settings "ScoreHitBase" $v
$v = %HitOwnAv
SlistSetValue /s_Settings "ScoreHitOwnAv" $v
$v = %HitOwnBase
SlistSetValue /s_Settings "ScoreHitOwnBase" $v
$v = %Miss
SlistSetValue /s_Settings "ScoreHitMiss" $v
$v = %RecoveryTime
SlistSetValue /s_Settings "AvRecoverySec" $v
$v = %BaseHitTime
SlistSetValue /s_Settings "BaseRecoverySec" $v
$v = %ShotsLeft
SlistSetValue /s_Settings "MaxShots" $v
SListSave /s_Settings $FSettings %r
EndSub
Sub SetGameLength
%GameLength = %Value
Max %GameLength %GameLength 2
# change to seconds
Mul %GameSec %GameLength 60
Sbt %WarnSec %GameSec 60
Gosub SaveSettings
Concat $a "GameLength set to " %GameLength " minutes"
Whisper &Source $a
EndSub
Sub SetMaxShots
%ShotsLeft = %Value
Max %ShotsLeft %ShotsLeft 10
Gosub SaveSettings
Concat $a "MaxShots set to " %ShotsLeft " for new team members and for energizers"
Whisper &Source $a
EndSub
Sub LoadAvatar
SListLoad /s_Avatar $AvatarFile %r
IfInt %r = 0 Goto LoadAvatar1
$RedAv = "First one on list"
%RedAv = 0
$GreenAv = "Second one on list"
%GreenAv = 1
Label LoadAvatar1
SListGetField /s_Avatar "Red" 1 %RedAv
SListGetField /s_Avatar "Red" 2 $RedAv
SListGetField /s_Avatar "Green" 1 %GreenAv
SListGetField /s_Avatar "Green" 2 $GreenAv
IntAdd %r %RedAv 1
Concat $a "Red avatar is # " %r " on the list: " $RedAv
Say $a
IntAdd %r %GreenAv 1
Concat $a "Green avatar is # " %r " on the list: " $GreenAv
Say $a
EndSub
Sub ScanField
ClearLists
Concat $a "Scanning at " @Field ", please wait until I finish..."
Say $a
%IsQuerying = 1
OnQueryCompleteEvent EndScan
QueryAt @Field
EndSub
Event EndScan
%IsQuerying = 2
Say Finished scanning
EndEvent
Event Reconnect
IfInt %IsQuerying > 0 Gosub ScanField
EndEvent
Sub AddError
Concat $Error $Error $Err
Inc %Error
EndSub
Sub FindNWTSEB
# searches for NWTop ans SEBottom markers
Concat $Err "North-West-Top marker not found, please include in Action field: 'create " $NWTop "'. "
FilterClear
ResClear
FilterAction $NWTop
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 @NWTop = ~NWTSEB
Else Gosub AddError
Concat $Err "Sout-East-Bottom marker not found, please include in Action field: 'create " $SEBottom "'. "
FilterClear
ResClear
FilterAction $SEBottom
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 @SEBottom = ~NWTSEB
Else Gosub AddError
EndSub
Sub BotPosition
LocMidPoint @Seat @NWTop @SEBottom
GetAltitude @Seat @NWTop
WarpLocal @Seat
EndSub
Sub FindBases
# searches for bases
Concat $Err $Green " base not found, please include in Action field: 'create " $GreenBase "'. "
FilterClear
ResClear
FilterAction $GreenBase
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~GreenBase = ~NWTSEB
Else Gosub AddError
Concat $Err $Red " base not found, please include in Action field: 'create " $RedBase "'. "
FilterClear
ResClear
FilterAction $RedBase
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~RedBase = ~NWTSEB
Else Gosub AddError
EndSub
Sub FindJoin
# searches for registrars
Concat $Err $Green " registrar not found, please include in Action field: 'create " $GreenJoin "'. "
FilterClear
ResClear
FilterAction $GreenJoin
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~GreenJoin = ~NWTSEB
Else Gosub AddError
Concat $Err $Red " registrar not found, please include in Action field: 'create " $RedJoin "'. "
FilterClear
ResClear
FilterAction $RedJoin
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~RedJoin = ~NWTSEB
Else Gosub AddError
Concat $Err $NoJoin " registrar not found, please include in Action field: 'create " $NoJoin "'. "
FilterClear
ResClear
FilterAction $NoJoin
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~NoJoin = ~NWTSEB
Else Gosub AddError
EndSub
Sub SetJoin
Suspend
FilterClear
ResClear
FilterAction $RedJoin
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetJoin_Red
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetRedJoin
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetJoin_Red
FilterClear
ResClear
FilterAction $GreenJoin
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetJoin_Green
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetGreenJoin
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetJoin_Green
FilterClear
ResClear
FilterAction $NoJoin
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetJoin_No
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetNoJoin
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetJoin_No
Do
EndSub
Sub SetRedJoin
~n = ~NWTSEB
GetDescription ~n $JoinRedDes
ObjectChange ~NWTSEB ~n
EndSub
Sub SetGreenJoin
~n = ~NWTSEB
GetDescription ~n $JoinGreenDes
ObjectChange ~NWTSEB ~n
EndSub
Sub SetNoJoin
~n = ~NWTSEB
GetDescription ~n $NoJoinDes
ObjectChange ~NWTSEB ~n
EndSub
Sub ClearJoin
Suspend
FilterClear
ResClear
FilterAction $RedJoin
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label ClearJoin_Red
IfGetResObjectItem ~NWTSEB %ScoreI Gosub ClearDescription
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto ClearJoin_Red
FilterClear
ResClear
FilterAction $GreenJoin
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label ClearJoin_Green
IfGetResObjectItem ~NWTSEB %ScoreI Gosub ClearDescription
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto ClearJoin_Green
FilterClear
ResClear
FilterAction $NoJoin
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label ClearJoin_No
IfGetResObjectItem ~NWTSEB %ScoreI Gosub ClearDescription
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto ClearJoin_No
Do
EndSub
Sub ClearDescription
~n = ~NWTSEB
GetDescription ~n ""
ObjectChange ~NWTSEB ~n
EndSub
Sub FindEnergizers
# searches for energizers
Concat $Err $Green " energizer not found, please include in Action field: 'create " $GreenEnergizer "'. "
FilterClear
ResClear
FilterAction $GreenEnergizer
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~GreenEnergizer = ~NWTSEB
Else Gosub AddError
Concat $Err $Red " energizer not found, please include in Action field: 'create " $RedEnergizer "'. "
FilterClear
ResClear
FilterAction $RedEnergizer
ResFromSurveyFilter
IfGetResObjectItem ~NWTSEB 1 ~RedEnergizer = ~NWTSEB
Else Gosub AddError
EndSub
Sub SetScores
Suspend
Concat $Err $Red " score board(s) not found, please include in Action field: 'create " $RedBoard "'. "
FilterClear
ResClear
FilterAction $RedBoard
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetScores_Red
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetScoreRed
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetScores_Red
Concat $Err $Green " score board(s) not found, please include in Action field: 'create " $GreenBoard "'. "
FilterClear
ResClear
FilterAction $GreenBoard
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetScores_Green
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetScoreGreen
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetScores_Green
Do
EndSub
Sub SetScoreRed
SListAddField /s_REDS 8 %ScoreRed
Concat $Score %ScoreRed
~n = ~NWTSEB
GetDescription ~n $Score
ObjectChange ~NWTSEB ~n
EndSub
Sub SetScoreGreen
SListAddField /s_GREENS 8 %ScoreGreen
Concat $Score %ScoreGreen
~n = ~NWTSEB
GetDescription ~n $Score
ObjectChange ~NWTSEB ~n
EndSub
#-
Sub SetNames
Suspend
Concat $Err $Red " names board(s) not found, please include in Action field: 'create " $RedNames "'. "
SListGetNames /s_REDS $RedMembers
FilterClear
ResClear
FilterAction $RedNames
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetNames_Red
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetNamesRed
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetNames_Red
Concat $Err $Green " names board(s) not found, please include in Action field: 'create " $GreenNames "'. "
SListGetNames /s_GREENS $GreenMembers
FilterClear
ResClear
FilterAction $GreenNames
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label SetNames_Green
IfGetResObjectItem ~NWTSEB %ScoreI Gosub SetNamesGreen
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto SetNames_Green
Do
EndSub
Sub SetNamesRed
~n = ~NWTSEB
GetDescription ~n $RedMembers
ObjectChange ~NWTSEB ~n
EndSub
Sub SetNamesGreen
~n = ~NWTSEB
GetDescription ~n $GreenMembers
ObjectChange ~NWTSEB ~n
EndSub
Sub SetLaserNotice
Concat $Err "Notice board not found, please include in Action field: 'create " $LaserNotice "'. "
FilterClear
FilterAction $LaserNotice
ResClear
ResFromSurveyFilter
ResCount %c
%d = 1
IfInt %c < 1 Gosub AddError
IfGetResObjectItem ~NWTSEB %d #
Else EndSub
~n = ~NWTSEB
GetDescription ~n $LaserNoticeDes
ObjectChange ~NWTSEB ~n
EndSub
# ======================
# REGISTER TEAMS
# ======================
Sub InitialiseRegister
%Stage = 1
OnChatEvent
OnObjectClickEvent
OnAvatarClickEvent
SlistSetText /s_Menu MenuRegister
SlistSetText /s_MenuAll MenuAllRegister
SListLoad /s_REDS $FReds %r
SListLoad /s_GREENS $FGreens %r
SListClear /s_REDS
SListClear /s_GREENS
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Gosub CheckRegisters
Gosub SetScores
Gosub SetJoin
OnChatEvent ChatRegister
OnObjectClickEvent ObjectClickRegister
$b = %RegMinimum
$c = %RegMaximum
Concat $a "Registering teams... You have from " $b " to " $c " minutes to register, "
Concat $a $a "you may start playing after " $b " minutes"
Say $a
EndSub
Event ChatRegister
%o = 0
GetChatPerson &Source
GetName $Source &Source
GetAvatar %SourceAv &Source
GetChatline $Chatline
Trim $Chatline $Chatline
Split $a $b $Chatline " "
IfString $a = $BotName %o = 1
Else IfChatIsWhisper %o = 2
IfInt %o = 0 EndEvent
Else IfInt %o = 2 $b = $Chatline
SplitFromEnd $d $Value $b " "
Trim $d $d
%Value = $Value
IfPerson &Source IsNotBoss Goto ChatRegisterAll
IfSListGetValue /s_Menu $b $c Do $c
Else IfSListGetValue /s_Menu $d $c Do $c
Else Whisper &Source Unknown command
EndEvent
Label ChatRegisterAll
IfSListGetValue /s_MenuAll $b $c Do $c
Else Whisper &Source Unknown player-command
EndEvent
Event ObjectClickRegister
OnObjectClickEvent
GetSourcePerson &Source
GetAvatar %SourceAv &Source
GetName $Source &Source
IfPerson &Source IsBot Goto OCREnd
GetTargetObject ~j
GetAction $z ~j
IfString $RedJoin IsIn $z Gosub RegisterRed
Else IfString $GreenJoin IsIn $z Gosub RegisterGreen
Else IfString $NoJoin IsIn $z Gosub RegisterOut
Label OCREnd
OnObjectClickEvent ObjectClickRegister
EndEvent
Event ObjectClickRegister2
OnObjectClickEvent
GetSourcePerson &Source
GetAvatar %SourceAv &Source
GetName $Source &Source
IfPerson &Source IsBot Goto OCR2End
GetTargetObject ~j
GetAction $z ~j
IfString $RedJoin IsIn $z Gosub RegisterRed
Else IfString $GreenJoin IsIn $z Gosub RegisterGreen
Else IfString $NoJoin IsIn $z Gosub RegisterOut
Else IfString $LaserNotice IsIn $z Gosub CheckPlayers
Label OCR2End
OnObjectClickEvent ObjectClickRegister2
EndEvent
Sub ClearTeams
SListClear /s_REDS
SListClear /s_GREENS
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Gosub CheckRegisters
Say Teams cleared
EndSub
Sub LoadTeams
SListLoad /s_REDS $FReds %r
SListSave /s_REDS $FReds %r
SListLoad /s_GREENS $FGreens %r
SListSave /s_GREENS $FGreens %r
Gosub CheckRegisters
Say Teams loaded
EndSub
Sub SaveTeams
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Say Teams saved
EndSub
Sub RegisterRed
IfSlistGetValue /s_GREENS $Source $d SListDeleteName /s_GREENS $Source
# youhit, hityou, hitbase, missed
Concat $b %ShotsLeft ",0,0,0,0,0,0,0,0"
SListSetValue /s_REDS $Source $b
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Gosub SetNames
Concat $a $Source ", you are now in " $RedTitle
IfInt %SourceAv = %RedAv Goto RegisterRedWhisper
Concat $a $a ", you must wear avatar " $RedAv
Label RegisterRedWhisper
Gosub GetRedSource
Gosub MakeSScoreCard
Concat $a $a " - " $SScoreCard
Whisper &Source $a
EndSub
Sub RegisterGreen
IfSlistGetValue /s_REDS $Source $d SListDeleteName /s_REDS $Source
# youhit, hityou, hitbase, missed
Concat $b %ShotsLeft ",0,0,0,0,0,0,0,0"
SListSetValue /s_GREENS $Source $b
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Gosub SetNames
Concat $a $Source ", you are now in " $GreenTitle
IfInt %SourceAv = %GreenAv Goto RegisterGreenWhisper
Concat $a $a ", you must wear avatar " $GreenAv
Label RegisterGreenWhisper
Gosub GetGreenSource
Gosub MakeSScoreCard
Concat $a $a " - " $SScoreCard
Whisper &Source $a
EndSub
Sub RegisterOut
IfSlistGetValue /s_REDS $Source $d SListDeleteName /s_REDS $Source
IfSlistGetValue /s_GREENS $Source $d SListDeleteName /s_GREENS $Source
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Gosub SetNames
Concat $a $Source ", you are free to go"
Whisper &Source $a
EndSub
Sub CheckRegisters
Suspend
Concat $Err $Red " team board(s) not found, please include in Action field: 'create " $RedNames "'. "
SListGetNames /s_REDS $RedMembers
FilterClear
ResClear
FilterAction $RedNames
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label CheckRegisters_Red
IfGetResObjectItem ~NWTSEB %ScoreI Gosub CheckNamesRed
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto CheckRegisters_Red
Concat $Err $Green " team board(s) not found, please include in Action field: 'create " $GreenNames "'. "
SListGetNames /s_GREENS $GreenMembers
FilterClear
ResClear
FilterAction $GreenNames
ResFromSurveyFilter
ResCount %ScoreC
%ScoreI = 1
IfInt %ScoreI > %ScoreC Gosub AddError
Label CheckRegisters_Green
IfGetResObjectItem ~NWTSEB %ScoreI Gosub CheckNamesGreen
Inc %ScoreI
IfInt %ScoreI <= %ScoreC Goto CheckRegisters_Green
GetDateTime !t
Do
EndSub
Sub CheckNamesRed
~n = ~NWTSEB
GetDescription $n ~NWTSEB
IfString $RedMembers = $n EndSub
GetDescription ~n $RedMembers
ObjectChange ~NWTSEB ~n
EndSub
Sub CheckNamesGreen
~n = ~NWTSEB
GetDescription $n ~NWTSEB
IfString $GreenMembers = $n EndSub
GetDescription ~n $GreenMembers
ObjectChange ~NWTSEB ~n
EndSub
Sub CheckPlayers
SListGetCount /s_REDS %r
SListGetCount /s_GREENS %g
IfInt %r > 0 IfInt %g > 0 ResetTo InitPlay
Else Say Not enough players to play: each team must have at least one player.
EndSub
Sub Reset
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
Run
EndSub
Text MenuRegister
menu=Whisper &Source Say my name followed by: avatars, scorecard, clear teams, load teams, save teams, Reds, Greens, I withdraw, register, play, reset
avatars=Gosub LoadAvatar
clear teams=Gosub ClearTeams
load teams=Gosub LoadTeams
save teams=Gosub SaveTeams
register me Red=Gosub RegisterRed
put me in Reds=Gosub RegisterRed
and me in Reds=Gosub RegisterRed
me in Reds=Gosub RegisterRed
in Reds=Gosub RegisterRed
Reds=Gosub RegisterRed
register me Green=Gosub RegisterGreen
put me in Greens=Gosub RegisterGreen
and me in Greens=Gosub RegisterGreen
me in Greens=Gosub RegisterGreen
in Greens=Gosub RegisterGreen
Greens=Gosub RegisterGreen
I withdraw=Gosub RegisterOut
play=Gosub CheckPlayers
register=ResetTo InitRegister
scorecard=Gosub WhisperScoreCard
reset=Gosub Reset
EndText
Text MenuAllRegister
menu=Whisper &Source Say my name followed by: avatars, scorecard, Reds, Greens, I withdraw
avatars=Gosub LoadAvatar
put me in Reds=Gosub RegisterRed
and me in Reds=Gosub RegisterRed
me in Reds=Gosub RegisterRed
in Reds=Gosub RegisterRed
Reds=Gosub RegisterRed
put me in Greens=Gosub RegisterGreen
and me in Greens=Gosub RegisterGreen
me in Greens=Gosub RegisterGreen
in Greens=Gosub RegisterGreen
Greens=Gosub RegisterGreen
I withdraw=Gosub RegisterOut
scorecard=Gosub WhisperScoreCard
EndText
# ======================
# PLAY
# ======================
Sub InitialisePlay
%Stage = 2
OnChatEvent
OnObjectClickEvent
OnAvatarClickEvent
Gosub ClearJoin
$LaserNoticeDes = "Playing"
Gosub SetLaserNotice
%LastMinuteWarn = 1
SlistSetText /s_Menu MenuPlay
SlistSetText /s_MenuAll MenuAllPlay
OnChatEvent ChatPlay
OnObjectClickEvent ObjectClickPlay
OnAvatarClickEvent AvatarClickPLay
SListLoad /s_REDS $FReds %r
SListSave /s_REDS $FReds %r
SListLoad /s_GREENS $FGreens %r
SListSave /s_GREENS $FGreens %r
TListClear /t_Recovering
TListClear /t_BaseHit
#Gosub CheckRegisters
Concat $a "This game lasts " %GameLength " minutes. ****** GAME STARTS NOW ******"
Say $a
EndSub
Sub TerminatePlay
OnChatEvent
OnObjectClickEvent
OnAvatarClickEvent
Concat $a "****** GAME OVER ****** You have " %BreakLength " minutes to collect your score cards. "
Concat $a $a "To do so, whisper to me: scorecard"
Say $a
SListSave /s_REDS $FReds %r
SListSave /s_GREENS $FGreens %r
ResetTo InitBreak
EndSub
Event ChatPlay
%o = 0
GetChatPerson &Source
GetName $Source &Source
GetChatline $Chatline
Trim $Chatline $Chatline
Split $a $b $Chatline " "
IfString $a = $BotName %o = 1
Else IfChatIsWhisper %o = 2
IfInt %o = 0 EndEvent
Else IfInt %o = 2 $b = $Chatline
SplitFromEnd $d $Value $b " "
Trim $d $d
%Value = $Value
IfPerson &Source IsNotBoss Goto ChatPlayAll
IfSListGetValue /s_Menu $b $c Do $c
Else IfSListGetValue /s_Menu $d $c Do $c
Else Whisper &Source Unknown command
EndEvent
Label ChatPlayAll
IfSListGetValue /s_MenuAll $b $c Do $c
Else Whisper &Source Unknown player-command
EndEvent
Sub WarnLastMinute
IfInt %LastMinuteWarn = 0 EndSub
Say ****** LAST MINUTE ******
%LastMinuteWarn = 0
Gosub SetScores
EndSub
Sub CheckScores
GetDifSecond %z !u
IfInt %z < 20 EndSub
GetDateTime !u
Gosub SetScores
EndSub
Text MenuPlay
menu=Whisper &Source Say my name followed by: avatars, scorecard, pause, reset
avatars=Gosub LoadAvatar
scorecard=Gosub WhisperScoreCard
pause=Gosub TerminatePlay
reset=Gosub Reset
EndText
Text MenuAllPlay
menu=Whisper &Source Say my name followed by: avatars, scorecard
avatars=Gosub LoadAvatar
scorecard=Gosub WhisperScoreCard
EndText
Event AvatarClickPlay
IfTargetDefined GetSourceTarget &Source &Target
Else EndEvent
IfLoc &Source IsInCube @NWTop @SEBottom
Else EndEvent
IfLoc &Target IsInCube @NWTop @SEBottom %TargetIsInField = 1
Else %TargetIsInField = 0
GetName $Source &Source
GetAvatar %SourceAv &Source
GetName $Target &Target
GetAvatar %TargetAv &Target
IfSlistGetValue /s_REDS $Source $d Gosub AvatarSourceRed
Else IfSlistGetValue /s_GREENS $Source $d Gosub AvatarSourceGreen
EndEvent
Sub IsInField
IfLoc @WhereIs IsInCube @NWTop @SEBottom %IsInField = 1
Else %IsInField = 0
EndSub
# -------
# avatars
# -------
Sub AvatarSourceRed
# check avatar of source
IfInt %SourceAv <> %RedAv Goto AvatarSourceRedWrong
IfSlistGetValue /s_REDS $Target $d Gosub RedShotRed
Else IfSlistGetValue /s_GREENS $Target $d Gosub RedShotGreen
EndSub
Label AvatarSourceRedWrong
Gosub SayWrongAvRed
Gosub RedShotWasted
EndSub
Sub AvatarSourceGreen
# check avatar of source
IfInt %SourceAv <> %GreenAv Goto AvatarSourceGreenWrong
IfSlistGetValue /s_GREENS $Target $d Gosub GreenShotGreen
Else IfSlistGetValue /s_REDS $Target $d Gosub GreenShotRed
EndSub
Label AvatarSourceGreenWrong
Gosub SayWrongAvGreen
Gosub GreenShotWasted
EndSub
Sub SayWrongAvRed
Concat $a "You are not wearing your " $Red " uniform, " $Source
Concat $a $a ", your shots do not count but you may be shot down. "
Concat $a $a "You must wear: " $RedAv
Whisper &Source $a
EndSub
Sub SayWrongAvGreen
Concat $a "You are not wearing your " $Green " uniform, " $Source
Concat $a $a ", your shots do not count but you may be shot down. "
Concat $a $a "You must wear: " $GreenAv
Whisper &Source $a
EndSub
# -------
# objects
# -------
Event ObjectClickPlay
IfTargetDefined GetSourceTarget &Source ~Target
Else EndEvent
IfLoc &Source IsInCube @NWTop @SEBottom
Else EndEvent
IfLoc ~Target IsInCube @NWTop @SEBottom %TargetIsInField = 1
Else %TargetIsInField = 0
GetName $Source &Source
GetAvatar %SourceAv &Source
GetAction $Target ~Target
IfSlistGetValue /s_REDS $Source $d Gosub ObjectSourceRed
Else IfSlistGetValue /s_GREENS $Source $d Gosub ObjectSourceGreen
EndEvent
Sub ObjectSourceRed
# check avatar of source
IfInt %SourceAv <> %RedAv Goto ObjectSourceRedWrong
IfString $RedBase IsIn $Target Gosub RedShotRedBase
Else IfString $GreenBase IsIn $Target Gosub RedShotGreenBase
Else IfString $RedEnergizer IsIn $Target Gosub RedEnergize
Else Gosub RedShotWasted
EndSub
Label ObjectSourceRedWrong
Gosub SayWrongAvRed
Gosub RedShotWasted
EndSub
Sub ObjectSourceGreen
# check avatar of source
IfInt %SourceAv <> %GreenAv Goto ObjectSourceGreenWrong
IfString $RedBase IsIn $Target Gosub GreenShotRedBase
Else IfString $GreenBase IsIn $Target Gosub GreenShotGreenBase
Else IfString $GreenEnergizer IsIn $Target Gosub GreenEnergize
Else Gosub GreenShotWasted
EndSub
Label ObjectSourceGreenWrong
Gosub SayWrongAvGreen
Gosub GreenShotWasted
EndSub
# ======================
# BREAK
# ======================
Sub InitialiseBreak
%Stage = 3
OnChatEvent
OnObjectClickEvent
OnAvatarClickEvent
SlistSetText /s_Menu MenuBreak
SlistSetText /s_MenuAll MenuAllBreak
OnChatEvent ChatBreak
Gosub SetScores
EndSub
Event ChatBreak
%o = 0
GetChatPerson &Source
GetName $Source &Source
GetChatline $Chatline
Trim $Chatline $Chatline
Split $a $b $Chatline " "
IfString $a = $BotName %o = 1
Else IfChatIsWhisper %o = 2
IfInt %o = 0 EndEvent
Else IfInt %o = 2 $b = $Chatline
SplitFromEnd $d $Value $b " "
Trim $d $d
%Value = $Value
IfPerson &Source IsNotBoss Goto ChatBreakAll
IfSListGetValue /s_Menu $b $c Do $c
Else IfSListGetValue /s_Menu $d $c Do $c
Else Whisper &Source Unknown command
EndEvent
Label ChatBreakAll
IfSListGetValue /s_MenuAll $b $c Do $c
Else Whisper &Source Unknown player-command
EndEvent
Event ObjectClickBreak2
OnObjectClickEvent
GetSourcePerson &Source
GetAvatar %SourceAv &Source
GetName $Source &Source
IfPerson &Source IsBot Goto OCB2End
GetTargetObject ~j
GetAction $z ~j
IfString $LaserNotice IsIn $z ResetTo InitRegister
Label OCB2End
OnObjectClickEvent ObjectClickBreak2
EndEvent
Text MenuBreak
menu=Whisper &Source Say my name followed by: avatars, scorecard, register, play, reset, set gamelength <#minutes>, set maxshots <#shots>
avatars=Gosub LoadAvatar
register=ResetTo InitRegister
play=Gosub CheckPlayers
scorecard=Gosub WhisperScoreCard
set gamelength=Gosub SetGameLength
set maxshots=Gosub SetMaxShots
reset=Gosub Reset
EndText
Text MenuAllBreak
menu=Whisper &Source Say my name followed by: :), scorecard
:)=Whisper &Source :)~
scorecard=Gosub WhisperScoreCard
EndText
# ======================
# SCORES
# ======================
Sub GetRedSource
SListGetFields /s_REDS $Source 8 %SShotsLeft %SShots %SHitAv %SWasHit %SHitBase %SHitOwnAv %SHitOwnBase %SScore
EndSub
Sub GetGreenSource
SListGetFields /s_GREENS $Source 8 %SShotsLeft %SShots %SHitAv %SWasHit %SHitBase %SHitOwnAv %SHitOwnBase %SScore
EndSub
Sub SetRedSource
IntMul %x %SHitAv %HitAv
%SScore = %x
IntMul %x %SHitBase %HitBase
IntAdd %SScore %SScore %x
IntMul %x %SHitOwnAv %HitOwnAv
IntAdd %SScore %SScore %x
IntMul %x %SHitOwnBase %HitOwnBase
IntAdd %SScore %SScore %x
SListSetFields /s_REDS $Source 8 %SShotsLeft %SShots %SHitAv %SWasHit %SHitBase %SHitOwnAv %SHitOwnBase %SScore
SListAddField /s_REDS 8 %ScoreRed
EndSub
Sub SetGreenSource
IntMul %x %SHitAv %HitAv
%SScore = %x
IntMul %x %SHitBase %HitBase
IntAdd %SScore %SScore %x
IntMul %x %SHitOwnAv %HitOwnAv
IntAdd %SScore %SScore %x
IntMul %x %SHitOwnBase %HitOwnBase
IntAdd %SScore %SScore %x
SListSetFields /s_GREENS $Source 8 %SShotsLeft %SShots %SHitAv %SWasHit %SHitBase %SHitOwnAv %SHitOwnBase %SScore
SListAddField /s_GREENS 8 %ScoreGreen
EndSub
Sub MakeSScoreCard
%acc = 0
IfInt %SShots = 0 Goto MakeSScoreCard1
Add %acc %SHitAv %SHitBase
Add %acc %acc %SHitOwnAv
Add %acc %acc %SHitOwnBase
Mul %acc %acc 100
Div %acc %acc %SShots
Label MakeSScoreCard1
StringFromReal $acc %acc 1
Concat $SScoreCard $RedTitle ": " %ScoreRed ", " $GreenTitle ": " %ScoreGreen
Concat $SScoreCard $SScoreCard ". Personal score: " %SSCore ", shots " %SShots ", hits " %SHitAv ", base-hits " %SHitBase
Concat $SScoreCard $SScoreCard ", own-team-hits " %SHitOwnAv ", own-base-hits " %SHitOwnBase ", accuracy " $acc "%. Shots left: " %SShotsLeft
EndSub
#--
Sub GetRedTarget
SListGetFields /s_REDS $Target 8 %TShotsLeft %TShots %THitAv %TWasHit %THitBase %THitOwnAv %THitOwnBase %TScore
EndSub
Sub GetGreenTarget
SListGetFields /s_GREENS $Target 8 %TShotsLeft %TShots %THitAv %TWasHit %THitBase %THitOwnAv %THitOwnBase %TScore
EndSub
Sub SetRedTarget
IntMul %x %THitAv %HitAv
%TScore = %x
IntMul %x %THitBase %HitBase
IntAdd %TScore %TScore %x
IntMul %x %THitOwnAv %HitOwnAv
IntAdd %TScore %TScore %x
IntMul %x %THitOwnBase %HitOwnBase
IntAdd %TScore %TScore %x
SListSetFields /s_REDS $Target 8 %TShotsLeft %TShots %THitAv %TWasHit %THitBase %THitOwnAv %THitOwnBase %TScore
SListAddField /s_REDS 8 %ScoreRed
EndSub
Sub SetGreenTarget
IntMul %x %THitAv %HitAv
%TScore = %x
IntMul %x %THitBase %HitBase
IntAdd %TScore %TScore %x
IntMul %x %THitOwnAv %HitOwnAv
IntAdd %TScore %TScore %x
IntMul %x %THitOwnBase %HitOwnBase
IntAdd %TScore %TScore %x
SListSetFields /s_GREENS $Target 8 %TShotsLeft %TShots %THitAv %TWasHit %THitBase %THitOwnAv %THitOwnBase %TScore
SListAddField /s_GREENS 8 %ScoreGreen
EndSub
Sub MakeTScoreCard
%acc = 0
IfInt %TShots = 0 Goto MakeTScoreCard1
Add %acc %THitAv %THitBase
Add %acc %acc %THitOwnAv
Add %acc %acc %THitOwnBase
Mul %acc %acc 100
Div %acc %acc %TShots
Label MakeTScoreCard1
StringFromReal $acc %acc 1
Concat $TScoreCard $RedTitle ": " %ScoreRed ", " $GreenTitle ": " %ScoreGreen
Concat $TScoreCard $TScoreCard ". Personal score: " %TScore ", shots " %TShots ", hits " %THitAv ", base-hits " %THitBase
Concat $TScoreCard $TScoreCard ", own-team-hits " %THitOwnAv ", own-base-hits " %THitOwnBase ", accuracy " $acc "%. Shots left: " %TShotsLeft
EndSub
#--
Sub FindScoreCard
$SScoreCard = ""
IfSlistGetValue /s_REDS $Source $d Goto FindScoreCardRed
Else IfSlistGetValue /s_GREENS $Source $d Goto FindScoreCardGreen
Else Goto FindScoreCardNone
EndSub
Label FindScoreCardRed
Concat $Team "You are in " $RedTitle " - "
Gosub GetRedSource
Gosub MakeSScoreCard
Concat $Team $Team $SScoreCard
EndSub
Label FindScoreCardGreen
Concat $Team "You are in " $GreenTitle " - "
Gosub GetGreenSource
Gosub MakeSScoreCard
Concat $Team $Team $SScoreCard
EndSub
Label FindScoreCardNone
Concat $Team "You are not registered - "
SListAddField /s_REDS 8 %ScoreRed
SListAddField /s_GREENS 8 %ScoreGreen
Concat $Team $RedTitle " " %ScoreRed ", " $GreenTitle " " %ScoreGreen
EndSub
Sub WhisperScoreCard
Gosub FindScoreCard
Whisper &Source $Team
EndSub
#--
Sub RedShotGreen
# first check if allowed to shoot
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto RedShotGreenNot
TItemGetTimeout /t_Recovering $Target %t
IfInt %t <> 0 Goto RedShotGreenNot
Gosub GetRedSource
IfInt %SShotsLeft < 1 Goto RedShotGreenNoShots
inc %SShots
dec %SShotsLeft
inc %SHitAv
Gosub SetRedSource
Gosub MakeSScoreCard
Concat $a $Source ", you hit " $Green " " $Target " for " %HitAv " - " $SScoreCard
Whisper &Source $a
TItemSetTimeOut /t_Recovering $Target %RecoveryTime
Gosub GetGreenTarget
Inc %TWasHit
Gosub SetGreenTarget
Concat $a $Target ", you were hit by " $Red " " $Source ", " %RecoveryTime " seconds recovery. Total times hit: " %TWasHit
Whisper &Target $a
EndSub
Label RedShotGreenNot
Gosub RedShotWasted
EndSub
Label RedShotGreenNoShots
Gosub RedShotNoShots
EndSub
Sub RedShotRed
# first check if allowed to shoot
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto RedShotRedNot
TItemGetTimeout /t_Recovering $Target %t
IfInt %t <> 0 Goto RedShotRedNot
Gosub GetRedSource
IfInt %SShotsLeft < 1 Goto RedShotRedNoShots
inc %SShots
dec %SShotsLeft
inc %SHitOwnAv
Gosub SetRedSource
Gosub MakeSScoreCard
Concat $a $Source ", you hit your own warrior " $Target " for " %HitOwnAv " - " $SScoreCard
Whisper &Source $a
TItemSetTimeOut /t_Recovering $Target %RecoveryTime
Gosub GetRedTarget
Inc %TWasHit
Gosub SetRedTarget
Concat $a $Target ", you were hit by team-mate " $Source ", " %RecoveryTime " seconds recovery. Total times hit: " %TWasHit
Whisper &Target $a
EndSub
Label RedShotRedNot
Gosub RedShotWasted
EndSub
Label RedShotRedNoShots
Gosub RedShotNoShots
EndSub
Sub RedShotGreenBase
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto RedShotGreenBaseNot
TItemGetTimeout /t_BaseHit $GreenTitle %t
IfInt %t <> 0 Goto RedShotGreenBaseNot
Gosub GetRedSource
IfInt %SShotsLeft < 1 Goto RedShotGreenBaseNoShots
inc %SShots
dec %SShotsLeft
inc %SHitBase
Gosub SetRedSource
Gosub MakeSScoreCard
TItemSetTimeOut /t_BaseHit $GreenTitle %BaseHitTime
Concat $a $Red " " $Source " hit the " $Green " base! " $Green " base is disabled for " %BaseHitTime " seconds"
Say $a
Concat $a $Source ", you hit the " $Green " base for " %HitBase " - " $SScoreCard
Whisper &Source $a
EndSub
Label RedShotGreenBaseNot
Gosub RedShotWasted
EndSub
Label RedShotGreenBaseNoShots
Gosub RedShotNoShots
EndSub
Sub RedShotRedBase
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto RedShotRedBaseNot
TItemGetTimeout /t_BaseHit $RedTitle %t
IfInt %t <> 0 Goto RedShotRedBaseNot
IfInt %HitOwnBase = 0 Goto RedShotRedBaseNot
Gosub GetRedSource
IfInt %SShotsLeft < 1 Goto RedShotRedBaseNoShots
inc %SShots
dec %SShotsLeft
inc %SHitOwnBase
Gosub SetRedSource
Gosub MakeSScoreCard
TItemSetTimeOut /t_BaseHit $RedTitle %BaseHitTime
Concat $a $Red " " $Source " hit the home base! " $Red " base is disabled for " %BaseHitTime " seconds"
Say $a
Concat $a $Source ", you hit your home base for " %HitOwnBase " - " $SScoreCard
Whisper &Source $a
EndSub
Label RedShotRedBaseNot
Gosub RedShotWasted
EndSub
Label RedShotRedBaseNoShots
Gosub RedShotNoShots
EndSub
Sub RedShotWasted
Gosub GetRedSource
IfInt %SShotsLeft < 1 Goto RedShotWastedNoShots
inc %SShots
dec %SShotsLeft
Gosub SetRedSource
#Gosub MakeSScoreCard
Concat $a "Wasted shot - Shots left: " %SShotsLeft
Whisper &Source $a
EndSub
Label RedShotWastedNoShots
Gosub RedShotNoShots
EndSub
Sub RedShotNoShots
Gosub MakeSScoreCard
Concat $a $Source ", you have no shots left, re-energize!"
Whisper &Source $a
EndSub
Sub GreenShotRed
# first check if allowed to shoot
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto GreenShotRedNot
TItemGetTimeout /t_Recovering $Target %t
IfInt %t <> 0 Goto GreenShotRedNot
Gosub GetGreenSource
IfInt %SShotsLeft < 1 Goto GreenShotRedNoShots
inc %SShots
dec %SShotsLeft
inc %SHitAv
Gosub SetGreenSource
Gosub MakeSScoreCard
Concat $a $Source ", you hit " $Red " " $Target " for " %HitAv " - " $SScoreCard
Whisper &Source $a
TItemSetTimeOut /t_Recovering $Target %RecoveryTime
Gosub GetRedTarget
Inc %TWasHit
Gosub SetRedTarget
Concat $a $Target ", you were hit by " $Green " " $Source ", " %RecoveryTime " seconds recovery. Total times hit: " %TWasHit
Whisper &Target $a
EndSub
Label GreenShotRedNot
Gosub GreenShotWasted
EndSub
Label GreenShotRedNoShots
Gosub GreenShotNoShots
EndSub
Sub GreenShotGreen
# first check if allowed to shoot
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto GreenShotGreenNot
TItemGetTimeout /t_Recovering $Target %t
IfInt %t <> 0 Goto GreenShotGreenNot
Gosub GetGreenSource
IfInt %SShotsLeft < 1 Goto GreenShotGreenNoShots
inc %SShots
dec %SShotsLeft
inc %SHitOwnAv
Gosub SetGreenSource
Gosub MakeSScoreCard
Concat $a $Source ", you hit your own warrior " $Target " for " %HitOwnAv " - " $SScoreCard
Whisper &Source $a
TItemSetTimeOut /t_Recovering $Target %RecoveryTime
Gosub GetGreenTarget
Inc %TWasHit
Gosub SetGreenTarget
Concat $a $Target ", you were hit by team-mate " $Source ", " %RecoveryTime " seconds recovery. Total times hit: " %TWasHit
Whisper &Target $a
EndSub
Label GreenShotGreenNot
Gosub GreenShotWasted
EndSub
Label GreenShotGreenNoShots
Gosub GreenShotNoShots
EndSub
Sub GreenShotRedBase
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto GreenShotRedBaseNot
TItemGetTimeout /t_BaseHit $RedTitle %t
IfInt %t <> 0 Goto GreenShotRedBaseNot
Gosub GetGreenSource
IfInt %SShotsLeft < 1 Goto GreenShotRedBaseNoShots
inc %SShots
dec %SShotsLeft
inc %SHitBase
Gosub SetGreenSource
Gosub MakeSScoreCard
TItemSetTimeOut /t_BaseHit $RedTitle %BaseHitTime
Concat $a $Green " " $Source " hit the " $Red " base! " $Red " base is disabled for " %BaseHitTime " seconds"
Say $a
Concat $a $Source ", you hit the " $Red " base for " %HitBase " - " $SScoreCard
Whisper &Source $a
EndSub
Label GreenShotRedBaseNot
Gosub GreenShotWasted
EndSub
Label GreenShotRedBaseNoShots
Gosub GreenShotNoShots
EndSub
Sub GreenShotGreenBase
TItemGetTimeout /t_Recovering $Source %t
IfInt %t <> 0 Goto GreenShotGreenBaseNot
TItemGetTimeout /t_BaseHit $GreenTitle %t
IfInt %t <> 0 Goto GreenShotGreenBaseNot
IfInt %HitOwnBase = 0 Goto GreenShotGreenBaseNot
Gosub GetGreenSource
IfInt %SShotsLeft < 1 Goto GreenShotGreenBaseNoShots
inc %SShots
dec %SShotsLeft
inc %SHitOwnBase
Gosub SetGreenSource
Gosub MakeSScoreCard
TItemSetTimeOut /t_BaseHit $GreenTitle %BaseHitTime
Concat $a $Green " " $Source " hit the home base! " $Green " base is disabled for " %BaseHitTime " seconds"
Say $a
Concat $a $Source ", you hit your home base for " %HitOwnBase " - " $SScoreCard
Whisper &Source $a
EndSub
Label GreenShotGreenBaseNot
Gosub GreenShotWasted
EndSub
Label GreenShotGreenBaseNoShots
Gosub GreenShotNoShots
EndSub
Sub GreenShotWasted
Gosub GetGreenSource
IfInt %SShotsLeft < 1 Goto GreenShotWastedNoShots
inc %SShots
dec %SShotsLeft
Gosub SetGreenSource
#Gosub MakeSScoreCard
Concat $a "Wasted shot - Shots left: " %SShotsLeft
Whisper &Source $a
EndSub
Label GreenShotWastedNoShots
Gosub GreenShotNoShots
EndSub
Sub GreenShotNoShots
Gosub MakeSScoreCard
Concat $a $Source ", you have no shots left, re-energize!"
Whisper &Source $a
EndSub
#====================
# Energizers
#====================
Sub RedEnergize
# &Source ~Target
Gosub GetRedSource
@a = ~Target
LocMove3d @a 0.10 0 -90
IfLoc &Source IsInVCylinder @a 1.5 1.5 #
Else Goto RedEnergizeNot
IfInt %SShotsLeft < %ShotsLeft %SShotsLeft = %ShotsLeft
Else Goto RedEnergizeTooMuch
Gosub SetRedSource
Concat $a "Energized... - Shots left: " %SShotsLeft
Whisper &Source $a
EndSub
Label RedEnergizeTooMuch
Concat $a "No need to energize... - Shots left: " %SShotsLeft ", maximum refill: " %ShotsLeft
Whisper &Source $a
EndSub
Label RedEnergizeNot
Concat $a "Out of range to energize..."
IfInt %SShotsLeft >= %ShotsLeft Concat $a $a " and no need to energize... - Shots left: " %SShotsLeft ", maximum refill: " %ShotsLeft
Else Concat $a $a " - Shots left: " %SShotsLeft ", maximum refill: " %ShotsLeft
Whisper &Source $a
EndSub
Sub GreenEnergize
# &Source ~Target
Gosub GetGreenSource
@a = ~Target
LocMove3d @a 0.10 0 -90
IfLoc &Source IsInVCylinder @a 1.5 1.5 #
Else Goto GreenEnergizeNot
IfInt %SShotsLeft < %ShotsLeft %SShotsLeft = %ShotsLeft
Else Goto GreenEnergizeTooMuch
Gosub SetGreenSource
Concat $a "Energized... - Shots left: " %SShotsLeft
Whisper &Source $a
EndSub
Label GreenEnergizeTooMuch
Concat $a "No need to energize... - Shots left: " %SShotsLeft ", maximum refill: " %ShotsLeft
Whisper &Source $a
EndSub
Label GreenEnergizeNot
Concat $a "Out of range to energize..."
IfInt %SShotsLeft >= %ShotsLeft Concat $a $a " and no need to energize... - Shots left: " %SShotsLeft ", maximum refill: " %ShotsLeft
Else Concat $a $a " - Shots left: " %SShotsLeft ", maximum refill: " %ShotsLeft
Whisper &Source $a
EndSub
Sub ClearConfirmed
ClearListAS
ClearListAF
ClearListDS
ClearListDF
EndSub
|