• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Damage Engine Damage Dealing Loop

Status
Not open for further replies.
Level 10
Joined
Jun 6, 2007
Messages
392
I've made an ability, which is a custom cleaving attack but works for ranged heroes too. I'm using DamageEvent for damage detection. When the effect is triggered, I get a debug message saying that there is a damage recursion and I should disable the trigger before dealing damage. However, I have done that. Here's my trigger:
JASS:
scope FlameBurst initializer init

    globals
        private constant integer ABIL_CODE = 'A03T'
        private constant real AREA = 400
        private trigger T
    endglobals
    
    private function True takes nothing returns boolean
        return true
    endfunction
    
    private function Actions takes nothing returns boolean
        local integer chance
        local location targetloc
        local group targetgroup
        local unit u
        
        if not ( GetUnitAbilityLevel(udg_DamageEventSource, ABIL_CODE) > 0  and udg_DamageEventPhysical) then
            return false
        endif
        
        call DisableTrigger(T)

        set chance = 20 + 10*GetUnitAbilityLevel(udg_DamageEventSource, ABIL_CODE)
        if chance > GetRandomInt(0, 99) then
            
            set targetloc = GetUnitLoc(udg_DamageEventTarget)
            set targetgroup = GetUnitsInRangeOfLocMatching(AREA, targetloc, Filter(function True))
            loop
                set u = FirstOfGroup(targetgroup)
                exitwhen u == null
                if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(udg_DamageEventSource)) and not IsUnitType(u, UNIT_TYPE_STRUCTURE) and GetUnitState(u, UNIT_STATE_LIFE) > 0 then
                    
                    call UnitDamageTarget(udg_DamageEventSource, u, udg_DamageEventAmount,true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
                    
                    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl", u, "origin"))
                endif
                call GroupRemoveUnit(targetgroup, u)
            endloop
            
            call DestroyGroup(targetgroup)
            call RemoveLocation(targetloc)
            set targetloc = null
            set u = null
            set targetgroup = null
        endif
        
        call EnableTrigger(T)
        
        return false
    endfunction

    private function init takes nothing returns nothing
        set T = CreateTrigger(  )
        call TriggerRegisterVariableEvent( T, "udg_DamageEvent", EQUAL, 1.00 )
        call TriggerAddCondition( T, Condition( function Actions ) )
    endfunction

endscope
Any idea why this happens?
 
Level 10
Joined
Jun 6, 2007
Messages
392
Hmm.. Do you mean the damage engine system trigger? Strange, this GUI trigger works perfectly fine:
  • Frost Breath
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has buff Frost Breath ) Equal to True
      • DamageEventPhysical Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Set TempPoint = (Position of DamageEventTarget)
      • Set TempGroup = (Units within 250.00 of TempPoint matching (((Owner of DamageEventSource) is an enemy of (Owner of (Matching unit))) Equal to True))
      • Set Damage = ((0.25 + (0.15 x (Real((Level of Frost Breath for DamageEventSource))))) x (Real((Intelligence of DamageEventSource (Include bonuses)))))
      • Special Effect - Create a special effect at TempPoint using war3mapImported\IceNova.mdx
      • Special Effect - Destroy (Last created special effect)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause DamageEventSource to damage (Picked unit), dealing Damage damage of attack type Spells and damage type Universal
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Trigger - Turn on (This trigger)
 
Status
Not open for further replies.
Top