LOzan 10 Posted February 27, 2015 Dear members of the Arma community, I'm working on a (relatively ambitious, but isn't the journey the whole point?) scenario in which the player can recruit, train, and outfit units and assign them to squads through a Troop Manager dialog, sort of similar to the officers' dialog from DUWS. To store the characteristics of each unit, I am storing each set of characteristics in a variable generated when the unit is recruited, such as the unit's experience to date and the squad the unit is a part of. However, I've run into a problem: I have no idea how to identify the variable attached to each unit and ensure it is unique. This means that the entire plan falls apart: there is nothing to place in the arrays determining platoon organization, there is no way to store unit capabilities, etc. What I need is a system for generating each variable as the units are recruited, i.e. the first unit is associated with a variable like unit1, the next is unit2... automatically with each new unit. Does anybody know how to get past this hurdle, or know of an alternative method of achieving what I've set out to do? The idea is to create an EndWar-style sense of ownership of each unit and record persistent improvements a unit receives, making unit permadeath all the harsher... :cool: Share this post Link to post Share on other sites
shuko 59 Posted February 27, 2015 Either use a variable which actually describes the units instead of generic unit1 etc. Or use arrays to store all the needed info from which you can refer to the unit object directly without needing to name them all. Share this post Link to post Share on other sites
Rydygier 1309 Posted February 27, 2015 setVariable perhaps? 1. (IMO recommended - most "natural" way to bind variable with some unit, avoiding by the way some complications) _justSpawnedUnit setVariable ["LOZ_MyCharacteristics",[[i]list,of,all,values[/i]]]; then: _data = _justSpawnedUnit getVariable ["LOZ_MyCharacteristics",[]]; 2. missionNamespace setVariable ["LOZ_MyCharacteristics" + (str _justSpawnedUnit),[[i]list,of,all,values[/i]]]; then: _data = missionNamespace getVariable ["LOZ_MyCharacteristics" + (str _justSpawnedUnit),[]]; 3. or even "database" array like: myUnitsData = [[unit1,[[i]list,of,all,values[/i]]],[unit2,[[i]list,of,all,values[/i]]],...]; to add new: myUnitsData pushBack [_justSpawnedUnit,[[i]list,of,all,values[/i]]]; to obtain values for a unit: _data = []; { if ((_x select 0) isEqualTo _unitIWantToCheck) exitWith { _data = _x select 1 } } foreach myUnitsData; Share this post Link to post Share on other sites
LOzan 10 Posted February 28, 2015 I may be missing something, but wouldn't setVariable encounter the same issue with objects names as it would with variable identifiers? Share this post Link to post Share on other sites
jshock 513 Posted February 28, 2015 setVariable in the object namespace is local to the object (AFAIK), so you can have the same variable name for every recruited unit to store the values you want to, but locally to the unit. So say you set a variable name "unitRankVar" on two units, you set one as a Sergeant and one as Private, so when you go to check these variables on each respective unit later, the variable will return Sergeant for the first and Private for the second, one does not overwrite the other. Share this post Link to post Share on other sites