Here's a short tutorial
The various subversions of a given plane are defined through their armament array in the main java file of the aircraft, and we use this as a reference to give orders to hide or show meshes accrodingly, when a specific armament is present (= when a given subversion is selected through the armament menu in the QMB).
Here 3 versions "2xVickers" "2xVickers+2PV1" "2xOerlikon" and we want to show accordingly the meshes of 2 guns, 4 guns or 2 cannons
We can add other meshes if we wish, such as a special gunsight for the cannon, or a cockpit blister for one of the version, whatever... the principle is always the same
if...this version Mesh Visible true (or false)
The code is as follows (pay attention to teh fact that the conditions,as usual, are defined at the beginning of teh java file, athough the versions are defined at through the armamanent array at the end of the file)
public void onAircraftLoaded()
{
super.onAircraftLoaded();
if(super.thisWeaponsName.equals("2xVickers"))
{
hierMesh().chunkVisible("WGun1_D0", true);
hierMesh().chunkVisible("WGun2_D0", true);
hierMesh().chunkVisible("WGun3_D0", false);
hierMesh().chunkVisible("WGun4_D0", false);
hierMesh().chunkVisible("WCannon1_D0", false);
hierMesh().chunkVisible("WCannon2_D0", false);
return;
}
if(super.thisWeaponsName.equals("2xVickers+2PV1"))
{
hierMesh().chunkVisible("WGun1_D0", true);
hierMesh().chunkVisible("WGun2_D0", true);
hierMesh().chunkVisible("WGun3_D0", true);
hierMesh().chunkVisible("WGun4_D0", true);
hierMesh().chunkVisible("WCannon1_D0", false);
hierMesh().chunkVisible("WCannon2_D0", false);
return;
}
if(super.thisWeaponsName.equals("2xOerlikon"))
{
hierMesh().chunkVisible("WGun1_D0", false);
hierMesh().chunkVisible("WGun2_D0", false);
hierMesh().chunkVisible("WGun3_D0", false);
hierMesh().chunkVisible("WGun4_D0", false);
hierMesh().chunkVisible("WCannon1_D0", true);
hierMesh().chunkVisible("WCannon2_D0", true);
return;
} else
{
return;
}
}
then the armament array definitions
Aircraft.weaponTriggersRegister(class1, new int[] {
0, 0, 0, 0, 1, 1
});
Aircraft.weaponHooksRegister(class1, new String[] {
"_MGUN01", "_MGUN02", "_MGUN03", "_MGUN04", "_CANNON01", "_CANNON02"
});
try
{
ArrayList arraylist = new ArrayList();
Property.set(class1, "weaponsList", arraylist);
HashMapInt hashmapint = new HashMapInt();
Property.set(class1, "weaponsMap", hashmapint);
byte byte0 = 11;
String s = "2xVickers";
Aircraft._WeaponSlot a_lweaponslot[] = new Aircraft._WeaponSlot[byte0];
a_lweaponslot[0] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
a_lweaponslot[1] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
a_lweaponslot[2] = null;
a_lweaponslot[3] = null;
for(int i = 11; i < byte0; i++)
a_lweaponslot[i] = null;
arraylist.add(s);
hashmapint.put(Finger.Int(s), a_lweaponslot);
s = "2xVickers+2xPV1";
a_lweaponslot = new Aircraft._WeaponSlot[byte0];
a_lweaponslot[0] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
a_lweaponslot[1] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
a_lweaponslot[2] = new Aircraft._WeaponSlot(0, "MGunPV1", 750);
a_lweaponslot[3] = new Aircraft._WeaponSlot(0, "MGunPV1", 750);
a_lweaponslot[4] = null;
a_lweaponslot[5] = null;
for(int j = 11; j < byte0; j++)
a_lweaponslot[j] = null;
arraylist.add(s);
hashmapint.put(Finger.Int(s), a_lweaponslot);
s = "2xOerlikon";
a_lweaponslot = new Aircraft._WeaponSlot[byte0];
a_lweaponslot[0] = null;
a_lweaponslot[1] = null;
a_lweaponslot[2] = null;
a_lweaponslot[3] = null;
a_lweaponslot[4] = new Aircraft._WeaponSlot(1, "MGunMadsen20", 60);
a_lweaponslot[5] = new Aircraft._WeaponSlot(1, "MGunMadsen20", 60);
a_lweaponslot[6] = null;
a_lweaponslot[7] = null;
a_lweaponslot[8] = null;
a_lweaponslot[9] = null;
a_lweaponslot[10] = null;
for(int k = 11; k < byte0; k++)
a_lweaponslot[k] = null;
arraylist.add(s);
hashmapint.put(Finger.Int(s), a_lweaponslot);
s = "none";
a_lweaponslot = new Aircraft._WeaponSlot[byte0];
for(int l = 0; l < byte0; l++)
a_lweaponslot[l] = null;
arraylist.add(s);
hashmapint.put(Finger.Int(s), a_lweaponslot);
}
catch(Exception exception) { }
}
}