Spell Problems

simonake

New Member
Reaction score
72
I have 2 problems occuring with this trigger. (I started vJass tonight...Means it's my first spell)

1. When I click syntax check, it tells me that the text is out of function

2. My spell might contain mistakes, I wanted to know if there was leaks, defaults.
Obiously + rep if you help me finding bugs :D


JASS:

scope Mass Entangle Root initializer Init

globals
    private integer SPELL_LEVEL
    private player OWNER
endglobals
function C takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
function CG takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction
function G takes nothing returns nothing
    local player a = OWNER
    local integer i = SPELL_LEVEL
    local unit genum = GetEnumUnit()
    local location gl = GetUnitLoc( genum)
    set dummy = CreateUnitAtLoc( a, 'h000', gl, 0.00)
    call UnitAddAbility( dummy, 'A001')
    call SetUnitAbilityLevel( dummy, 'A001, i)
    call IssueTargetOrder( dummy, "entangle", genum)
call RemoveLocation( gl)
 set a = null
 set genum = null
 set gl = null
 
endfunction
function A takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local location cl = GetUnitLoc( c)
    local unit dummy
    set SPELL_LEVEL = GetUnitAbilityLevel( c, 'A000')
    set OWNER = GetOwningPlayer( c)
    local real range = 250.00 * I2R( l )
    local group inrange = GetUnitsInRangeOfLocMatching( range, cl, Condition( function CG)
    call ForGroup( inrange, function G)
 call RemoveLocation( cl)
  set c = null
  set inrange = null
  set cl = null
endfunction
//===========================================================================
function InitTrig_Mass_Entangle_Root takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function C ))
    call TriggerAddAction( t, function A )
endfunction

endscope
 

WolfieeifloW

WEHZ Helper
Reaction score
372
First off.
If this is 'simple' why can't you fix it?

And don't use the Syntax Check button.
It fails.

And why are you using locations :p ?
JASS is X/Y.
 

Sevion

The DIY Ninja
Reaction score
413
What is the exact error you get (If I had a penny for every time I said that... I'd be poor as fuck, but I'd have something... Maybe a candy bar)

Edit: Bah. No refresh == fail.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Yeah, Locations leak.
X/Y doesn't.

And cool.

And I'd help you but I have to do my King Lear essay soo... :p .
Sorry.


EDIT: Refresh wasn't originally set to fail Sevion.
So it's "...refresh = fail" :p .
 

Sevion

The DIY Ninja
Reaction score
413
Locations only leak if you don't remove the location and set the variable to null.
 

simonake

New Member
Reaction score
72
One more thing, I cannot play them. When I start wc3, I cannot play these maps -_- wtf?

There was no error -_- when i saved, everything went good.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
X/Y's don't leak no matter what you do :p .
It's only smart to use something that can't hurt you no matter what ;) .
 

Sevion

The DIY Ninja
Reaction score
413
Save then do Control + F9.

It may be an issue of you saving then scrolling around in the script or something.
 

Romek

Super Moderator
Reaction score
963
> scope Mass Entangle Root initializer Init
Scope names can't have spaces.
Also, you seem to be missing alot of ending brackets.

Every '(' needs a ')'.

Also, the 'Syntax Check' button doesn't support vJass, and requires the entire map script. Useless, really.
 

Sevion

The DIY Ninja
Reaction score
413
ROMY! Why did you have to see the obvious and make me miss it? :(

You used an illusion spell on me... T_T'

If you're parsing vJASS, use Save. Nothing else calls JassHelper unless you do it through the Command Prompt etc... But I think you'd rather use Save.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
After I read, I just feel it is bad coded. You haven't handle Jass properly, why go on to vJass?

Error : InitTrig_Mass_Entangle_Root
Correction : Init

Use this, this is fully MUI and better than yours 1 :
JASS:
scope MassEntangleRoot initializer Init

private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Act takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local location cl = GetUnitLoc( c)
    local unit dummy
    local integer lv = GetUnitAbilityLevel( c, 'A000')
    local player p = GetOwningPlayer( c)
    local real range = 250. * lv
    local group inrange = CreateGroup()
    local unit temp
    call GroupEnumUnitsInRangeOfLoc(inrange,cl,range,null)
	
    loop
	set temp = FirstOfGroup(inrange)
    exitwhen temp == null
	if IsUnitEnemy(temp,p) == true then
	    set dummy = CreateUnit( p, 'h000', GetUnitX(temp),GetUnitY(temp), 0.00)
            call UnitAddAbility( dummy, 'A001')
	    call SetUnitAbilityLevel( dummy, 'A001', lv)
	    call IssueTargetOrder( dummy, "entangle", temp)
	    call UnitApplyTimedLife(dummy, 'BTLF', 1.2)
        endif
    endloop
	
    call DestroyGroup(inrange)
    call RemoveLocation( cl)
    set c = null
    set inrange = null
    set cl = null
    set dummy = null
    set p = null
    set temp = null
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( t, Condition( function Cond))
    call TriggerAddAction( t, function Act)
    set t = null
endfunction

endscope
 

Romek

Super Moderator
Reaction score
963
> ROMY! Why did you have to see the obvious and make me miss it?
Illusion Spell.

> You used an illusion spell on me... T_T'
Level 4 ;D

> After I read, I just feel it is bad coded. You haven't handle Jass properly, why go on to vJass?
vJass is an extension of Jass, and it makes Jassing easier.
There's no problem with learning about scopes and encapsulation before learning Jass fully. Init_Trig_Name functions suck. As do prefixes.

> Use this, this is fully MUI and better than yours 1 :
The point is that he learns how to do it himself, not gets other people to do it.
In fact, your one's pretty bad too. You don't remove units from the group in the FoG loop. So you'll hit the op. limit, and crash the thread.
You could also use a global group, to avoid destroying the groups.
 

Viikuna

No Marlo no game.
Reaction score
265
And that code sucks too. It would be way better, if you used only one global group and one global dummy unit + filterfunc for doing actions intead of FirstOfGroup loop.

Ans yea, you should learn vJass and normal Jass features side by side. Normal Jass alone is actually pretty horrible sometimes.
 

Tom Jones

N/A
Reaction score
437
Haha global unit for group enumeration, y'all've lost your marbles :D:nuts::confused: And just like that I used my smiley quota for the next month.
 

Viikuna

No Marlo no game.
Reaction score
265
Whats wrong with using global dummy unit for casting those entangling roots?

:confused: ( Me uses smileys too )
 

Tom Jones

N/A
Reaction score
437
There is nothing wrong with it, it's just utterly pointless.

Not to say that I never done it, I actually do it whenever I can:
JASS:
struct whatever
    unit u
    ...

    method ...
        call GroupEnumUnitsInRect(...)
        loop
            set whatever(0).u = FirstOfGroup(...)
            exitwhen whatever(0).u == null
            ...
            call GroupRemoveUnit(...,whatever(0).u)
        endloop
    endmethod
endstruct
 

Viikuna

No Marlo no game.
Reaction score
265
Since it is an AoE spell, and CreateUnit is probably the slowest native there is, it is efficient.

And you can also do all your actions in filterfunc, so you dont have to even do that loop.
 

Tom Jones

N/A
Reaction score
437
We're speaking past each other, I thought you meant using a global unit a enumeration unit.
 
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