Trying to convert GUI trigger to vJass

Zaraf

New Member
Reaction score
22
I'm trying to convert the following GUI triggers into vJass, but I'm running into a problem with it not working correctly.

Here are the two GUI triggers:

Trigger:
  • Energy Blade Activation
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to (==) Energy Blade Tower
    • Actions
      • Player - Limit training of Energy Blade Tower to 0 for (Owner of (Triggering unit))
      • Trigger - Turn on Energy Blade Autoattack <gen>


Trigger:
  • Energy Blade Autoattack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to (==) Energy Blade Tower
          • (Unit-type of (Attacking unit)) Equal to (==) Energy Blade Tower 2
          • (Unit-type of (Attacking unit)) Equal to (==) Energy Blade Tower 3
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiple ConditionsAnd - All (Conditions) are true
            • Conditions
              • (Level of Auto Ability - ON (Tower Ability) for (Attacking unit)) Equal to (==) 1
              • (Mana of (Attacking unit)) Equal to (==) (Max mana of (Attacking unit))
              • ((Attacked unit) is A flying unit) Equal to (==) False
        • Then - Actions
          • Unit - Order (Attacking unit) to starfall
        • Else - Actions



I continue using the first GUI trigger, and converted the second one into vJass. I only switched the "Trigger - Turn on Energy Blade Autoattack <gen>" to the vJass version, so I think this is the problem, but I'm not sure how else to do this.

JASS:
scope EnergyBladeAutoAttack initializer Init

    private function Cond takes nothing returns boolean
        local integer i = GetUnitTypeId(GetAttacker())
        return (i == ENERGY_BLADE_TOWER_ID) or (i == ENERGY_BLADE_2_TOWER_ID) or (i == ENERGY_BLADE_3_TOWER_ID)
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit    u        = GetAttacker()
        local unit    c        = GetTriggerUnit() //Attacked unit (the creep)
        local real    Mana     = GetUnitState(u, UNIT_STATE_MANA)
        local real    maxMana  = GetUnitState(u, UNIT_STATE_MAX_MANA)
        local boolean IsFlying = IsUnitType(c, UNIT_TYPE_FLYING)
        
        if ((GetUnitAbilityLevel(u, AUTO_ABILITY_ON)) == 1) and (Mana == maxMana) and (IsFlying == false) then
            call IssueImmediateOrder(u, &quot;starfall&quot;)
        endif
        set u = null
        set c = null
    endfunction

//===========================================================================

    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call DisableTrigger(t)
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(t, Condition( function Cond))
        call TriggerAddAction(t, function Actions)
    endfunction

endscope


I'm not entirely sure how I can combine both of these GUI triggers into a single vJass code since there are different events to deal with. But I would like to have both has vJass together if possible (or even as separate triggers if required).

I hope I was clear enough in what the problem is. Thanks for any help!
 
Reaction score
341

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
    private function Actions takes nothing returns nothing
        local unit u = GetAttacker()
        local unit c = GetTriggerUnit()
        
        if ((GetUnitAbilityLevel(u, AUTO_ABILITY_ON)) == 1) and GetUnitState(u, UNIT_STATE_MANA) == GetUnitState(u, UNIT_STATE_MAX_MANA) and IsUnitType(c, UNIT_TYPE_FLYING)== false) then//No need to create so many variables since you use it once only.
            call IssueImmediateOrder(u, &quot;starfall&quot;)
        endif
        set u = null
        set c = null
    endfunction

    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(t, Condition( function Cond))
        call TriggerAddAction(t, function Actions)
        set t = null
    endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top