Home   Help Search Login Register  

Author Topic: [A2]Adding a Weapon  (Read 3204 times)

0 Members and 1 Guest are viewing this topic.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
[A2]Adding a Weapon
« on: 01 Jul 2009, 12:33:07 »
I put this in here, as there doesn't appear to be an "Arma2 - Configs & Scripting" forum yet.

I'm taking the plunge from scripting/mission-making, and trying to do some basic add-on related stuff.  I've read a bunch of tutorials, etc. but I can't make my 'sample' work... I wonder if anyone can give me a hand.  I'm simply PBO'ing this config.cpp, and dropping it in a modfolder's addons folder, and loading that mod.

The properties are rather 'random' at the moment, so I don't expect the weapon to actually do anything useful - I just would like it to appear in a unit's loadout.

I've fixed all of the errors I was getting in the RPT file, and now when I do
Code: [Select]
this addWeapon "TestWeapon";no errors occur (either on-screen or in the loadout), etc. but the weapon doesn't show in the unit's loadout.

Would someone mind taking a look and let me know what I'm doing wrong?  Additionally, can anyone point me in the direction of a good tutorial... I'd rather have something that explains the format a bit better than the Biki (which is very vague in this area), or a bunch of non-specific/too-specific forum threads.

Thanks in advance:

Code: [Select]
class CfgPatches
{
class TestWeapon
{
units[] = {};
weapons[] = {"TestWeapon"};
requiredVersion = 0.1;
requiredAddons[] = {"CAData","CA_Anims_Char"};
};
};
class cfgRecoils
{
ATest_Recoil[] = {0,0,0};
};
class cfgAmmo
{
class Default;
class ATestAmmo: Default
{
hit = 500;
indirectHit = 150;
indirectHitRange = 2.5;
model = "\ca\weapons\empty";
simulation = "laserDesignate";
simulationStep = 0.1;
cost = 5000;
timeToLive = 0;
soundHit[] = {"Ca\sounds\Weapons\explosions\explosion_mega_09",19.9526,1,1500};
soundFly[] = {"Ca\sounds\Weapons\explosions\rocket_fly1",0.0001,4};
maxSpeed = 350;
irLock = 0;
manualControl = 1;
maxControlRange = 0;
aiRateOfFire = 0;
aiRateOfFireDistance = 500;
initTime = 0;
 maneuvrability = 0;
};
};
class cfgMagazines
{
class CA_Magazine;
class ATestMagazine: CA_Magazine
{
scope = 2;
displayName = "Testing!";
picture = "\CA\weapons\data\equip\m_battery_CA.paa";
ammo = "ATestAmmo";
count = 1;
initSpeed = 30;
nameSound = "laserdesignator";
descriptionShort = "Testing!";
};
};
class cfgWeapons
{
class LauncherCore;
class TestWeapon: LauncherCore
{
cursor = "Missile";
cursorAim = "\ca\Weapons\Data\clear_empty";
cursorSize = 0;
descriptionShort = "A test.";
displayName = "Test!";
fireLightDuration = 0;
fireLightIntensity = 0;
forceOptics = 0;
Laser = 1;
magazines[] = {"ATestMagazine"};
model = "\ca\weapons\soflam";
modelOptics = "\ca\weapons\optika_SOFLAM";
muzzles[] = {};
nameSound = "laserdesignator";
opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"};
picture = "\CA\weapons\data\equip\m_satchel_CA.paa";
primary = 0;
recoil = "ATest_Recoil";
scope = 1;
selectionFireAnim = "zasleh";
showSwitchAction = 1;
simulation = "weapon";
type = 0;
value = 10;
class Library
{
libTextDesc = "A test!";
};
};
};

Added [A2] tag to the subject line for now...
« Last Edit: 01 Jul 2009, 17:19:40 by Wolfrug »

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: [A2]Adding a Weapon
« Reply #1 on: 01 Jul 2009, 19:31:37 »
 without having time for a detailed look , i can see already one problem that is

 in weaponcfg
 scope = 1; scope in this sense means the availability of the weapon , not the thing we look through
 should be 2 for accessible .
 maybe that will fix it, if not i will try to load up the config later.

 
I love ofp

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: [A2]Adding a Weapon
« Reply #2 on: 02 Jul 2009, 03:14:17 »
Thanks Deano... but it still doesn't work, unfortunately.  On the plus side... I understand scope a little better now! :)

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: [A2]Adding a Weapon
« Reply #3 on: 02 Jul 2009, 12:10:08 »
hmm , try something like this, i have inherited from the class you seem to be trying to imitate,
 if you have not already get a hold of worldeaters dump config and you can look what i have done , which is to inherit from the last point of the class where possible so i dont intefere with any core classes , which will then effect any others that inherit from it.
 second is to add scope = 2 where its not already.
 i dont have much time but this should work , if it does you can then manipulate to suite your needs.

