# Event Pack worker. Start through the `event` command from eventManager.ser.
func PrepareDuelLoadout with @loadoutTargets $loadoutWeapon
ClearInventory @loadoutTargets destroy
GiveItem @loadoutTargets $loadoutWeapon
ForceEquip @loadoutTargets $loadoutWeapon
end
if {VarExists $serPackActive} is false
Print "Event Pack rejected a direct run of eventDuel. Use the 'event' command."
stop
end
if {VarExists $serPackName} is false
Print "Event Pack rejected a direct run of eventDuel. Use the 'event' command."
stop
end
if $serPackActive is false or $serPackName isnt "Duel"
Print "Event Pack rejected a direct run of eventDuel. Use the 'event' command."
stop
end
if {VarExists @eventParticipants} is false
Print "Event Pack rejected a direct run of eventDuel. Use the 'event' command."
stop
end
attempt
global $serPackPhase = "Preparing round"
SetRoundLock true
SetLobbyLock false
SetFriendlyFire true
Decontamination disable
Warhead stop
Warhead lock
WaveRespawnTokens chaosWave set 0
WaveRespawnTokens miniChaosWave set 0
WaveRespawnTokens miniMtfWave set 0
WaveRespawnTokens mtfWave set 0
WaveRespawnTime chaosWave set 1h
WaveRespawnTime miniChaosWave set 1h
WaveRespawnTime miniMtfWave set 1h
WaveRespawnTime mtfWave set 1h
CleanupPickups
CleanupRagdolls
StartRound
wait 1s
@eventParticipants = Intersect @eventParticipants @all
if {AmountOf @eventParticipants} < 2
global $serPackPhase = "Cancelled — restarting"
Broadcast @all 5s "DUEL CANCELLED
Fewer than two participants remain connected. The round will restart."
wait 5s
RestartRound
stop
end
SetRole @all Spectator None
wait 500ms
LockDoor Lcz173 AdminCommand
@queue = @eventParticipants
@champion = Take @queue 1
@queue = Except @queue @champion
$duelNumber = 0
Broadcast @all 8s "DUEL
Weapon: {$eventWeapon}
The winner stays in the arena to face the next challenger."
while {AmountOf @queue} > 0
@connectedChampion = Intersect @champion @all
if {AmountOf @connectedChampion} is 0
@champion = Take @queue 1
@queue = Except @queue @champion
continue
end
@challenger = Take @queue 1
@queue = Except @queue @challenger
@connectedChallenger = Intersect @challenger @all
if {AmountOf @connectedChallenger} is 0
continue
end
$duelNumber = $duelNumber + 1
global $serPackPhase = "Duel {$duelNumber}"
@duelists = Join @champion @challenger
SetRole @duelists ClassD None
wait 500ms
SetMaxHealth @duelists 100
SetHealth @duelists 100
SetGodMode @duelists true
GiveEffect @duelists Ensnared 7s
SetCustomInfo @champion "DUEL | DEFENDER"
SetCustomInfo @challenger "DUEL | CHALLENGER"
run PrepareDuelLoadout @duelists $eventWeapon
TPRoom @champion Lcz173 -3 1 0
TPRoom @challenger Lcz173 3 1 0
Broadcast @all 6s "DUEL {$duelNumber}
{@champion -> name} versus {@challenger -> name}"
Countdown @duelists 6s "STARTING IN %seconds%..."
wait 6s
ClearEffect @duelists Ensnared
SetGodMode @duelists false
ClearCountdown @duelists
$duelSeconds = 0
while $duelSeconds < 90
wait 1s
$duelSeconds = $duelSeconds + 1
@connectedDuelists = Intersect @duelists @all
@aliveDuelists = Filter @connectedDuelists isAlive true
@intruders = Except @alivePlayers @aliveDuelists
if {AmountOf @intruders} > 0
SetRole @intruders Spectator None
end
if {AmountOf @aliveDuelists} < 2
break
end
end
@connectedDuelists = Intersect @duelists @all
@aliveDuelists = Filter @connectedDuelists isAlive true
if {AmountOf @aliveDuelists} > 1
Broadcast @all 5s "TIME LIMIT REACHED
The duelist with more HP wins."
$championHealth = @champion -> health
$challengerHealth = @challenger -> health
if $championHealth > $challengerHealth
@duelWinner = @champion
elif $challengerHealth > $championHealth
@duelWinner = @challenger
else
@duelWinner = Take @aliveDuelists 1
Broadcast @all 4s "HP is tied — the duel winner was selected at random."
end
@duelLoser = Except @aliveDuelists @duelWinner
Kill @duelLoser "Duel: lost on time"
wait 1s
@champion = @duelWinner
elif {AmountOf @aliveDuelists} is 1
@champion = @aliveDuelists
elif {AmountOf @connectedDuelists} > 0
@champion = Take @connectedDuelists 1
SetRole @champion ClassD None
wait 500ms
Broadcast @all 4s "Both duelists died — the advancing player was selected at random."
else
@champion = @empty
end
@connectedChampion = Intersect @champion @all
if {AmountOf @connectedChampion} is 1
@connectedEliminated = Except @connectedDuelists @champion
if {AmountOf @connectedEliminated} > 0
SetCustomInfo @connectedEliminated ""
end
SetGodMode @champion true
SetMaxHealth @champion 100
SetHealth @champion 100
SetCustomInfo @champion "DUEL | WAITING"
Broadcast @all 4s "{@champion -> name} wins duel {$duelNumber}."
wait 3s
end
end
global $serPackPhase = "Finishing"
@connectedChampion = Intersect @champion @all
if {AmountOf @connectedChampion} is 1
SetGodMode @champion true
SetCustomInfo @champion "DUEL WINNER"
Broadcast @all 9s "DUEL WINNER
{@champion -> name}"
else
Broadcast @all 8s "DUEL ENDED WITHOUT A WINNER"
end
wait 9s
SetCustomInfo @all ""
RestartRound
on_error with $eventError $eventErrorType
global $serPackPhase = "Failure — restarting"
Print "Event Pack Duel error ({$eventErrorType}): {$eventError}" Red
Broadcast @all 7s "DUEL STOPPED
A technical error occurred. The round will restart safely."
SetCustomInfo @all ""
ClearEffect @all Ensnared
SetGodMode @all false
wait 7s
RestartRound
end