• 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.

[Trigger] Damage Modification

Status
Not open for further replies.
Level 3
Joined
Sep 30, 2012
Messages
31
I am using Bribe's DDS in order to perform damage modifications on incoming damage. However, I am running in to a problem where certain parts of the Damage Mod trigger are not running. In particular, the "Warrior Spirit" and "Damage Block" parts never run until the second trigger, "Piercing Taunt", is run for the first time (Arcane Barrier runs normally). After that trigger is run, the first trigger begins running normally for the rest of the game (as far as I can tell).

I have used Game Text Display to verify that the variables are exactly what they should be, but still the trigger does not run. Could there be something wrong with the local variables?

  • Damage Mods
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: local unit udg_unit = udg_DamageEventTarget
      • Custom script: local unit udg_unit2 = udg_DamageEventSource
      • Custom script: local integer udg_handle_num = GetUnitUserData(udg_unit)
      • Custom script: local integer udg_handle_num2 = GetUnitUserData(udg_unit2)
      • Custom script: local real udg_temp_real = 0
      • -------- Multiplicative Mods First --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (unit has buff Arcane Barrier ) Equal to True
        • Then - Actions
          • Set temp_real = ((0.05 + (0.05 x (Real((Level of Arcane Barrier for unit))))) x DamageEventPrevAmt)
          • Set ArcaneBarrierStorage[handle_num] = (ArcaneBarrierStorage[handle_num] + temp_real)
          • Set DamageEventAmount = (DamageEventPrevAmt - temp_real)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (unit has buff Warrior's Spirit ) Equal to True
            • Then - Actions
              • Set DamageEventAmount = (DamageEventPrevAmt x (0.90 - (0.10 x (Real((Level of Warrior's Spirit for unit))))))
            • Else - Actions
      • -------- Additive Mods Last --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of unit) Equal to Royal Guard
          • DamageEventType Equal to 0
          • (Random real number between 0.00 and 1.00) Greater than or equal to 0.75
        • Then - Actions
          • Set DamageEventAmount = (Max(0.00, (DamageEventPrevAmt - (Real((Strength of unit (Include bonuses)))))))
        • Else - Actions
  • Piercing Taunt Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Piercing Taunt
    • Actions
      • Set unit = (Triggering unit)
      • Set handle_num = (Custom value of unit)
      • Set PiercingTauntTimer[handle_num] = (2.00 + (0.50 x (Real((Level of Piercing Taunt for unit)))))
      • Unit Group - Add unit to PiercingTauntGroup
 
Level 14
Joined
Nov 17, 2010
Messages
1,266
I think the variable: unit is not set to anything until you run the Piercing Taunt trigger. So basically the other trigger doesn't know which unit is 'unit'

Maybe I'm totally wrong, but that's what I noticed at first glance
 
Level 3
Joined
Sep 30, 2012
Messages
31
The problem is the ITE.

This is a common problem when people try to use local shadowing.

Locals are only available in the function they are created in. GUI turns ITE conditions into there own function. So those locals do not exist in there.

Also you don't need locals in here.

If this is the case, then why does part of the trigger which uses locals work? And why does the other part "turn on" later? You could be correct but something doesn't quite add up.

And I don't technically need locals but I would rather not create extra variables for this function. The globals which they shadow can't be changed without screwing up other functions.
 
Level 3
Joined
Sep 30, 2012
Messages
31
Make variables that are called TempVariableType then use them when needed.
Never use temp variables for anything other than temporary things.
It defeats the purpose of making them temp variables.

They are used for temporary things. It's just that when I have a trigger with "Pick All Units in some group and damage them", this trigger is fired off in the middle of the first trigger, due to how the DDS works. So any temporary variables used in the first trigger cannot be used in this trigger without interfering.

Anyways, I have redone the trigger without local variables and it seems to work now. I am still utterly confused as to why the part of the trigger works and the other part doesn't, seeing as both use the local variables. If you or anyone else could shed some light, I would be most grateful.
 
Level 3
Joined
Sep 30, 2012
Messages
31
It does not work because local variables only work in the function they are declared.

The conditions are separated into their own functions.
The rest of the actions stay in one function.
That is why it does not work.

The arcane barrier part of the trigger uses local variables and never fails to work correctly.

And the other two parts begin working after the Piercing Taunt trigger runs for the first time during the map.

These two parts are what I do not understand. Thanks for your patience.
 
Level 5
Joined
Jan 27, 2014
Messages
164
GUI ITE creates a separate function.

Example:
GUI version
Code:
Test
    Events
    Conditions
    Actions
        Custom script:   local integer udg_int = 0
        Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                int Equal to 1
                int Equal to 2
            Then - Actions
                Unit - Create 2 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
            Else - Actions

JASS version
JASS:
function Trig_Test_Func003C takes nothing returns boolean
    if ( not ( udg_int == 1 ) ) then
        return false
    endif
    if ( not ( udg_int == 2 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Test_Actions takes nothing returns nothing
    local integer udg_int = 0
    call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
    if ( Trig_Test_Func003C() ) then
        call CreateNUnitsAtLoc( 2, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction

Your locals only work in the Trig_Test_Actions function.
For the condition function, Trig_Test_Func003C, the local does not exist in there. That's why you get error when you test.


On a related note, you can only create one pseudo locals for one variable type. I see a few unit locals your trigger. I don't think that'd work.
 
Level 3
Joined
Sep 30, 2012
Messages
31
Your locals only work in the Trig_Test_Actions function.
For the condition function, Trig_Test_Func003C, the local does not exist in there. That's why you get error when you test.

Yes, I understand that a separate function is created now. All I'm wondering is why it starts working 100% after a completely unrelated trigger is called.

On a related note, you can only create one pseudo locals for one variable type. I see a few unit locals your trigger. I don't think that'd work.

I don't use any of the secondary locals in this (yet), but that is good information to know. Thanks.
 
Level 3
Joined
Sep 30, 2012
Messages
31
I have several other spell triggers which also utilize those variables, however none of them "activate" the trigger (so to speak).

Ah well, perhaps it's just another mystery of WorldEdit.
+rep, by the way
 
Status
Not open for further replies.
Top