HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Attack Indexing help

01-09-2011, 09:05 PM#1
Nestharus
I've been writing an AttackIndexer, but I just realized something troubling... if the attacking unit is removed during an attack, EventDamageSource will return null, meaning that the following script displays 0. I made priest have like 3000 range and 9000 sight radius and 4500 acquisition range and .01 cooldown on attack with 1 dmg per attack, lol...

Anyone know a way to fix this? : O

Unit recycling isn't an answer as the abilities and what not screw it up as well as the techs ;O... if a tech goes between players, yea... if an ability is permanent, yea...

Well, I could hook RemoveUnit and have a dummy for it somewhere in the background that stores it's data (in AttackIndexer) until all of its attacks are done ; |, but GetEventDamageSource would still return null... I can't hook RemoveUnit and make it stop calling : |... I could just say don't remove units and use RemoveUnitEx instead >.>. I could fix this with cJASS definitions if cJASS actually worked... /cry

Collapse JASS:
struct tester extends array
    private static unit u1
    private static unit u2
    private static method onD takes nothing returns boolean
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(DamageEvent.sourceId))
        return false
    endmethod
    private static method run2 takes nothing returns nothing
        call RemoveUnit(u1)
        call DestroyTimer(GetExpiredTimer())
    endmethod
    private static method run takes nothing returns nothing
        local fogmodifier f = CreateFogModifierRect(Player(0), FOG_OF_WAR_VISIBLE, WorldBounds.world, false, false)
        call FogModifierStart(f)
        set u1 = CreateUnit(Player(0), 'hmpr', WorldBounds.centerX-2500, WorldBounds.centerY, 0)
        set u2 = CreateUnit(Player(8), 'hpea', WorldBounds.centerX, WorldBounds.centerY, 0)
        call IssueTargetOrder(u1, "attack", u2)
        call TimerStart(GetExpiredTimer(), 2, false, function thistype.run2)
    endmethod
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(), 0, false, function thistype.run)
        call DamageEvent.EVENT.register(Condition(function thistype.onD))
    endmethod
endstruct

edit
Quote:
Well, attacks have data attached to them. Once an attack is created, it doesn't matter whether the unit exists or not. It's difficult to retrieve attack data if said unit was removed ;P.

If you have 3 projectiles and 3 units were removed, there's no way to know which projectile belongs to which unit.

Each unit has its own attack recycling (50 instances per unit). The attack struct itself is retrieved by the unit id + the unit's current attack id (this way few objects are needed for insano stability ;D).

8190 attacks can be on the map at one time. Obviously, not all units can fill out their complete attack queues, but the overall script is very stable.

I could do global attack indexing with 44 objects and 10000 max total attacks on the map though, meaning unit user data isn't needed.
01-12-2011, 11:02 AM#2
Bribe
What about accounting for ExplodeUnitBJ or units destroyed by a siege unit? Those things will also return null under the same circumstances.

If the source unit or target unit is null, the damage should be 0 anyway.