• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] I'd appreciate help with these 2 things

Status
Not open for further replies.
Level 6
Joined
Mar 20, 2008
Messages
208
I'm trying to setup a global function in the map editor, to be used by 4 different triggers.

The Unit_Pauser is the function I am trying to make accessible by all 4 triggers, but the map editor is being a pain in the ass.

I've resorted to giving each trigger their own unit pauser, which is something I did not want to do.

JASS:
function Trig_Night_Elf_Unit_Selection_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetAttacker()) == 'ewsp'
endfunction

function Unit_Pauser4 takes nothing returns nothing
    call PauseUnitBJ( true, GetEnumUnit() )
endfunction

function Trig_Night_Elf_Unit_Selection_Actions takes nothing returns nothing
   local unit attacker = GetAttacker() 
   local unit attacked = GetTriggerUnit()
   
   if(udg_Selects[3]) then
       call CreateNUnitsAtLoc( 10, GetUnitTypeId(attacked), GetOwningPlayer(attacker), GetRectCenter(gg_rct_Nelf_Show), bj_UNIT_FACING )
       call ForGroupBJ(GetUnitsInRectAll(gg_rct_Nelf_Show), function Unit_Pauser4)
   else
       call CreateNUnitsAtLoc( 10, GetUnitTypeId(attacked), GetOwningPlayer(attacker), GetRectCenter(gg_rct_Nelf_Hidden), bj_UNIT_FACING )
       call ForGroupBJ(GetUnitsInRectAll(gg_rct_Nelf_Hidden), function Unit_Pauser4)
   endif
   
   set udg_UnitsLeft[3] = ( udg_UnitsLeft[3] + 10 )
   set udg_Selects[3] = not( udg_Selects[3] )
   call KillUnit( attacked )
   call KillUnit( attacker )
   set attacker = null
   set attacked = null 
endfunction

"Expected a function name" is the error thrown

My second problem, is the very same code
This was my original attempt to make this more efficient than what the GUI editor gave me. But it threw some errors.
JASS:
   local unit attacker = GetAttacker() 
   local unit attacked = GetTriggerUnit()
   local rect placement //local region placement was also tried, same error

   if(udg_Selects[3]) then
        placement = gg_rct_Nelf_Hidden
   else
        placement = gg_rct_Nelf_Show
   endif 

call CreateNUnitsAtLoc( 10, GetUnitTypeId(attacked), GetOwningPlayer(attacker), GetRectCenter(placement), bj_UNIT_FACING )
call ForGroupBJ(GetUnitsInRectAll(placement), function Unit_Pauser4)

   set udg_UnitsLeft[3] = ( udg_UnitsLeft[3] + 10 )
   set udg_Selects[3] = not( udg_Selects[3] )
   call KillUnit( attacked )
   call KillUnit( attacker )
   set attacker = null
   set attacked = null 
endfunction

The error given was "Expected a reserved type or handle type"
for the line "local rect placement"

Any help is appreciated
 
Level 9
Joined
Mar 25, 2005
Messages
252
1. Get jassnewgenpack and read what jasshelper's manual says about libraries
or
put the function you want to share in your maps header, which you can find by selecting your maps name in the trigger editor.

2. It seems that "placement" is the name of a type which means that you can't use it as a variable name. Try replacing with some other name.
 
Status
Not open for further replies.
Top