I don't want AIDS to index my dummy units =/

SineCosine

I'm still looking for my Tangent
Reaction score
77
JASS:
//! runtextmacro BuffType("SlowDown")
    //! runtextmacro SetBuffName("Chilled")
    //! runtextmacro SetBuffAlignment("NEGATIVE")
    //! runtextmacro SetBuffTooltip("This unit has been chilled; it moves more slowly than it usually does.")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNFrost.blp")
//! runtextmacro BuffStruct()
    integer Slow
    effect e
    string SlowE = "Abilities\\Spells\\Other\\FrostDamage\\FrostDamage.mdl"
    string SlowAP = "chest"
    
    method onApply takes nothing returns nothing
        call Status[this.unit].modMoveSpeedPercentBonus(-Slow)
        set this.e = AddSpecialEffectTarget(SlowE, this.unit, SlowAP)
    endmethod
    
    method onRemove takes nothing returns nothing
        if GetUnitTypeId(this.unit)!=0 then // if the unit still exists.
            call Status[this.unit].modMoveSpeedPercentBonus(Slow)
        endif
        call DestroyEffect(this.e)
        set this.e = null
    endmethod
    
    static method apply takes unit target, integer Amount, real duration returns nothing
        local thistype this=thistype.create(null)
        set this.Slow = Amount
        call this.setUnit(target)
        call this.destroyTimed(duration)
    endmethod

//! runtextmacro EndBuff()
scope Slower initializer OnInit
    globals
        private constant integer PhebeId = 'o01G'
        
        private constant real Range = 600.00
        private constant integer AI = 'A029'
    endglobals

    private function OnDamage takes nothing returns boolean
        if Damage_IsAttack() == true and Status[GetTriggerUnit()].getMoveSpeedPercentBonus() == 0 then
            if GetUnitTypeId(GetEventDamageSource()) == PhebeId then
                call SlowDown.apply(GetTriggerUnit(), 30, 5.0)
            endif
            
            if GetUnitAbilityLevel(GetEventDamageSource(), AI) > 0 then
                call IssueBonusOrder(GetEventDamageSource(), "Slow", Range)
            endif
        endif
        
        return false
    endfunction
    
    private function OnInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function OnDamage))
    endfunction

endscope


I figured I'd just drop this here..
Remember when you guys told me that adding this:
JASS:
        if GetUnitTypeId(this.unit)!=0 then // if the unit still exists.
            //Stuff
        endif

Should solve it?

Well, I thought it would, so I never tested it after that.
(I got lazy to work on the map.)
I just tried it..
And AIDS is giving me errors as soon as the affected units die ._.

[EDIT]
The error is none other than this:
Error using AIDS: Trying to get the unit of unassigned index.

I haz been cursed!
(Or something like that)

I'll gladly upload the map with the scenario on request >.>
It won't bug on the 1st level on occasion, but the 2nd level onwards bugs like mad (Well, only error messages)
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:

//! runtextmacro BuffType("SlowDown")
    //! runtextmacro SetBuffName("Chilled")
    //! runtextmacro SetBuffAlignment("NEGATIVE")
    //! runtextmacro SetBuffTooltip("This unit has been chilled; it moves more slowly than it usually does.")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNFrost.blp")
//! runtextmacro BuffStruct()
    integer Slow
    effect e
    string SlowE = "Abilities\\Spells\\Other\\FrostDamage\\FrostDamage.mdl"
    string SlowAP = "chest"
    
    method onApply takes nothing returns nothing
        call Status[this.unit].modMoveSpeedPercentBonus(-Slow)
        set this.e = AddSpecialEffectTarget(SlowE, this.unit, SlowAP)
    endmethod
    
    method onRemove takes nothing returns nothing
        if GetUnitTypeId(this.unit)!=0 then // if the unit still exists.
            call Status[this.unit].modMoveSpeedPercentBonus(Slow)
        endif
        call DestroyEffect(this.e)
        set this.e = null
    endmethod
    
    static method apply takes unit target, integer Amount, real duration returns nothing
        local thistype this=thistype.create(null)
        set this.Slow = Amount
        call this.setUnit(target)
        call this.destroyTimed(duration)
    endmethod

//! runtextmacro EndBuff()
scope Slower initializer OnInit
    globals
        private constant integer PhebeId = 'o01G'
        
        private constant real Range = 600.00
        private constant integer AI = 'A029'
    endglobals

    private function OnDamage takes nothing returns boolean
        if Damage_IsAttack() == true and Status[GetTriggerUnit()].getMoveSpeedPercentBonus() == 0 then
            if GetUnitTypeId(GetEventDamageSource()) == PhebeId then
                call SlowDown.apply(GetTriggerUnit(), 30, 5.0)
            endif
            
            if GetUnitAbilityLevel(GetEventDamageSource(), AI) > 0 then
                call IssueBonusOrder(GetEventDamageSource(), "Slow", Range)
            endif
        endif
        
        return false
    endfunction
    
    private function OnInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function OnDamage))
    endfunction

