Welcome, Guest Sunday 20th April 2014, 22:27:51
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: SPON_getWeaponType (DO NOT SUBMIT)  (Read 1588 times)
0 Members and 1 Guest are viewing this topic.
Spooner
*
Offline Offline


Mostly useless


WWW
« on: 16 Oct 2007, 20: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.

* SPON_getWeaponType_v0-1-0.zip (8.01 KB - downloaded 257 times.)
« Last Edit: 16 Oct 2007, 23:15:44 by Spooner » Logged

[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)
Spooner
*
Offline Offline


Mostly useless


WWW
« 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:
#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 » Logged

[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)
Mr.Peanut
Former Staff
****
Offline Offline

urp!


« Reply #2 on: 26 Jun 2008, 13:11:57 »

Combine and optimise.  Shhh
Logged

urp!
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: