- Joined
- Dec 12, 2008
- Messages
- 7,385
This is broken. Do not use it.
ASS no longer uses this system to store data.
It still actually is functional, but assists are not retrievable when using ASS through this snippet.
JASS:
/************************************************
*
* CombatDataStorage
* v1.4.0.0
* By Magtheridon96
*
* Allows the retrieval of Player Hero:
* - Kills
* - Deaths
* - Suicides
* - Denies
* - Assists (Only with AdvancedStreakSystem implemented)
*
* Useful for AoS maps.
*
* API:
* ----
*
* function GetPlayerKillsById takes integer i returns integer
* function GetPlayerDeathsById takes integer i returns integer
* function GetPlayerDeniesById takes integer i returns integer
* function GetPlayerSuicidesById takes integer i returns integer
* function GetPlayerAssistsById takes integer i returns integer
* - Retrieve values given a player id
*
************************************************/
library CombatDataStorage requires RegisterPlayerUnitEvent
globals
// DataVars
private integer array kills
private integer array deaths
private integer array denies
private integer array suicides
// When you deny a hero, do you get a kill?
private constant boolean DENIES_COUNT_KILLS = false
// When you get denied, do you get a death?
private constant boolean DENIES_COUNT_DEATHS = false
// Does suicide count as a death?
private constant boolean SUICIDE_DEATH = true
endglobals
private function E takes nothing returns nothing
local unit u = GetTriggerUnit()
local player k = GetOwningPlayer(GetKillingUnit())
local integer i = GetPlayerId(GetTriggerPlayer())
local integer j = GetPlayerId(k)
if IsUnitType(u,UNIT_TYPE_HERO) then
if u == GetKillingUnit() then
set suicides[i] = suicides[i] + 1
static if SUICIDE_DEATH then
set deaths[i] = deaths[i] + 1
endif
elseif IsUnitEnemy(u, k) then
set kills[j] = kills[j] + 1
set deaths[i] = deaths[i] + 1
else
set denies[j] = denies[j] + 1
static if DENIES_COUNT_KILLS then
set kills[j] = kills[j] + 1
endif
static if DENIES_COUNT_DEATHS then
set deaths[i] = deaths[i] + 1
endif
endif
endif
set u = null
set k = null
endfunction
function GetPlayerKillsById takes integer i returns integer
return kills[i]
endfunction
function GetPlayerDeathsById takes integer i returns integer
return deaths[i]
endfunction
function GetPlayerDeniesById takes integer i returns integer
return denies[i]
endfunction
function GetPlayerSuicidesById takes integer i returns integer
return suicides[i]
endfunction
static if LIBRARY_ASS then
private struct A extends array
static integer array assists
endstruct
function IncreasePlayerAssistsById takes integer i returns nothing
set A.assists[i] = A.assists[i] + 1
endfunction
function GetPlayerAssistsById takes integer i returns integer
return A.assists[i]
endfunction
endif
private module Init
private static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH,function E)
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
Feel free to comment..
Last edited: