• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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

Status
Not open for further replies.

Mognakor

M

Mognakor

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.
 
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!!!!
 
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.
Back
Top