In the Fullscreen Inventory 2, where is the items stored like which varaible, also what script would i need to run to move an item to the inventory screen?
but then how what is the code that activates when a item is sent to the inventory, like for example - i want to make a unit pick up an item and automatically send it to the inventory system, i know there is an autopick up but i want this to work even if they haven't got it on.
yeah thou there is a problem all of it is written in JASS scripting, i only know the basics, which is all conditions are at the bottom, and events and actions are at the top or something similar to that is it possible for anyone that knows JASS well to look at the code and tell me which part i need to copy and exactly how i need to implement it.
//################################################################################ constant function fs_H2I takes handle h returns integer return h return 0 endfunction
constant function fs_I2U takes integer i returns unit return i return null endfunction
constant function fs_I2T takes integer i returns trigger return i return null endfunction
constant function fs_I2TT takes integer i returns texttag return i return null endfunction
constant function fs_I2It takes integer i returns item return i return null endfunction
constant function fs_I2D takes integer i returns destructable return i return null endfunction
constant function fs_I2FM takes integer i returns fogmodifier return i return null endfunction
//################################################################################ function setcfg takes string key, string val returns nothing call StoreString(udg_fs_cache, "config", key, val) endfunction
function set_session_param takes string key, string val returns nothing call StoreString(udg_fs_cache, "session" + cfg("player"), key, val) endfunction
//################################################################################ function fs_chr takes integer i returns string local string abc = "abcdefghijklmnopqrstuvwxyz" local string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" local string digits = "0123456789" if i >= 65 and i <= 90 then return SubString(ABC, i-65,i-64) elseif i >= 97 and i <= 122 then return SubString(abc, i-97,i-96) elseif i >= 48 and i <= 57 then return SubString(digits, i-48,i-47) endif return "" endfunction
//################################################################################ function fs_iif takes boolean cond, string s1, string s2 returns string if cond then return s1 endif return s2 endfunction
//################################################################################ constant function fs_Coords2Id takes integer x, integer y returns integer return y * 20 + x endfunction
//################################################################################ function fs_BuildGroupIDs takes nothing returns nothing local integer i = 0 local integer g local integer array count loop exitwhen i >= 200 set g = get_session_iparam("tk_group" + I2S(i)) if g != -1 then call set_session_iparam("tk_groupid" + I2S(i), count[g]) set count[g] = count[g] + 1 else call set_session_iparam("tk_groupid" + I2S(i), -1) endif set i = i + 1 endloop endfunction
//################################################################################ function fs_SetTrackableGroup takes integer tid, integer g returns nothing call set_session_iparam("tk_group" + I2S(tid), g) endfunction
//################################################################################ function fs_GetTrackableGroup takes integer tid returns integer return get_session_iparam("tk_group" + I2S(tid)) endfunction
//################################################################################ function fs_GetTrackableGroupID takes integer tid returns integer return get_session_iparam("tk_groupid" + I2S(tid)) endfunction
//################################################################################ function fs_GetTriggeringTrackableID takes nothing returns integer return get_session_iparam("fs_trigger_tid") endfunction
//################################################################################ function fs_GetPlayerID takes nothing returns integer return cfgi("player") endfunction
//################################################################################ function fs_GetTrackableX takes integer tid returns real return cfgr("tk_" + I2S(tid) + "_x" + I2S(fs_GetPlayerID())) return get_session_rparam("tk_x" + I2S(tid)) endfunction
//################################################################################ function fs_GetTrackableY takes integer tid returns real return cfgr("tk_" + I2S(tid) + "_y" + I2S(fs_GetPlayerID())) return get_session_rparam("tk_y" + I2S(tid)) endfunction
//################################################################################ function fs_AddNamedTextTag takes string name, real x, real y, string msg, real size returns nothing local texttag tt local integer id = get_session_iparam("fs_texttags")
call set_session_iparam("fs_texttag_" + name, fs_H2I(tt)) call set_session_iparam("fs_texttag" + I2S(id), fs_H2I(tt)) call set_session_iparam("fs_texttags", id + 1) // call debugMsg("fs_AddNamedTextTag: name = " + name + " x = " + R2SW(x, 0, 0) + ", y = " + R2SW(y, 0, 0) + ", msg = " + msg) endfunction
//################################################################################ function fs_SetNamedTextTagText takes string name, string msg, real size returns nothing local texttag tt = fs_I2TT(get_session_iparam("fs_texttag_" + name)) if size == 0 then set size = cfgr("fs_texttag_size") endif call SetTextTagText(tt, msg, size) endfunction
//################################################################################ function fs_PlaySound takes string soundfile returns nothing if cfgi("fs_sound") == 0 then return endif if Player(fs_GetPlayerID()) == GetLocalPlayer() then call PlaySound(soundfile) endif endfunction
//################################################################################ function fs_RegisterEffect takes integer id, string name returns nothing call StoreInteger(udg_fs_cache, "FX", name, id) endfunction
//################################################################################ function fs_AddBackgroundEffectXY takes string modelfile, real x, real y, boolean useskin returns destructable local destructable d local integer id = get_session_iparam("fs_effects")
if useskin then set modelfile = modelfile + get_session_param("fs_skin") endif set d = CreateDestructable(GetStoredInteger(udg_fs_cache, "FX", modelfile), get_session_rparam("fs_base_x") + x, get_session_rparam("fs_base_y") + y, 0, 1.0, 1)
call set_session_iparam("fs_effect" + I2S(id), fs_H2I(d)) call set_session_iparam("fs_effects", id + 1) return d endfunction
//################################################################################ function fs_ClickHandler takes nothing returns nothing local integer tid = get_object_iparam(GetTriggeringTrackable(), "id") local integer p = get_object_iparam(GetTriggeringTrackable(), "p")
call setcfg("player", I2S(p)) if get_session_iparam("fs_enabled") == 0 then return endif
//################################################################################ function fs_HoverHandler takes nothing returns nothing local integer tid = get_object_iparam(GetTriggeringTrackable(), "id") local integer p = get_object_iparam(GetTriggeringTrackable(), "p")
call setcfg("player", I2S(p)) if get_session_iparam("fs_enabled") == 0 then return endif
//################################################################################ constant function fs_GetRaceID takes integer p returns string local race r = GetPlayerRace(Player(p)) if r == RACE_NIGHTELF then return "4" elseif r == RACE_UNDEAD then return "2" elseif r == RACE_ORC then return "3" endif return "1" endfunction
//################################################################################ function fs_Shutdown takes integer p returns nothing local integer i local destructable d local texttag tt
local real x local real y
call setcfg("player", I2S(p))
if get_session_iparam("fs_enabled") == 0 then return endif
// ############ reset camera and visibility ############ if Player(p) == GetLocalPlayer() then call SetCameraBoundsToRect(bj_mapInitialCameraBounds) call ResetToGameCamera(0) call SetCameraPosition(get_session_rparam("fs_cam_x"), get_session_rparam("fs_cam_y")) endif
set x = get_session_rparam("fs_base_x") set y = get_session_rparam("fs_base_y")
call DestroyFogModifier(fs_I2FM(get_session_iparam("fs_fogmodifier"))) call SetFogStateRect(Player(p), FOG_OF_WAR_MASKED, Rect(x + 100 , y + 100, x + 2100, y + 1100), false)
set i = get_session_iparam("fs_effects") - 1 loop exitwhen i < 0 set d = fs_I2D(get_session_iparam("fs_effect" + I2S(i))) call RemoveDestructable(d) set i = i - 1 endloop
set i = get_session_iparam("fs_texttags") - 1 loop exitwhen i < 0 set tt = fs_I2TT(get_session_iparam("fs_texttag" + I2S(i))) call DestroyTextTag(tt) set i = i - 1 endloop
//################################################################################ function fs_LoadModule takes integer p, string modname returns nothing local integer i = 0 local real x local real y local fogmodifier fm
if p >= cfgi("max_players") then call fs_echo(p, "|c00ff0000ERRORr cannot access fullscreen interface") call fs_echo(p, "(try increasing max_players setting in map configuration)") return endif
call setcfg("player", I2S(p))
if get_session_iparam("fs_enabled") == 1 then call fs_Shutdown(p) endif
set x = cfgr("fs_base_x" + I2S(p)) set y = cfgr("fs_base_y" + I2S(p)) call set_session_rparam("fs_base_x", x) call set_session_rparam("fs_base_y", y)
set fm = CreateFogModifierRect(Player(p), FOG_OF_WAR_VISIBLE, Rect(x + 100 , y + 100, x + 2100, y + 1100), false, false) call set_session_iparam("fs_fogmodifier", fs_H2I(fm)) call FogModifierStart(fm)
//################################################################################ function fs_InitPlayer takes nothing returns nothing local timer tm = GetExpiredTimer() local integer p = cfgi("player") local integer i = 0 local integer j local trackable tk local trigger t local real x local real y
if p >= cfgi("max_players") then call DestroyTimer(tm) return endif
set x = cfgr("base_x") set y = cfgr("base_y") + p * 1200
if y + 1100 > GetRectMaxY(GetWorldBounds()) then call fs_echo(-1, "|c00ff0000WARNINGr FSGUI Init: not enough map space for players " + I2S(p + 1) + "+") call fs_echo(-1, "(try increasing your map height)") call setcfg("max_players", I2S(p)) call DestroyTimer(tm) return endif
set i = 0 loop exitwhen i >= 10 set j = 0 loop exitwhen j >= 20 set tk = CreateTrackable("square.mdx", x + 74 + 100 * j, y + 962 - 100 * i, 0) set t = CreateTrigger() call TriggerRegisterTrackableHitEvent(t, tk) call TriggerAddAction(t, function fs_ClickHandler) set t = CreateTrigger() call TriggerRegisterTrackableTrackEvent(t, tk) call TriggerAddAction(t, function fs_HoverHandler) call set_object_iparam(tk, "p", p) call set_object_iparam(tk, "id", i * 20 + j)
// ### dummy left & right border trackables call CreateTrackable("square.mdx", x + 74 + 2000, y + 962 - 100 * i, 0) call CreateTrackable("square.mdx", x + 74 - 100 , y + 962 - 100 * i, 0)
set i = i + 1 endloop
// ### dummy top & bottom border trackables
set i = -1 loop exitwhen i > 20 call CreateTrackable("square.mdx", x + 74 + 100 * i, y + 1062 , 0) call CreateTrackable("square.mdx", x + 74 + 100 * i, y - 38, 0)
set i = i + 1 endloop
call setcfg("player", I2S(p + 1))
endfunction
//################################################################################ function fs_Initialize takes nothing returns nothing local integer i = 0 local integer p = 0 local integer j local trigger t local timer tm local real x local real y
// ############### set up workspace ############## call setcfg("base_x", R2S(GetRectMinX(bj_mapInitialPlayableArea) + 100.00)) call setcfg("base_y", R2S(GetRectMinY(bj_mapInitialPlayableArea) + 100.00))
set bj_mapInitialPlayableArea = Rect(cfgr("base_x") + 2300, GetRectMinY(bj_mapInitialPlayableArea), GetRectMaxX(bj_mapInitialPlayableArea), GetRectMaxY(bj_mapInitialPlayableArea))
// ############### set up path blocker line ############## set x = cfgr("base_x") + 2200 set y = GetRectMinY(GetWorldBounds())
loop exitwhen y > GetRectMaxY(GetWorldBounds()) call CreateDestructable('BX00', x, y, 0, 1.28, 0) set y = y + 128 endloop
// ############### auto detect max players if necessary ############## if cfgi("max_players") <= 0 then loop exitwhen i >= 12 if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then call setcfg("max_players", I2S(i + 1)) endif set i = i + 1 endloop endif
set tm = CreateTimer() call TimerStart(tm, 0.00, true, function fs_InitPlayer) endfunction
//################################################################################ function InitTrig_FSGUI_main_script takes nothing returns nothing local trigger t
set t = CreateTrigger() call TriggerRegisterTimerEventPeriodic(t, 0.05) call TriggerAddAction(t, function fs_ForceCameraAction)
set gg_trg_FSGUI_main_script = CreateTrigger() call TriggerAddAction(gg_trg_FSGUI_main_script, function fs_Initialize)
set udg_fs_cache = InitGameCache("FSGUI.w3v") call FlushGameCache(udg_fs_cache) call SaveGameCache(udg_fs_cache) set udg_fs_cache = InitGameCache("FSGUI.w3v") endfunction
ps. i tried e-mailing him the project i found out was abandoned along time ago and thnxs for helping
//################################################################################ function inv100_GetItemName takes integer itemId returns string local integer i = 0 if HaveStoredString(udg_fs_cache, I2S(itemId), "name") then return GetStoredString(udg_fs_cache, I2S(itemId), "name") endif return "Unknown Item (" + inv100_ItemID2String(itemId) + ")" endfunction
//################################################################################ function inv100_GetItemDesc takes integer itemId returns string local integer i = 0 if HaveStoredString(udg_fs_cache, I2S(itemId), "desc") then return GetStoredString(udg_fs_cache, I2S(itemId), "desc") endif return "Hmm seems like the description is lost...." endfunction
//################################################################################ function inv100_GetItemFX takes integer itemId returns string if itemId == 0 then return "empinv" + get_session_param("fs_skin") endif if not HaveStoredInteger(udg_fs_cache, "FX", "inv100_item" + I2S(itemId)) then set itemId = 'sclp' endif return "inv100_item" + I2S(itemId) endfunction
//################################################################################ function inv100_GetItemCost takes integer itemId returns integer if HaveStoredInteger(udg_fs_cache, I2S(itemId), "cost") then return R2I(GetStoredInteger(udg_fs_cache, I2S(itemId), "cost") * cfgr("inv100_sell_rate")) endif return 0 endfunction
//################################################################################ function inv100_IsMainInventoryFull takes unit u returns boolean local integer i = 0 loop exitwhen i >= 6 if UnitItemInSlot(u, i) == null then return false endif set i = i + 1 endloop return true endfunction
//################################################################################ function inv100_IsEnabled takes player p returns boolean call setcfg("player", I2S(GetPlayerId(p))) return get_session_iparam("fs_enabled") == 1 and get_session_param("fs_module") == "inv100" endfunction
//################################################################################ function inv100_UnitItemInSlot takes unit u, integer slot returns item return fs_I2It(get_object_iparam(u, "inv100_item" + I2S(slot))) endfunction
//################################################################################ function UnitAddItemToSlotMy takes unit u, item it, integer slot returns nothing local integer i = 0
// ### following simple order method doesn't seem to work w/ paused units... :/ // call UnitAddItem(u, it) // call IssueTargetOrderById(u, 852002 + slot, it) // return
call UnitRemoveItem(u, it) loop exitwhen i >= 6 or i > slot if i < slot then if UnitItemInSlot(u, i) == null then call UnitAddItemById(u, 'phlt') endif elseif i == slot then call UnitAddItem(u, it) endif set i = i + 1 endloop set i = 0 loop exitwhen i >= 6 or i >= slot if GetItemTypeId(UnitItemInSlot(u, i)) == 'phlt' then call RemoveItem(UnitItemInSlot(u,i )) endif set i = i + 1 endloop endfunction
//################################################################################ function inv100_UnitAddItemToSlot takes unit u, item it, integer slot returns nothing if GetItemTypeId(inv100_UnitItemInSlot(u, slot)) != 0 or IsItemPowerup(it) then return endif call UnitRemoveItem(u, it) call set_object_iparam(u, "inv100_item" + I2S(slot), fs_H2I(it)) call SetItemVisible(it, false) call SetItemPosition(it, get_session_rparam("fs_base_x") - 100, get_session_rparam("fs_base_y") - 100 + slot * 10) endfunction
//################################################################################ function inv100_UnitDropItemSlot takes unit u, integer slot returns nothing local item it = fs_I2It(get_object_iparam(u, "inv100_item" + I2S(slot))) call SetItemVisible(it, true) call SetItemPosition(it, GetUnitX(u), GetUnitY(u)) call set_object_iparam(u, "inv100_item" + I2S(slot), 0) endfunction
//################################################################################ function inv100_UnitHasItem takes unit u, item it returns boolean local integer i = 0 local integer slots = get_object_iparam(u, "inv100_rows") * get_object_iparam(u, "inv100_cols")
loop exitwhen i >= slots if inv100_UnitItemInSlot(u, i) == it then return true endif set i = i + 1 endloop return false endfunction
//################################################################################ function inv100_UnitHasItemOfType takes unit u, integer it returns boolean local integer i = 0 local integer slots = get_object_iparam(u, "inv100_rows") * get_object_iparam(u, "inv100_cols")
loop exitwhen i >= slots if GetItemTypeId(inv100_UnitItemInSlot(u, i)) == it then return true endif set i = i + 1 endloop return false endfunction
//################################################################################ function inv100_SetInventorySize takes unit u, integer rows, integer cols returns nothing if rows < 1 then set rows = 1 elseif rows > 10 then set rows = 10 endif if cols < 1 then set cols = 1 elseif cols > 10 then set cols = 10 endif call set_object_iparam(u, "inv100_rows", rows) call set_object_iparam(u, "inv100_cols", cols) endfunction
//################################################################################ function inv100_UseItem takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = fs_I2U(get_object_iparam(t, "unit")) local integer charges = get_object_iparam(t, "charges") local integer tid = get_object_iparam(t, "tid") local integer g = fs_GetTrackableGroup(tid) local integer slot = fs_GetTrackableGroupID(tid) local item it = UnitItemInSlot(u, 0)
//################################################################################ function inv100_ClickHandler takes nothing returns nothing local integer tid = fs_GetTriggeringTrackableID() local integer g = fs_GetTrackableGroup(tid) local integer slot = fs_GetTrackableGroupID(tid) local integer p = fs_GetPlayerID() local unit u = fs_I2U(get_session_iparam("unit"))
local integer tid2 = get_session_iparam("selected_cell") local integer g2 = fs_GetTrackableGroup(tid2) local integer slot2 = fs_GetTrackableGroupID(tid2) local integer charges
local string str local item it local item it2 = fs_I2It(get_session_iparam("selected_item"))
local timer t
if g == -1 then return endif
if g == 2 then call fs_Shutdown(fs_GetPlayerID()) return endif
// ####### validity checks #######
if g == 3 and not IsItemSellable(it2) then return endif
if g == 4 and (GetItemCharges(it2) == 0 or GetItemTypeId(inv100_UnitItemInSlot(u, -1)) != 0) then return endif
if g == 5 and GetItemTypeId(it2) == 0 then return endif
// ####### auto-pickup button #######
if g == 6 then if get_object_iparam(u, "inv100_auto_pickup") == 0 then if inv100_IsMainInventoryFull(u) then call fs_SetNamedTextTagText("button_label", "|cffffcc00Free at least one slot in your main inventory.|r", 0) call fs_PlaySound("Sound\\Interface\\Error.wav") return endif
if inv100_IsMainInventoryFull(u) then call set_object_iparam(u, "inv100_auto_pickup", 0) call fs_AddNamedEffect("button_pickup_selected", "", 0, false) endif
endfunction
//################################################################################ function inv100_HoverHandler takes nothing returns nothing local integer tid = fs_GetTriggeringTrackableID() local integer g = fs_GetTrackableGroup(tid) local integer slot = fs_GetTrackableGroupID(tid)
local integer p = fs_GetPlayerID() local unit u = fs_I2U(get_session_iparam("unit")) local string str local item it
if get_session_iparam("selected_cell") != -1 then set it = fs_I2It(get_session_iparam("selected_item")) elseif g == 0 then set it = UnitItemInSlot(u, slot) elseif g == 1 then set it = inv100_UnitItemInSlot(u, slot) else set it = null endif
if g == 6 then set str = "Pickup to Extended Inventory: |cffffcc00" + fs_iif(get_object_iparam(u, "inv100_auto_pickup") == 1, "ON", "OFF") + "|r" elseif g == 2 then set str = "Return to Game (|cffffcc00ESC|r)" elseif g == 3 then set str = fs_iif(get_session_iparam("selected_cell") != -1 and IsItemSellable(it), "Sell Item", " ") elseif g == 4 then set str = fs_iif(get_session_iparam("selected_cell") != -1 and GetItemCharges(it) > 0, "Use Item", " ") elseif g == 5 then set str = fs_iif(get_session_iparam("selected_cell") != -1, "Drop Item", " ") else set str = " " endif call fs_SetNamedTextTagText("button_label", str, 0)
//################################################################################ function inv100_PlayCineFilter takes nothing returns nothing if cfgi("inv100_fadefilter") == 0 then return endif if Player(fs_GetPlayerID()) != GetLocalPlayer() then return endif call SetCineFilterTexture("ReplaceableTextures\\CameraMasks\\Black_mask.blp") call SetCineFilterStartColor(0, 0, 0, 255) call SetCineFilterEndColor(0, 0, 0, 0) call SetCineFilterDuration(1.00) call DisplayCineFilter(true) endfunction
//################################################################################ function inv100_DetectShop takes nothing returns nothing if GetUnitAbilityLevel(GetEnumUnit(), 'Apit') >= 1 then call set_session_iparam("allow_sell", 1) endif endfunction
//################################################################################ function inv100_Init takes nothing returns nothing local integer i local integer tid local unit u = GetTriggerUnit() local integer rows local integer cols local integer x = 0 local integer y = 0 local item it local group gr
set rows = get_object_iparam(u, "inv100_rows") set cols = get_object_iparam(u, "inv100_cols") if rows == 0 or cols == 0 then set rows = cfgi("inv100_default_rows") set cols = cfgi("inv100_default_cols") endif call inv100_SetInventorySize(u, rows, cols) set rows = get_object_iparam(u, "inv100_rows") set cols = get_object_iparam(u, "inv100_cols")
// ####### detect nearby shop to allow sell mode #######
call set_session_iparam("allow_sell", 0)
if cfgi("inv100_sell_mode") == 1 then set gr = CreateGroup() call GroupEnumUnitsInRange(gr, GetUnitX(u), GetUnitY(u), cfgr("inv100_sell_range"), null) call ForGroup(gr, function inv100_DetectShop) call DestroyGroup(gr) elseif cfgi("inv100_sell_mode") == 2 then call set_session_iparam("allow_sell", 1) endif
// ####### attach auto-pickup trigger #######
if get_object_iparam(u, "inv100_enabled") == 0 then call TriggerRegisterUnitEvent( fs_I2T(cfgi("inv100_exit_trigger")), u, EVENT_UNIT_DEATH ) call TriggerRegisterUnitEvent( fs_I2T(cfgi("inv100_pickup_trigger")), u, EVENT_UNIT_PICKUP_ITEM ) call set_object_iparam(u, "inv100_enabled", 1) endif
set y = 0 loop exitwhen y >= rows set x = 0 loop exitwhen x >= cols set tid = fs_Coords2Id(x + 9, y) call fs_SetTrackableGroup(tid, 1) call fs_AddBackgroundEffect("central", tid, true)
set it = inv100_UnitItemInSlot(u, y * cols + x)
if GetItemTypeId(it) == 0 or IsItemOwned(it) or RectContainsItem(it, bj_mapInitialPlayableArea) then call set_object_iparam(u, "inv100_item" + I2S(y * cols + x), 0) set it = null endif
call inv100_DrawItem(tid, it)
set x = x + 1 endloop set y = y + 1 endloop call set_object_iparam(u, "inv100_item-1", 0)
set y = 1 loop exitwhen y >= rows - 1 call fs_AddBackgroundEffect("borderL" , fs_Coords2Id(9, y), true) call fs_AddBackgroundEffect("borderR" , fs_Coords2Id(8 + cols, y), true) set y = y + 1 endloop
set x = 1 loop exitwhen x >= cols - 1 call fs_AddBackgroundEffect("borderU" , fs_Coords2Id(x + 9, 0), true) call fs_AddBackgroundEffect("borderD" , fs_Coords2Id(x + 9, rows - 1), true) set x = x + 1 endloop
//################################################################################ function inv100_SaveToCache takes gamecache cache, string missionkey, string label, unit u returns nothing local integer i = 0 local integer rows = get_object_iparam(u, "inv100_rows") local integer cols = get_object_iparam(u, "inv100_cols") call StoreBoolean(cache, missionkey, label + "_inventory", true) call StoreInteger(cache, missionkey, label + "_rows", rows) call StoreInteger(cache, missionkey, label + "_cols", cols) call StoreInteger(cache, missionkey, label + "_auto_pickup", get_object_iparam(u, "inv100_auto_pickup")) loop exitwhen i >= rows * cols call StoreInteger(cache, missionkey, label + "_item" + I2S(i), GetItemTypeId(inv100_UnitItemInSlot(u, i))) call StoreInteger(cache, missionkey, label + "_charges" + I2S(i), GetItemCharges(inv100_UnitItemInSlot(u, i))) set i = i + 1 endloop // call dbg("saved label '" + label + "'...") endfunction
//################################################################################ function inv100_LoadFromCache takes gamecache cache, string missionkey, string label, unit u returns nothing local integer i = 0 local integer rows = GetStoredInteger(cache, missionkey, label + "_rows") local integer cols = GetStoredInteger(cache, missionkey, label + "_cols") local item it if not HaveStoredBoolean(cache, missionkey, label + "_inventory") then return endif call inv100_SetInventorySize(u, rows, cols) set rows = get_object_iparam(u, "inv100_rows") set cols = get_object_iparam(u, "inv100_cols") call set_object_iparam(u, "inv100_auto_pickup", GetStoredInteger(cache, missionkey, label + "_auto_pickup")) loop exitwhen i >= rows * cols call RemoveItem(inv100_UnitItemInSlot(u, i)) if GetStoredInteger(cache, missionkey, label + "_item" + I2S(i)) != 0 then set it = CreateItem(GetStoredInteger(cache, missionkey, label + "_item" + I2S(i)), 0, 0) call SetItemCharges(it, GetStoredInteger(cache, missionkey, label + "_charges" + I2S(i))) call inv100_UnitAddItemToSlot(u, it, i) endif set i = i + 1 endloop if get_object_iparam(u, "inv100_enabled") == 0 then call TriggerRegisterUnitEvent( fs_I2T(cfgi("inv100_pickup_trigger")), u, EVENT_UNIT_PICKUP_ITEM ) call set_object_iparam(u, "inv100_enabled", 1) endif // call dbg("loaded label '" + label + "'...") endfunction
//################################################################################ function inv100_AutoPickupAction takes nothing returns nothing local integer i = 0 local unit u = GetTriggerUnit() local integer p = GetPlayerId(GetOwningPlayer(u)) local integer slots = get_object_iparam(u, "inv100_rows") * get_object_iparam(u, "inv100_cols")
if IsItemPowerup(GetManipulatedItem()) or get_session_iparam("fs_enabled") == 1 or get_object_iparam(u, "inv100_auto_pickup") == 0 then return endif
loop exitwhen i >= slots if GetItemTypeId(inv100_UnitItemInSlot(u, i)) == 0 then call inv100_UnitAddItemToSlot(u, GetManipulatedItem(), i) return endif set i = i + 1 endloop endfunction
//################################################################################ function inv100_ExitEscapeAction takes nothing returns nothing if cfgi("inv100_allow_escape") == 1 then call fs_Shutdown(GetPlayerId(GetTriggerPlayer())) endif endfunction
//################################################################################ function inv100_ExitOnDeathAction takes nothing returns nothing local integer p = GetPlayerId(GetOwningPlayer(GetDyingUnit())) call setcfg("player", I2S(p)) if get_session_iparam("unit") == fs_H2I(GetDyingUnit()) then call fs_Shutdown(p) endif endfunction
//################################################################################ function inv100_EnterAction takes nothing returns nothing if GetSpellAbilityId() != cfgi("inv100_ability") then return endif
//################################################################################ function InitTrig_inventory_module takes nothing returns nothing local trigger t local integer i = 0
set t = CreateTrigger() call TriggerAddAction(t, function inv100_AutoPickupAction) call setcfg("inv100_pickup_trigger", I2S(fs_H2I(t)))
set t = CreateTrigger() call TriggerAddAction(t, function inv100_ExitOnDeathAction) call setcfg("inv100_exit_trigger", I2S(fs_H2I(t)))
set t = CreateTrigger() call TriggerAddAction(t, function inv100_ExitEscapeAction) loop exitwhen i >= 12 call TriggerRegisterPlayerEventEndCinematic(t, Player(i)) set i = i + 1 endloop
set t = CreateTrigger() call TriggerAddAction(t, function inv100_EnterAction) call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CHANNEL) endfunction