TriggerRegisterUnitStateEvent problem

Magoiche

Member
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.
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
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
*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
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
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
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
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.
@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
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.
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 ?
 

Troll-Brain

You can change this now in User CP.
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
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() ) == 'H000' and GetUnitAbilityLevel( GetTriggerUnit(), 'A004' ) &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 ), 'u001', x, y, 0.00 )
    call UnitApplyTimedLife( bj_lastCreatedUnit, 'BTLF', 5.00 )
    call UnitAddAbility( bj_lastCreatedUnit, 'A006' )
    call SetUnitAbilityLevel( bj_lastCreatedUnit, 'A006', 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.
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.
  • tom_mai78101 tom_mai78101:
    Would like to get some annual forum statistics report.
  • The Helper The Helper:
    there are stats in the xenforo forum admin section and we have matomo stats we started collecting beginning of the year so we will not have annual on that until next year
  • The Helper The Helper:
    I thought you had keys to the bathroom Tom? Ghan does Tom have access to the stats thread in the bathroom
  • The Helper The Helper:
    since I started jacking with the bots on the site we doubled our page views on the site in a week lol
  • The Helper The Helper:
    I have been having lots of fun
  • The Helper The Helper:
    we have had like 6000 views of the American Airlines economy class thread in the last week
  • The Helper The Helper:
    I ought to stick a travel affiliate link or something on that page to try and monetize that they are just going there and leaving it might even be bots I am not sure
  • The Helper The Helper:
    I just got into it with the Atari VCS Facebook Moderator I started trolling him and almost got banned
  • The Helper The Helper:
    They deleted one of my posts one time so I was trolling him on a help post I put up because I am evil I guess and bored and the guy handled it well I loved his attitude Atari has a good social media presence even if they do not have many games.
  • The Helper The Helper:
    The French Atari they call them even though they are like totally based in America they just have French Money coming in. Gotta love it
  • Ghan Ghan:
    Microsoft buying Activision Blizzard holy crap!
  • The Helper The Helper:
    I know right holy cow
  • Accname Accname:
    Thats not going to save it.
  • The Helper The Helper:
    It might
  • The Helper The Helper:
    They are going to use alot of that IP in the Metaverse
  • The Helper The Helper:
    I found a new section of the stats that is freaking interesting!
  • The Helper The Helper:
    oh yeah this is what I was looking for good job matomo! These are some sweet stats I am learning the interface on it too!
  • The Helper The Helper:
    If anyone ever asks later how I found out about it was watching the site bots but not watching what they were doing but asking myself why they were here?
  • The Helper The Helper:
    there must be a reason and ok that is it
  • The Helper The Helper:
    the past and the future all come together into one
  • The Helper The Helper:
    the search engines are what built thehelper.net the search engines will make it big again maybe
  • The Helper The Helper:
    the real question is are 5 million links better than 60 real good links?
  • The Helper The Helper:
    the answer is 60 lol
  • The Helper The Helper:
    unless you put 100k links on it lol then you get something

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top