Trigger 'boss' ability

malfy

New Member
Reaction score
4
I made a boss hero with a single level unit ability based on 'Holy Light' and the purpose is to be a self heal for the boss. I made it so that it cant target self (and it works properly) and changed the OrderId string to 'farsight'

Then I made the following trigger in gui, changed it to custom text and filled in the order with the 'farsight' string. Now the trigger is functioning and the boss uses it on himself basically everytime the cooldown is up, however the problem is the FIRST time he uses the ability is life is not yet under the value on the trigger condition "22000.00." The boss units hp is 35500 and he uses the heal the first time when his hp is around 30000.

now that this trigger is not in gui i no longer understand it, so like what would I have to do to make it so that the first heal doesnt happen until his life is less than 22000?

JASS:
function Trig_boss_protect_2_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'Hart' ) ) then
        return false
    endif
    return true
endfunction

function Trig_boss_protect_2_Func001001 takes nothing returns boolean
    return ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) < 22000.00 )
endfunction

function Trig_boss_protect_2_Actions takes nothing returns nothing
    if ( Trig_boss_protect_2_Func001001() ) then
        call IssueTargetOrderBJ( GetTriggerUnit(), "farsight", GetTriggerUnit() )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_boss_protect_2 takes nothing returns nothing
    set gg_trg_boss_protect_2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_boss_protect_2, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_boss_protect_2, Condition( function Trig_boss_protect_2_Conditions ) )
    call TriggerAddAction( gg_trg_boss_protect_2, function Trig_boss_protect_2_Actions )
endfunction
 

PrisonLove

Hard Realist
Reaction score
78
Try this, it should work:

JASS:
function Trig_boss_protect_2_Conditions takes nothing returns boolean
    return GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE)) < 22000.00
endfunction

function Trig_boss_protect_2_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    call IssueTargetOrder( u, "farsight", u )
    set u = null
endfunction

//===========================================================================
function InitTrig_boss_protect_2 takes nothing returns nothing
    set gg_trg_boss_protect_2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_boss_protect_2, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_boss_protect_2, Condition( function Trig_boss_protect_2_Conditions ) )
    call TriggerAddAction( gg_trg_boss_protect_2, function Trig_boss_protect_2_Actions )
endfunction
 

Jesus4Lyf

Good Idea™
Reaction score
397
Try this, it should work
Neatening code and removing the [LJASS]GetUnitTypeId(GetTriggerUnit()) == 'Hart'[/LJASS] does not give the impression that it should suddenly work. It gave me the impression it should suddenly break things. I do not think there is any problem in the trigger (but have no idea why you converted it to custom text, you can do all that in GUI) - I think it is a problem that neutral units will automatically cast certain spells. Try removing the ability until the unit's life drops below 22000.
 

Hatebreeder

So many apples
Reaction score
381
Whats with the GUI to Jass convert?
Anyways, that DoNothing() does nothing, so remove the else section so you have:

JASS:
 if YOURCONDITIONTRIGGER then
   //do your actions
endif


Or just remove the whole senceless if/then/else action.
 

PrisonLove

Hard Realist
Reaction score
78
Neatening code and removing the [LJASS]GetUnitTypeId(GetTriggerUnit()) == 'Hart'[/LJASS] does not give the impression that it should suddenly work. It gave me the impression it should suddenly break things. I do not think there is any problem in the trigger (but have no idea why you converted it to custom text, you can do all that in GUI) - I think it is a problem that neutral units will automatically cast certain spells. Try removing the ability until the unit's life drops below 22000.

Actually, it should work if you think about it logically. The trigger will only fire if the Boss is attacked and his health is below 22000. I removed the [LJASS]GetUnitTypeId(GetTriggerUnit()) == 'Hart'[/LJASS] because the spell event was not ability based, therefore there was no need for it.

With this current trigger, it should fire every time the boss is attacked, while his health is below 22000. Obviously if the spell is on cooldown, it will not fire.

It should in no way break things, as this trigger does the same thing as the old one, only neatens it up and removed an unnecessary condition. How would making code neater break something anyway? That makes no logical sense, if anything it can only make it better if done correctly.

You may be correct that neutral (and computer controlled units in general) tend to cast certain spells at any time, but if the spell is custom, that should not happen anyway.

Quite frankly, the spell should have worked in the first place, I don't see why it broke, but have a go with the neater version and test it out. If it doesn't work then, oh well, we'll try again.
 

saw792

Is known to say things. That is all.
Reaction score
280
You may be correct that neutral (and computer controlled units in general) tend to cast certain spells at any time, but if the spell is custom, that should not happen anyway.

But it does happen, and will happen. It's a part of the inbuilt AI for neutral units that they automatically cast appropriate spells at certain times. We can only assume that the game checks the base order id of the abilities the unit has before deciding when to cast them, so this really has nothing to do with it being a custom ability or not. Just do what Jesus4Lyf said.
 

PrisonLove

Hard Realist
Reaction score
78
Well, when you create a custom ability, the computer never casts that ability on its own. They only cast it when you modify a pre-existing ability.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
That's not always true...I've had a neutral dummy unit cast a custom Finger of Death on its own.
 

PrisonLove

Hard Realist
Reaction score
78
Really? Because I have NEVER seen a computer cast a custom spell before. Are you sure it wasn't a modified version of the original Finger of Death spell?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top