endscope


I figured I'd just drop this here..
Remember when you guys told me that adding this:
JASS:


        if GetUnitTypeId(this.unit)!=0 then // if the unit still exists.
            //Stuff
        endif

Should solve it?

Well, I thought it would, so I never tested it after that.
(I got lazy to work on the map.)
I just tried it..
And AIDS is giving me errors as soon as the affected units die ._.

[EDIT]
The error is none other than this:


I haz been cursed!
(Or something like that)

I'll gladly upload the map with the scenario on request >.>
It won't bug on the 1st level on occasion, but the 2nd level onwards bugs like mad (Well, only error messages)
Same dealio, post me a map showing the bug in action, and I'll try my best to help you solve it. :)

Assumption is it's not a system bug, though.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
ARGH!
Recently, TH.net has been really slow on my browser >.>

All the other websites seem to load fine, though.
 

Attachments

  • AH-S TD 3-1k.w3x
    798.6 KB · Views: 186

Jesus4Lyf

Good Idea™
Reaction score
397
You need this, man.
JASS:
library RemoveBuffsOnDeath uses BuffStruct
    private struct DeathRemover extends BuffStruct
        private method removeBuff takes nothing returns nothing
            call this.setUnit(null)
        endmethod
        private static method onDeath takes nothing returns boolean
            local BuffList list=BuffList[GetDyingUnit()]
            call list.forEachBuff(BUFF_ALIGNMENT_NEGATIVE,thistype.removeBuff)
            call list.forEachBuff(BUFF_ALIGNMENT_NEUTRAL,thistype.removeBuff)
            call list.forEachBuff(BUFF_ALIGNMENT_POSITIVE,thistype.removeBuff)
            return false
        endmethod
        private static method onInit takes nothing returns nothing
            local trigger t=CreateTrigger()
            call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
            call TriggerAddCondition(t,Filter(function thistype.onDeath))
        endmethod
    endstruct
endlibrary

That moves buffs off units when they die, which calls the onRemove method without destroying the actual buff. So destroyTimed will still destroy it at the right point.

You may also remove the previous fix to see if the unit existed.
JASS:
    method onRemove takes nothing returns nothing
        call Status[this.unit].modMoveSpeedPercentBonus(Slow) // no longer needs the check
        call DestroyEffect(this.e)
        set this.e = null
    endmethod

Obviously none of what you're seeing are system bugs, but rather part of the (small) learning curve. BuffStruct is a framework around how to remove and apply buffs, and gives tools for handling when to add/remove/destroy. You were removing the buff after the unit died, which involved modifying the move speed of a unit which didn't exist. This solution causes the buff to be removed as the unit dies, which is the correct thing you wish to achieve...
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Mm..
Thanks for taking the time out to help me =)
I'll bookmark this for when I can get my JNGP WE to open >.>

Strangely enough, my WC3 and normal WE work fine.
It's just the JNGP WE that won't open no matter what I do =/
 

SanKakU

Member
Reaction score
21
i ran a test to see if units would get indexed if i tried altering it.
some of them started to get indexed anyway.

JASS:
    private function UnitIndexingFilter takes unit u returns boolean
        return GetPlayerId(GetOwningPlayer(u))>1
    endfunction


is there something wrong with my code or something wrong with aids?

if the unit is owned by player 0 or player 1, is there any other way the units could be getting indexed? i'm using [ljass]GetUnitId[/ljass]
 

tooltiperror

Super Moderator
Reaction score
231
if the unit is owned by player 0 or player 1, is there any other way the units could be getting indexed?

It's hard to answer such a vague question when you're speaking in [LJASS]engrish[/LJASS]. For the sake of everyone, get a free text editor for spelling and grammar support, and type out your posts there and then copy them over.

For the actual answer, the only way would be to force an index, but I don't think AIDS supports that (Ask Jesus4Lyf).
 

SanKakU

Member
Reaction score
21
Even if the AIDS filter returns false, if an AIDS struct must be instanciated for the unit, it will index the unit also.

None of Status, BuffStruct or Damage seem to do this, but perhaps something else does...
As said in AIDS thread...

that's the very first thing i checked for. i couldn't find anything equating to that. if you'll notice in the other thread i searched the entire aids trigger to find what else could be causing it. so far my results are inconclusive. my understanding of how aids works is yet insufficient.

edit: and like i already said, by the time i can finally successfully do as you asked in that post, i'll have gotten so far in finding THE SOURCE OF the bug that i might as well fix the bug myself. at least i assume i'll be able to fix it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top