• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] vJASS: Syntax Error

Status
Not open for further replies.
Level 11
Joined
Mar 31, 2009
Messages
732
JASS:
//library pieceType:
//textmacro instance: PieceType("pawn", "h000", "h006")
    function is_pawn takes unit piece returns boolean
        return ((GetUnitTypeId(piece) == 'h000') or (GetUnitTypeId(piece) == 'h006'))
    endfunction
//end of: PieceType
Compiler complains about the line "function is_pawn takes unit piece returns boolean", says "Syntax Error".

I don't see anything wrong with it?
Attached the latest source map (wouldn't compile, so don't try running the map).
 
Last edited:
Ah yeah I already picked up on those yesterday. Thanks though.


Having a separate issue now though.

I have a function to decide what direction a piece should be facing. Its supposed to face the unit with the least health.
It seems to be working as expected, only the command to rotate it doesn't seem to ever fire.

JASS:
    globals
        group enumGrp = CreateGroup()
    endglobals

    function TrueFilter takes nothing returns boolean
        return true
    endfunction
    
    function Get_unit_in_square takes real x, real y returns unit
        call GroupEnumUnitsInRange(enumGrp, x, y, 200, Filter(function TrueFilter))
        return FirstOfGroup(enumGrp)
        // leeeeeeeeeeeeeeeak
    endfunction


    function Facing_AI_choose takes unit turner returns nothing
        local real angle = 0
        local real ox = GetUnitX(turner)
        local real oy = GetUnitY(turner)
        local real x
        local real y
        local real bestX = ox
        local real bestY = oy
        local real targetHealth = 150000
        local unit targetUnit
        
        loop
            exitwhen angle == 360
            set x = ox + 384. * Cos(angle * bj_DEGTORAD)
            set y = oy + 384. * Sin(angle * bj_DEGTORAD)
            set targetUnit = Get_unit_in_square(x, y)
            if (targetUnit != null and IsPlayerEnemy(GetOwningPlayer(targetUnit), GetOwningPlayer(turner)) and targetHealth > GetUnitState(targetUnit, UNIT_STATE_LIFE)) then
                set bestX = x
                set bestY = y
                set targetHealth = GetUnitState(targetUnit, UNIT_STATE_LIFE)
                call dbug("cc")
            endif
            set angle = angle + 90
        endloop
        
        call dbug(GetUnitName(turner) + R2S(bestX) + R2S(bestY) + R2S(ox) + R2S(oy))
        if (bestX == ox and bestY == oy) then
            set targetUnit = null
            call dbug("returns")
            return
        endif
        call IssuePointOrderById(turner, 'A000', bestX, bestY)
        set targetUnit = null
    endfunction
I've tried testing it on a unit that I am controlling, to watch if it works. It seems to calculate the correct coordinates, but the Issue command never works..

Edit: I wrapped a debug message around the IssuePointOrderById function, and it is returning false. I don't understand why though. The unit is valid, the ability is valid, and the coordinates are in range...
 

Attachments

Last edited:
Err... Then why do those ById functions even exist?

And anyway, I only changed it to ById because it wasn't working without it. Changed it back and its still not working.
That call is returning false when used, yet I see no reason it should.
The target points are in range, the order string is valid...
 
To solve your problem...
The OrderID of your Change Facing skill is 852466.
'A000' translates to 1093677104, which is not the correct OrderID.

To get the OrderID of anything, just get a trigger that registers unit orders and
call BJDebugMsg(I2S(GetUnitCurrentOrder(GetTriggerUnit()))).

Hope that helps.
 
I've tried using order strings, I've tried using ability IDs.
It seems that in this function, the IssuePointOrder command is returning false, no matter what the order is. This is the code that should work:

JASS:
call dbug("DEBUG: " + GetUnitName(turner) + " (Destination " + R2S(bestX) + ", " + R2S(bestY) + ") (Origin " + R2S(ox) + ", " + R2S(oy) + ")")
        call dbug(B2S(IssuePointOrder(turner, "stampede", bestX, bestY)))

And I've tried changing the "stampede" (order string I picked, tried changing that around too) to "move", so that the whole function call matches a working IssuePointOrder call from another trigger, and that didn't work either.

The only thing I can think of is that there is some kind of conflict causing the that order call to not work, but I can't figure out what that could be.
I've made it attempt to do this on a player controlled unit, and I don't even see a "Out of range" or anything (not that I'd know if it would do that).

Edit: Solved. Not sure how, think it was due to the base ID.
 
Last edited:
Status
Not open for further replies.
Back
Top