OFPEC Forum

Addons & Mods Depot => OFP - Addons & Mods General => Topic started by: Tyger on 21 Jan 2006, 23:15:10

Title: weapons replacement and the config.cpp
Post by: Tyger on 21 Jan 2006, 23:15:10
Okay, I'm uber-lazy(tm), and to recode the config.cpp (config.bin) for a weapons replacement mod will take several hours/days to do. I don't really want to spend that time doing it.

So frankly, do you need to recode the entire config.cpp (config.bin) to replace certain weapons, or can you do it with an addon or such (i.e. without recoding the config.cpp?)

For example, if I wanted to replace just the M16 with SJB's M16A2, here is the config code:
Code: [Select]
class M16:Riffle
      {
      scopeWeapon=2;
      scopeMagazine=2;
      valueWeapon=0;
      valueMagazine=1;
      model="\SJB_TOSM4\SJB_M16A2_proxy.p3d";
      modelOptics="\SJB_Optics\optic_m16.p3d";
      optics=1;
      opticsZoomMin=0.35;
      opticsZoomMax=0.35;
      displayName="M16A2";
      displayNameMagazine="5.45x45mm M16A2";
      shortNameMagazine="5.45x45mm";
      drySound[]={"\SJB_TOSM4\sound\Dry.ogg",0.01,1};
      magazines[]={"M16","Mortar"};
      modes[]={"Single","Burst"};

      class Single
         {
         ammo="BulletSingleW";
         multiplier=1;
         burst=1;
         displayName="5.45x45mm Semi";
         dispersion=0.0002;
         sound[]={"\SJB_TOSM4\sound\M16_SS.wss","db0",1};
         soundContinuous=0;
         reloadTime=0.07;
         ffCount=1;
         recoil="riffleSingle";
         autoFire=0;
         aiRateOfFire=5.0;
         aiRateOfFireDistance=500;
         useAction=0;
         useActionTitle="";
         };

      class Burst
         {
         ammo="BulletBurstW";
         multiplier=1;
         burst=3;
         displayName="5.45x45mm Burst";
         dispersion=0.0004;
         sound[]={"\SJB_TOSM4\sound\M16B3.ogg",1.0,1};
         soundContinuous=0;
         reloadTime=0.1;
         ffCount=3;
         recoil="riffleBurst3";
         autoFire=0;
         aiRateOfFire=5.0;
         aiRateOfFireDistance=500;
         useAction=0;
         useActionTitle="";
         };
      };

Now do I have to do that for the config.cpp or can I just .pbo that with a little extra code and be finished with it?
Title: Re:weapons replacement and the config.cpp
Post by: h- on 22 Jan 2006, 16:47:54
It should work as an addon pbo if you just keep the original BIS classname(s) on the weapon(s)..
Of course you need the whole shabang of CfgPatches etc to get the config of yers to work, but anyway.....

Why don't you just try it? Not even the Lazy(tm) is that lazy.. ::) ;D
Title: Re:weapons replacement and the config.cpp
Post by: Tyger on 22 Jan 2006, 23:10:15
Yes, I do need the CfgPatches to make it work apparently.

I replaced that section in the CONFIG.cpp, then stuck it in a mod folder and had a go. The game wouldn't start up...

What would the CfgPatches section require? i.e. How would I use the CfgPatches thing? I'll take a stab and see if I get close...

Code: [Select]
class CfgPatches
{
   class M16
   {
      units[] = {};
      weapons[] = {M16};
      requiredVersion = 1.96;
   };
};

Would that be it possibly?
Title: Re:weapons replacement and the config.cpp
Post by: Planck on 23 Jan 2006, 02:47:44
Ahhhh.....well,

Code: [Select]
class CfgPatches
{
   class nameofmypbo
   {
      units[] = {};
      weapons[] = {cfgweaponsclassname};
      requiredVersion = 1.96;
   };
};


That should do it



Planck
Title: Re:weapons replacement and the config.cpp
Post by: Tyger on 23 Jan 2006, 04:28:50
So if I'm replacing the M16 in the game, then it would look like this?

config.cpp
Code: [Select]
class CfgPatches
{
   class WpnReplace
   {
      units[] = {};
      weapons[] = {M16};
      requiredVersion = 1.96;
   };
};

or would it be that inside the WpnReplace.pbo? The latter probably, Im guessing.
Title: Re:weapons replacement and the config.cpp
Post by: Planck on 23 Jan 2006, 13:56:11
class nameofmypbo is the name of the pbo containing your model file, and presumably its textures and other related gubbins.

cfgweaponsclassname is the classname you have given the weapon in cfgweapons.

So, if my model was in a pbo called fandabadozie.pbo and the classname given in the cfgweapons section of my config was spudgun, it would look thus:

Code: [Select]
class CfgPatches
{
  class fandabadozie
  {
      units[] = {};
      weapons[] = {spudgun};
      requiredVersion = 1.96;
  };
};

 ;D


Planck
Title: Re:weapons replacement and the config.cpp
Post by: Tyger on 24 Jan 2006, 22:42:32
Okay, thanks  ;)