- Joined
- Jul 10, 2007
- Messages
- 6,306
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
local unit u
if (IsItemOwned(i)) then
set u = GetItemOwner(i)
call SetUnitX(u, x)
call SetUnitY(u, y)
set u = null
else
call SetItemPosition(i, x, y)
endif
Read = YesAgain, the item owner's position is the item's position, so it would only make sense that changing or reading the item's position would change/change the owner's position >.>.
struct ItemPos extends array if (modOwner) then
call SetUnitY(GetItemOwner(i), y)
else
set u = GetItemOwner(i)
call UnitDropItemPoint(GetItemOwner(i), i, GetWidgetY(u), y)
set u = null
endif
library ItemPosition uses GetItemOwner // hiveworkshop.com/forums/showthread.php?t=184563
//Version 3.0.0.0
/*
function ItemGetX takes item i returns real
function ItemGetY takes item i returns real
function ItemGetZ takes item i returns real
//! runtextmacro ITEM_POSITION("whichItem", "xVarName", "yVarName")
- A textmacro that automatically sets variables "x" and "y".
function ItemSetX takes item i, real x returns nothing
function ItemSetY takes item i, real y returns nothing
function ItemSetZ takes item i, real z, real rate returns nothing
function ItemSetPosition takes item i, real x, real y returns nothing
Setting the item's position using these controls will set the item
owner's position as well. If you don't want this feature, don't use
these functions.
*/
globals
private location l = Location(0., 0.)
public unit tU
endglobals
function ItemGetX takes item i returns real
if (IsItemOwned(i)) then
return GetUnitX(GetItemOwner(i))
endif
return GetItemX(i)
endfunction
function ItemGetY takes item i returns real
if (IsItemOwned(i)) then
return GetUnitY(GetItemOwner(i))
endif
return GetItemY(i)
endfunction
function ItemGetZ takes item i returns real
if (IsItemOwned(i)) then
set tU = GetItemOwner(i)
call MoveLocation(l, GetUnitX(tU), GetUnitY(tU))
return GetLocationZ(tU) + GetUnitFlyHeight(u)
endif
call MoveLocation(l, GetItemX(i), GetItemY(i))
return GetLocationZ(l)
endfunction
//! textmacro ITEM_POSITION takes ITEM, X, Y
if (IsItemOwned($ITEM$)) then
set ItemPosition_tU = GetItemOwner($ITEM$)
set $X$ = GetUnitX(ItemPosition_tU)
set $Y$ = GetUnitY(ItemPosition_tU)
endif
set $X$ = GetItemX($ITEM$)
set $Y$ = GetItemY($ITEM$)
//! endtextmacro
function ItemSetPosition takes item i, real x, real y returns nothing
if (IsItemOwned(i)) then
set tU = GetItemOwner(i)
call SetUnitX(tU, x)
call SetUnitY(tU, y)
else
call SetItemPosition(i, x, y)
endif
endfunction
function ItemSetX takes item i, real x returns nothing
if (IsItemOwned(i)) then
call SetUnitX(GetItemOwner(i), x)
else
call SetItemPosition(i, x, GetItemY(i))
endif
endfunction
function ItemSetY takes item i, real y returns nothing
if (IsItemOwned(i)) then
call SetUnitY(GetItemOwner(i), y)
else
call SetItemPosition(i, GetItemX(i), y)
endif
endfunction
function ItemSetZ takes item i, real z, real rate returns nothing
if (IsItemOwned(i)) then
set tU = GetItemOwner(i)
call MoveLocation(l, GetUnitX(tU), GetUnitY(tU))
call SetUnitFlyHeight(tU, z + GetLocationZ(l), rate)
endif
endfunction
endlibrary
private function GetUnitZ takes unit u returns real
call MoveLocation(zl, GetUnitX(u), GetUnitY(u))
return GetUnitFlyHeight(u) + GetLocationZ(zl)
endfunction
function ItemGetZ takes item i returns real
if (IsItemOwned(i)) then
return GetUnitZ(GetItemOwner(i))
endif
call MoveLocation(zl, GetWidgetX(i), GetWidgetY(i))
return GetLocationZ(zl)
endfunction
function ItemSetPosZ takes item i, real x, real y, real z, boolean modOwner returns nothing
