HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

More then 1 event in 1 Scope

01-29-2008, 02:26 PM#1
Gwypaas
Is it possible to have more then 1 event inside a scope? I need to have events that runs 3 different actions to make my spell working. Right now im using 3 different librarys to get it all working but that's not perfect.
01-29-2008, 03:00 PM#3
tamisrah
What the heck are you trying to do? (=> post trigger code)

If this is what you want to know, this works perfectly fine:
Collapse JASS:
scope blubb
function InitTrig_NewTrigger takes nothing returns nothing
    call TriggerRegisterAnyUnitEventBJ( ... )
    call TriggerRegisterBuildSubmenuEventBJ( ... )
    call TriggerRegisterDeathEvent( ... )
    call TriggerRegisterDestDeathInRegionEvent( ... )
    call TriggerRegisterTrackableTrackEvent( ... )
endfunction
endscope
01-29-2008, 03:08 PM#4
Gwypaas
I have a spell. Inside that spell I need 3 different events that causes 3 different actions to run.
01-29-2008, 03:16 PM#5
tamisrah
You may create as many triggers as you want. If you want three events to be registered with one unique reaction each just create three triggers and you done.

I think you misunderstood what a scope actually is, else I just don't get what you're asking.
01-29-2008, 03:29 PM#6
Gwypaas
What I want to know if I can have 3 different events that runs 3 different actions in same scope block. And if you are able to can you please show me an example? I'm not 100% sure on how it works because scopes must have the same name as the trigger and if it doesn't the trigger won't run at all. That's why im asking.
01-29-2008, 03:52 PM#7
Zandose
I can't use the editor right now, but you should understand I think. You make the three triggers in one function.
Collapse JASS:
scope test

private function Actions1 takes nothing returns nothing
    //Actions...
endfunction
private function Actions2 takes nothing returns nothing
    //Actions...
endfunction
private function Actions3 takes nothing returns nothing
    //Actions...
endfunction
private function Conditions1 takes nothing returns nothing
    return //Condition...
endfunction
private function Conditions2 takes nothing returns nothing
    return //Condition...
endfunction
private function Conditions3 takes nothing returns nothing
    return //Condition...
endfunction

public function InitTrig takes nothing returns nothing
    local trigger t
    //You can also create seperate trigger variables for each trigger/condition/action.
    //local t1 = CreateTrigger()
    //local t2 = CreateTrigger()
    //call AddEvent(t1, EVENT_TYPE)
    //call AddCondition(t1, Condition(function Conditions1))
    //call AddActions(t1, Function Action1)
    //call AddEvent(t2, EVENT_TYPE)
    //call AddCondition(t2, Condition(function Conditions2))
    //call AddActions(t2, Function Action2)
    //------------------------------------------------
    set t = CreateTrigger() //New ID.
    call AddEvent(t, EVENT_TYPE)
    call AddCondition(t, Condition(function Conditions1))
    call AddActions(t, Function Action1)
    //------------------------------------------------
    set t = CreateTrigger() //New ID.
    call AddEvent(t, EVENT_TYPE)
    call AddCondition(t, Condition(function Conditions2))
    call AddActions(t, Function Action2)
    //------------------------------------------------
    set t = CreateTrigger() //New ID
    call AddEvent(t, EVENT_TYPE)
    call AddCondition(t, Condition(function Conditions3))
    call AddActions(t, Function Action3)
endfunction

endscope
01-29-2008, 08:33 PM#8
Gwypaas
+Rep for you (If im able to :D)

Now I have another problem in this function:

Collapse JASS:
private function ActionsDD takes nothing returns nothing
    local LunarUserData d
    local group g = udg_LunarGroup
    local group g2 = CreateGroup()
    local integer i = 0
    local unit u
    local integer UnitsGroup = CountUnitsInGroup(g)
    local integer tmp
    local integer tmp1
    local integer tmp2
    loop
        exitwhen i > UnitsGroup
        set u = FirstOfGroup(g)
        set d = GetUnitUserData(u)
        set d.CurrHP = GetUnitState(u, UNIT_STATE_LIFE)
        
        if (d.CurrHP < d.LastHP and d.DamageTT > 0) then
            set d.DD = d.LastHP - d.CurrHP
            set tmp = d.DamageTT-R2I(d.DD)
            set tmp1 = RMaxBJ(0.0,tmp)
            set tmp2 = tmp1-tmp
            
            //call SetUnitState(u, UNIT_STATE_LIFE, d.DD)
        endif
        
        call GroupAddUnit(g2,u)
        call GroupRemoveUnit(g, u)
        set i = i+1
    endloop
    call DestroyGroup(g)
    set g = null
    call DestroyGroup(g2)
    set g2 = null
endfunction
When I run Wc3 in debug mode it says im trying to remove a group twice everytime it runs.
01-29-2008, 09:03 PM#9
Zandose
I think your missing some stuff there. Post the full function and struct. Also, why are you using udg_LunarGroup, no NewGen WE?

Off-Hand: Does the first unit in a unitgroup start at 0, and should "exitwhen i > UnitsGroup" be "exitwhen i = UnitsGroup"?
01-29-2008, 10:46 PM#10
TaintedReality
We need to know what udg_LunarGroup is. Do you ever create it again after destroying it? You destroy LunarGroup every time this function is run, and my guess is that it's never recreated.

Also, there's no need for the i variable. Instead of counting the units in the group, you can just use "exitwhen u==null" after the "set u = FirstOfGroup(g)" line, because that means there are no more units in the group.

Quote:
Off-Hand: Does the first unit in a unitgroup start at 0, and should "exitwhen i > UnitsGroup" be "exitwhen i = UnitsGroup"?

The function is CountUnitsInGroup, so if there's 1 unit in the group, then it returns 1, and if there's no units, then 0. However, he IS looping one too many times (I think), but he shouldn't be looping that way anyways.
01-30-2008, 08:50 AM#11
Gwypaas
Ok when I get home ill try to set i = 1.
And the udg_Lunar group is just the group it runs on. I made it like that because I don't know if they are going to use NewGen when they create the initializing triggers and it's easy to change :P
01-30-2008, 07:46 PM#12
TaintedReality
Quote:
Ok when I get home ill try to set i = 1.

There's no reason to use i at all. Read my previous post ^^.
Quote:
And the udg_Lunar group is just the group it runs on. I made it like that because I don't know if they are going to use NewGen when they create the initializing triggers and it's easy to change :P

But do you ever recreate it after this function? If it's just created once at the start of the map, then you destroy it each time this function is run, that's not going to work so well.