Code: [Select]
class CfgPatches
{
class TestWeapons
{
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {"CAData","CA_Anims_Char"};
};
};

class cfgAmmo
{
class Laserbeam ;
class ATestAmmo: Laserbeam
    {
      hit = 500;
      indirectHit = 150;
      indirectHitRange = 2.5;
      model = "\ca\weapons\empty";
      simulation = "laserDesignate";
      simulationStep = 0.1;
      cost = 5000;
      timeToLive = 0;
      soundHit[] = {
        "Ca\sounds\Weapons\explosions\explosion_mega_09",
        19.9526,
        1,
        1500
      };
      soundFly[] = {
        "Ca\sounds\Weapons\explosions\rocket_fly1",
        0.0001,
        4
      };
      maxSpeed = 350;
      irLock = 1;
      manualControl = 1;
      maxControlRange = 0;
      aiRateOfFire = 0;
      aiRateOfFireDistance = 500;
      initTime = 0;
      maneuvrability = 0;
    };
  
};
class Laserbatteries ;
class atestmagazine :Laserbatteries
  {
      scope = 2;
      displayName = "Laser Marker";
      picture = "\CA\weapons\data\equip\m_battery_CA.paa";
      ammo = "Laserbeam";
      count = 1;
      initSpeed = 30;
      nameSound = "laserdesignator";
      descriptionShort = "Laser Designator batteries";
    };
    
class cfgWeapons
{
class Laserdesignator;
class TestWeapon: Laserdesignator
    {
      scope = 2;
      model = "\ca\weapons\soflam";
      modelOptics = "\ca\weapons\optika_SOFLAM";
      opticsPPEffects[] = {
        "OpticsCHAbera1",
        "OpticsBlur1"
      };
      displayName = "Laser Marker";
      picture = "\Ca\weapons\Data\Equip\W_SOFLAM_CA.paa";
      magazines[] = {
        "atestmagazine"
      };
      cursor = "Missile";
      cursorAim = "\ca\Weapons\Data\clear_empty";
      cursorAimOn = "Laser";
      cursorSize = 1;
      showSwitchAction = 1;
      simulation = "weapon";
      forceOptics = 2;
      Laser = 1;
      descriptionShort = "Laser Designator";
    };
};
« Last Edit: 02 Jul 2009, 12:13:42 by DeanosBeano »
I love ofp

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: [A2]Adding a Weapon
« Reply #4 on: 02 Jul 2009, 16:06:36 »
The requiredAddons line looks odd. Did you try adding "CAweapons" to the list?
try { return true; } finally { return false; }

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: [A2]Adding a Weapon
« Reply #5 on: 02 Jul 2009, 16:38:32 »
 You raise an interesting point,
 In this instance although yes it does require CA_weapons ,there is no need to put it or any other CA_X because they are a pre requiste for the game itself to work therefore its a given they will be loaded.
 for conformity and good practice however i think it should be added in case he gets something made here and someone ever uses it with a Total conversion mod that does not load CA_weapons .

 
I love ofp

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: [A2]Adding a Weapon
« Reply #6 on: 04 Jul 2009, 09:41:01 »
Try this, it is the basic minimum you would need just to inherit from the arma2 classes I think.


Code: [Select]
class CfgPatches
{
  class TestWeapons
  {
    units[] = {};
    weapons[] = {};
    requiredVersion = 0.1;
    requiredAddons[] = {"CAWeapons","CAData","CA_Anims_Char"};
  };
};


class cfgAmmo
{
  class Laserbeam;

  class ATestAmmo: Laserbeam {};
};


class cfgMagazines
{
  class CA_Magazine;
  class Laserbatteries: CA_Magazine {};

  class atestmagazine: Laserbatteries
  {
    displayName = "Laser Marker";
    ammo = "ATestAmmo";
    descriptionShort = "Laser Designator Batteries";
  };
};


class cfgWeapons
{
  class LaserDesignator;

  class TestWeapon: Laserdesignator
  {
    displayName = "Laser Marker";
    magazines[] = {"atestmagazine"};
    opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"};
    descriptionShort = "Laser Designator";
  };
};


Edit:  OOPS.....fixed


Planck
« Last Edit: 04 Jul 2009, 20:59:18 by Planck »
I know a little about a lot, and a lot about a little.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: [A2]Adding a Weapon
« Reply #7 on: 04 Jul 2009, 11:23:17 »
 thats a nice lightweight version ,

 it would need slightly more weight in the form of a "  after caweapons to work though ;).

 

I love ofp

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: [A2]Adding a Weapon
« Reply #8 on: 04 Jul 2009, 20:26:18 »
Thanks guys, will try these out later (been away for a few days :)).

Edit: It all appears to work!  Thanks guys :)  Will post again if I encounter any troubles expanding upon the basic definition!
« Last Edit: 06 Jul 2009, 12:15:15 by JamesF1 »