OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Spooner on 16 Oct 2007, 21:43:52
-
SPON_getWeaponType v0.1.0
- Released: 2007-10-16
- SQF function in a single file
- Includes demo mission
Works out the type of a weapon, based on its name ("M9" -> PISTOL, "M16A2" -> RIFLE, etc).
Well, this function works fine for BIS weapons, but I'm not sure of its "correctness" with non-BIS weapons (It depends on inheritance, so slightly altered weapons are likely to work fine, but completely new types of weapons could give faulty or "TYPE_UNKNOWN" responses). Hmm...I'm sure Mandoble can tear it to shreds :whistle:
ChangeLog
v0.1.0 - First release at OFPEC.
-
Oops, I realise now that this function is an over-engineered solution to a simpler solution in most cases. If you need to tell the difference between a goggles and a binocs type or if you want to know the vehicle weapon type, then it could still be useful. You can get the most useful info from just finding out what slots the weapon uses:
#define VEHICLE 0
#define PRIMARY 1
#define PISTOL 2
#define SECONDARY 4
#define SUPPORT 5
#define OPTIC 4096
_weaponClass = "M5A5";
_weaponType = getNumber (configFile >> "CfgWeapons" >> _weaponClass >> "type");
switch (_weaponType) do
{
case PRIMARY:
{
};
// ... etc ...
};
SUPPORT weapons are those that use both the PRIMARY and SECONDARY weapon slots, such as MGs. OPTIC is binocs, laser, NV-goggles.
Not sure whether to leave the SPON_getWeaponType function as it is, delete it, or use a combination of the two methods to optimise the function. Anyone care?
-
Combine and optimise. :shhh: