TriggerRegisterUnitStateEvent problem

Magoiche

Member
Reaction score
20
I made this trigger to remove the spell when deactivate the skill.
But now i noticed that if the mana ends the skill is deactivated but the other skill don't get removed. x.x

I tried to the trigger to run too when the unit as 6 mana or less.

JASS:
scope InsanityDeactivation initializer Initial

private function Conditions takes nothing returns boolean
    if ( GetIssuedOrderId() == String2OrderIdBJ("unimmolation") ) then
        return true
    else
        return false
    endif
endfunction

private function Actions takes nothing returns nothing
    call UnitRemoveAbility( GetTriggerUnit(), 'A005' )
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local unit u = GetTriggerUnit()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerRegisterUnitStateEvent( trig, u, UNIT_STATE_MANA, LESS_THAN_OR_EQUAL, 6.00 )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


But it just don't work(The mana part). Why?


Quick Questions

1. String2OrderIdBJ its better use it or inline it?

2. CreateNUnitsAtLoc its better use it or inline it?

3. Whats better/faster?

I.
JASS:

if something then
return true
else
return false
endif


or

II.
JASS:

if something then
return true
endif
return false


Thanks =}
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
But it just don't work(The mana part). Why?
Because GetIssuedOrderId() == 0 with the mana event, so your condition return false, you need to check witch event fire the trigger in your condition, with the function GetTriggerEventId()

1. String2OrderIdBJ its better use it or inline it?
It is one of the useless BJ, so yes use the native one instead

2. CreateNUnitsAtLoc its better use it or inline it?
Most of the time you need to create one unit, so in this case the native one is ofc the best, but if you want to create many i would say why not use this one.
But honestly using locations are in most of cases just useless (need to manage leaks and simply useless since there are the same functions with X/Y arguments witch are faster).
There are only two cases you need a location :

1) GetSpellTargetLoc
2) GetLocationZ

And for the terrain height you can use a global location and the function MoveLocation, instead of create/destroy an other location

3. Whats better/faster?
It should be exactly the same, just choice witch one you prefer.
 

Magoiche

Member
Reaction score
20
I didn't find the native for String2OrderIdBJ.
What is it?

Here shows this:

JASS:
function String2OrderIdBJ takes string orderIdString returns integer
    local integer orderId
    
    // Check to see if it's a generic order.
    set orderId = OrderId(orderIdString)
    if (orderId != 0) then
        return orderId
    endif

    // Check to see if it's a (train) unit order.
    set orderId = UnitId(orderIdString)
    if (orderId != 0) then
        return orderId
    endif

    // Unrecognized - return 0
    return 0
endfunction


About the GetTriggerEventId().
0 will be the first event? In this case TriggerRegisterAnyUnitEventBJ.
Right?
 

Magoiche

Member
Reaction score
20
*autoheadshot*

...
Sorry for that. It was in my face and i don't see it. x.x
Ty

But what about the GetTriggerEventId()?
About the GetTriggerEventId().
0 will be the first event? In this case TriggerRegisterAnyUnitEventBJ.
Right?
 

Azlier

Old World Ghost
Reaction score
461
A serious problem is that the unit you are specifying the event to run for is, for some reason, GetTriggerUnit. In the Initial function. There is no GetTriggerUnit for this function.
 

Magoiche

Member
Reaction score
20
hmmm... lol?

There is no GetTriggerUnit in the initial trigger?
The triggerunit apears where? conditions? x.x

Also thanks Troll-Brain for the GetTriggerEventId help.
 

Azlier

Old World Ghost
Reaction score
461
You use GetTriggerUnit() in the Initial function. No, GetTriggerUnit() does not return the unit that's in your head. In this case, it returns... null?
 

emjlr3

Change can be a good thing
Reaction score
395
your trigger is incomplete, you do nothing if its the mana event, and use some phantom triggerunit

what you need is something like...

JASS:
scope InsanityDeactivation initializer Initial

private struct data
    unit u
    timer t

    method onDestroy takes nothing returns nothing
        call ReleaseTimer(.t)
    endmethod
