• 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] Condition Error

Status
Not open for further replies.
Level 5
Joined
Nov 22, 2009
Messages
181
i did this:

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

then wenever i try to test the trigger i was working on it reported an error saying endfunction is the wrong operator for the command (i think it was command. it could have been something else after the "operator" part).

what is the problem?
 
Level 5
Joined
Nov 22, 2009
Messages
181
srry dr but I ended up replacing the entire thing with:

JASS:
function Trig_portal_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function portal_action takes nothing returns nothing
    local location loc1 = GetRectCenter(RectFromCenterSizeBJ(GetUnitLoc(GetSpellAbilityUnit()), 100.00, 100.00))
    local location loc2 = GetRectCenter(RectFromCenterSizeBJ(GetSpellTargetLoc(), 100.00, 100.00))
    local unit portal1
    local unit portal2
        call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), loc1, bj_UNIT_FACING )
        set portal1 = GetLastCreatedUnit()
        call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), loc2, bj_UNIT_FACING )
        set portal2 = GetLastCreatedUnit()
        call WaygateSetDestinationLocBJ( portal1, loc2 )
        call WaygateSetDestinationLocBJ( portal2, loc1 )
        call RemoveLocation(loc1)
        call RemoveLocation(loc2)
        set loc1 = null
        set loc2 = null
        set portal1 = null
        set portal2 = null
endfunction
function InitTrig_portal takes nothing returns nothing
  set gg_trg_portal = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_portal, EVENT_PLAYER_UNIT_SPELL_FINISH )
    call TriggerAddCondition( gg_trg_portal, Condition( function Trig_portal_Conditions ) )
    call TriggerAddAction( gg_trg_portal, function portal_actions )
endfunction
Unfortunately, there are even more errors than before, but the original error is no longer one of them. This JASS script is supposed to create 2 Portals. Unit 'h000' is a custom unit called Portal with the waygate ability. One portal should be located at the casters location and the other should be located at the ability's target location. Then it should set the waygate destination of the first portal to the location of the
second and vice versa.

The errors say:
Line 64:Expected a variable name
the line is: set gg_trg_portal = CreateTrigger( )
Line 65: Expected a name
and it seems to go to the "EVENT_PLAYER_UNIT_SPELL_FINISH" in the add event part of the InitTrig_portal function.
Line 66: Expected a name
then it shows and highlights : Condition( function Trig_portal_Conditions ) )
Line 67: Expected a name
it shows and highlights ", function portal_actions )"

Do you know what i need to fix?
 
Last edited:
Level 5
Joined
Nov 22, 2009
Messages
181
k first, i have no idea what the TESH syntax checker is or how to turn it off etc. Second i do not have a global valiable for it. ty both.

also what does gg stand for anyways. i mean i thought it automatically created a global for each trigger

yay it worked! thank you guys

nvm. there are no more error messages and it actually tested the map but the spell didn't do anything.
 
Last edited by a moderator:
gg_trg_portal

Is that defined? Have you created that global? Unless a variable exists, it will throw errors on every line which refers to that variable.

I believe that line is always present when you convert GUI to script (gg_trg_TriggerName).........

on the trigger:

you use local loc1 = XX then you use set loc1 = XX... remove the second one.... you can also transfer the CreateUnit to this
local unit portal1 = CreateUnitblahblahblah.......
and why would you need GetRectCenter(RectFromCenterblahblah..)..... you get the center of a rect that you created from that very center????
 
Level 5
Joined
Nov 22, 2009
Messages
181
ok i will do the first 2 things you mentioned but im confused by the last comment. the one about getting the rect center.
Also, do you guys know why it is:
JASS:
if ( not ( GetSpellAbilityId() == 'A000' ) ) then return false
instead of:
JASS:
if ( GetSpellAbilityID() =='A000') then return true
 
Last edited:
Level 5
Joined
Nov 22, 2009
Messages
181
why would i do that though? i mean its not being used for any other functions is it? feel free to correct me if im wrong. i just barely understand this stuff.so please clarify that.

oh i see never mind.
i was thinking of the actions function. lol :)
but that wont work because conditions have to return a boolean value.
 
Last edited by a moderator:
Level 5
Joined
Apr 12, 2009
Messages
125
This should work, but I'm not sure about the spell.

JASS:
function portal_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//==================================

