selectWeapon – Talk
Jump to navigation
Jump to search
mNo edit summary |
(Correct reading of a modes and muzzles weapon subclasses) |
||
Line 14: | Line 14: | ||
[[User:Planck|Planck]] 23:49, 12 April 2007 (CEST) | [[User:Planck|Planck]] 23:49, 12 April 2007 (CEST) | ||
==== Correct reading of a modes and muzzles weapon subclasses ==== | |||
I've idea about this code: | |||
if (count _muzzles > 1) then | |||
{ | |||
player selectWeapon (_muzzles select 0); | |||
} | |||
else | |||
{ | |||
player selectWeapon _type; | |||
}; | |||
And if we have such a config we get semantic error: | |||
class MySuperRifle : AK74 { | |||
// ... | |||
muzzles[] = {"MySuperRifleRealMuzzle"}; | |||
class MySuperRifleRealMuzzle : AK74 { | |||
// ... | |||
}; | |||
}; | |||
or such config: | |||
class MySuperRifle : AK74 { | |||
// ... | |||
muzzles[] = {"MySuperRifleRealMuzzle", "this"}; | |||
class MySuperRifleRealMuzzle : AK74 { | |||
// ... | |||
}; | |||
}; | |||
So we must check such condition: ((_muzzles select 0) != "this"), but not the (count _muzzles > 1). | |||
private [ | |||
"_weaponClassName", "_weaponConfig", "_muzzles", | |||
"_firstMuzzleName", "_realMuzzleName" | |||
]; | |||
_weaponClassName = primaryWeapon player; | |||
if (_weaponClassName != "") then { | |||
_weaponConfig = configFile >> "CfgWeapons" >> _weaponClassName; | |||
_muzzles = getArray (_weaponConfig >> "muzzles"); | |||
if (count _muzzles > 0) then { | |||
_firstMuzzleName = _muzzles select 0; | |||
_realMuzzleName = ( | |||
if (_firstMuzzleName != "this") then { | |||
_firstMuzzleName | |||
} else { | |||
_weaponClassName | |||
} | |||
); | |||
player selectWeapon _realMuzzleName; | |||
}; | |||
} | |||
All of this is also true for reading "modes" subclasses | |||
[[User:DenV|denisko.redisko (denvdmj)]] ([[User talk:DenV|talk]]) 07:04, 4 January 2015 (CET) |
Latest revision as of 07:04, 4 January 2015
Original BI comref states:
unit selectWeapon weapon
Description states:
Selects the given weapon. For weapon values see CfgWeapons.
Example states:
soldierOne selectWeapon "LAWLauncher"
Perhaps "M136" would have been better. ;)
Planck 23:49, 12 April 2007 (CEST)
Correct reading of a modes and muzzles weapon subclasses
I've idea about this code:
if (count _muzzles > 1) then { player selectWeapon (_muzzles select 0); } else { player selectWeapon _type; };
And if we have such a config we get semantic error:
class MySuperRifle : AK74 { // ... muzzles[] = {"MySuperRifleRealMuzzle"}; class MySuperRifleRealMuzzle : AK74 { // ... }; };
or such config:
class MySuperRifle : AK74 { // ... muzzles[] = {"MySuperRifleRealMuzzle", "this"}; class MySuperRifleRealMuzzle : AK74 { // ... }; };
So we must check such condition: ((_muzzles select 0) != "this"), but not the (count _muzzles > 1).
private [ "_weaponClassName", "_weaponConfig", "_muzzles", "_firstMuzzleName", "_realMuzzleName" ]; _weaponClassName = primaryWeapon player; if (_weaponClassName != "") then { _weaponConfig = configFile >> "CfgWeapons" >> _weaponClassName; _muzzles = getArray (_weaponConfig >> "muzzles"); if (count _muzzles > 0) then { _firstMuzzleName = _muzzles select 0; _realMuzzleName = ( if (_firstMuzzleName != "this") then { _firstMuzzleName } else { _weaponClassName } ); player selectWeapon _realMuzzleName; }; }
All of this is also true for reading "modes" subclasses
denisko.redisko (denvdmj) (talk) 07:04, 4 January 2015 (CET)