Editors Depot - Mission Editing and Scripting > Arma2 - Editing/Scripting Resources Beta Testing & Submission

RUG Inventory for Arma 2

(1/2) > >>

Wolfrug:
RUG Inventory v.0.7
now converted for Arma 2 from ArmA  :clap:

This script-suite allows you to add a vehicle-variable driven and very customizable RPG-like inventory system to your missions. Create your own items and inventories, and then freely move items from one inventory to the other - even allowing dropping it on the ground! Currently in BETA for testing. Not tested in MP, no support as of now.

Use: Try the test mission and read some of the comments on some of the scripts and functions to get a deeper understanding as to how things work. Currently does not contain all planned features, but that shouldn't limit the usability as of now. Important when porting to your own mission is to copy the custom dialog (RUG_Controls.h and RUG_Inventory.h) as well as the #includes in the description.ext to your own description.ext. Do not move any of the scripts that are inside the RUG_Inventory folder anywhere else, and keep the RUG_Inventory folder in the main folder of your mission (I.e. MissionName\RUG_Inventory).

How to create your own items : see the description in the test mission's comments (specifically Template_Items.sqf).

How to create your own inventories : see the description in the test mission's comments, the init.sqf, and RUG_Inventory.sqf

How to easily add, remove and transfer items: use RUG_EasyAdd, RUG_EasyRemove and RUG_EasyTransfer. See their script headings for usage!

Advanced use : Use your imagination, and check out the test mission for some ideas.

Future implementation:
- Possible smarter use of the "leave on ground" inventory, currently leaves a permanent inventory on the ground + weaponholder if any item is ever dropped on the ground.
- Integrated shopping system. [DONE]
- Better-looking dialog. [Partly done]
- Better support and implementation of the default "use" action. [DONE]
- More example missions to showcase the scripts.
- More functions for more in-depth item/inventory-manipulation. [DONE]
- MP-testing if possible
- SP-campaign compatibility testing.
- Proper commenting of scripts!! [Mostly done]

Known issues:
- Dropping items onto the ground will really drop them into the inventory of a weaponholder. This weaponholder will disappear if you use the "gear" action on it.
- Shortly after an entity dies, they will become non-entities for the Arma 2 engine, meaning their bodies can no longer be looted or interacted with. The only solution to this that I can imagine would be to make their "loot" actions actually refer to another unit somewhere else (e.g. a game logic). They can, however, be looted for a few moments after death.
- Not MP compatible AFAIK, but it's all based on vehicle variables and global vars, so there's nothing stopping you from making it as MP'riffic as you want.
- Barter system does not take into account capitalism, inflation or anything else. Value remains constant, whether buying or selling.
- Holstering allows for the infamous big weapon + launcher 'exploit' (e.g. machinegun and M136). Do not consider serious enough to fix.
- No support for OA backpacks at the moment. Confusion reigns when wearing both a launcher and a backpack.


Version history:

v.0.7 BETA
- Added RUG_EasyCheck, for simple checking whether an inventory contains x amounts of whatever item (returns true/false). Should now be possible to do just about anything without actually using any other commands than the four "Easy" ones.
- Fixed it up for Arma 2 release, should work fine now :) Arma 2 example mission has some stuff in it to give people an idea of how it all works.
- Added a 'Your items' bag for Arma 2, which contains all the items you are carrying (map, compass etc). Also removed the RUG Inventory ones since they're obsolete. Arma 2 items can be added and edited to the scripts inside the itemControl.sqf under RUG_Inventory\ItemActions.
- Minor improvements to gunControl.sqf and RUG_Inventory.sqf (now crouches when opening an 'empty' inventory).
- Changed the font ;)
- Fixed many instances of overriding nil. My bad!

v.0.6 BETA
- Improved RUG_EasyAdd and RUG_EasyTransfer by adding an optional true/false switch for checking if there is space: they now output false and do not move any items if check is set to true and there is not enough size to add/transfer the items
- Added new function, RUG_Inventory_InitVehicleVars, which inits the necessary vehicle variables (RUG_Inventory_Size and RUG_Inventory_Name) independently of the RUG_Inventory.sqf script where they used to be initialized.
- Removed some more nil= appearances from some of the template items. Oops
- Added a "RUG_Inventory_Core.Intro" map to the package -> only contains the scripts and init files, and has properly named and ordered template items so as to avoid the clutter of the other test mission. For advanced users (um, that's me, I guess).
- Added some comments to the HireMan.sqf and BuyVehicle.sqf scripts -> note to users, there are many MUCH better ways of doing this, but since the scripts are there...

v.0.5 BETA
- Added RUG_EasyAdd, RUG_EasyRemove and RUG_EasyTransfer functions: allows for simplified item adding/removing/transfering of items. Also added custom resources and a sound to notify of items being added/removed using these commands. Instructions for use in their headers
- Moved the bulk of the global variable initialization to RUG_Inventory_Init.sqf which should now be run to init the inventory system.
- Slight changes in RUG_Inventory.h (moved some controls around a little - the general text area should have some more space now)
- Added a text to the ammo bag inventory screen instead of the standard one.
- Made all executions of RUG_Inventory.sqf and RUG_Inventory_Trade.sqf within the scripts use spawn instead of execvm.
- Added more comments to various scripts and added some more instructions to the in-game items.
- None of the scripts that require the string name of the item are case sensitive any longer.
- Added RUG_Inventory_Monitor.sqf script which simply checks for certain items that need to immediately affect a unit when they are added/removed. Currently used to switch the map/compass etc. on and off.
- Removed the nil = in front of a bunch of scripts. Oops for redefining engine commands!
- Fixed a problem by which the Your ammo inventory could be filled with size 0 items which would then be lost. Now you cannot put any items of any size inside an inventory with a size of 0.
- Minor fixes in various scripts etc.
- Changed the look of the inventory screen slightly - old look is available in ORIGINALRUG_Inventory.h if you want to revert to it :) New look has more space for general messages and slightly more space for descriptions, as well as a slightly larger picture.
- Added green (positive balance) and red (negative balance) text to the Balance number when trading


