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

Easy way to prevent the unit order without order target point?

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
i tryed make unit stop pick up a item when unit ordered to target and target is a item, the call IssueImmediateOrder (u , "stop") dont work, only way to stop unit is call IssuePointOrder (u, "move", GetUnitX(u), GetUnitY(u)) but this way unit facing to target position what i dont want, also he have a walk->stand animation, have any reason why stop dont work in that trigger where player oderer a unit and target another unit or item?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Show your trigger.As I know so far unit allways execute stop order.

i dont think that help, coz i explained the problem :p also it is solveable with order move unit to his current position then set unit faceing just maybe have easier way then ordering and faceing


JASS:
function Trig_Start_Harvest_Actions takes nothing returns nothing
    local integer ilv
    local item itm = GetOrderTargetItem()
    local unit u = GetOrderedUnit()
    local unit ut = GetOrderTargetUnit()
    local integer cv = GetUnitUserData(u)
    local integer i
    local integer n
    local integer pl
    local real r
    if GetPlayerController(GetTriggerPlayer()) == MAP_CONTROL_USER then
        set pl = GetPlayerId(GetOwningPlayer(u)) + 1
        if itm != null then
           set ilv = GetItemLevel(itm)
            if (itm == udg_Item_Last[pl] and udg_Item_Last[pl] != null) or (ilv > 1200 and ilv < 1203) or GetItemTypeId(itm) == 'gold' then
                if ilv > 1200 and ilv < 1203 and GetItemUserData(itm) == 0 then
                    call IssueImmediateOrder( u, "stop" )
                    if GetIssuedOrderId() == OrderId("smart") then
                        set i = LoadInteger(udg_Stat_Table, 8989, GetHandleId(itm))
                        if LoadItemHandle(udg_Stat_Table, 8983, cv) != null then
                            if cv == i then
                                call SaveInteger(udg_Stat_Table, 8989, GetHandleId(LoadItemHandle(udg_Stat_Table, 8983, cv)), 0)
                                set i = 0
                            endif
                            call DestroyTextTag(LoadTextTagHandle(udg_Stat_Table, 9984, cv))
                            call SaveTextTagHandle(udg_Stat_Table, 8984, cv, null)
                            call SaveItemHandle(udg_Stat_Table, 8983, cv, null)
                        endif
                        if LoadInteger(udg_Stat_Table, 8987, cv) != 0 or LoadInteger(udg_Stat_Table, 8980, cv) == 1 then
                            call SaveInteger(udg_Stat_Table, 8980, cv, 0)
                            call SaveInteger(udg_Stat_Table, 8981, cv, - 1)
                            call SaveInteger(udg_Stat_Table, 8982, cv, 0)
                            call SaveReal(udg_Stat_Table, 8985, cv, 0)
                            call SaveReal(udg_Stat_Table, 8986, cv, 0)
                            if LoadInteger(udg_Stat_Table, 8987, cv) != 0 then
                                set udg_H_U[LoadInteger(udg_Stat_Table, 8987, cv)] = udg_H_U[udg_H_I]
                                call SaveInteger(udg_Stat_Table, 8987, cv, 0)
                                set udg_H_I = udg_H_I - 1
                            endif
                        endif
                        if i == 0 then
                            set udg_H_I = udg_H_I + 1
                            set udg_H_U[udg_H_I] = u
                            if ilv == 1201 then
                                set n = 80 - R2I((GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 1), true) + GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 2), true) + GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 3), true)) / 3.00 * 4)
                            else
                                set n = 60 - (GetCraftLv(LoadInteger(udg_Stat_Table, 27000 + cv, 4), true) * 4)
                            endif

                            call SaveInteger(udg_Stat_Table, 8980, cv, 1)
                            call SaveInteger(udg_Stat_Table, 8981, cv, - 1)
                            call SaveInteger(udg_Stat_Table, 8982, cv, n)
                            call SaveItemHandle(udg_Stat_Table, 8983, cv, itm)
                            call SaveTextTagHandle(udg_Stat_Table, 8984, cv, null)
                            call SaveReal(udg_Stat_Table, 8985, cv, GetItemX(itm))
                            call SaveReal(udg_Stat_Table, 8986, cv, GetItemY(itm))
                            call SaveInteger(udg_Stat_Table, 8987, cv, udg_H_I)
                            call SaveInteger(udg_Stat_Table, 8989, GetHandleId(itm), cv)
                            call IssuePointOrder (u, "unloadall", GetItemX(itm), GetItemY(itm))
                            if udg_H_I == 1 then
                                call EnableTrigger( gg_trg_Harvester_Timer )
                            endif
                        else
                            call IssuePointOrder (u, "move", GetItemX(itm), GetItemY(itm))
                        endif
                    endif

                endif
            else
                call Mb_Item_ToolTip (itm, cv, 0, 0)
                set udg_Item_Last[pl] = itm
                set r = GetUnitFacing(u)
                call IssuePointOrder (u, "move", GetUnitX(u), GetUnitY(u))
                call SetUnitFacing(u, r)

            endif
        else
            set udg_Item_Last[pl] = null
            if ut != null then
                if GetUnitTypeId(ut) == 'h004' and IsUnitType(u, UNIT_TYPE_HERO) then
                    //call IssueImmediateOrder( u, "stop" )
                    //call IssueTargetOrder( u, "repair", ut )
                elseif GetOwningPlayer(u) != GetOwningPlayer(ut) then
                    if udg_Unit_Last[pl] != ut then
                       if udg_Mb_Type[pl] == 0 then
                         call scaning (u, ut, GetTriggerPlayer())
                         set udg_Scan_Index = udg_Scan_Index + 1
                         set udg_Scan_Unit[udg_Scan_Index] = u
                         set udg_Scan_Target[udg_Scan_Index] = ut
                       else
                         call DestroyMultiboard(udg_Mb_Table[pl])
                         set udg_Mb_Type[pl] = 0
                         call scaning (u, ut, GetTriggerPlayer())
                         set udg_Scan_Index = udg_Scan_Index + 1
                         set udg_Scan_Unit[udg_Scan_Index] = u
                         set udg_Scan_Target[udg_Scan_Index] = ut
                       endif
                       set udg_Unit_Last[pl] = ut
                       set r = GetUnitFacing(u)
                       call IssuePointOrder (u, "move", GetUnitX(u), GetUnitY(u))
                       call SetUnitFacing(u, r)
                    endif
                endif
               
            else
              set udg_Unit_Last[pl] = null
            endif

        endif
    endif
    set itm = null
    set u = null
    set ut = null