function portal_action takes nothing returns nothing
    local location loc1 = GetRectCenter(RectFromCenterSizeBJ(GetUnitLoc(GetSpellAbilityUnit()), 100.00, 100.00))
    local location loc2 = GetRectCenter(RectFromCenterSizeBJ(GetSpellTargetLoc(), 100.00, 100.00))
    local unit portal1
    local unit portal2
        call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), loc1, 270 )
        set portal1 = GetLastCreatedUnit()
        call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), loc2, 270 )
        set portal2 = GetLastCreatedUnit()
        call WaygateSetDestinationLocBJ( portal1, loc2 )
        call WaygateSetDestinationLocBJ( portal2, loc1 )
        call RemoveLocation(loc1)
        call RemoveLocation(loc2)
        set loc1 = null
        set loc2 = null
        set portal1 = null
        set portal2 = null
endfunction
//===================================

function portal takes nothing returns nothing
    local trigger portal = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( portal, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( portal, Condition( function portal_Conditions ) )
    call TriggerAddAction( portal, function portal_action )
endfunction
 
JASS:
function portal_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//==================================

function portal_action takes nothing returns nothing
    local real u  = GetSpellAbilityUnit()
    local real x0 = GetUnitX(GetSpellAbilityUnit())
    local real y0 = GetUnitX(GetSpellAbilityUnit())
    local real x1 = GetSpellTargetX()
    local real y1 = GetSpellTargetY()
    local unit p0 = CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()), 'h000', x0, y0, 270)
    local unit p1 = CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()), 'h000', x1, y1, 270)
    call WaygateSetDestination(p0, x1, y1)
    call WaygateSetDestination(p1, x0, y0)
    set u = null
    set p0 = null
    set p1 = null
endfunction
//===================================

function portal takes nothing returns nothing
    local trigger portal = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( portal, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( portal, Condition( function portal_Conditions ) )
    call TriggerAddAction( portal, function portal_action )
endfunction
 
Level 5
Joined
Nov 22, 2009
Messages
181
r0obfish i dont think you can do that because for the first function you put return boolean and then you went and put return ability id code which is not boolean. and (correct me if im wrong) but i thought All conditions have to return boolean. and the rest of it looks exactly like what i have. Same with element of water, only yours is using x- and y-intercepts right? I'm guessing (based on the fact that i know next to nothing about jass that i am wrong about the having to return a boolean value; though.
I'll go ahead and try that.
 
Mine and r0bfish's functions do return booleans - GetSpellAbilityId() == 'A000' is a comparison, so it forms a boolean. If the spell id is, in fact, 'A000', it forms true, otherwise it forms false.

Mine does not use x- and y-"intercepts". It merely uses coordinates instead of locations. Coordinates are faster and leak-free. My code is better, bascially. By a long way.
 
Level 5
Joined
Nov 22, 2009
Messages
181
Mine and r0bfish's functions do return booleans - GetSpellAbilityId() == 'A000' is a comparison, so it forms a boolean. If the spell id is, in fact, 'A000', it forms true, otherwise it forms false.

Mine does not use x- and y-"intercepts". It merely uses coordinates instead of locations. Coordinates are faster and leak-free. My code is better, bascially. By a long way.

my bad. thats actually what i meant. must have gotten it mixed up with homework :). Now I see how that is.

I just made it work in GUI but i don't know what im doing wrong in Jass. also is this leakless?
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Portal (Archimonde)
    • Actions
      • Unit - Create 1 Portal for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
      • Neutral Building - Set (Last created unit) destination to (Target point of ability being cast)
      • Neutral Building - Enable (Last created unit)
      • Unit - Create 1 Portal for (Owner of (Casting unit)) at (Target point of ability being cast) facing Default building facing degrees
      • Neutral Building - Set (Last created unit) destination to (Position of (Casting unit))
      • Neutral Building - Enable (Last created unit)
 
Last edited by a moderator:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Unit - Create 1 Portal for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
Neutral Building - Set (Last created unit) destination to (Target point of ability being cast)
Unit - Create 1 Portal for (Owner of (Casting unit)) at (Target point of ability being cast) facing Default building facing degrees
Neutral Building - Set (Last created unit) destination to (Position of (Casting unit))
Each one of those leaks 1 location each per execution.
 
Status
Not open for further replies.
Top