| 02-08-2007, 04:07 AM | #1 |
Ok, this is what IM doing to get my unit out of a game cache, it has to be MUI (Multi instancable) PS, does JASS:local integer x = 451995 set X = S2I("") JASS:globals unit array udg_Backpack_Unit timerdialog array udg_TimerWind rect gg_rct_Rect_035 trigger gg_trg_Reviving_Heroes gamecache udg_Game_Cache endglobals function Revive_Func0X20 takes nothing returns boolean return (GetUnitTypeId(GetTriggerUnit()) == 'H001' or GetUnitTypeId(GetTriggerUnit()) == 'N00U' or GetUnitTypeId(GetTriggerUnit()) == 'H002' or GetUnitTypeId(GetTriggerUnit()) == 'E003' or GetUnitTypeId(GetTriggerUnit()) == 'N01J' or GetUnitTypeId(GetTriggerUnit()) == 'N00R') and (UnitHasItemOfTypeBJ(udg_Backpack_Unit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1], 'I00N') == false) endfunction function Func_1 takes nothing returns nothing local timer t = GetExpiredTimer() local integer x = GetStoredInteger(udg_Game_Cache, "player", "x")+1 local string s = GetStoredString(udg_Game_Cache, "player", "s") local unit u = RestoreUnit(udg_Game_Cache, "player", s, Player(x), GetRectCenterX(gg_rct_Rect_035), GetRectCenterY(gg_rct_Rect_035), 270.00) local location loc = GetRectCenter(gg_rct_Rect_035) call BJDebugMsg(GetUnitName(u)) //call ReviveHeroLoc(u, loc, false) call ShowUnit(udg_Backpack_Unit[x], true) call SetUnitPositionLoc(udg_Backpack_Unit[x], loc) call PanCameraToTimedLocForPlayer(GetOwningPlayer(u), loc, 0.00) call RemoveLocation(loc) set loc = null call DestroyTimerDialog(udg_TimerWind[x]) call DestroyTimer(t) set t = null call FlushStoredInteger(udg_Game_Cache, "player", "x") call FlushStoredString(udg_Game_Cache, "player", "s") call FlushStoredUnit(udg_Game_Cache, "player", s) set x = S2I("")//(Does this null an integer?) set u = null set s = 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 s = I2S(x) + GetUnitName(u) local string pn = GetPlayerName(GetOwningPlayer(u)) call StoreUnit(udg_Game_Cache, "player", s, u) call StoreInteger(udg_Game_Cache, "player", "x", x) call StoreString(udg_Game_Cache, "player", "s", s) call BJDebugMsg("Initilized == true") call TimerStart(t, 23, false, function Func_1) set udg_TimerWind[x] = CreateTimerDialogBJ(t, pn + "'s Revive") call ShowUnitHide(udg_Backpack_Unit[x]) set t = null set u = null set s = "" set pn = "" set x = S2I("") //(Does this null the variable ?) 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 PS do I have to have some sort of system to "use" handles, and store them into game caches, and so on |
| 02-08-2007, 12:02 PM | #2 | |
Quote:
no, Seriously no. Besides of the fact you don't need to null integers. -- I don't see the point in using the gamecache natives directly, besides of incompatibilities because of the variable names, threatening to fill the gamecache file set too much (Remember the limit?) Gamecache is already too slow so the removal of function calls optimization is not a big deal. .. Because you used them you got seriously confused? StoreUnit stores the whole unit, and to retrieve it you use RestoreUnit, most likelly you only wanted to store a reference to the unit, for that you typecast the unit variable to an integer, store the integer in gamecache, then load the integer and typecast it back to unit. JASS:// transforms a reference to a handle into an integer that can be stored in gamecache function H2I takes handle h returns integer return h return 0 endfunction //transforms an integer into a unit reference function I2U takes integer i returns unit return i return null endfunction |