endfunction
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
I barely understand your explanation, let me rephrase in my way.
You want it so that "this" certain unit will be ordered to stop if the order is directed to either unit or item.

Is this correct ?

If it's so, here's a test map.

ty the effort but this aint simplier with timer, 1 order and with 2 unit promp than, so i am not sure better/faster way than this?
JASS:
                set r = GetUnitFacing(u)
                call IssuePointOrder (u, "move", GetUnitX(u), GetUnitY(u))
                call SetUnitFacing(u, r)

anyway +rep
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Ah yeah I was thinking of that - save the Facing of the unit, and after issue, re-order it to face the saved angle.
But I don't think it will work, but since you have tested it, it works.

yea work, just i tryed avoid the order moveing but still with short code, anyway u can see in my signature, in full screen system is work pretty well just there a minor issue about animation sometime :D
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
MoveUnit also stops any orders.
If you can figure out how much the default offset is, then you could use that.

Default offset? - Getting a unit's position will for some reason always move it to a point that is more down and left.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
MoveUnit also stops any orders.
If you can figure out how much the default offset is, then you could use that.

Default offset? - Getting a unit's position will for some reason always move it to a point that is more down and left.

for me dont work this, unit going to target position even he was moved
JASS:
call SetUnitPosition(u, GetUnitX(u)+1, GetUnitY(u)+1 )

if i use higher value the noticeable the "teleportation" :p
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
for me dont work this, unit going to target position even he was moved
JASS:
call SetUnitPosition(u, GetUnitX(u)+1, GetUnitY(u)+1 )

if i use higher value the noticeable the "teleportation" :p

I am not really sure what the offset should be. I've just noticed that every time the unit's position is retrieved it makes a slight mistake. Maybe it rounds to the neares 8 or 16 pixels.
 
Status
Not open for further replies.
Top