v.0.4 BETA
- Added examples for how to purchase stuff such as soldiers and vehicles
- Added a working system for transfering magazines between gear and inventory
- Fixed some minor issues with some of the existing items


v.0.3 BETA
- Added MANY new items + pictures, showcasing the various uses of the inventory system
- Spiffed up the dialog again slightly by adding item pictures
- Changes to Take/Drop/Use default actions : placing a code within the [{}] of the spawn will make that code launch if the action is successfully completed (take/drop/use). The code will have the following parameters : _this select 0 = _curValue (amount dropped/taken/used), _curSel (item dropped/taken/used), _i (number that indicates how many times the scripts have run - they will run once for every case of _curvalue. Useful for limiting the script running to just one for instance).
- Added integrated gear-menu functionality - simply press "G" while in inventory mode to access the gear menu of the object (if applicable), and then close the gear menu to return to the inventory. Still researching possibility of doing this in a reverse order.
- Added functionality to transfer all types of guns (main, secondary and pistols) from inventory to gear (via a special item). Also left some guns in the ammo box to showcase this.
- Added comments here and there

V.0.2 BETA
- Added a working trading system, invoked simply by changing the action to "RUG_Inventory_Trade.sqf".
- Changes to the way items are created due to the trading system - now requires a third element in the 9th entry : value
- Small changes to all scripts to accomodate for the trading system.
- Slight visual overhaul of the inventory screen - still pending further improvements.
- Added new function : RUG_Inventory_ftotalvalue : returns total value of inventory
- Added new scripts : RUG_Inventory_Trade.sqf and RUG_Inventory_TradeCheck.sqf
- Added ability to flag items undroppable/takeable/sellable/buyable (with default scripts).

v0.1 BETA
- Initial release

Wolfrug
14.12.2010

loki72:
really glad to see this making it back. :)

just tested.. something about a NIL being overridden?


--- Code: ---11:19:43 WARNING: NIL VARIABLE OVERRIDEN; Please fix Mission or loaded addon-scripts
11:19:44 Error in expression <e = _values select _i;
11:19:44
11:19:44 call _code;
11:19:44 };
11:19:44
11:19:44 nil;
11:19:44 >
11:19:44   Error position: <nil;
11:19:44 >
11:19:44   Error Undefined variable in expression: nil
11:19:44 File x\cba\addons\hashes\fnc_hashEachPair.sqf, line 27
11:20:18 Error in expression <e = _values select _i;
11:20:18
11:20:18 call _code;
11:20:18 };
11:20:18
11:20:18 nil;
11:20:18 >
11:20:18   Error position: <nil;
11:20:18 >
11:20:18   Error Undefined variable in expression: nil
11:20:18 File x\cba\addons\hashes\fnc_hashEachPair.sqf, line 27

--- End code ---

Wolfrug:
Thanks loki! Crap, ages since I looked over these scripts, lots of old nil='s left in there. Now I'm ashamed.  :-[ Anyway, I fixed most of them as far as I can tell, and reuploaded the mission. Please let me know if it persists. My bad!

Same goes for all the other...two..people who downloaded it: please do redownload :)

Wolfrug out.

loki72:
not to worry..

but you did miss a couple.. :P

temControl.sqf
Line 168: nil = [_InventoryObject,_owner, 0, [_InventoryObject,_owner]] spawn RUG_Inventory_MainWindow;

RUG_Inventory_Drop.sqf
Line 106: nil = [RUG_Inventory_Target, RUG_Inventory_Caller, 0, [RUG_Inventory_Target, RUG_Inventory_Caller]] spawn RUG_Inventory_TradeWindow;

i changed them to yo = blah.. and all is well in RUG_land

 :cool2:

i think arma has finally come along enough to make small scale rpg's now..

h-:
Just a quick question:
Why are you using such a way to execute scripts within a script?  ???

You only need to use the "handler method" when executing scripts in the global scope (waypoints, triggers, etc.) and even then you can use a local variable, inside scripts you can just type [RUG_Inventory_Target, RUG_Inventory_Caller, 0, [RUG_Inventory_Target, RUG_Inventory_Caller]] spawn RUG_Inventory_TradeWindow;..

Navigation

[0] Message Index

[#] Next page

Go to full version