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

[JASS] Spells Problem 3 (difficult = medium-low hight)

Status
Not open for further replies.
Hi guys, I have this trigger in GUI:

  • 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
              • 5 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
And this it's converted JASS format:

JASS:
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 ( 5 >= 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

Now, every1 knows this is not efficient. Trying to solve that i created the following trigger:

JASS:
function IcyAura_Conds takes nothing returns boolean  
    local integer ICchance = 5 
    local integer lv = GetUnitAbilityLevel(GetFilterUnit(), 'B01G')  
    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')  
    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)  
    endif  
    set e = null  
    set en = null  
    set dum = null 
endfunction 
//========================================================================== 
function Icy_Aura_GroupCall takes nothing returns nothing  
    call ForGroup( GetRandomSubGroup(1, GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function IcyAura_Conds))), function IcyAura_Acts ) 
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

Now this trigger is for LEVEL ONE only ... but it does NOT work ... i already asked for help that my problem continues ... nothign happens, the spell does nothing ... which is bad ...

I tried to make a trigger for all 3 levels, but because i couldn't do so, now i as for your help to do a trigger for level 1 ... please ... Maybe if i figure out how to make it work for level , i may be able to make it work for all 3 levels.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
JASS:
function check takes nothing returns boolean
if UnitHasBuffBJ(GetFilterUnit(),'B01G') then
return true
else
return false
endif
endfunction

function IcyAura_Acts takes nothing returns nothing
local unit en
local group g
local effect e
local unit dum
local integer a = 5
local integer b = GetRandomInt(0,100)
call GroupEnumUnitsInRect(g,GetEntireMapRect(),Filter(function check))
set en = GroupPickRandomUnit(g)
if (en == null) == false and a>b then
set e = 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)  
endif
endfunction

 
//=========================================================================== 
function InitTrig_Icy_Aura takes nothing returns nothing  
    local trigger IcyAura = CreateTrigger( )  
    call TriggerRegisterTimerEventPeriodic( IcyAura, 2 )  
    call TriggerAddAction( IcyAura, function IcyAura_Acts )  
    set IcyAura = null 
endfunction

Try this one
EDITED (I forgot the chance :D added now)
Hmm delete the chance thing for testing please as you know %5 is too low and you may wait 10-20 minutes :D

And Give me a contact info like MSN there are easier ways to make these kind of things but we cant discuss them here
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Need_O2, why don't you indent stuff? It makes it much pwettier -.-

Anyways, here's an optimized version; (your version also had a bug which would cause it not to work)

JASS:
function check takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(),'B01G') > 0
endfunction

function IcyAura_Acts takes nothing returns nothing
    local unit en
    local group g = CreateGroup()
    local effect e
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,Filter(function check))
    set en = GroupPickRandomUnit(g)
    if en != null and GetRandomInt(0,100)<5 then
        set e = 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)
        call UnitAddAbility(dum, 'A02K')
        call IssueTargetOrder(dum, "thunderbolt", en)
        call TriggerSleepAction(3)
        call DestroyEffect(e)
        set e = null
        set en = null
    endif
    call DestroyGroup(g)
    set g = null
endfunction

function InitTrig_Icy_Aura takes nothing returns nothing
    set gg_trg_Icy_Aura = CreateTrigger()
    call TriggerRegisterTimerEvent( gg_trg_Icy_Aura, 2, true )
    call TriggerAddAction( gg_trg_Icy_Aura, function IcyAura_Acts )
endfunction
 
Thx =) for your help guys. Need_O2, thx for trying ... i actually don't have an MSN for Warcraft ... I just have huge problems getting one (it seems it never works, no matter what i do) but i can give you my clans e-mail, with Gmail, that enables people to talk just like MSN: F l a m e . P h o e n i x . s o r (weird A) g m a i l . c o m

Remove the spaces to get my e-mail. Also "(weird A) = @". All this stuff with my e-mail is to prevent bots from stalking me or stealing my e-mail for unknown purposes (Thx PurplePoot, he told me this :piru: ).

Also, i would like to have a look, on your hero sysetm O2.
+rep for helping me.

PurplePoot, thx again. I will rep+ you if i can (i am trying to give you rep points since november 1945 but somehow i just can't ... dam the system lol).
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
heyya poot I actually didnt get on it
just worked for 1min or less sorry :/ I was so confused with other things
 
Level 5
Joined
Sep 19, 2006
Messages
152
If you want a 5% chance, you could even use
if GetRandomInt (1, 20) == 1 then.....

PurplePoot, I dont' think I've come across the "if en != null" command yet What does it mean?
 
First i know that != is not equal ... lol ... i am actually learning how to make programs in my university (i wanna be a programmer when i grow up !!! yeee !!!), lol so even if maths are difficult and some times complicated, it is something i really wanna do ... and know what "!=" is, is basic (I think).

About the chances ... werrmm i don't remember if i set them to 100% ... i will do that today (probably) i see what happens.

PS: Thx to PP and to all other mods, that somehow contributed for me to learn JASS, thus making for me a lot easier to learn JAVA and introducing me that way, to the world of programing :piru: .
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Flame_Phoenix said:
First i know that != is not equal ... lol ... i am actually learning how to make programs in my university (i wanna be a programmer when i grow up !!! yeee !!!), lol so even if maths are difficult and some times complicated, it is something i really wanna do ... and know what "!=" is, is basic (I think).
PurplePoot said:
DistantHaze, != means Not Equal.
DistantHaze said:
PurplePoot, I dont' think I've come across the "if en != null" command yet What does it mean?
Bleh .
 
Status
Not open for further replies.
Top