• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] WorldEdit gives me an error but JassCraft says it should work

Status
Not open for further replies.
Level 1
Joined
Feb 25, 2010
Messages
4
I wanted to script a system for stunning units by calling a function so i won't have to create dummy, give the spell to it etc. each time i need it for one of my spells.

The code is:
JASS:
function MyStun takes unit aStunSource, unit aStunUnit, integer aStun returns nothing
    local player MyStunSource = GetOwningPlayer(aStunSource)
    local unit array MyStunUnit
    local integer MyStun = aStun
    local location MyStunPoint = null
    
    set MyStunUnit[1] = aStunUnit
    set MyStunPoint = GetUnitLoc(MyStunUnit[1])

    call CreateNUnitsAtLoc( 1, 'h003', MyStunSource, MyStunPoint, bj_UNIT_FACING )
    set MyStunUnit[2] = GetLastCreatedUnit()
    call UnitAddAbilityBJ( MyStun, MyStunUnit[2] )
    call IssueTargetOrderBJ( MyStunUnit[2], "thunderbolt", MyStunUnit[1] )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', MyStunUnit[2] )
    call RemoveLocation(MyStunPoint)
endfunction
aStunSource is the unit casting any spell that uses this script
aStunUnit is the unit being affected by this
aStun is the id of the ability i use so i can use it stuns with different durations

When i compiled it the first time WorldEdit gave me some errors so i checked it with JassCraft and after fixing some errors it looked like what is written above and JassCraft told me it should work.
But when i put this code into WorldEdit and try to save it says gives me the error: "Reserved type or handle-type expected" on this two lines:

JASS:
    local integer MyStun = aStun
    local location MyStunPoint = null

+Rep for the one who helps me with this, because i really got no idea whats wrong there.
 
Level 6
Joined
Nov 3, 2008
Messages
117
First of all don't use those BJ's and don't use arrays as locals. This code could look like this:
JASS:
function MyStun takes unit aStunSource, unit aStunUnit, integer aStun returns nothing
    local unit MyStunCaster = CreateUnit( Player(15), 'h003', GetUnitX(aStunUnit),GetUnitY(aStunUnit),0.)
    call UnitAddAbility(MyStunCaster,aStun)
    call IssueTargetOrder( MyStunCaster, "thunderbolt", aStunUnit )
    call UnitApplyTimedLife( 1.00, 'BTLF', MyStunCaster)
endfunction

I'd say you kinda converter GUI code in Jass and added some lines!!!!
 
Level 1
Joined
Feb 25, 2010
Messages
4
ty for helping me

you're right i'm quite new to jass and didn't really had the time to get elaborate on it, yet

+rep
 
Status
Not open for further replies.
Top