| 08-01-2008, 05:45 PM | #1 |
How to? I want to check if the unit's current order is Move, but how? |
| 08-01-2008, 05:48 PM | #2 |
JASS:native GetUnitCurrentOrder takes unit whichUnit returns integer constant native OrderId2String takes integer orderId returns string |
| 08-01-2008, 05:56 PM | #3 |
What do you want me to use the second one for if the first returns integer? And what is the raw code of the Move? |
| 08-01-2008, 06:04 PM | #4 |
Move raw code: 'Amov' Move order id: 851986 Order id's can be found with: constant native OrderId takes string orderIdString returns integer OrderId2String takes the result from GetUnitCurrentOrder and converts it to a string. |
| 08-01-2008, 06:14 PM | #5 |
Well, my actions won't execute. This is my condition; JASS:private function OrderedConditions takes nothing returns boolean return GetUnitCurrentOrder(GetOrderedUnit()) == OrderId("move") endfunction And this is the full code; JASS:library AS globals private constant integer ACraw = 'n000' // Raw code of the Army Controller private constant integer AGraw = 'A000' // Raw code of the Attack Ground spell private constant integer Araw = 'nhea' // Raw code of the custom Archer private constant integer Units = 12 // Number of units in each "army" endglobals globals private integer int = 0 private group array Group private trigger TRG = CreateTrigger() private trigger OSE = CreateTrigger() private real x private real y endglobals private constant function AttackGroundConditions takes nothing returns boolean return GetSpellAbilityId() == AGraw endfunction private function grp takes nothing returns nothing call IssuePointOrder(GetEnumUnit(), "attackground", x, y) endfunction private function AttackGroundActions takes nothing returns nothing local unit u = GetSpellAbilityUnit() local location l = GetSpellTargetLoc() local group g = CreateGroup() local integer i = 0 local unit s set x = GetLocationX(l) set y = GetLocationY(l) call GroupAddGroup(Group[GetUnitUserData(u)], g) call ForGroup(g, function grp) call RemoveLocation(l) call DestroyGroup(g) set l = null set g = null set u = null set s = null endfunction private function OrderedConditions takes nothing returns boolean return GetUnitCurrentOrder(GetOrderedUnit()) == OrderId("move") endfunction private function OrderedActions takes nothing returns nothing local unit u = GetOrderedUnit() local integer i = 1 local location ul = GetUnitLoc(u) local location ol = GetOrderPointLoc() local location array l local group g = CreateGroup() local unit d call GroupAddGroup(Group[GetUnitUserData(u)], g) call SetUnitPositionLoc(u, ol) loop exitwhen i > Units set d = FirstOfGroup(g) set l[i] = PolarProjectionBJ(ol, GetRandomReal(90, 180), GetRandomReal(GetUnitFacing(u) - 90, GetUnitFacing(u) + 90)) call IssuePointOrderLoc(d, "move", l[i]) call RemoveLocation(l[i]) call GroupRemoveUnit(g, d) set i = i + 1 endloop loop exitwhen i > Units set l[i] = null set i = i + 1 endloop call RemoveLocation(ul) call RemoveLocation(ol) call DestroyGroup(g) set ul = null set ol = null set g = null set u = null set d = null endfunction private function SoldActions takes nothing returns nothing local unit u = GetSoldUnit() local location ul = GetUnitLoc(u) local location array l local integer i = 1 local unit array d set int = int + 1 set Group[int] = CreateGroup() loop exitwhen i > Units set l[i] = PolarProjectionBJ(ul, GetRandomReal(90, 180), GetRandomReal(GetUnitFacing(u) - 90, GetUnitFacing(u) + 90)) set d[i] = CreateUnitAtLoc(GetOwningPlayer(u), GetUnitTypeId(u), l[i], GetUnitFacing(u)) call RemoveLocation(l[i]) set i = i + 1 endloop set d[0] = CreateUnitAtLoc(GetOwningPlayer(u), ACraw, ul, GetUnitFacing(u)) call SetUnitUserData(d[0], int) if GetUnitTypeId(u) == Araw then call UnitAddAbility(d[0], AGraw) endif call TriggerRegisterUnitEvent(TRG, d[0], EVENT_UNIT_ISSUED_POINT_ORDER) call TriggerRegisterUnitEvent(OSE, d[0], EVENT_UNIT_SPELL_EFFECT) call TriggerAddCondition(TRG, Condition(function OrderedConditions)) call TriggerAddAction(TRG, function OrderedActions) call TriggerAddCondition(OSE, Condition(function AttackGroundConditions)) call TriggerAddAction(OSE, function AttackGroundActions) if GetLocalPlayer() == GetOwningPlayer(u) then call ClearSelection() call SelectUnit(d[0], true) endif call RemoveUnit(u) call RemoveLocation(ul) set ul = null set u = null set i = 1 loop exitwhen i > Units set l[i] = null call GroupAddUnit(Group[int], d[i]) call UnitAddAbility(d[i], 'Aloc') set d[i] = null set i = i + 1 endloop debug call BJDebugMsg(I2S(CountUnitsInGroup(Group[int]))) endfunction //=========================================================================== function InitTrig_ArmySystem takes nothing returns nothing local trigger t1 = CreateTrigger() local trigger t2 = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_SELL) call TriggerAddAction(t2, function SoldActions) endfunction endlibrary |
| 08-01-2008, 06:16 PM | #6 |
Try GetIssuedOrderId() instead of GetUnitCurrentOrder(GetOrderedUnit()) |
| 08-01-2008, 06:21 PM | #7 | |
Quote:
Also tried that. |
| 08-01-2008, 06:24 PM | #8 |
Debug messages; see whats happening.. Start with something like this: JASS:private function OrderedConditions takes nothing returns boolean call BJDebugMsg(OrderId2String(GetIssuedOrderId())) return false endfunction Edit: Adding the same conditions and actions N times isn't nessesary. |
| 08-01-2008, 06:37 PM | #9 |
Uhm... Hehe... It was "smart" not "move".. Sorry :) +repped. EDIT: I would rep if I could.. |
| 08-01-2008, 06:49 PM | #10 |
Check for both smart and move. Smart is a right-click event (which can also be attack if targetting a widget) and move is by using the move ability and then left-clicking. |
