| 02-10-2007, 05:46 AM | #1 |
Will this work? im trying to convert a location to an integer (perhaps I should use reals?) function L2I and function I2L JASS:globals unit array udg_Backpack_Unit rect gg_rct_Rect_035 trigger gg_trg_Reviving_Heroes gamecache udg_Game_Cache unit array udg_Hero endglobals function Revive_Func0X20 takes nothing returns boolean return UnitHasItemOfTypeBJ(udg_Backpack_Unit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1], 'I00N') == true endfunction function H2I takes handle h returns integer return h return 0 endfunction function I2U takes integer i returns unit return i return null endfunction function I2Timer takes integer i returns timerdialog return i return null endfunction function L2I takes location l returns integer return l return 0 endfunction function I2L takes integer i returns location return i return null endfunction function Revive_FuncA0G3 takes nothing returns nothing local timer t = GetExpiredTimer() local string t_s = I2S(H2I(t)) local location loc = I2L(GetStoredInteger(udg_Game_Cache, "t_s", "loc")) local integer x = GetStoredInteger(udg_Game_Cache, "t_s", "x") local unit u = I2U(GetStoredInteger(udg_Game_Cache, "t_s", "unit")) call ReviveHeroLoc(u, loc, true) call ShowUnit(udg_Backpack_Unit[x], true) call FlushStoredMission(udg_Game_Cache, t_s) call PanCameraToTimedLocForPlayer(GetOwningPlayer(u), loc, 0.00) call RemoveLocation(loc) set loc = null call DestroyTimer(t) set t = null set u = null endfunction function Revive takes nothing returns nothing local timer t = CreateTimer() local unit u = GetTriggerUnit() local integer x = GetPlayerId(GetOwningPlayer(u))+1 local string t_s = I2S(H2I(t)) local string pn = GetPlayerName(GetOwningPlayer(u)) local location l = GetUnitLoc(u) call StoreInteger(udg_Game_Cache, "t_s", "loc", L2I(l)) call StoreInteger(udg_Game_Cache, "t_s", "unit", H2I(u)) call StoreInteger(udg_Game_Cache, "t_s", "pn", x) call TimerStart(t, 5, false, function Revive_FuncA0G3) call ShowUnit(udg_Backpack_Unit[x], false) set u = null set t = null endfunction //=========================================================================== function InitTrig_Reviving_Heroes takes nothing returns nothing set gg_trg_Reviving_Heroes = CreateTrigger( ) call TriggerAddCondition(gg_trg_Reviving_Heroes,Condition(function Revive_Func0X20)) call TriggerAddAction( gg_trg_Reviving_Heroes, function Revive ) call TriggerRegisterAnyUnitEventBJ(gg_trg_Reviving_Heroes, EVENT_PLAYER_UNIT_DEATH) endfunction |
| 02-10-2007, 06:06 AM | #2 |
Couldn't you just use GetLocationX() and GetLocationY() to get values, and then convert them to integers, or something of that sort? I'm sure you could figure out a system for adding/subtracting/multiplying/dividing those values to get a new value? |
| 02-10-2007, 06:09 AM | #3 |
Yea good idea, thanks Btw will JASS:function I2Item takes integer i returns item return i return null endfunction function blah takes nothing returns nothing call UnitRemoveItem(u, I2Item('I00N')) endfunction I wanna remove any item of type "I00N" |
| 02-10-2007, 06:56 AM | #4 |
JASS:function I2Item takes integer i returns item return i return null endfunction function blah takes nothing returns nothing call UnitRemoveItem(u, I2Item('I00N')) endfunction Do you really need that? It seems quite weird, because 'I00N' is a bit big and I'm almost sure it will return null because that. But I can be wrong. For a single item type, you can simply go on this : JASS:function RemoveItemType takes unit whichUnit,integer itemId returns integer local integer index local item indexItem set index = 0 loop set indexItem = UnitItemInSlot(whichUnit, index) if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then call UnitRemoveItem(whichUnit,indexItem) endif set index = index + 1 exitwhen index >= 6 endloop endfunction |
| 02-10-2007, 09:31 AM | #5 | |
Quote:
Did you even read what I said about handles and slots? |
| 02-10-2007, 11:26 AM | #6 | |
Quote:
Please, this is so wrong. Please get some understanding about the differences between item ids and references... I will say it once: If what you are doing actually uses a return bug exploiter of the form [take integer return some handle type] what you are doing is most likely unsafe and you should avoid to use it. |
| 02-10-2007, 08:55 PM | #7 |
I thought of looping through the inventory, then removing it when I found that item type |
| 02-10-2007, 10:38 PM | #8 |
The handle to integer is only used to reference a single handle. It is not an item or an item-type, but a specific item. Ex: Bob has Claws of Attack + 5 Joe has Claws of Attack + 5 They are both the same type of item, but the return bug will return a different integer because they are different items It is mainly used to store values in a gamecache, using it as a string or integer. Ex. Some spells manipulate units. Instead of storing all the units in a global variable, you could store the units in a gamecache, under the handle of the casting unit. Then you can use Integer to Unit to get the units back after the desired wait period. |
