Home   Help Search Login Register  

Author Topic: SPON_getWeaponType (DO NOT SUBMIT)  (Read 3553 times)

0 Members and 1 Guest are viewing this topic.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
SPON_getWeaponType (DO NOT SUBMIT)
« 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.
« Last Edit: 17 Oct 2007, 00:15:44 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON_getWeaponType (DO NOT SUBMIT)
« Reply #1 on: 24 Nov 2007, 12:52:48 »
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:
Code: [Select]
#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?
« Last Edit: 24 Nov 2007, 12:55:26 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: SPON_getWeaponType (DO NOT SUBMIT)
« Reply #2 on: 26 Jun 2008, 14:11:57 »
Combine and optimise.  :shhh:
urp!