First Trigger

Mike889

New Member
Reaction score
15
Syntax Error

Hello guys! I'm trying to make a spell that teleports all allied heroes within 375 range of the caster to the targeted unit. I'm using Mass Teleport as the base skill. When I try to sabe the map, jasshelper returns an error with the function C1 saying "syntax error". Here is my trigger:
Code:
MassTeleport1
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Teleporte em Massa (Jaina Proudmoore)
    Actions
        Set TargetArray[(Player number of (Owner of (Triggering unit)))] = (Target unit of ability being cast)

JASS:
scope MassTeleport2 initializer Init

private function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01U' ) ) then
        return false
    endif
    return true
endfunction

private function C1 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
endfunction

private function C2 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(Caster())) == true )
endfunction

private function C3 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

private function C12 takes nothing returns boolean
    return GetBooleanAnd( C1(), C2() )
endfunction

private function C4 takes nothing returns boolean
    return GetBooleanAnd( C12(), C3() )
endfunction

private function A1 takes nothing returns nothing
    call AddSpecialEffectTargetUnitBJ( "origin", GetEnumUnit(), "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call SetUnitPositionLoc( GetEnumUnit(), TargetPos)
endfunction

function A2 takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_TargetArray[GetConvertedPlayerId(GetOwningPlayer(Caster()))]) == true ) ) then
        return false
    endif
    return true
endfunction

