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
964
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: 266
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top