Moderator
M
Moderator
17:39, 8th Mar 2014
PurgeandFire: Review:
http://www.hiveworkshop.com/forums/2496930-post27.html
PurgeandFire: Review:
http://www.hiveworkshop.com/forums/2496930-post27.html
// Kill Streak / Player Kills Counting System
// version 1.1.0 by deathismyfriend
// Function List
//
//
// This function pauses the game timer.
// This is the timer that tells when to reset the individual kills of that unit.
// function RCSPauseGameTimer takes nothing returns nothing
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: call RCSPauseGameTimer()
//
//
// This function starts the timer if you have paused it. ( It is on to start the game)
// This is the timer that tells when to reset the individual kills of that unit.
// function RCSStartGameTimer takes nothing returns nothing
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: call RCSStartGameTimer()
//
//
// This function allows users to retrieve the individual kills from that unit.
// function RCSGetIndivKillsFromUnit takes unit u returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: call RCSGetIndivKillsFromUnit( udg_tempUnit)
//
//
// This function allows users to retrieve the total individual kills from that unit.
// The total kills are the kills that unit got from the start of the game.
// function RCSGetIndivTotalKillsFromUnit takes unit u returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: call RCSGetIndivTotalKillsFromUnit( udg_tempUnit)
//
//
// This function checks each unit to see if that unit has gotten a kill
// within the desired time limit set by the user.
// This function takes each unit and checks against the limit.
// Since the normal method of my system only checks the time limit when that unit kills a new unit.
// This function corrects that inaccuracy. This should be called everytime that you want to get
// the kills for that unit for a purpose like a damage boost or something else like that.
// function RCSForceIndividualKills takes nothing returns nothing
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: call RCSForceIndividualKills()
//
//
// This function checks each unit to see if that unit has gotten a kill
// function RCSGetPlayerTotalKills takes player p returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: set udg_tempInteger = RCSGetPlayerTotalKills( udg_tempPlayer)
//
//
// function RCSGetPlayerNonHeroKills takes player p returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: set udg_tempInteger = RCSGetPlayerNonHeroKills( udg_tempPlayer)
//
//
// function RCSGetPlayerHeroKills takes player p returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: set udg_tempInteger = RCSGetPlayerHeroKills( udg_tempPlayer)
//
//
// function RCSGetPlayerTotalDeaths takes player p returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: set udg_tempInteger = RCSGetPlayerTotalDeaths( udg_tempPlayer)
//
//
// function RCSGetPlayerNonHeroDeaths takes player p returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: set udg_tempInteger = RCSGetPlayerNonHeroDeaths( udg_tempPlayer)
//
//
// function RCSGetPlayerHeroDeaths takes player p returns integer
// To use this use the custom script below. ( You can Copy and Paste it.)
// Custom script: set udg_tempInteger = RCSGetPlayerHeroDeaths( udg_tempPlayer)
//
//
function RCSGetPlayerTotalKills takes player p returns integer
return udg_RCSKillDeathCounterPlayer[ GetPlayerId( p)]
endfunction
function RCSGetPlayerNonHeroKills takes player p returns integer
return udg_RCSKillDeathCounterPlayer[ GetPlayerId( p) + 16]
endfunction
function RCSGetPlayerHeroKills takes player p returns integer
return udg_RCSKillDeathCounterPlayer[ GetPlayerId( p) + 32]
endfunction
function RCSGetPlayerTotalDeaths takes player p returns integer
return udg_RCSKillDeathCounterPlayer[ GetPlayerId( p)+ 48]
endfunction
function RCSGetPlayerNonHeroDeaths takes player p returns integer
return udg_RCSKillDeathCounterPlayer[ GetPlayerId( p) + 64]
endfunction
function RCSGetPlayerHeroDeaths takes player p returns integer
return udg_RCSKillDeathCounterPlayer[ GetPlayerId( p) + 80]
endfunction
function RCSGetIndivKillsFromUnit takes unit u returns integer
local boolean b = IsUnitType( u, UNIT_TYPE_HERO)
local real time = udg_RCSGameTime + udg_RCSGameTimeAccuracy
local integer id = GetHandleId( u)
if not b and RCSNonHeroKillsIndividualFilter() then
if udg_RCSGameTimeReset[1] > ( udg_RCSGameTime - LoadReal( udg_RCSHashtable, id, 0)) then
return LoadInteger( udg_RCSHashtable, id, 1)
else
call SaveInteger( udg_RCSHashtable, id, 1, 0)
return 0
endif
elseif b and RCSHeroKillsIndividualFilter() then
if udg_RCSGameTimeReset[2] > ( udg_RCSGameTime - LoadReal( udg_RCSHashtable, id, 0)) then
return LoadInteger( udg_RCSHashtable, id, 1)
else
call SaveInteger( udg_RCSHashtable, id, 1, 0)
return 0
endif
endif
return 0
endfunction
function RCSGetIndivTotalKillsFromUnit takes unit u returns integer
return LoadInteger( udg_RCSHashtable, GetHandleId(u), 3)
endfunction
function RCSForceGroupEnumIndKills takes nothing returns nothing
local unit u = GetEnumUnit()
local integer id = GetHandleId(u)
local boolean b = IsUnitType( u, UNIT_TYPE_HERO)
if not b and udg_RCSIndividualKillsBoolean[1] and RCSNonHeroKillsIndividualFilter() then // This filter out the non hero kills
if udg_RCSGameTimeReset[1] < ( udg_RCSGameTime - LoadReal( udg_RCSHashtable, id, 0)) then
call SaveInteger( udg_RCSHashtable, id, 1, 0)
set udg_RCSKillerUnit = u
set udg_RCSInteger = 0
call RCSKillStreakCheckKills()
set udg_RCSKillerUnit = null
endif
elseif b and udg_RCSIndividualKillsBoolean[2] and RCSHeroKillsIndividualFilter() then // This filter out the hero kills
if udg_RCSGameTimeReset[1] < ( udg_RCSGameTime - LoadReal( udg_RCSHashtable, id, 0)) then
call SaveInteger( udg_RCSHashtable, id, 2, 0)
set udg_RCSKillerUnit = u
set udg_RCSInteger = 0
call RCSKillStreakCheckKills()
set udg_RCSKillerUnit = null
endif
endif
set u = null
endfunction
function RCSForceIndividualKills takes nothing returns nothing
call ForGroup( udg_RCSKillsUnitGroup, function RCSForceGroupEnumIndKills)
endfunction
function RCSRegisterIndividualKills takes unit dead, unit killer, integer id, integer childKey returns integer
local integer i = LoadInteger( udg_RCSHashtable, id, childKey)
set i = i + 1
call SaveInteger( udg_RCSHashtable, id, childKey, i)
if RCSKillsResetKills() then
call FlushChildHashtable( udg_RCSHashtable, id)
if not IsUnitInGroup( killer, udg_RCSKillsUnitGroup) then
call GroupRemoveUnit( udg_RCSKillsUnitGroup, dead)
endif
endif
return i
endfunction
function RCSResetIndividualKills takes unit dead, unit killer, integer id, integer childKey, integer kills returns nothing
call SaveInteger( udg_RCSHashtable, id, childKey, kills)
if RCSKillsResetKills() then
call FlushChildHashtable( udg_RCSHashtable, id)
if not IsUnitInGroup( killer, udg_RCSKillsUnitGroup) then
call GroupRemoveUnit( udg_RCSKillsUnitGroup, dead)
endif
endif
endfunction
function RCSKillCounterActions takes nothing returns boolean
local unit dead = GetTriggerUnit()
local unit killer = GetKillingUnit()
local integer pId = GetPlayerId( GetOwningPlayer( killer))
local boolean b = IsUnitType( killer, UNIT_TYPE_HERO)
local integer id
local integer i
local integer pId2 = GetPlayerId( GetOwningPlayer( dead))
local real time
set udg_RCSDeadUnit = dead
set udg_RCSKillerUnit = killer
if RCSEveryKillsIndividualFilter() then // This counts individual kills.
if not IsUnitInGroup( killer, udg_RCSKillsUnitGroup) then
call GroupAddUnit( udg_RCSKillsUnitGroup, killer)
endif
set time = udg_RCSGameTime + udg_RCSGameTimeAccuracy
set id = GetHandleId( killer)
// This checks the timeout for that unit.
if udg_RCSGameTimerBoolean then
if not b and udg_RCSIndividualKillsBoolean[1] and RCSNonHeroKillsIndividualFilter() then // This filter out the non hero kills
if udg_RCSGameTimeReset[1] > ( udg_RCSGameTime - LoadReal( udg_RCSHashtable, id, 0)) then
call RCSRegisterIndividualKills( dead, killer, id, 1)
else
call RCSResetIndividualKills( dead, killer, id, 1, 1)
endif
call SaveReal( udg_RCSHashtable, id, 0, time)
elseif b and udg_RCSIndividualKillsBoolean[2] and RCSHeroKillsIndividualFilter() then // This filter out the hero kills
if udg_RCSGameTimeReset[1] > ( udg_RCSGameTime - LoadReal( udg_RCSHashtable, id, 0)) then
call RCSRegisterIndividualKills( dead, killer, id, 2)
else
call RCSResetIndividualKills( dead, killer, id, 2, 1)
endif
call SaveReal( udg_RCSHashtable, id, 0, time)
endif
if udg_RCSIndividualKillsBoolean[3] and RCSTotalKillsIndividualFilter() then // This filter out the total kills
call RCSRegisterIndividualKills( dead, killer, id, 3)
endif
else
if RCSNonHeroKillsIndividualFilter() and not b then // This filter out the non hero kills
call RCSRegisterIndividualKills( dead, killer, id, 1)
elseif RCSHeroKillsIndividualFilter() and b then // This filter out the hero kills
call RCSRegisterIndividualKills( dead, killer, id, 2)
endif
if RCSTotalKillsIndividualFilter() then // This filter out the total kills
call RCSRegisterIndividualKills( dead, killer, id, 3)
endif
endif
endif
set udg_RCSPlayerInteger = pId + 1
if RCSEveryKillsCounterFilter() then // This filter out the kills that are the same for all kills.
if RCSNonHeroKillsCounterFilter() and not b then // This filter out the non hero kills
// Increase for non-hero units.
set i = pId + 16
set udg_RCSKillDeathCounterPlayer[ i] = udg_RCSKillDeathCounterPlayer[ i] + 1
set udg_RCSInteger = udg_RCSKillDeathCounterPlayer[ i]
call RCSNonHeroKillsCounterActions()
elseif RCSHeroKillsCounterFilter() and b then // This filter out the hero kills
// Increase for hero units.
set i = pId + 32
set udg_RCSKillDeathCounterPlayer[ i] = udg_RCSKillDeathCounterPlayer[ i] + 1
set udg_RCSInteger = udg_RCSKillDeathCounterPlayer[ i]
call RCSHeroKillsCounterActions()
endif
if RCSTotalKillsCounterFilter() then // This filter out the total kills
// Increase for all units.
set udg_RCSKillDeathCounterPlayer[ pId] = udg_RCSKillDeathCounterPlayer[ pId] + 1
set udg_RCSInteger = udg_RCSKillDeathCounterPlayer[ pId]
call RCSTotalKillsCounterActions()
endif
endif
set b = IsUnitType( dead, UNIT_TYPE_HERO)
set udg_RCSPlayerInteger = pId2 + 1
if RCSEveryDeathsCounterFilter() then // This filter out the kills that are the same for all kills.
if RCSNonHeroDeathsCounterFilter() and not b then // This filter out the non hero kills
// Increase for non-hero units.
set i = pId2 + 64
set udg_RCSKillDeathCounterPlayer[ i] = udg_RCSKillDeathCounterPlayer[ i] + 1
set udg_RCSInteger = udg_RCSKillDeathCounterPlayer[ i]
call RCSNonHeroDeathsCounterActions()
elseif RCSHeroDeathsCounterFilter() and b then // This filter out the hero kills
// Increase for hero units.
set i = pId2 + 80
set udg_RCSKillDeathCounterPlayer[ i] = udg_RCSKillDeathCounterPlayer[ i] + 1
set udg_RCSInteger = udg_RCSKillDeathCounterPlayer[ i]
call RCSHeroDeathsCounterActions()
endif
if RCSTotalDeathsCounterFilter() then // This filter out the total kills
// Increase for all units.
set i = pId2 + 48
set udg_RCSKillDeathCounterPlayer[ i] = udg_RCSKillDeathCounterPlayer[ i] + 1
set udg_RCSInteger = udg_RCSKillDeathCounterPlayer[ i]
call RCSTotalDeathsCounterActions()
endif
endif
set dead = null
set killer = null
set udg_RCSDeadUnit = null
set udg_RCSKillerUnit = null
return false
endfunction
function RCSGameTimerEventEnd takes nothing returns nothing
set udg_RCSGameTime = udg_RCSGameTime + udg_RCSGameTimeAccuracy
endfunction
function RCSPauseGameTimer takes nothing returns nothing
call PauseTimer( udg_RCSGameTimer)
endfunction
function RCSStartGameTimer takes nothing returns nothing
call TimerStart( udg_RCSGameTimer, udg_RCSGameTimeAccuracy, true, function RCSGameTimerEventEnd)
endfunction
function RCSGameTimerSetup takes nothing returns nothing
local timer t = GetExpiredTimer()
call TimerStart( udg_RCSGameTimer, udg_RCSGameTimeAccuracy, true, function RCSGameTimerEventEnd)
set udg_RCSKillsUnitGroup = CreateGroup()
call DestroyTimer(t)
set t = null
endfunction
//===========================================================================
function InitTrig_RCSKillCounterCode takes nothing returns nothing
local trigger t = CreateTrigger()
if udg_RCSHashtable == null then
set udg_RCSHashtable = InitHashtable()
endif
call TimerStart( CreateTimer(), 0.01, false, function RCSGameTimerSetup)
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition( t, Condition( function RCSKillCounterActions))
set t = null
endfunction