| 12-04-2007, 07:49 PM | #1 |
I was in the process of making a spell when I came across some sort of logical error in an if-statement. After further investigation, I got it to work, but I had to "go around" the bug (if it is a bug). JASS:if GetUnitCurrentOrder( <unit> ) != OrderId( <string> ) then JASS:if OrderId2String( GetUnitCurrentOrder( <unit> ) ) != <string> then |
| 12-05-2007, 04:09 PM | #2 |
GetUnitCurentOrder == 0 when the order was given. Use this for be sure : call BJDebugMsg ( I2S ( GetUnitCurrentOrder (<unit>) ) ) but it takes some time for give an immediate order if the unit has received a point or widget target , what a joke :p I mean you can't order it immediatly after the event run. If i need it i do that : JASS:function Trig_test_Actions takes nothing returns nothing local unit u = GetTriggerUnit () call PauseUnit( u,true ) call IssueImmediateOrderById ( u , 851973 ) // if the unit has an immediate order it is "saved" call PauseUnit( u,false ) endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing set gg_trg_test = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_test, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_test, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerAddAction( gg_trg_test, function Trig_test_Actions ) endfunction Instead of call IssueImmediateOrderById ( u , 851973 ) you can order to stop, but the others orders don't work, if you want an other you must order it after the unpause. Ok it's not the subject but it's intersting, no ? ^^ |
| 12-05-2007, 04:30 PM | #3 |
Please assume I'm not an idiot. I debugged what the GetUnitCurrentOrder returned, converted it to a string, and it came out with "blizzard" (I did this before the if statement). What its basically telling me is this: JASS:call BJDebugMsg(OrderId2String(GetUnitCurrentOrder(<unit>))) if (GetUnitCurrentOrder(<unit>) != OrderId("blizzard")) then call BJDebugMsg(OrderId2String(GetUnitCurrentOrder(<unit>))) endif JASS:if (OrderId2String(GetUnitCurrentOrder(<unit>)) != "blizzard") then ... endif To add to that, this if-statement is called on a timer event, so it is not "immediately" after he is issued the order. Regardless, though, think the problem through before typing out the first thing that pops into your head. If you had even read my entire question I'm sure you could've figured it out. ** EDIT ** Sorry if I was rude. By the way, JASS:call BJDebugMsg( I2S( GetUnitCurrentOrder( <unit> ) ) This is not the problem however. For some reason: JASS:GetUnitCurrentOrder(...) != OrderId(...) JASS:OrderId2String( GetUnitCurrentOrder(...) ) != <order string> In more mathematical terms, this means that "Arctan(X) != Y" yet "Tan(Y) = X". |
| 12-06-2007, 12:11 PM | #4 |
yes you were rude but i have read the post really quickly, sorry. strange i test it for "smart" and it works. I assume you're not an idiot but i don't lie for the bug, just try it : JASS:function Trig_test_Actions takes nothing returns nothing call IssueImmediateOrderBJ( GetTriggerUnit(), "holdposition" ) call BJDebugMsg ( "obey me ffs unit !") endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing set gg_trg_test = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_test, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_test, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerAddAction( gg_trg_test, function Trig_test_Actions ) endfunction |
| 12-06-2007, 10:06 PM | #5 |
Yea I tested it all appropriately. The fact is he is under the order of "blizzard" yet for some reason it says he isn't. Somehow, this statement returns true even though it is not: JASS:if ( GetUnitCurrentOrder( <unit> ) != OrderId( "blizzard" ) ) then Anybody can see that this would check if the unit's current order ID is the same as the order ID of "blizzard", basically, whether or not the unit is casting blizzard. To further check this, I do: JASS:if ( GetUnitCurrentOrder( <unit> ) != OrderId( "blizzard" ) ) then call BJDebugMsg( OrderId2String( GetUnitCurrentOrder( <unit> ) ) ) endif Now, anybody initially looking at this code would think that the 'BJDebugMsg' would display anything but the text "blizzard", yet it still detects blizzard as being the unit's current order. It is, too. Blizzard is actually the unit's current order, though the if-statement for some reason doesn't recognize it. Altering the if-statement to look like this: JASS:if ( OrderId2String( GetUnitCurrentOrder( <unit> ) ) != "blizzard" ) then Now it works, even though I haven't changed the content of the if-statement at all, it is merely written a different way. In principle, I took the "OrderId" function from the right-hand-side and inversed it to the left-hand-side, for some reason this makes all the difference. |
| 12-06-2007, 10:18 PM | #6 |
Alright. I'm deleting the post. I don't know what exactly caused it but for some reason it works fine now. |
