Tutorial GUI -> vJASS

cleeezzz

The Undead Ranger.
Reaction score
268
i tried the demo and i got kinda lost (especially the actions)


JASS:
scope StealLife

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

private function Actions takes nothing returns nothing
    set udg_LifeStolen = ( 500.00 * I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) )
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + udg_LifeStolen ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetSpellTargetUnit(), udg_LifeStolen, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

//===========================================================================
public function InitTrig_StealLife takes nothing returns nothing
    local trigger StealLife = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StealLife, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( StealLife, Condition( function Conditions ) )
    call TriggerAddAction( StealLife, function Actions )
endfunction

endscope
 

cleeezzz

The Undead Ranger.
Reaction score
268

Kenny

Back for now.
Reaction score
202
i dont change any of that?

You dont have to, but it is advised that you do.

JASS:
set udg_LifeStolen = ( 500.00 * I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) )

can become:
JASS:
local real LifeStolen = ( 500.00 * I2R(GetUnitAbilityLevel(GetTriggerUnit(),'A000')) )


It uses a local variable intead of a user defined global variable from GUI. GetUnitAbilityLevelSwapped() becomes GetUnitAbilityLevel(), as the 'Swapped' one is a BJ or 'fluff' function, so it is unnecessary.

SetUnitLifeBJ() and UnitDamageTargetBJ() can become:

SetUnitLife() and UnitDamageTarget(), but this means that the arguements inside will change position, and a few things will need to be added, that is another benefit of vJass as it will tell you what arguements are needed in those functions and in what order, to ensure it works properly.

GetUnitStateSwap() is also a BJ function that is unnecessary, use GetUnitState instead. Same goes for this as well, the arguements will be switch for some reason.

I think it is by default that vJass will show you which functions are BJ's, they are orange in colour by default, and there are normally functions that do the exact same thing, but are not BJ's, these are faster and are prefered by most Jassers.
 

cleeezzz

The Undead Ranger.
Reaction score
268
ah i see. i guess ill try converting my newb MPI GUI spells into vJASS tomorrow o_O
 

Cohadar

master of fugue
Reaction score
209
Updated tutorial to cover scope initializer
(did not exist at time of making)
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Oh god. I never knew that the scope had to be initialized if the InitTrig was only called InitTrig. And that was the reason I kept sticking to something like:
function InitTrig_Jump instead of public function InitTrig.
 

Cohadar

master of fugue
Reaction score
209
Oh god. I never knew that the scope had to be initialized if the InitTrig was only called InitTrig. And that was the reason I kept sticking to something like:
function InitTrig_Jump instead of public function InitTrig.

No, InitTrig had to be public if it was called only InitTrig.
If you use initializer it can be public or private and you can call it what ever you want.
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
> No, InitTrig had to be public if it was called only InitTrig.
Then why doesn't anything work when I use a public InitTrig? Yes, the scope name is the same as the trigger name, but for some strange reason it never works. That's why I stick to a normal InitTrig function...
 

Jedimindtrixxx

┻━┻ ︵ ¯\(ツ)/¯ ︵ ┻━┻
Reaction score
168
w00t i did it! yay! i feel special ^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top