function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPos = GetUnitLoc(udg_TargetArray[GetConvertedPlayerId(GetOwningPlayer(Caster()))])
    local location Loc = GetUnitLoc(Caster())
    if ( A2() ) then
        call ForGroupBJ( GetUnitsInRangeOfLocMatching(375.00, Loc, Condition(C4, A1)
        call AddSpecialEffectTargetUnitBJ( "origin", Caster(), "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    else
        call DisplayTimedTextToPlayer( GetOwningPlayer(Caster()), 0, 0, 10.00, "O alvo não está vivo." )
    endif
    set Caster = null
    call RemoveLocation(TargetPos)
    call RemoveLocation(Loc)
    set Loc = null
    set TargetPos = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger MassTeleport2 = CreateTrigger()
    set MassTeleport2 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(MassTeleport2, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(MassTeleport2, Condition(function Conditions))
    call TriggerAddAction(MassTeleport2, function Actions)
endfunction

endscope
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
You can't nest functions like that. That's why it's causing an error. There's no function nesting in JASS.
 

Mike889

New Member
Reaction score
15
What is "function nesting" =X
How to fix that?
I just made a "pick all units matching condition" and converted to custom text. Then I copied the functions, pasted them on that trigger and renamed each one accordingly, =P I am then trying to make all variables locals and using private functions.
 

Azlier

Old World Ghost
Reaction score
461
Function nesting is putting functions inside functions, which you can't do.
 

Romek

Super Moderator
Reaction score
963
JASS:
function A takes nothing returns nothing

   function B takes nothing returns nothing // SYNTAX! This function is inside A.

   endfunction

endfunction
 

Sevion

The DIY Ninja
Reaction score
413

T.s.e

Wish I was old and a little sentimental
Reaction score
133
JASS:
return (((((((((((((((((IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true)))))))))))))))))]

Would syntax because of the ] at the end :D

Your code could use a cleanup.
JASS:
scope MassTeleport2 initializer Init

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

private function C1 takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local unit f = GetFilterUnit()
    if IsUnitType(f), UNIT_TYPE_HERO) == true then
       if IsUnitAlly(GetFilterUnit(), GetOwningPlayer(u) == true then// Caster? Locals cannot be passed over code functions
        if GetWidgetLife(f) > 0.405 then
          set u = null
          set f = null
          return true
        endif
      endif
    endif
   set u = null
   set f = null
   return false
endfunction

private function Callback takes nothing returns nothing
    local effect f = AddSpecialEffectTarget(...)
    local unit u = GetTriggerUnit()
    local location l = GetUnitLoc(udg_TargetArray[GetPlayerId(GetOwningPlayer(u)))-1])
    call DestroyEffect(f)
    call SetUnitPositionLoc( GetEnumUnit(), l)
    call RemoveLocation(l)
    set l = null
    set u = null
    set f = null
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local group g = CreateGroup()
    local effect f
    local location TargetPos = GetUnitLoc(udg_TargetArray[GetPlayerId(GetOwningPlayer(Caster()))-1])//Ew gui global
    local location Loc = GetUnitLoc(Caster())
    if GetWidgetLife(Caster) > 0.405 then
        call GroupEnumUnitsInRange(g, ...)
        call ForGroup(g, function Callback)
        set f = AddSpecialEffectTarget(..)
        call DestroyEffect(f)
        set f = null
    else
        call DisplayTimedTextToPlayer( GetOwningPlayer(Caster), 0, 0, 10.00, "O alvo não está vivo." )
    endif
    set Caster = null
    call RemoveLocation(TargetPos)
    call RemoveLocation(Loc)
    set Loc = null
    set TargetPos = null
endfunction

private function Init takes nothing returns nothing
    local trigger MassTeleport2 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(MassTeleport2, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(MassTeleport2, Condition(function Conditions))
    call TriggerAddAction(MassTeleport2, function Actions)
endfunction

endscope
 

Sevion

The DIY Ninja
Reaction score
413
Would syntax because of the ] at the end

Yeah, I wondered why it said [JASS instead of
JASS:
 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
 

Mike889

New Member
Reaction score
15
Wow, thanks, now I understand better how to make a trigger with its conditions and actions :D
I going to study more JASS, =P
So blizzard matching functions cannot be used in vJass, right?
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
They can, but it won't be any different from using regular GUI.
 

Mike889

New Member
Reaction score
15
Yeah, indeed =P

Anyway, I am still getting errors with the trigger:
attachment.php
JASS:
scope MassTeleport2 initializer Init

private function Conditions takes nothing returns boolean
  return GetSpellAbilityId() == &#039;A01U&#039;
endfunction

private function C1 takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local unit t = GetFilterUnit()
    if IsUnitType(t), UNIT_TYPE_HERO) == true then
       if IsUnitAlly(GetFilterUnit(), GetOwningPlayer(u) == true then
        if GetWidgetLife(t) &gt; 0.405 then
          set u = null
          set t = null
          return true
        endif
      endif
    endif
   set u = null
   set t = null
   return false
endfunction

private function Callback takes nothing returns nothing
    local effect f = AddSpecialEffectTarget(&quot;Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl&quot;, GetEnumUnit(), origin)
    local unit u = GetTriggerUnit()
    local location l = GetUnitLoc(udg_TargetArray[GetPlayerId(GetOwningPlayer(u)))-1])
    call DestroyEffect(f)
    call SetUnitPositionLoc( GetEnumUnit(), l)
    call RemoveLocation(l)
    set l = null
    set u = null
    set f = null
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local group g = CreateGroup()
    local effect f
    local location TargetPos = GetUnitLoc(udg_TargetArray[GetPlayerId(GetOwningPlayer(Caster()))-1])
    local location Loc = GetUnitLoc(Caster())
    local real x = GetLocationX(Loc)
    local real y = GetLocationY(Loc)
    if GetWidgetLife(Caster) &gt; 0.405 then
        call GroupEnumUnitsInRange(g, x, y, 375, function C1)
        call ForGroup(g, function Callback)
        set f = AddSpecialEffectTarget(&quot;Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl&quot;, Caster(), origin)
        call DestroyEffect(f)
        set f = null
    else
        call DisplayTimedTextToPlayer( GetOwningPlayer(Caster), 0, 0, 10.00, &quot;O alvo não está vivo.&quot; )
    endif
    set Caster = null
    call RemoveLocation(TargetPos)
    call RemoveLocation(Loc)
    set Loc = null
    set TargetPos = null
endfunction

private function Init takes nothing returns nothing
    local trigger MassTeleport2 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(MassTeleport2, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(MassTeleport2, Condition(function Conditions))
    call TriggerAddAction(MassTeleport2, function Actions)
endfunction

endscope

And why subtract one from the Player Number?
JASS:
    local location TargetPos = GetUnitLoc(udg_TargetArray[GetPlayerId(GetOwningPlayer(Caster()))-1])

So if the owner is player 11 it would result in 10, not 11 o_O.
 

Attachments

  • l.JPG
    l.JPG
    136.5 KB · Views: 263
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