• 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] Why doesn't this work?

Status
Not open for further replies.
Level 5
Joined
Sep 10, 2006
Messages
185
  • Shatter
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Fountain of Blood
    • Actions
      • -------- Locals --------
      • Custom script: local unit udg_ShatterUnit
      • Custom script: local location udg_ShatterPos
      • Custom script: local effect udg_ShatterEffect
      • -------- Set Variables --------
      • Set ShatterUnit = (Attacked unit)
      • Set ShatterPos = (Position of ShatterUnit)
      • Set ShatterInt = (Random integer number between 1 and 2)
      • -------- Actions --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ShatterInt Equal to 1
        • Then - Actions
          • Game - Display to (All players) the text: gg
          • Special Effect - Create a special effect attached to the origin of ShatterUnit using Abilities\Spells\Undead\FreezingBreath\FreezingBreathTargetArt.mdl
          • Set ShatterEffect = (Last created special effect)
          • Unit - Pause ShatterUnit
          • Wait 2.00 seconds
          • Unit - Unpause ShatterUnit
          • Special Effect - Destroy ShatterEffect
          • Special Effect - Create a special effect at ShatterPos using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
          • Set ShatterEffect = (Last created special effect)
          • Special Effect - Destroy ShatterEffect
          • Unit - Set life of ShatterUnit to ((Life of ShatterUnit) - ((Max life of ShatterUnit) x 0.75))
        • Else - Actions
      • -------- Null Locals --------
      • Custom script: call RemoveLocation(udg_ShatterPos)
      • Custom script: set udg_ShatterUnit = null
JASS:
function Trig_Shatter_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetAttacker()) == 'nbfl' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Shatter_Func010C takes nothing returns boolean
    if ( not ( udg_ShatterInt == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Shatter_Actions takes nothing returns nothing
    // Locals
    local unit udg_ShatterUnit
    local location udg_ShatterPos
    local effect udg_ShatterEffect
    // Set Variables
    set udg_ShatterUnit = GetAttackedUnitBJ()
    set udg_ShatterPos = GetUnitLoc(udg_ShatterUnit)
    set udg_ShatterInt = GetRandomInt(1, 2)
    // Actions
    if ( Trig_Shatter_Func010C() ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_508" )
        call AddSpecialEffectTargetUnitBJ( "origin", udg_ShatterUnit, "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl" )
        set udg_ShatterEffect = GetLastCreatedEffectBJ()
        call PauseUnitBJ( true, udg_ShatterUnit )
        call TriggerSleepAction( 2 )
        call PauseUnitBJ( false, udg_ShatterUnit )
        call DestroyEffectBJ( udg_ShatterEffect )
        call AddSpecialEffectLocBJ( udg_ShatterPos, "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl" )
        set udg_ShatterEffect = GetLastCreatedEffectBJ()
        call DestroyEffectBJ( udg_ShatterEffect )
        call SetUnitLifeBJ( udg_ShatterUnit, ( GetUnitStateSwap(UNIT_STATE_LIFE, udg_ShatterUnit) - ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_ShatterUnit) * 0.75 ) ) )
    else
    endif
    // Null Locals
    call RemoveLocation(udg_ShatterPos)
    set udg_ShatterUnit = null
endfunction

//===========================================================================
function InitTrig_Shatter takes nothing returns nothing
    set gg_trg_Shatter = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shatter, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Shatter, Condition( function Trig_Shatter_Conditions ) )
    call TriggerAddAction( gg_trg_Shatter, function Trig_Shatter_Actions )
endfunction

All that happens is the game display "gg". It's supposed to put the freezing breath art on them, pause them for 2 seconds, then reduce their hp by 25%.

ty to anyone who helps.

EDIT: Added jass version if that helps.
 
Level 25
Joined
May 11, 2007
Messages
4,650
I aint good on leak triggers, but it couldn't be like that the first 3 anti leak triggers actually remove who is the attacker? As it seems that it doesn't save Shatterunit as a variable.
 
Level 25
Joined
May 11, 2007
Messages
4,650
Hehe, told ya I wasn't good at that ;) , but I'm hellish sure that the game doesn't save the unit . For some reason. .

Do a game text - name of unit(shatterunit) just to see if it's like I think?
 
Level 5
Joined
Sep 10, 2006
Messages
185
Hehe, told ya I wasn't good at that ;) , but I'm hellish sure that the game doesn't save the unit . For some reason. .

Do a game text - name of unit(shatterunit) just to see if it's like I think?

It doesn't save it... why doesn't it save it?!?!?!
 
Level 5
Joined
Sep 10, 2006
Messages
185
Aight, well I'm out for the night. If anyone can figure out why ShatterUnit isn't being saved, feel free to post.
cyall
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Why do you always bump, or double post ._. There ´still is an edit button for a reason.

I suggest, try
  • Set ShatterUnit = (Triggering unit)
instead of attacked unit. Attacked unit is just referring to Triggering Unit while itself is global, and Triggering Unit is local...
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Learn to read and use JASS code. The problem with the local global trick is you don't really know what your code is doing, so you cannot possible debug it properly. It looks like it should work, so likely the abuse (and unnecessary abuse in some cases - attacked unit is triggering unit, and that carries over waits) of local declarations, which tends to be a bit dodgy, I think.

And your leak fixing is wrong. You need to null all non-permament-handle pointing handle variables. If you don't know what that means, research it (preferably at WC3C, unless there's a good tutorial on it around here, which I don't think there is).
 
Status
Not open for further replies.
Top