Jump to content

Warehouse control functions


Recommended Posts

  • ED Team

 

Warehouse control functions in DCS 

Update 2.8.8.43489 on 16th August 2023.

We are pleased to include warehouse inventory script functions. Thank you to @Grimes for initial testing and feedback, and overall creative multiplayer and mission content creators community for driving us forward.


Airbase get Warehouse example

airbase:getWarehouse()

local  w = airbase:getWarehouse()

w:addItem("A-10C",3)  -- add 3 

w:removeItem("A-10C",1)  --remove 1

w:setItem("A-10C",10)  --force to have  10 

local count =  w:getItemCount("A-10C")

w:addLiquid(0,300)  -- add 300 kg of jet fuel 

w:removeLiquid(0,100)  -- remove 100 kg of jet fuel 

local amount  = w:getLiquidAmount(0)   -- current amount

w:setLiquidAmount(0,500)

local   owner =  w:getOwner()  -- get owner object


-- weapon can be managed or using string resource name , or  indexed type table
w:addItem("weapons.missiles.AIM_120C",3) 
--or 
w:addItem({4, 4, 7, 106},3)    

Warehouse get Inventory example

warehouse:getInventory()

Usage example: 

local airbase = Airbase.getByName('Wadi al Jandali')
local warehouse = airbase:getWarehouse()
local inventory = warehouse:getInventory()

local function dump(o)
if type(o) == 'table' then
local s = '

{\n' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',\n' end return s .. '}
\n'
else
return tostring(o)
end
end

env.info(dump(inventory))

inventory = {
liquids = {},  map of [enum_of_liquid] = numeric_current_amout in kg,
weapon = {},  map of ["string key"] = numeric_current_amout,
aircraft = {},  map of ["string key"] = numeric_current_amout,
}

out sample :

