struct BountySys extends array
private static constant integer LEVEL_MULTIPLIER = 5
private static constant integer HERO_LEVEL_MULTIPLIER = 10
private static leaderboard b = null
private static method r takes nothing returns nothing
local player p = GetOwningPlayer(GetKillingUnit())
if (IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)) then
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)+GetHeroLevel(GetTriggerUnit())*LEVEL_MULTIPLIER)
else
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)+GetUnitLevel(GetTriggerUnit())*HERO_LEVEL_MULTIPLIER)
endif
call LeaderboardSetItemValue(b, LeaderboardGetPlayerIndex(b, p), GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD))
endmethod
private static method l takes nothing returns nothing
call LeaderboardRemovePlayerItem(b, GetTriggerPlayer())
endmethod
private static method e takes nothing returns nothing
local trigger t = CreateTrigger()
local trigger t2 = CreateTrigger()
local integer i = 15
local player p
set b = CreateLeaderboard()
loop
set p = Player(i)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_DEATH, null)
if (GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER) then
call LeaderboardAddItem(b, "Bounty", 0, p)
call TriggerRegisterPlayerEvent(t2, p, EVENT_PLAYER_LEAVE)
call PlayerSetLeaderboard(p, b)
endif
exitwhen i == 0
set i = i - 1
endloop
call TriggerAddAction(t, function thistype.r)
call TriggerAddAction(t2, function thistype.l)
call LeaderboardDisplay(b, true)
call LeaderboardSortItemsByValue(b,false)
set t = null
set t2 = null
call DestroyTimer(GetExpiredTimer())
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function thistype.e)
endmethod
endstruct