function in jass

exge

New Member
Reaction score
15
whats wrong with the following function ...it refuses to compile
PHP:
function DummyCast takes unit caster, unit target, abilcode spellabilcode,string order returns nothing
call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(caster), GetUnitLoc(caster), bj_UNIT_FACING )
local unit dummy = GetLastCreatedUnit()
call UnitAddAbilityBJ(spellabilcode,dummy)
call IssueTargetOrderBJ(dummy, order,target)
call UnitApplyTimedLifeBJ( 2.00, 'BTLF',dummy)
endfunction
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
I only looked at it for .5 seconds, but I'd say you could start by moving the local declaration to be the first function of the function.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
With your coding the correct function will look like this:
Code:
function DummyCast takes unit caster, unit target, integer spellabilcode,string order returns nothing
local unit dummy 
call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(caster), GetUnitLoc(caster), bj_UNIT_FACING )
set dummy = GetLastCreatedUnit()
call UnitAddAbilityBJ(spellabilcode,dummy)
call IssueTargetOrderBJ(dummy, order,target)
call UnitApplyTimedLifeBJ( 2.00, 'BTLF',dummy)
endfunction

abilcode doesn't excist, they are integers.
And the above post.
 

Chocobo

White-Flower
Reaction score
409
You can optimize it.

Code:
function DummyCast takes unit caster, unit target, integer spellabilcode,string order returns nothing
local unit dummy
call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(caster), GetUnitLoc(caster), bj_UNIT_FACING )
set dummy = GetLastCreatedUnit()
call UnitAddAbility(spellabilcode,dummy)
call IssueTargetOrder(dummy, order,target)
call UnitApplyTimedLife( 2.00, 'BTLF',dummy)
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
function DummyCast takes unit caster, unit target, integer spellabilcode,string order returns nothing
    local unit dummy = CreateUnit(GetOwningPlayer(caster), 'h003', GetUnitX(caster), GetUnitY(caster), bj_UNIT_FACING)
    call UnitAddAbility(dummy,spellabilcode)
    call IssueTargetOrder(dummy, order,target)
    call UnitApplyTimedLife( dummy, 'BTLF', 2.00)
    // set bj_lastCreatedUnit=dummy
    // If you want to use Last Created Unit with this dummy then uncomment the above line
    set dummy = null
endfunction
 
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