code34 248 Posted January 1, 2016 Object Oriented INVENTORYLastest version : 0.4 by Code34Like to Donate ? Donate with paypal Download from DropBox Download from Armaholic GitHub: https://github.com/code34/oo_inventory.altis Reference: http://forums.bistudio.com/showthread.php?167980-Object-Oriented-SQF-Scripting-and-Compiling Description OO INVENTORY is a class (object oriented) that enhances the usage/operations on units concerning their inventory by adding or improve BIS standard commands. Features: add new inventory commands refactory command name as standard retrieve informations concerning magazines/bullets retrieve informations concerning vest/uniform/backpack give some methods to take off inventory get / set method to interract with inventory give some methods to clear inventory Licence: Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author OO_INVENTORY 0.2 is totaly deprecated, and replaced by PDWDocumentation Quote /* Author: code34 nicolas_boiteux@yahoo.fr Copyright © 2013-2016 Nicolas BOITEUX CLASS OO_INVENTORY - a class to manage unit inventory This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -------------------------------------------------------------------------------------------------------------- Function: _inventory = ["new", _unit] call OO_INVENTORY; create a new OO_INVENTORY object Parameters: _unit : unit object wich we will manage inventory -------------------------------------------------------------------------------------------------------------- Function: _version = "getVersion" call _inventory; Return OO_INVENTORY version Parameters: none Return : string _version -------------------------------------------------------------------------------------------------------------- Function: ["setUnit", _unit] call _inventory; Set a new unit object Parameters: _unit : unit object wich we will manage inventory Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearInventory" call _inventory; Clear all inventory of the unit object Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearBackPack" call _inventory; Clear backpack inventory of the unit object Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearBackpackItems" call _inventory; Clear items of backpack inventory (without weapons) Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearBackpackWeapons" call _inventory; Clear weapons of backpack inventory (without items) Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearUniform" call _inventory; Clear uniform inventory of the unit object Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearUniformItems" call _inventory; Clear items of uniform inventory (without weapons) Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearUniformWeapons" call _inventory; Clear weapons of uniform inventory (without items) Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearVest" call _inventory; Clear vest inventory of the unit object Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearVestItems" call _inventory; Clear items of vest inventory (without weapons) Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "clearVestWeapons" call _inventory; Clear weapons of vest inventory (without items) Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "takeOffInventory" call _inventory; Take off all inventory Parameters: nothing Return : groundweaponholder containing objects -------------------------------------------------------------------------------------------------------------- Function: "takeOffVest" call _inventory; Take off vest + contents Parameters: nothing Return : groundweaponholder containing objects -------------------------------------------------------------------------------------------------------------- Function: "takeOffUniform" call _inventory; Take off uniform + contents Parameters: nothing Return : groundweaponholder containing objects -------------------------------------------------------------------------------------------------------------- Function: "takeOffBackPack" call _inventory; Take off backpack + contents Parameters: nothing Return : nothing -------------------------------------------------------------------------------------------------------------- Function: "takeOffPrimaryWeapon" call _inventory; Take off Primary weapon + magazine loaded Parameters: nothing Return : groundweaponholder containing objects -------------------------------------------------------------------------------------------------------------- Function: "takeOffSecondaryWeapon" call _inventory; Take off Secondary weapon + magazine loaded Parameters: nothing Return : groundweaponholder containing objects -------------------------------------------------------------------------------------------------------------- Function: "takeOffHandGun" call _inventory; Take off Hand Gun + magazine loaded Parameters: nothing Return : groundweaponholder containing objects -------------------------------------------------------------------------------------------------------------- Function: _type = "getPrimaryWeaponType" call _inventory; Get the primary weapon type Parameters: nothing Return : string - type of the primary weapon -------------------------------------------------------------------------------------------------------------- Function: _type = "getSecondaryWeaponType" call _inventory; Get the secondary weapon type Parameters: nothing Return : string - type of the secondary weapon -------------------------------------------------------------------------------------------------------------- Function: _type = "getHandGunType" call _inventory; Get the hand gun type Parameters: nothing Return : string - type of the hand gun -------------------------------------------------------------------------------------------------------------- Function: _type = "getBackPackType" call _inventory; Get the backpack type Parameters: nothing Return : string - type of the backpack -------------------------------------------------------------------------------------------------------------- Function: _backpack = "getBackPack" call _inventory; Get the backpack of unit Parameters: nothing Return : object - backpack of the unit -------------------------------------------------------------------------------------------------------------- Function: _array = "getBackPackItems" call _inventory; Get all items type in the backpack (without weapons) Parameters: nothing Return : array containing all the items type in the backpack -------------------------------------------------------------------------------------------------------------- Function: _array = "getBackPackWeapons" call _inventory; Get all weapons in the backpack Parameters: nothing Return : array containing all the items type in the backpack -------------------------------------------------------------------------------------------------------------- Function: _type = ["getAmmoLoadedType", _source] call _inventory; Get the ammo type loaded for the source weapon Parameters: _source can be : "primaryweapon", "secondaryweapon", "handgun", "grenade" Return : string - type of the ammo loaded -------------------------------------------------------------------------------------------------------------- Function: _count = ["getAmmoLoadedCount", _source] call _inventory; Get the ammos count loaded for the source weapon Parameters: _source can be : "primaryweapon", "secondaryweapon", "handgun", "grenade" Return : scalar - number of ammo loaded for the source weapon -------------------------------------------------------------------------------------------------------------- Function: _count = ["getMagazinesCountByType", _type] call _inventory; Get count of magazines depending of magazine class Parameters: string _type - class of magazine Return : scalar - number of magazines avalaible -------------------------------------------------------------------------------------------------------------- Function: _count = ["getAmmoCountByType", _type] call _inventory; Get count of bullets depending of magazine class Parameters: string _type - class of magazine Return : scalar - number of bullets avalaible -------------------------------------------------------------------------------------------------------------- Function: _count = ["getAmmoCountByWeapon", _source] call _inventory; Get count of bullets depending of weapon Parameters: _source can be : "primaryweapon", "secondaryweapon", "handgun" Return : scalar - number of bullets avalaible -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasBackPack" call _inventory; Check if unit has a backpack Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasVest" call _inventory; Check if unit has a Vest Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasUniform" call _inventory; Check if unit has an uniform Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasPrimaryWeapon" call _inventory; Check if unit has a primary weapon Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasSecondaryWeapon" call _inventory; Check if unit has a secondary weapon Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasHandGun" call _inventory; Check if unit has a hand gun Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasHeadGear" call _inventory; Check if unit has a head gear Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _bool = "hasGoggles" call _inventory; Check if unit has a goggles Parameters: nothing Return : bool - true if he has -------------------------------------------------------------------------------------------------------------- Function: _array = "getInventory" call _inventory; Get inventory of the unit object Parameters: nothing Return : Array containing : 0 - headgear 1 - goggles 2 - uniform 3 - uniformitems 4 - vest 5 - vestitems 6 - backpack 7 - backpackitems 8 - magazinesAmmoFull 9 - primaryweapon 10 - primaryweaponitems 11 - secondaryweapon 12 - secondaryweaponitems 13 - handgunweapon 14- handgunitems 15- assigneditems -------------------------------------------------------------------------------------------------------------- Function: ["setInventory", _array] call _inventory; Set inventory of the unit object Parameters: _array containing : 0 - headgear 1 - goggles 2 - uniform 3 - uniformitems 4 - vest 5 - vestitems 6 - backpack 7 - backpackitems 8 - magazinesAmmoFull 9 - primaryweapon 10 - primaryweaponitems 11 - secondaryweapon 12 - secondaryweaponitems 13 - handgunweapon 14- handgunitems 15- assigneditems Return : nothing -------------------------------------------------------------------------------------------------------------- Function: = ["delete", _inventory] call OO_INVENTORY; destroy the OO_INVENTORY object Parameters: _inventory - OO_INVENTORY object to delete Readme Quote /* Author: code34 nicolas_boiteux@yahoo.fr Copyright © 2013-2016 Nicolas BOITEUX CLASS OO_INVENTORY - a class to manage unit inventory This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ Create an inventory object to load/save unit inventory Usage: put the "oo_inventory.sqf" and the "oop.h" files in your mission directory put this code into your mission init.sqf call compilefinal preprocessFileLineNumbers "oo_inventory.sqf"; See example mission in directory: init.sqf Licence: You can share, modify, distribute this script but don't remove the licence and the name of the original author logs: 0.3 - add bullets count methods - add clear methods - add get methods - add Takeoff methods - add setUnit methods - add hasX methods - fix interface - fix magazine methods/locality - fix gps - update documentation 0.2 - add accessors set/get - rebuild constructor - add doc 0.1 - OO_INVENTORY - from combat-assault.eu mission Example init.sqf Quote call compilefinal preprocessFileLineNumbers "oo_inventory.sqf"; // create a new inventory _inventory = ["new", toto] call OO_INVENTORY; sleep 2; hint format ["OO_INVENTORY version: %1", "getVersion" call _inventory]; sleep 2; // get bullet _result = ["getAmmoCountByWeapon", "primaryweapon"] call _inventory; hint format ["count bullets for primary weapon %1", _result]; sleep 2; // get bullet _result = ["getAmmoCountByWeapon", "secondaryweapon"] call _inventory; hint format ["count bullets for secondary weapon %1", _result]; sleep 2; // get bullet _result = ["getAmmoCountByWeapon", "handgun"] call _inventory; hint format ["count bullets for hand gun %1", _result]; sleep 2; // get uniform _result = "getUniformItems" call _inventory; hint format ["Uniform Items: %1 ", _result]; sleep 2; // get uniform _result = "getUniformWeapons" call _inventory; hint format ["Uniform Weapons: %1 ", _result]; sleep 2; // get vest _result = "getVestItems" call _inventory; hint format ["Vest Items: %1 ", _result]; sleep 2; // get vest _result = "getVestWeapons" call _inventory; hint format ["Vest Weapons: %1 ", _result]; sleep 2; hint "AI spend 1 bullet"; toto fire ("getPrimaryWeaponType" call _inventory); sleep 2; hint format ["Secondary ammo type %1 count %2", ["getAmmoLoadedType", "secondaryweapon"] call _inventory, ["getAmmoLoadedCount", "secondaryweapon"] call _inventory]; sleep 2; _type = ["getAmmoLoadedType", "primaryweapon"] call _inventory; _result = ["getAmmoCountByType", _type] call _inventory; hint format ["primary weapon bullets count %1",_result]; sleep 2; _result = ["getMagazinesCountByType", _type] call _inventory; hint format ["primary magazines count %1",_result]; sleep 2; toto fire ("getHandGunType" call _inventory); sleep 2; // get Backpack toto addItemToBackpack "itemGPS"; _result = "getBackPackItems" call _inventory; hint format ["Backpack Items: %1 ", _result]; sleep 2; // get Backpack _result = "getBackPackWeapons" call _inventory; hint format ["Backpack Weapons: %1 ", _result]; sleep 2; // get Backpack _result = "getBackPackType" call _inventory; hint format ["Backpack: %1 ", _result]; sleep 2; // get current ammos _count = ["getAmmoLoadedCount", "primaryweapon"] call _inventory; hint format ["Nb of ammos loaded in primary weapon %1", _count]; sleep 2; // get current ammos _count = ["getAmmoLoadedCount", "secondaryweapon"] call _inventory; hint format ["Nb of ammos loaded in secondary weapon %1", _count]; sleep 2; // get current ammos _count = ["getAmmoLoadedCount", "handgun"] call _inventory; hint format ["Nb of ammos loaded in hand gun %1", _count]; sleep 2; // get current ammos _count = ["getAmmoLoadedCount", "grenade"] call _inventory; hint format ["Nb of ammos loaded in grenade %1", _count]; sleep 2; // get inventory content _array = "getInventory" call _inventory; hint format ["inventory content: %1", _array]; sleep 2; // Clear inventory of character "clearInventory" call _inventory; sleep 2; // set inventory ["setInventory", _array] call _inventory; hint "set Inventory back"; sleep 2; // check if backpack _result = "hasBackPack" call _inventory; hint format ["has backpack %1", _result]; sleep 2; // check if vest _result = "hasVest" call _inventory; hint format ["has Vest %1", _result]; sleep 2; // check if uniform _result = "hasUniform" call _inventory; hint format ["has Uniform %1", _result]; sleep 2; // check if goggle _result = "hasGoggles" call _inventory; hint format ["has Goggles %1", _result]; sleep 2; // check if goggle _result = "hasPrimaryWeapon" call _inventory; hint format ["has Primary Weapon %1", _result]; sleep 2; _result = "hasSecondaryWeapon" call _inventory; hint format ["has Secondary Weapon %1", _result]; sleep 2; _result = "hasHandGun" call _inventory; hint format ["has Hand Gun %1", _result]; sleep 2; _result = "hasHeadGear" call _inventory; hint format ["has Head Gear %1", _result]; sleep 2; // clear inventory "clearBackPack" call _inventory; "clearBackpackItems" call _inventory; "clearBackpackWeapons" call _inventory; "clearVest" call _inventory; "clearVestItems" call _inventory; "clearVestWeapons" call _inventory; "clearUniform" call _inventory; "clearUniformItems" call _inventory; "clearUniformWeapons" call _inventory; hint "clear content of : Backpack + vest + uniform"; sleep 2; ["setInventory", _array] call _inventory; hint "set same Inventory as begining"; sleep 2; "takeOffVest" call _inventory; "takeOffUniform" call _inventory; "takeOffBackPack" call _inventory; hint "take off vest, uniform, backpack"; sleep 2; "takeOffPrimaryWeapon" call _inventory; hint "take off primary weapon"; sleep 2; "takeOffSecondaryWeapon" call _inventory; hint "take off secondary weapon"; sleep 2; "takeOffHandGun" call _inventory; hint "take off hand gun"; sleep 2; "takeOffInventory" call _inventory; hint "take off all inventory"; sleep 2; ["setUnit", tata] call _inventory; hint "change to next unit"; sleep 2; // Clear inventory of character "clearInventory" call _inventory; hint "clear inventory of next unit"; sleep 2; // set inventory ["setInventory", _array] call _inventory; hint "set same Inventory as first unit"; sleep 2; 1 Share this post Link to post Share on other sites
code34 248 Posted January 2, 2016 hi :) you can find/view the coding session at this place :) part 1 http://www.twitch.tv/code34/v/32950237 part 2 http://www.twitch.tv/code34/v/32988581 Share this post Link to post Share on other sites
Guest Posted January 2, 2016 Release frontpaged on the Armaholic homepage. Object Oriented Inventory v0.3 ** Armaholic now supports authors with donation button/links. If you have those please contact me! Share this post Link to post Share on other sites
code34 248 Posted January 2, 2016 Release frontpaged on the Armaholic homepage. Object Oriented Inventory v0.3 ** Armaholic now supports authors with donation button/links. If you have those please contact me! Hello Foxhound ! Thanks you for the update, and have a nice happy new year :) Share this post Link to post Share on other sites
code34 248 Posted January 7, 2016 any feedbacks about this last release ? :D Share this post Link to post Share on other sites
Ranwer135 308 Posted January 8, 2016 I haven't tried it yet, but I can say that it is a masterpiece! ;) Share this post Link to post Share on other sites
code34 248 Posted January 25, 2016 any other feedback about this ? :) 1 Share this post Link to post Share on other sites
code34 248 Posted October 25, 2017 hi just release the new version 0.4 :) - fix addweapon for items - fix typo - add isequalto instead == - use native array method - fix setinventory bug https://github.com/code34/oo_inventory.altis Share this post Link to post Share on other sites
Netarion 2 Posted August 27, 2018 Nice job! It allows to me to customize equipment of a unit easily and reload this equipment when the unit repop after their death. The function that puts all the codes of the objects of a unit at the clipboard is a very good thing!! Continue to do a good job! ;) 1 Share this post Link to post Share on other sites
davidoss 550 Posted August 27, 2018 Well i do not understand for what is that all. You can achieve the same inventory manipulation just using BIS stuff. Can someone please explain to me what's is going about? Share this post Link to post Share on other sites
code34 248 Posted August 28, 2018 To better understand you should look at the list of methods described above. There are many more features than is proposed by BIS. Most of the time the interest is in the fact that you can trigger more precise actions on individual elements, and all the functions are ready to use and in the same class. Share this post Link to post Share on other sites
davidoss 550 Posted August 28, 2018 Thanks for tips and for your work on this. Share this post Link to post Share on other sites