10:15:16:245 2023-08-07 07:15:15.225 INFO SCRIPTING (Main): {
10:15:16:245 ["liquids"] =

{ 10:15:16:245 [1] = 100000, 10:15:16:245 [2] = 100000, 10:15:16:245 [3] = 100000, 10:15:16:245 [0] = 100000, 10:15:16:245 }
10:15:16:245 ,
10:15:16:245 ["weapon"] = {
10:15:16:245 ["weapons.nurs.SNEB_TYPE253_F1B"] = 100,
10:15:16:245 ["weapons.bombs.BDU_45LGB"] = 100,
10:15:16:245 ["weapons.missiles.AGM_65H"] = 100,
10:15:16:245 ["weapons.missiles.P_24T"] = 100,
10:15:16:245 ["weapons.missiles.AGM_154"] = 100,
10:15:16:245 ["weapons.bombs.British_GP_500LB_Bomb_Mk5"] = 100,
10:15:16:245 ["weapons.nurs.SNEB_TYPE252_F1B"] = 100, 

 

Warehouse get ResourceMap example

Warehouse.getResourceMap()
getResourceMap - return string to wstype mapping for weapon and objects in DCS
! note ! - wstype can be NULL for some objects (like shells or some categories of static objects )

local resource_map = Warehouse.getResourceMap()  ["string_key"] =

{lev1,lve2,lev3,lev4}
for k,o in pairs(resource_map) do
env.info(string.format('[\"%s\"]\t\t\t=

{%d,%d,%d,%d}
,',k,o[1],o[2],o[3],o[4]))
end  

 

 

 

  • Like 27
  • Thanks 10

smallCATPILOT.PNG.04bbece1b27ff1b2c193b174ec410fc0.PNG

Forum rules - DCS Crashing? Try this first - Cleanup and Repair - Discord BIGNEWY#8703 - Youtube - Patch Status

Windows 11, NVIDIA MSI RTX 3090, Intel® i9-10900K 3.70GHz, 5.30GHz Turbo, Corsair Hydro Series H150i Pro, 64GB DDR @3200, ASUS ROG Strix Z490-F Gaming, HP Reverb G2

Link to comment
Share on other sites

It is the greatest addition since clouds. Probably even greater one! 

  • Like 2

Верните короновирус в качестве главной проблемы, спать в маске буду, обещаю.

Скрытый текст

Hardware: AMD 5900x, 64Gb RAM@3200MHz, NVidia RTX3070 8Gb, Monitor 3440x1440(21:9), Samsung 980pro 1Tb NVMe SSD, VKB Gunfighter+MCGU, Virpil Throttle CM3, VKB T-Rudder, TrackIR.

 

Link to comment
Share on other sites

Thanks ED, definitely a big directional change to support the foundations of the core things people love to use out there. ALready written a persistent warehouse system from this:
https://github.com/thebgpikester/SWS

SImple Warehouse Saving.

  • Like 8
  • Thanks 2

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Can we have a checkbox for groups that prevents them from affecting warehouse stocks when they spawn despawn? This way AI can be set to ignore warehouses, but players can have limited weapons.

Also an issue with Unit.getAmmo(). The typeName returned in that function for the unit weapons in the unit loadout does not match the ones the unit uses when it spawns from the warehouse in all cases. AIM-9M is one example of this.

  • Like 1
Link to comment
Share on other sites

44 minutes ago, Dzsekeb said:

Can we have a checkbox for groups that prevents them from affecting warehouse stocks when they spawn despawn? This way AI can be set to ignore warehouses, but players can have limited weapons.

Also an issue with Unit.getAmmo(). The typeName returned in that function for the unit weapons in the unit loadout does not match the ones the unit uses when it spawns from the warehouse in all cases. AIM-9M is one example of this.

Technically you can add the weapons and fuel at spawn time to keep AI going when there is nothing left in the WH, but really the better option is to granularly handle the players pylon by pylon which has been requested a long time back. I'm hopeful that if we all say thanks, then we might get such a gift again and some sort of pylon checking will eventually come.

  • Like 2
  • Thanks 1

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

This is an amazing step forward thought a core ME feature, I want really say Thanks to ED!
It will be amazing have this feature in place when will be time to play with C-130 and CH-47 😉

FlySafe!

  • Like 3

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

5 minutes ago, Pikey said:

Technically you can add the weapons and fuel at spawn time to keep AI going when there is nothing left in the WH, but really the better option is to granularly handle the players pylon by pylon which has been requested a long time back. I'm hopeful that if we all say thanks, then we might get such a gift again and some sort of pylon checking will eventually come.

You could do that if Unit:getAmmo() returned the exact weapon names that the warehouse api uses, and if it returned pods and fuel tanks and such.

As it stand its not really viable unless you want to hand currate all weapon types, track all AI spawns and despawns to correct the stocks and you dont care about tracking pods and fuel tanks at all. 

Link to comment
Share on other sites

6 minutes ago, Schmidtfire said:

Can we get this to work with ME triggers without using scripts?

Long term it would be nice with a supply UI (like the rearming menu) to deliver or pick up inventory when playing a mission.

These, like many API commands aren't mirrored in the Trigger actions. Trigger actions pertain to DCS Worlds standard mission-as-a-session format. With extended missions it reaches beyond your typical one session scenario and I would say this is aimed at long running or multiplayer missions to make the best use of it. For the Airbase API commands that werent mentioned in the change logs, you can use the TRIGGER DO SCRIPT and write the command directly, thereby using the same mechanism of having no script file (albeit, its the same thing) You can also copy scripts into these triggers to make them a trigger, so its a bit of a blurred line.

 

 

7 minutes ago, Dzsekeb said:

You could do that if Unit:getAmmo() returned the exact weapon names that the warehouse api uses, and if it returned pods and fuel tanks and such.

As it stand its not really viable unless you want to hand currate all weapon types, track all AI spawns and despawns to correct the stocks and you dont care about tracking pods and fuel tanks at all. 

Unit:getAmmo() returns wsTypes() afaik? If so then then the wsTypes is an enumeration that misbehaves and changes so its not good for use. However, may I introduce you to getResourceMap() released today which translates wsType to friendly name and makes your life much easier?
If you use getInventory() on the warehouse you will get friendly names like SWS.SimpleWarehouse["Kobuleti"]["weapon"]["weapons.bombs.AB_250_2_SD_10A"] = 100 the wsTypes is a 4 letter code where the last two aren't always the same. That API feature can fix this issue you speak of.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Wiki articles for functions added with this patch: https://wiki.hoggitworld.com/view/Category:Game_Patch_2.8.8

  • Like 7
  • Thanks 2

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

27 minutes ago, Pikey said:

These, like many API commands aren't mirrored in the Trigger actions. Trigger actions pertain to DCS Worlds standard mission-as-a-session format. With extended missions it reaches beyond your typical one session scenario and I would say this is aimed at long running or multiplayer missions to make the best use of it. For the Airbase API commands that werent mentioned in the change logs, you can use the TRIGGER DO SCRIPT and write the command directly, thereby using the same mechanism of having no script file (albeit, its the same thing) You can also copy scripts into these triggers to make them a trigger, so its a bit of a blurred line.

 

 

Unit:getAmmo() returns wsTypes() afaik? If so then then the wsTypes is an enumeration that misbehaves and changes so its not good for use. However, may I introduce you to getResourceMap() released today which translates wsType to friendly name and makes your life much easier?
If you use getInventory() on the warehouse you will get friendly names like SWS.SimpleWarehouse["Kobuleti"]["weapon"]["weapons.bombs.AB_250_2_SD_10A"] = 100 the wsTypes is a 4 letter code where the last two aren't always the same. That API feature can fix this issue you speak of.

It returns a list of weapon descriptions, out of which the best identifier you have is a typeName, which does not match the getInventory returned types in all cases. 

AFAIK wsType is not included in this

Link to comment
Share on other sites

6 minutes ago, Dzsekeb said:

It returns a list of weapon descriptions, out of which the best identifier you have is a typeName, which does not match the getInventory returned types in all cases. 

AFAIK wsType is not included in this

the string is
weapons.missiles.AIM_9

for the 9M. It's an anomaly for sure. Once you have a look at the print out from the warehouse it should be easy to use. hth.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

If it helps anyone this is the table in the liquids part of the warehouse and what they are if anyone wants to add it to some docs (if not already)

-- [1] = 4999000 -- AV GAS

-- [2] = 4998000 -- WATER METH

-- [3] = 4997000 -- DIESEL FUEL

-- [0] = 5000000 --JET FUEL

 

Edited by eaglefirefly
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...