• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[System] CDS {Combat Data Storage}

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:
Level 3
Joined
Jun 3, 2010
Messages
47
>a player can only have one hero
Just make it use an indexer and make it MUI. This is just plain silly.

>function F1
>function F2
No script using names like these should be approved, ever.

JASS:
set t=null
You don't need to null triggers in one time initilization.

>Alternate wrappers
Useless.
 
Denies are pretty rare these days, with anti-backstab detection. Using
this would mean you'd basically want to differentiate between denies
and normal kills, and if not then triggering this yourself wouldn't take
much effort at all.

So this has limited uses, but when it is useful it's not too terrible. The
short variable names don't do anything for the script, however, except
hinder readability. The library name is already way too long for it to
make a difference, you'd be better using Vexorian's Optimizer if you
wanted to bother, which is working mostly fine.
 
Top