Question about enabling triggers and more...

Magoiche

Member
Reaction score
20
1. Is there a way to enable a trigger inside the same script?

Example triggers:

JASS:
scope lol initializer Initial


private function Actions takes nothing returns nothing
    call EnableTrigger( gg_trg_Untitled_Trigger_002 )
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


JASS:
scope lol2 initializer Initial


private function Actions takes nothing returns nothing
    call EnableTrigger( gg_trg_Untitled_Trigger_003 )
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


But i can only do that is they are in diferent triggers(CTRL + T)
There is a way to do it in the same trigger?

2. GetUnitsInRangeOfLocMatching, CountUnitsInGroup, GroupPickRandomUnit, GetUnitsInRangeOfLocMatching inline or use them?

3. What is a boolexpr? And a pooledwait?

4. Why those trigger don't work?

JASS:
scope DarkRageInitial initializer Initial

globals
    integer AttacksNumberCounter = 0
    unit Caster = GetTriggerUnit()
endglobals

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A007'
endfunction

private function Actions takes nothing returns nothing
    call EnableTrigger( gg_trg_Untitled_Trigger_002 )
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


JASS:
scope DarkRageAttacks initializer Initial

private function TargetAndGroupConditions takes nothing returns boolean
    return IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( Caster ) ) == true and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE ) == false and GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) <= 0
endfunction

private function DarkRageAttack takes nothing returns nothing
    local location CasterLoc = GetUnitLoc( Caster )
    local group PossibleTargets = GetUnitsInRangeOfLocMatching(500.00, CasterLoc, Condition( function TargetAndGroupConditions ) )
    local integer NOfPossibleTargets = CountUnitsInGroup(PossibleTargets)
    local unit Target = GroupPickRandomUnit( GetUnitsInRangeOfLocMatching(500.00, CasterLoc, Condition( function TargetAndGroupConditions ) ) )
    local location TargetLoc = GetUnitLoc( Target )
    local real x = GetLocationX( TargetLoc ) + 50.00 * Cos(GetRandomReal(0, 360) * bj_DEGTORAD)
    local real y = GetLocationY( TargetLoc ) + 50.00 * Sin(GetRandomReal(0, 360) * bj_DEGTORAD)
    local location AttackLandingLoc = Location(x,y)
    set AttacksNumberCounter = ( AttacksNumberCounter + 1 )
    if ( NOfPossibleTargets == 0 ) then
    else
        call UnitDamageTarget( Caster, Target, 300.00, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_LIGHT_CHOP )
        call SetUnitPositionLoc( Caster, AttackLandingLoc )
    endif
endfunction

private function DarkSlamUse takes nothing returns nothing
    local real x = GetUnitX( Caster )
    local real y = GetUnitY( Caster )
    local unit Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u001', x, y, 0.00 )
    call UnitApplyTimedLife( Dummy, 'BTLF', 5.00 )
    call UnitAddAbility( Dummy, 'A006' )
    call SetUnitAbilityLevel( Dummy, 'A006', 2 )
    call IssueImmediateOrder( Dummy, "thundercalp" )
    call DestroyEffect( AddSpecialEffectLoc( "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", GetUnitLoc( Dummy ) ) )
    set Dummy = null
endfunction

private function ZeroAttacksNumberCounter takes nothing returns nothing
    set AttacksNumberCounter = 0
endfunction

private function Actions takes nothing returns nothing
    if (AttacksNumberCounter == ( 1 + ( 2 * GetUnitAbilityLevel( Caster, 'A007' ) ) ) ) then
        call ZeroAttacksNumberCounter()
        if ( GetUnitAbilityLevel( Caster, 'B004' ) > 0 ) then
            call EnableTrigger( gg_trg_Untitled_Trigger_003 )
        endif
        call DarkSlamUse()
    else
        call DarkRageAttack()
    endif
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterTimerEvent( trig, 0.45, true )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


JASS:
scope DarkRageInsanityShout initializer Initial

private function Actions takes nothing returns nothing
    local real x = GetUnitX( Caster )
    local real y = GetUnitY( Caster )
    local unit Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u001', x, y, 0.00 )
    if ( GetUnitAbilityLevel( Caster, 'B004' ) > 0 ) then
    call UnitApplyTimedLife( Dummy, 'BTLF', 5.00 )
    call UnitAddAbility( Dummy, 'A006' )
    call SetUnitAbilityLevel( Dummy, 'A006', 2 )
    call IssueImmediateOrder( Dummy, "stomp" )
    call DestroyEffect( AddSpecialEffectLoc( "Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl", GetUnitLoc( Dummy ) ) )
    endif
    set Dummy = null
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterTimerEvent( trig, 0.45, false )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


