• 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.

I'm bad at JASS and need help with this simple thing

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
EDIT: New Issue

  • Test
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Unit-type of (Ordered unit)) Equal to Peasant
    • Actions
      • Set RealXP1 = (X of (Target point of issued order))
      • Set RealYP1 = (Y of (Target point of issued order))
      • Custom script: call IssueBuildOrder(GetTriggerUnit(), "hbar", udg_RealXP1, udg_RealYP1)
      • Game - Display to Player Group - Player 1 (Red) the text: ORDER FIRED!
What I'm having issues with is the
JASS:
        Custom script:   call IssueBuildOrder(GetTriggerUnit(), "hbar", udg_RealXP1, udg_RealYP1)

NEW ISSUE - NOT SOLVED
Okay, so, I figured out what the problem is. It literally want a string. So I needed to do "hbar" instead of hbar.

The new issue is that, in-game it does nothing other then my
  • Game - Display to Player Group - Player 1 (Red) the text: ORDER FIRED!
function. It does not issue a build order.


OLD ISSUE - SOLVED
It keeps throwing me an error - "Expected a name" - I'm clearly doing something wrong, I mainly don't know what I'm doing.

This is the use of the function:
native IssueBuildOrder takes unit whichPeon, string unitToBuild, real x, real y returns boolean

I'm not quite sure what the issue is. udg_RealXP1 and udg_RealYP1 are Real Variables. Do these functions just not take variables period? I'm really confused...:goblin_boom:
 
Last edited:
Your function takes a string as paramater. "hbar" is a string, yes... but 'hbar' is actually an integer value. So use the OrderByID function. Also you do no need these two real variables because you can use the jass natives to get x and y:

  • Custom script: call IssueBuildOrderById(GetTriggerUnit(), 'hbar', GetOrderPointX(), GetOrderPointY())

And these trigger questions you should post in trigger&scripts forum next time. ;)
 
Level 12
Joined
May 20, 2009
Messages
822
Your function takes a string as paramater. "hbar" is a string, yes... but 'hbar' is actually an integer value. So use the OrderByID function. Also you do no need these two real variables because you can use the jass natives to get x and y:

  • Custom script: call IssueBuildOrderById(GetTriggerUnit(), 'hbar', GetOrderPointX(), GetOrderPointY())

And these trigger questions you should post in trigger&scripts forum next time. ;)

Haha! It worked! And it crashed the freakin' game, because there's nothing to check the order so it's just gonna forever and ever issue that order...Forever.

Woo! Now to actually get it set up right...xD!

EDIT: Wait, I think my excitement came too early. This may not yet be solved...

EDIT2: Okay, so, thanks to a nice little JASS trigger I can find out what every unit is ordered when they are given an order.

When a unit is ordered to build a building, the order is different for each building. Thankfully, these orders never change. Not based on position on the map, camera position, or anything.

So, this trigger now needs to be fully in JASS, because the normal Order Comparison Condition does not let you put in OrderIds, only strings. I know there's a JASS function that lets you do OrderIds, though.

I'm gonna need help for that...I'll see what I can get done, then update this comment.

EDIT3: Okay, here's the code I'm using

JASS:
    function Trig_Test_Copy_2_Conditions takes nothing returns boolean
        if ( not ( GetUnitTypeId(GetOrderedUnit()) == 'hpea' ) ) then
            return false
        endif
        return true
    endfunction
     
    function Trig_Test_Copy_2_Func002Func004C takes nothing returns boolean
        if ( ( GetIssuedOrderId() == OrderId("1751674741") ) ) then
            return true
        endif
        return false
    endfunction
     
    function Trig_Test_Copy_2_Func002C takes nothing returns boolean
        if ( not Trig_Test_Copy_2_Func002Func004C() ) then
            return false
        endif
        return true
    endfunction
     
    function Trig_Test_Copy_2_Actions takes nothing returns nothing
        if (  Trig_Test_Copy_2_Func002C() ) then
            call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_074" )
            call IssueBuildOrderById(GetTriggerUnit(), 'hbar', GetOrderPointX(), GetOrderPointY())
            call DisableTrigger( GetTriggeringTrigger() )
        else
        endif
    endfunction
     
    //===========================================================================
    function InitTrig_Test_Copy_2 takes nothing returns nothing
        set gg_trg_Test_Copy_2 = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Test_Copy_2, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
        call TriggerAddCondition( gg_trg_Test_Copy_2, Condition( function Trig_Test_Copy_2_Conditions ) )
        call TriggerAddAction( gg_trg_Test_Copy_2, function Trig_Test_Copy_2_Actions )
    endfunction