endstruct

private function Check takes nothing returns nothing
    local data d = GetCSData(GetExpiredTimer())

    if GetUnitState(d.u,UNIT_STATE_MANA)<=6 then // your mana check
        call UnitRemoveAbility(d.u,'A005')
        call d.destroy()
    elseif GetUnitAbilityLevel(d.u,'A005')<1 then // incase our order trigger removed it
        call d.destroy()
    endif
endfunction
private function Conditions takes nothing returns boolean
    local data d

    if GetIssuedOrder() == "unimmolation"  then
        call UnitRemoveAbility( GetTriggerUnit(), 'A005' )
    elseif GetIssuedOrder() == "immolation"
        // since your removing it at some point and I assume you add it initially, lets do some fun stuff here to run the mana check
        set d = data.create()
        set d.t = NewTimer()
        set d.u = GetTriggerUnit()
        call TimerStart(d.t,.2,true,function Check)
        call SetCSData(d.t,d)

        call UnitAddAbility(d.u,'A005')
    endif

    return false
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 ) )
endfunction

endscope
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
@emjlr3 : you have forgotten to say that you are using the library TimerUtils in your example.
And also CS_data, but i dunno about that, i don't use it.
 

Magoiche

Member
Reaction score
20
Hmmm...

Thanks for the trying to help emjlr3
But... Let me say what happened to my brain when i saw your post.

My Brain:

Before: ##
After: &%

x.x
Thanks anyway. I will save it and see if a can learn something later when i finish this trigger.

But now... about the GetTriggerUnit()...
What should i do about that?
A global var(i don't think so i.i)?

Sorry people but i am realy lost at this pont x.x
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
if it's an preplaced unit on the map, you need to select it with a gui action, convert it in jass and copy/paste the global variable.
It will be something like that :

gg_unit_<unitId>_<number>

EDIT : Or you want it for all unit preplaced in the map and will be created after ?
 

Magoiche

Member
Reaction score
20
Right now its a prepaced unit. but its just for testing.
After(in the oficial map) it will be created later.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Right now its a prepaced unit. but its just for testing.
After(in the oficial map) it will be crated later.
Then you have to add the event later in game, since it is a specific unit event.
You can copy the gui fonction to have an idea of how to do it.

And so you need to refer your trigger with a global variable.
 

Magoiche

Member
Reaction score
20
How do i add a event "later"?
copy the gui function... ok... but... what function? the specifc unit event?
 

Magoiche

Member
Reaction score
20
Thanks people you helped me alot.
I learned some things but there still more to learn.

Like:

Why this trigger don't work?

JASS:
scope InsanityShoutDeath initializer Initial

private function Conditions takes nothing returns boolean
    return GetUnitTypeId( GetTriggerUnit() ) == &#039;H000&#039; and GetUnitAbilityLevel( GetTriggerUnit(), &#039;A004&#039; ) &gt; 0
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX( u )
    local real y = GetUnitY( u )
    call CreateUnit( GetOwningPlayer( u ), &#039;u001&#039;, x, y, 0.00 )
    call UnitApplyTimedLife( bj_lastCreatedUnit, &#039;BTLF&#039;, 5.00 )
    call UnitAddAbility( bj_lastCreatedUnit, &#039;A006&#039; )
    call SetUnitAbilityLevel( bj_lastCreatedUnit, &#039;A006&#039;, 2 )
    call IssueImmediateOrder( bj_lastCreatedUnit, &quot;stomp&quot; )
    call AddSpecialEffectLoc( &quot;Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl&quot;, GetUnitLoc( bj_lastCreatedUnit ) )
    call DestroyEffect( bj_lastCreatedEffect )
endfunction

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

endscope


when it reach the Timedlife it "stops".

Why?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
bj_ are globals variables using by gui functions.
But the native CreateUnit returns an unit.

So you can do it :

JASS:
local unit u
set u = CreateUnit(...)


or a global unit variable ofc.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • 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 Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top