1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Opinion and help about spells

Discussion in 'Triggers & Scripts' started by Flame_Phoenix, Sep 14, 2007.

  1. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    Well somehow, i knew it didn't work... dam ... i knew it ....

    About local triggers i don't understand why they are so bad !!!
    You guys highly recommend them in your JASS tutorial !!!

    Example:
    Code (vJASS):
    function Condition_Function takes nothing returns boolean  
        return GetTriggerPlayer() == Player(0)
    endfunction
    function InitTrig_JASSTrigger takes nothing returns nothing  
        local trigger myTrigger = CreateTrigger()  
        call TriggerRegisterPlayerEvent(myTrigger, Player(0), EVENT_PLAYER_END_CINEMATIC)  
        call TriggerAddCondition(myTrigger, Condition(function Condition_Function))  
        call TriggerAddAction(myTrigger, function MyFunction)  
        set myTrigger = null
    endfunction


    Visit this link Beginning JJASS Tutorial Series

    If local triggers are so bad, why don't you change the tutorial !!! It has 5 starts .... jesus, i start to think that tutorial is crap .... It is the second error ... (ya, lesson 4 is a mess....)
    and so i have to put the AAchances before ... dam ... that will be bad for me ...=S

    About JassCraft, it means that i have to add this file rit ???
     
  2. HINDYhat

    HINDYhat

    Joined:
    Apr 22, 2007
    Messages:
    1,594
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    There's no use to make a local trigger, when you ALREADY have the global! The global won't get away. The only use for local triggers in this case would be 1 major trigger that would initialize all other triggers, like some sort of Map Init. But that could be sooooo messy.

    Us guys? wyrmlord recommends it.

    About JassCraft, yes that's it.
     
  3. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    MMm well, then it probably means 2 things:
    1 - Using global triggers is more efficient and fast than using local ones (rit ?)
    2 - Wyrmlord is not as good Jasser as he seems to be ... or as he says he is ...
    3 - lot's of tutorials need to be corrected here =S
     
  4. HINDYhat

    HINDYhat

    Joined:
    Apr 22, 2007
    Messages:
    1,594
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    1. Actually I've heard that locals work faster than globals, but that's not the problem. The problem is that you're using up memory for nothing.
    2. No, he's good.
    3. Maybe, I haven't checked them.

    Stick with the local triggers if you want to, but IMO it's better to keep the globals.
     
  5. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    Well, i have two problems ....
    I will now post the first one, and explain the second later.
    the first problem i have is with your spell ....it simply doesn't work in my WE...
    JassCraft says it is ok, but my WE doesn't run it.

    Here is the error my WE points out:

    Image1.jpg

    So i don't get what is the dam problem .... I also placed this script at my map's header:
    Code (vJASS):
    // ===========================
    function H2I takes handle h returns integer
        return h
        return 0
    endfunction

    // ===========================
    function LocalVars takes nothing returns gamecache
        // Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
        return InitGameCache("jasslocalvars.w3v")
    endfunction

    function SetHandleHandle takes handle subject, string name, handle value returns nothing
        if value==null then
            call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
        else
            call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
        endif
    endfunction

    function SetHandleInt takes handle subject, string name, integer value returns nothing
        if value==0 then
            call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
        else
            call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
        endif
    endfunction

    function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
        if value==false then
            call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
        else
            call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
        endif
    endfunction

    function SetHandleReal takes handle subject, string name, real value returns nothing
        if value==0 then
            call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
        else
            call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
        endif
    endfunction

    function SetHandleString takes handle subject, string name, string value returns nothing
        if value==null then
            call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
        else
            call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
        endif
    endfunction

    function GetHandleHandle takes handle subject, string name returns handle
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleInt takes handle subject, string name returns integer
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    endfunction
    function GetHandleBoolean takes handle subject, string name returns boolean
        return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
    endfunction
    function GetHandleReal takes handle subject, string name returns real
        return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
    endfunction
    function GetHandleString takes handle subject, string name returns string
        return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
    endfunction

    function GetHandleUnit takes handle subject, string name returns unit
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleTimer takes handle subject, string name returns timer
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleTrigger takes handle subject, string name returns trigger
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleEffect takes handle subject, string name returns effect
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleGroup takes handle subject, string name returns group
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleLightning takes handle subject, string name returns lightning
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction
    function GetHandleWidget takes handle subject, string name returns widget
        return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
        return null
    endfunction

    function FlushHandleLocals takes handle subject returns nothing
        call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
    endfunction


    So, this is kn of bad ... this is my first issue, please help =S
     
  6. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    H2U(GetHandleHandle)?

    Why don't you just use GetHandleUnit? It's way more efficient.
     
  7. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    mm, i see what you mean.
     
  8. HINDYhat

    HINDYhat

    Joined:
    Apr 22, 2007
    Messages:
    1,594
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    My script doesn't use H2U(GetHandleHandle)???
     
  9. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    MMm, sry wrong image .... anyway i already found a way to fix it sorry the dummy post =S. I will post my second question tomorrow. Thx by all the help HINDYhat and PurplePoot.
     
  10. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    My second problem is in my map header.
    Can i have 2 different script codes in the header ??? Like the HanldeVars script and the UNIT_MAX_STATE_LIFE system ??
     
  11. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Yeah, you can have as many as you want, just like anywhere else.
     
  12. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    Guys, is the spell Ok now ??

    Code (vJASS):
    function AnimalAura_Conds takes nothing returns boolean
        local integer AAchance
        if GetUnitAbilityLevel(GetKillingUnit(), 'B019' )>0 then
            set AAchance = 5
        elseif GetUnitAbilityLevel(GetKillingUnit(), 'B01A' )>0 then
            set AAchance = 10
        elseif GetUnitAbilityLevel(GetKillingUnit(), 'B01B' )>0 then        
            set AAchance = 15
        endif
        return GetRandomInt(1, 100) <= AAchance
    endfunction
    //===================================================================================
    function AnimalAura_Acts takes nothing returns nothing
        local unit Killer = GetKillingUnit()
        local unit dead = GetDyingUnit()
        local unit dum
        if GetUnitAbilityLevel(GetKillingUnit(), 'B019' ) > 0 then
            set dum = CreateUnit(GetOwningPlayer(Killer), 'h01H', GetUnitX(dead), GetUnitY(dead), 0.00)
            call UnitAddAbility(dum, 'A04V')
            call SetUnitAbilityLevel(dum, 'A04V', 1)
            call IssuePointOrder(dum, "darkportal", GetUnitX(dead), GetUnitY(dead))
            call UnitApplyTimedLife(dum, 'BTLF', 3.00)
            set Killer = null
            set dum = null
            set dead = null
        endif
        if GetUnitAbilityLevel(GetKillingUnit(), 'B01A' )>0 then
            set dum = CreateUnit(GetOwningPlayer(Killer), 'h01H', GetUnitX(dead), GetUnitY(dead), 0.00)
            call UnitAddAbility(dum, 'A04V')
            call SetUnitAbilityLevel(dum, 'A04V', 2)
            call IssuePointOrder(dum, "darkportal", GetUnitX(dead), GetUnitY(dead))
            call UnitApplyTimedLife(dum, 'BTLF', 3.00)
            set Killer = null
            set dum = null
            set dead = null
        endif
        if GetUnitAbilityLevel(GetKillingUnit(), 'B01B' )>0 then
            set dum = CreateUnit(GetOwningPlayer(Killer), 'h01H', GetUnitX(dead), GetUnitY(dead), 0.00)
            call UnitAddAbility(dum, 'A04V')
            call SetUnitAbilityLevel(dum, 'A04V', 2)
            call IssuePointOrder(dum, "darkportal", GetUnitX(dead), GetUnitY(dead))
            call UnitApplyTimedLife(dum, 'BTLF', 3.00)
            set Killer = null
            set dum = null
            set dead = null
        endif
    endfunction
    //===========================================================================
    function InitTrig_Animal_Aura takes nothing returns nothing
        local trigger AnimalAura = CreateTrigger(  )
        local integer index = 0
        loop
            exitwhen index == 16
            call TriggerRegisterPlayerUnitEvent(AnimalAura, Player(index), EVENT_PLAYER_UNIT_DEATH, null)
            set index = index +1
        endloop
        call TriggerAddCondition( AnimalAura, Condition( function AnimalAura_Conds ) )
        call TriggerAddAction( AnimalAura, function AnimalAura_Acts )
        set AnimalAura = null
    endfunction
     
  13. HINDYhat

    HINDYhat

    Joined:
    Apr 22, 2007
    Messages:
    1,594
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    Looks okay. Here's a bit of optimizn'

    Code (vJASS):
    function AnimalAura_Conds takes nothing returns boolean
        local integer AAchance=0
        local unit u=GetKillingUnit()
        if GetUnitAbilityLevel(u, 'B019' )>0 then
            set AAchance = 5
        elseif GetUnitAbilityLevel(u, 'B01A' )>0 then
            set AAchance = 10
        elseif GetUnitAbilityLevel(u, 'B01B' )>0 then
            set AAchance = 15
        endif
        set u=null
        return GetRandomInt(1, 100) <= AAchance
    endfunction
    //===================================================================================
    function AnimalAura_Acts takes nothing returns nothing
        local unit Killer = GetKillingUnit()
        local unit dead = GetTriggerUnit()
        local unit dum
        if GetUnitAbilityLevel(Killer, 'B019' ) > 0 then
            set dum = CreateUnit(GetOwningPlayer(Killer), 'h01H', GetUnitX(dead), GetUnitY(dead), 0.00)
            call UnitAddAbility(dum, 'A04V')
            call SetUnitAbilityLevel(dum, 'A04V', 1)
            call IssuePointOrder(dum, "darkportal", GetUnitX(dead), GetUnitY(dead))
            call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        endif
        if GetUnitAbilityLevel(Killer, 'B01A' )>0 then
            set dum = CreateUnit(GetOwningPlayer(Killer), 'h01H', GetUnitX(dead), GetUnitY(dead), 0.00)
            call UnitAddAbility(dum, 'A04V')
            call SetUnitAbilityLevel(dum, 'A04V', 2)
            call IssuePointOrder(dum, "darkportal", GetUnitX(dead), GetUnitY(dead))
            call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        endif
        if GetUnitAbilityLevel(Killer, 'B01B' )>0 then
            set dum = CreateUnit(GetOwningPlayer(Killer), 'h01H', GetUnitX(dead), GetUnitY(dead), 0.00)
            call UnitAddAbility(dum, 'A04V')
            call SetUnitAbilityLevel(dum, 'A04V', 2)
            call IssuePointOrder(dum, "darkportal", GetUnitX(dead), GetUnitY(dead))
            call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        endif
        set Killer = null
        set dum = null
        set dead = null
    endfunction
    //===========================================================================
    function InitTrig_Animal_Aura takes nothing returns nothing
        local integer index = 0
        set gg_trg_Animal_Aura = CreateTrigger()
        loop
            exitwhen index == 16
            call TriggerRegisterPlayerUnitEvent(gg_trg_Animal_Aura, Player(index), EVENT_PLAYER_UNIT_DEATH, null)
            set index = index +1
        endloop
        call TriggerAddCondition( gg_trg_Animal_Aura, Condition( function AnimalAura_Conds ) )
        call TriggerAddAction( gg_trg_Animal_Aura, function AnimalAura_Acts )
    endfunction


    Please... stop using local triggers.
     
  14. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Fail; use elseif, hindy :p
     
  15. HINDYhat

    HINDYhat

    Joined:
    Apr 22, 2007
    Messages:
    1,594
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    I thought about that, but maybe he wants it to be able to check for ALL abilities eh?
     
  16. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    This particular spell is an Aura with 3 buffs for each level.
    Every time a unit dies, if the killer has the buff, a dummy unit will be created and a spell will be cast.
    As i said there are 3 different buffs for each level. I will try to make 1 buff with 3 levels (perhaps it is more efficient) but i don't know yet.

    EDIT: After evaluating my spell i concluded that there is no need for me to replace the 3 different auras by 1 aura with 3 levels. The script wouldn't change in a significant way.
     
  17. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    Ok, guys, i have another problem with one of my spells.
    When evaluating my map i can easily find GUI spells that do give a lot of trouble... they leak a lot and stuff like that ...
    But now that i know JASS i can change that! (or i am trying too). I am an expert at making any kind of GUI auras, problem is that they leak and sometimes they are not MUI .... Now because my map is for multiplayer i need them to be MUI ...

    Anyway, here is an aura which i called IcyAura.

    It was one of my first aura spells, so i made 1 trigger for each level:
    • Icy Aura Lv1
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in (Random 1 units from (Units in (Playable map area) matching (((Matching unit) has buff Icy Aura (Lv1)) Equal to True))) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • 10 Greater than or equal to (Random integer number between 1 and 100)
              • Then - Actions
                • Unit - Create 1 Frsot Trap for Player 1 (Red) at (Position of (Picked unit)) facing Default building facing degrees
                • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
                • Unit - Create 1 Icy Aura for Player 1 (Red) at (Position of (Picked unit)) facing Default building facing degrees
                • Unit - Add Icy Aura (Dummy Spell Lv1) to (Last created unit)
                • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
                • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
              • Else - Actions
                • Do nothing


    This is for level 1 ... I have 2 other triggers for level 2 and 3, but i will not post them now.

    Here is the same trigger in converted JASS:
    Code (vJASS):
    function Trig_Icy_Aura_Lv1_Func001001002002 takes nothing returns boolean
        return ( UnitHasBuffBJ(GetFilterUnit(), 'B01G') == true )
    endfunction

    function Trig_Icy_Aura_Lv1_Func001Func001C takes nothing returns boolean
        if ( not ( 10 >= GetRandomInt(1, 100) ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_Icy_Aura_Lv1_Func001A takes nothing returns nothing
        if ( Trig_Icy_Aura_Lv1_Func001Func001C() ) then
            call CreateNUnitsAtLoc( 1, 'h01N', Player(0), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
            call UnitApplyTimedLifeBJ( 3.00, 'BTLF', GetLastCreatedUnit() )
            call CreateNUnitsAtLoc( 1, 'h01M', Player(0), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
            call UnitAddAbilityBJ( 'A02K', GetLastCreatedUnit() )
            call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", GetEnumUnit() )
            call UnitApplyTimedLifeBJ( 3.00, 'BTLF', GetLastCreatedUnit() )
        else
            call DoNothing(  )
        endif
    endfunction

    function Trig_Icy_Aura_Lv1_Actions takes nothing returns nothing
        call ForGroupBJ( GetRandomSubGroup(1, GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Icy_Aura_Lv1_Func001001002002))), function Trig_Icy_Aura_Lv1_Func001A )
    endfunction

    //===========================================================================
    function InitTrig_Icy_Aura_Lv1 takes nothing returns nothing
        set gg_trg_Icy_Aura_Lv1 = CreateTrigger(  )
        call TriggerRegisterTimerEventPeriodic( gg_trg_Icy_Aura_Lv1, 2 )
        call TriggerAddAction( gg_trg_Icy_Aura_Lv1, function Trig_Icy_Aura_Lv1_Actions )
    endfunction


    Well, pretty messed up ...

    And now here is my JASS trigger i tried to create for ALL 3 levels:
    Code (vJASS):
    function IcyAura_Conds takes nothing returns boolean
        local integer ICchance
        local integer lv = GetUnitAbilityLevel(GetFilterUnit(), 'B01G') > 0
        if lv == 1 then
            set ICchance = 5
        elseif lv == 2 then
            set ICchance = 10
        elseif lv == 3 then
            set ICchance = 15
        endif
        return lv > 0 and GetRandomInt(1, 100) <= ICchance
    endfunction
    //==========================================================================
    function IcyAura_Acts takes nothing returns nothing
        local effect e
        local unit en
        local unit dum
        local integer lvl = GetUnitAbilityLevel(GetFilterUnit(), 'B01G') > 0
        call ForGroupBJ( GetRandomSubGroup(1, GetUnitsInRectAll(GetPlayableMapRect(),null )))
        if lvl == 1 then
            set en = GetEnumUnit()
            call AddSpecialEffect("Doodads\\Cinematic\\FrostTrapUp\\FrostTrapUp.mdl", GetUnitX(en), GetUnitY(en))
            set dum = CreateUnit(Player(0), 'h01H', GetUnitX(en), GetUnitY(en), 0)
            call UnitApplyTimedLife(dum, 'BTLF', 2.00)
            call UnitAddAbility(dum, 'A02K')
            call SetUnitAbilityLevel(dum, 'A02K', 1)
            call IssueTargetOrder(dum, "thunderbolt", en)
            call TriggerSleepAction(3.0)
            call DestroyEffect(e)
        elseif lvl == 2 then
            set en = GetEnumUnit()
            call AddSpecialEffect("Doodads\\Cinematic\\FrostTrapUp\\FrostTrapUp.mdl", GetUnitX(en), GetUnitY(en))
            set dum = CreateUnit(Player(0), 'h01H', GetUnitX(en), GetUnitY(en), 0)
            call UnitApplyTimedLife(dum, 'BTLF', 2.00)
            call UnitAddAbility(dum, 'A02K')
            call SetUnitAbilityLevel(dum, 'A02K', 2)
            call IssueTargetOrder(dum, "thunderbolt", en)
            call TriggerSleepAction(3.0)
            call DestroyEffect(e)
        elseif lvl == 3 then
            set en = GetEnumUnit()
            call AddSpecialEffect("Doodads\\Cinematic\\FrostTrapUp\\FrostTrapUp.mdl", GetUnitX(en), GetUnitY(en))
            set dum = CreateUnit(Player(0), 'h01H', GetUnitX(en), GetUnitY(en), 0)
            call UnitApplyTimedLife(dum, 'BTLF', 2.00)
            call UnitAddAbility(dum, 'A02K')
            call SetUnitAbilityLevel(dum, 'A02K', 3)
            call IssueTargetOrder(dum, "thunderbolt", en)
            call TriggerSleepAction(3.0)
            call DestroyEffect(e)
        endif
        set e = null
        set en = null
        set dum = null  
    endfunction
    //===========================================================================
    function InitTrig_Icy_Aura takes nothing returns nothing
        local trigger IcyAura = CreateTrigger(  )
        call TriggerRegisterTimerEventPeriodic( IcyAura, 2 )
        call TriggerAddCondition(IcyAura, Condition(function IcyAura_Conds))
        call TriggerAddAction( IcyAura, function IcyAura_Acts )
        set IcyAura = null
    endfunction


    However i do have some problems with the "pick all unit is map that have the buff" part and because of that i need your help ...
    can you guys help me improve this script please ?
     
  18. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    ForGroup goes into a new function, it doesn't run the same function from then on.

    Also, you don't need an if for each level; just set the ability level of the dummy ability to lvl
     
  19. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    =S omg, i don't understand quite well what you mwan =S or i am afraid to do so =s
     
  20. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    Done, this is the best i could do to fix the problem, however i still get errors and it still doesn't work properly ... Any more suggestions ???

    Code (vJASS):
    function IcyAura_Conds takes nothing returns boolean
        local integer ICchance
        local integer lv = GetUnitAbilityLevel(GetFilterUnit(), 'B01G') > 0
        if lv == 1 then
            set ICchance = 5
        elseif lv == 2 then
            set ICchance = 10
        elseif lv == 3 then
            set ICchance = 15
        endif
        return lv > 0 and GetRandomInt(1, 100) <= ICchance
    endfunction
    //==========================================================================
    function Icy_Aura_GroupCall takes nothing returns nothing
        call ForGroupBJ( GetRandomSubGroup(1, GetUnitsInRectMatching(GetPlayableMapRect())), Condition(function IcyAura_Conds), function IcyAura_Acts )
    endfunction
    //==========================================================================
    function IcyAura_Acts takes nothing returns nothing
        local effect e
        local unit en
        local unit dum
        local integer lvl = GetUnitAbilityLevel(GetFilterUnit(), 'B01G') > 0
        if lvl == 1 then
            set en = GetEnumUnit()
            call AddSpecialEffect("Doodads\\Cinematic\\FrostTrapUp\\FrostTrapUp.mdl", GetUnitX(en), GetUnitY(en))
            set dum = CreateUnit(Player(0), 'h01H', GetUnitX(en), GetUnitY(en), 0)
            call UnitApplyTimedLife(dum, 'BTLF', 2.00)
            call UnitAddAbility(dum, 'A02K')
            call SetUnitAbilityLevel(dum, 'A02K', 1)
            call IssueTargetOrder(dum, "thunderbolt", en)
            call TriggerSleepAction(3.0)
            call DestroyEffect(e)
        elseif lvl == 2 then
            set en = GetEnumUnit()
            call AddSpecialEffect("Doodads\\Cinematic\\FrostTrapUp\\FrostTrapUp.mdl", GetUnitX(en), GetUnitY(en))
            set dum = CreateUnit(Player(0), 'h01H', GetUnitX(en), GetUnitY(en), 0)
            call UnitApplyTimedLife(dum, 'BTLF', 2.00)
            call UnitAddAbility(dum, 'A02K')
            call SetUnitAbilityLevel(dum, 'A02K', 2)
            call IssueTargetOrder(dum, "thunderbolt", en)
            call TriggerSleepAction(3.0)
            call DestroyEffect(e)
        elseif lvl == 3 then
            set en = GetEnumUnit()
            call AddSpecialEffect("Doodads\\Cinematic\\FrostTrapUp\\FrostTrapUp.mdl", GetUnitX(en), GetUnitY(en))
            set dum = CreateUnit(Player(0), 'h01H', GetUnitX(en), GetUnitY(en), 0)
            call UnitApplyTimedLife(dum, 'BTLF', 2.00)
            call UnitAddAbility(dum, 'A02K')
            call SetUnitAbilityLevel(dum, 'A02K', 3)
            call IssueTargetOrder(dum, "thunderbolt", en)
            call TriggerSleepAction(3.0)
            call DestroyEffect(e)
        endif
        set e = null
        set en = null
        set dum = null  
    endfunction
    //===========================================================================
    function InitTrig_Icy_Aura takes nothing returns nothing
        local trigger IcyAura = CreateTrigger(  )
        call TriggerRegisterTimerEventPeriodic( IcyAura, 2 )
        call TriggerAddCondition(IcyAura, Condition(function IcyAura_Conds))
        call TriggerAddAction( IcyAura, function Icy_Aura_GroupCall )
        set IcyAura = null
    endfunction