My bet is that there is no TriggerUnit so Caster = null.
But if its realy this i don't know how to make it. i.i
I was tinking if i make it a loop with wait will be better than a periodic event but not sure.

Sorry if i am asking to much. =/
 
Reaction score
341
Is there a way to enable a trigger inside the same script?

You could add a boolean check,

JASS:
private function test takes nothing returns boolean
    return someboolvar == true
endfunction

TriggerAddCondition(gg_trg_Untitled_Trigger_002 ,Condition(function test))



Just set the boolean to true or false, if you want the trigger on or off.

And a pooledwait?

Like TriggerSleepAction().

Why those trigger don't work?

I Woudn't initialize this

JASS:
unit Caster = GetTriggerUnit()


You could give some information about how it's not working (whats wrong).
 

Magoiche

Member
Reaction score
20
It just don't works.
I use the spell and nothing happens.
i.i

And about the trigger enabling.
If i want to change the name how i do that(Assuming that they all are in the same trigger)?

Another question(x.x):

This trigger works perfectly.
But the Actions function is executed if i order the unit to stop or hold position.

JASS:
scope InsanityDeactivation initializer Initial

private function Conditions takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local trigger trig = GetTriggeringTrigger()
    if GetIssuedOrderId() == OrderId( "unimmolation" ) then
        set trig = null
        return true
    elseif GetIssuedOrderId() == OrderId( "immolation" ) then
        call TriggerRegisterUnitStateEvent( trig, u, UNIT_STATE_MANA, LESS_THAN_OR_EQUAL, 1.00)
        set trig = null
        return false
    endif
    return true
endfunction
    
private function Actions takes nothing returns nothing
    call UnitRemoveAbility( GetTriggerUnit(), 'A005' )
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


Why? Where is the error?
 

saw792

Is known to say things. That is all.
Reaction score
280
Have a look at your Conditions function. First you check if the order given was turning off immolation. If it was, you return true, so the actions run. If it isn't unimmolation, then you check if it was immolation. If it was, you return false, so the actions run. If it isn't, you then return true. For every single other order. That means the actions run for every single other order (well, orders with no target anyway).
 

Magoiche

Member
Reaction score
20
I don't have time right now because i will go to sleep.
I will put a return false after the endif.

Thanks TriggerHappy and saw792.

Oh and Happy New Year(I am in 2009 already xD)
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
1) Just use GetTriggeringTrigger()
And you can't use the global gg_trg_Untitled_Trigger_002 since you don't set your created trigger with it.
But anyway don't use it, because if you will change the name of your trigger you will change the global name as well...
If you need to keep the control of your trigger outside the scope, you must use a global/englobal block inside your scope.

2) Inline them, or at least make your own functions, because a null argument in an enum function leak, true story ...
You need to use a boolexpr witch return true instead of simply use null.

http://www.wc3campaigns.net/showthread.php?t=101248

3) A boolexpr is a Condition or a Filter of a function witch return a boolean.

Extract of common.j :

JASS:
type boolexpr           extends     handle
type conditionfunc      extends     boolexpr
type filterfunc         extends     boolexpr

native Condition        takes code func returns conditionfunc
native Filter           takes code func returns filterfunc


Handle is the "father" type of all types except theses ones (integer,boolean,code,real,string).

There are other function like "And" witch returns a boolexpr but you shouldn't use them, i mean at least not yet, learm more things about the jass before.

In fact for a boolexpr argument you can use Filter or Condition, but to follow the jass convention you should use Filter for Enum,Filter groups,force and so one.
And Condition for trigger conditions, anyway you must use Condition for a trigger condition if you want to remove it this one specific later.


4 ) A PolledWait is a blizzard function , it use a "short" timer periodic + TriggerSleepAction.
If the game is paused, the timers are paused as well, but not TriggerSleepAction.
So the point of that function is to use an easy wait witch be paused when the game is paused.
It is innacurate (~ +/- 0.2 s) and leaks a non null handle, but it's easy to use.
Also the minimum wait possible is ~ +/- 0.2 s

If you need precision or waits under 0.2 s, use a timer instead, but it's far away more complicated.
 

Magoiche

Member
Reaction score
20
No. You not wasted your time because you are the only one who answered me about the booexpr, the Bjs and the pooled wait. So thanks =]

Now with the mana event:

I tried to put return false after the endif but now the mana event don't run x.x
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top