Simple Restore Health Trigger

Beetlebomb

New Member
Reaction score
43
Nope, that didn't seem to help it. However, I'll still keep the InitTrig part in there as a precaution. Thank you

Anyone else have any idea? Emjlr3? ^^
 

saw792

Is known to say things. That is all.
Reaction score
280
What is the name of the trigger in the left-hand pane?
 
Reaction score
341
... You don't know the name of your trigger?.... The name on the left side of the editor , that you defined ( or didn't , if not it should be Untitled_trigger_###) , by the little white paper icon.
 

emjlr3

Change can be a good thing
Reaction score
395
i dont have a comp with the WE, I cant do shit with this, sry
 

Beetlebomb

New Member
Reaction score
43
... You don't know the name of your trigger?.... The name on the left side of the editor , that you defined ( or didn't , if not it should be Untitled_trigger_###) , by the little white paper icon.

Of course I know what that was. Just my lack of common vocabulary didn't explain what a pane was(Which I know now).

The name of the trigger is Restore.

Appreciate the time put into helping me, everyone.

Beetlebomb

Edit: Is there another alternative I could take so I wouldn't have to bother with naming this preset unit? It seems like this is taking way more time then it should.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Edit: Is there another alternative I could take so I wouldn't have to bother with naming this preset unit? It seems like this is taking way more time then it should.

That's the wonders of vJASS :p

With vJASS you can name your triggers and functions whatever you wish, and create local triggers, as opposed to having to remember all the syntax junk. The only difference is putting it inside 'scope' and 'endscope' blocks. You also have to give the scope a name, and tell it which function is the starting function.

Example of a scope:

JASS:
scope Bwahaha initializer InitializingFunc

private function LolPoop takes nothing returns boolean
    return true
endfunction

private function ConditionsNot takes nothing returns nothing
    //Do stuff!
endfunction

private function InitializingFunc takes nothing returns nothing
//Making a function private lets you have multiple functions with the same name
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t,function LolPoop)
    call TriggerAddAction(t,function ConditionsNOT)
endfunction

endscope


In order to use vJASS, you have to download Newgen but it's a bit hard to get it working

However, if you don't feel like making the World Editor 999x better, you can change the names of these functions:

JASS:
function Heal takes nothing returns nothing
    local unit u = gg_unit_H000_0000
    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
    call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl", GetUnitX(u), GetUnitY(u)))
    set u = null
endfunction

//===========================================================================
function Restore_Health takes nothing returns nothing
    local trigger Restore = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic( Restore, Player(0) )
    call TriggerAddAction( Restore, function Heal )
endfunction


to:

JASS:
function Trig_Restore_Actions takes nothing returns nothing
    local unit u = gg_unit_H000_0000
    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
    call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl", GetUnitX(u), GetUnitY(u)))
    set u = null
endfunction

//===========================================================================
function InitTrig_Restore takes nothing returns nothing
    set gg_trg_Restore = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Restore, Player(0) )
    call TriggerAddAction( gg_trg_Restore, function Heal )
endfunction


I believe you also have to keep the trigger name as gg_trg_Restore, so I also fixed that in the InitTrig function.
 

emjlr3

Change can be a good thing
Reaction score
395
you can still use a local trigger and can name your actions functions whatever you please, but in order for the map to run that function during its loading, it needs to have the InitTrig_ prefix
 

Beetlebomb

New Member
Reaction score
43
Ok, It works now.

I just copied over Darthfett's JASS Code:

JASS:
function Trig_Restore_Actions takes nothing returns nothing
    local unit u = gg_unit_H000_0000
    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
    call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl", GetUnitX(u), GetUnitY(u)))
    set u = null
endfunction

//===========================================================================
function InitTrig_Restore takes nothing returns nothing
    set gg_trg_Restore = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Restore, Player(0) )
    call TriggerAddAction( gg_trg_Restore, function Heal )
endfunction


and it worked. Time to slowly change and compare to see what the problem was. I'll post it when I figure it out.

Thank you so much! ^^

EDIT: It seems to be coming from
JASS:
function InitTrig_Restore takes nothing returns nothing
    set gg_trg_Restore = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Restore, Player(0) )
    call TriggerAddAction( gg_trg_Restore, function Trig_Restore_Actions )
endfunction


Are you sure that I can still use a local here? Because it seems like that was the problem. Either that or my actions function name.
 

saw792

Is known to say things. That is all.
Reaction score
280
Yes you can use a local there. The problem was the name of the InitTrig function. It MUST read InitTrig_Your_Trigger_Name, the trigger name being taken from the left hand pane (by pane i mean... the area on the left that lists your GUI triggers).

At map initialisation there is a function called InitCustomTriggers() that is called from the main function of the map (i.e. the very first function executed). The InitCustomTrigger() function contains a whole list of function calls based on the names of the GUI triggers in the left hand pane of the trigger editor (i.e. it calls InitTrig_Untitled_Trigger_001(), InitTrig_Untitled_Trigger_002(), etc). If you change the name of one of these InitTrig function by converting to custom text it will differ from what exists in the InitCustomTriggers() function and thus will not be called, rendering your code useless.
 

Beetlebomb

New Member
Reaction score
43
Good to know, thank you very much! :)

Btw Saw792, It might have been your thread that I read earlier about unit animations playing and looping while sliding a unit. Do you mind looking over at my Charge Ability thread? I'm having a problem getting that to work(And you explain very clearly).

Thank you, regardless!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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