1751674741 is the order Id to build a farm, and then with the rest of the trigger it should order the Peasant to build a Barracks, but it doesn't...

What am I doing wrong?
 
Last edited:
Could you describe exactly what's your aim for this trigger? What should it do, what should it prevent.

To prevent infinite loop you can simply turn trigger off --> order unit --> start a timer that immedaitly expires --> turn on trigger (don't be scared, in jass it's much smarter than in gui)

If you want to stay in gui, you can use a "Wait (0)" seconds instead of the timer, and then turn trigger on again. ( doesn't really wait 0 seconds, but maybe ~0.2)

Or you can try to set your builder to a unitVariable. And if trgger gets fired you check if triggeringUnit is not equal this unitVariable.
Of course you would have to set this variable to "null" after.

If you want it to be in jass and it works a you want, come again with your code so we talk about how to optimize it a bit and make it look some simpler. :csmile:
 
Level 12
Joined
May 20, 2009
Messages
822
Could you describe exactly what's your aim for this trigger? What should it do, what should it prevent.

To prevent infinite loop you can simply turn trigger off --> order unit --> start a timer that immedaitly expires --> turn on trigger (don't be scared, in jass it's much smarter than in gui)

If you want to stay in gui, you can use a "Wait (0)" seconds instead of the timer, and then turn trigger on again. ( doesn't really wait 0 seconds, but maybe ~0.2)

Or you can try to set your builder to a unitVariable. And if trgger gets fired you check if triggeringUnit is not equal this unitVariable.
Of course you would have to set this variable to "null" after.

If you want it to be in jass and it works a you want, come again with your code so we talk about how to optimize it a bit and make it look some simpler. :csmile:

What I'm trying to achieve is making my Basic/Advanced Building system MUI compatible. This is getting close to that, if it works the way I hope it does.

When the order goes for the the Farm to be built, which the OrderId is 1751674741, I want it to replace that order with the order to build a barracks instead.

Because it's an OrderId and not an OrderString, I have to use JASS.

If I can get this to work then I'll (Mostly) know what to do after that point.
 
Oh, now I see a fail in your condition.

GetIssuedOrderId() == OrderId("1751674741")
-->
GetIssuedOrderId() == 1751674741

1. You already have the order integer. So you compare if GetIssuedOrderId() returns the same orderId you want.

2. OrderId() takes a string as argument. You write "1751674741". Id is the orderId which will be returned if you write in the equvalent string.

For example you we have the orderId for attack is 851983. But it's order string is "attack". That's difference.

I made a quick example trigger that orders a unit to build barracks if it gets point order 1751674741. (note: I hope you told me correct order :d)

JASS:
function TurnOnPointOrder takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call EnableTrigger(gg_trg_Build)
    call DestroyTimer(t)
    set t = null
endfunction

function PointOrder takes nothing returns nothing
    local timer t
    if GetIssuedOrderId() == 1751674741 then
        set t = CreateTimer()

        call DisableTrigger(gg_trg_Build)
        
        call IssueBuildOrderById(GetTriggerUnit(), 'hbar', GetOrderPointX(), GetOrderPointY())
        call BJDebugMsg("new build order")

        call TimerStart(t, 0, false, function TurnOnPointOrder)
        
        set t = null
    endif
endfunction

function InitTrig_Build takes nothing returns nothing
    set gg_trg_Build = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Build, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddAction(gg_trg_Build, function PointOrder )
endfunction
You would need to create a trigger named "Build" and paste the code there.
If the message "new build order" wont display, the orderId was wrong.
Just ask please if there is something you don't understand.
 
Level 12
Joined
May 20, 2009
Messages
822
Thanks for the help, that did it.

However, the worst-case scenario is confirmed. The issued order DOES still require the building to be enabled in order for it to be built...AND the building has to be in their Constructed Buildings list.

So now I will have to resort to Spellbooks->Then issue the build order and hide the normal Built Structures button.

EDIT: Do you got any better ideas? I forgot that Build "Tiny" Buildings do not display Gold/Lumber cost...Which honestly isn't a HORRIBLE backdraw but it's a backdraw none-the-less...
 
Last edited:
Level 6
Joined
Nov 24, 2012
Messages
218
There are alternatives but we would need more specific explanation of what you are trying to accomplish. Just what kind of advanced build system? I do not understand why you want for example building one structure to build a different one, eg farm to barracks. Perhaps that is not right way to go about it.

I can give 2 ways to have farm build barracks, but both have flaws. Most simple way is spawning a dummy unit to start the construction, disappear, then your main builder takes over, has to be human I believe. Another way is using the chaos ability, which can replace units without interrupting orders. You could have your peasant replaced on order fired with a copy of the peasant from object editor except this peasant can have 11 different structures, but now people would see 11 different structures on build menu, and it might be just a bit tough to know when to replace peasant back to normal. However none of this really achieves a custom build system.
 
Level 12
Joined
May 20, 2009
Messages
822
In a sense, this is...Sort of solved. But I am looking for alternatives still.

The building a farm from a barracks was just to experiment. For all intents and purposes, I now have a fully-functioning Basic and Advanced Building system, with just one particular flaw that it cannot display Gold and Lumber costs, so you have to input that in the description of the "Build Tiny Structure" ability yourself.

JASS:
    function Trig_Test_Copy_2_Conditions takes nothing returns boolean
        if ( not ( GetUnitTypeId(GetOrderedUnit()) == 'Worker ID' ) ) then
            return false
        endif
        return true
    endfunction
     
    function Trig_Test_Copy_2_Func002Func004C takes nothing returns boolean
        if ( ( GetIssuedOrderId() == Order ID) ) then
            return true
        endif
        return false
    endfunction
     
    function Trig_Test_Copy_2_Func002C takes nothing returns boolean
        if ( not Trig_Test_Copy_2_Func002Func004C() ) then
            return false
        endif
        return true
    endfunction
     
    function Trig_Test_Copy_2_Actions takes nothing returns nothing
        if (  Trig_Test_Copy_2_Func002C() ) then
            call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_074" )
            call IssueBuildOrderById(GetTriggerUnit(), 'Building ID', GetOrderPointX(), GetOrderPointY())
            call DisableTrigger( GetTriggeringTrigger() )
        else
        endif
    endfunction
     
    //===========================================================================
    function InitTrig_Test_Copy_2 takes nothing returns nothing
        set gg_trg_Test_Copy_2 = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Test_Copy_2, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
        call TriggerAddCondition( gg_trg_Test_Copy_2, Condition( function Trig_Test_Copy_2_Conditions ) )
        call TriggerAddAction( gg_trg_Test_Copy_2, function Trig_Test_Copy_2_Actions )
    endfunction

Say, the Peasant has 3 extra buttons. One is Level 1 Towers, one is Level 2 Towers, and the last is Level 3 Towers. You can have buildings in each of these completely separate command cards, and they will function completely normal as if it's the normal Build Building command card.

Now, I'm still up for alternatives. However, this is the most solid Basic/Advanced Build System I can come up with.

EDIT: Some information here was actually incorrect, but the general idea still works it just needs some slight tuning.

EDIT2: Or at least I think...
 
Last edited:
These pure converted gui triggers are just horrible. You can't read their conditins easily, cant read their strings, and it's just unnecessarily inefficient. ( yo, I saw your minor changes ^^)

I suggest you or to let in in pure gui, or try to read some tutorials about jass. If you have questions you can ask in trigger & scripts forum at any time, or also msg me.

For get buildings cost I would have two ideas:

1) Store the costs into hashtable. (use key of orderId as key)

2) When unit gets build-order, increase the gold/wood to a ridiculous high value, so player can build the building for sure.
Then after a 0-timeout timer you check if gold/wood is still more than your input. If not, you cancel order and can display detailed msg. (this method would probably need some tests to get it work)
 
JASS:
call DisableTrigger(gg_trg_Build)
call IssueBuildOrderById(GetTriggerUnit(), 'hbar', GetOrderPointX(), GetOrderPointY())
call BJDebugMsg("new build order")
call TimerStart(t, 0, false, function TurnOnPointOrder)

-->

JASS:
call DisableTrigger(gg_trg_Build)
call IssueBuildOrderById(GetTriggerUnit(), 'hbar', GetOrderPointX(), GetOrderPointY())
call BJDebugMsg("new build order")
call EnableTrigger(gg_trg_Build)
There's no point in the nulltimer. Orders should fire the event instantly.
 
Status
Not open for further replies.
Top