FriendlyIntentions 10 Posted April 3, 2014 Hey, I'm trying to add a single shot ak47 to learn about editing config files. In its present state this does not work, (/ instead of = error). This kind of worked when it was botched onto another user addon but my attempts at reverse engineering into a standalone have failed. I say kind of worked because the player could hold the weapon but couldn't pick up magazines or load the gun. The code is a modified copy of the code in original flashpoint config file. Also the picture in the gear notebook/map screen was missing (an error was shown) If anyone can give me any info on how to add a clone of an existing weapon to the game with a config file or point me to some tutorials it would be great. My end aim with this is to make a single shot only ak47 that can use a defined 12 round mag and the standard ak47 mag. Thanks in advance for any help. / BASIC DEFINES ////////////////////////////////////////////////////////////////////////////////// #define TEast 0 #define TWest 1 #define TGuerrila 2 #define TCivilian 3 #define TSideUnknown 4 #define TEnemy 5 #define TFriendly 6 #define TLogic 7 #define true 1 #define false 0 #define private 0 #define protected 1 #define public 2 #define WeaponNoSlot 0 // dummy weapons #define WeaponSlotPrimary 1 // primary weapons #define WeaponSlotSecondary 16 // secondary weapons #define WeaponSlotHandGun 2 // HandGun #define WeaponSlotHandGunItem 32 // HandGun magazines #define WeaponSlotItem 256 // items #define WeaponSlotBinocular 4096 // binocular #define WeaponHardMounted 65536 // START CONFIGS ////////////////////////////////////////////////////////////////////////////////// class CfgPatches { class myweaponsx { weapons[]= { AK47S }; requiredVersion = 1.90; requiredAddons[] = {BIS_Resistance,BIS_WeaponPack}; }; }; class CfgWeapons { access=3; ////////////////////////////////////////////////////////////////////// //BIS/ADDONS CLASS TREE class Default {}; class MGun: Default {}; class MachineGun7_6: MGun {}; class MachineGun7_6Manual: MachineGun7_6 {}; class PK: MachineGun7_6Manual {}; class M60: MachineGun7_6Manual {}; class Riffle: MGun {}; class M16: Riffle {}; class HKG3Base: M16 {}; class FALBase: HKG3Base {}; class M4: Riffle {}; class AK47: Riffle {}; class AK74: Riffle {}; class AK74SU: AK74 {}; class SniperRiffle: Riffle {}; class M21: SniperRiffle {}; class SVDDragunov: SniperRiffle {}; class HuntingRifleBase: SniperRiffle{}; class HandGunBase: Riffle {}; class CZ75Base: HandGunBase {}; class BerettaBase: CZ75Base {}; class TokarevBase: CZ75Base {}; class Put: Default {}; class PipeBomb: Put {}; class GrenadeLauncher: Default {}; class Throw: GrenadeLauncher {}; class HandGrenade: GrenadeLauncher {}; class TimeBomb: Default {}; class Mine: TimeBomb {}; class MineE: TimeBomb {}; class LAWLauncher: Default {}; class RPGLauncher: LAWLauncher {}; class CarlGustavLauncher: LAWLauncher {}; class AT4Launcher: CarlGustavLauncher {}; class AALauncher: CarlGustavLauncher {}; class 9K32Launcher: AALauncher {}; class LaserDesignatorBase: default {}; class LaserDesignator: LaserDesignatorBase {}; ////////////////////////////////////////////////////////////////////// ///New Weapons class AK47S: AK47 { scopeWeapon = 2; scopeMagazine = 2; model = AK_47_proxy; modelOptics = optika_ak47; optics = 1; opticsZoomMin = 0.35; opticsZoomMax = 0.35; displayName = "Ak47 Single Shot"; displayNameMagazine = $STR_MN_AK47; shortNameMagazine = $STR_SN_AK47; drySound[] = {"weapons\AK74Dry",0.01,1}; magazines[]={"AK47"}; modes[] = {Single}; class Single { ammo = BulletSingleG; multiplier = 1; burst = 1; displayName = $STR_DN_AK47; dispersion = 0.0002; sound[] = {"Weapons\AK74Single",1,1}; soundContinuous = 0; reloadTime = 0.15; ffCount = 1; recoil = riffleSingle; autoFire = 0; aiRateOfFire = 5; aiRateOfFireDistance = 500; useAction = 0; useActionTitle = ""; }; }; } Share this post Link to post Share on other sites
Lenyoga 326 Posted April 3, 2014 There's a few issues here, first I think the 'instead of' error is being caused by a missing ; right behind the last } and you also need to create an extra magazine (for example AK47SMag) in the config, derived from the AK47S. I'd give you a finished example, but I'm out of time right now. Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 3, 2014 (edited) Thanks for your response Lenyoga. I tried adding the extra ; after the last } but got the same 'instead of' error. If someone could give me an example of how this should be done properly, maybe with some comments explaining what parameters do what I would be very grateful. @@@@@@@@@@@@@@@ Also, why on the BIS config do a lot of the weapons not have magazine defines? Are they being defined as having the same name as the weapon by this piece in their inherited 'riffle' class... weaponType = WeaponSlotPrimary; magazineType = WeaponSlotItem Also there is no picture="WeaponPicturePath.paa" in the BIS config for AK47, its inherited riffle of riffles inherited mgun. If the questions in this section require a stupidly long explanation would it be easier to scrap the idea of directly cloning the BIS AK47 and start from riffle or even default, just using the AK47 model? @@@@@@@@@@@@@@@ Also does the class given in patches (class myweaponsx in this case) have to match anything else defined anywhere, or can that handle be anything. ---------------------- class CfgPatches { class myweaponsx ---------------------- Thanks for your help and I'm well aware these are large numbers of very noobish questions :) Edited April 3, 2014 by FriendlyIntentions Share this post Link to post Share on other sites
krzychuzokecia 717 Posted April 3, 2014 (edited) Try this: // BASIC DEFINES #define TEast 0 #define TWest 1 #define TGuerrila 2 #define TCivilian 3 #define TSideUnknown 4 #define TEnemy 5 #define TFriendly 6 #define TLogic 7 #define true 1 #define false 0 #define private 0 #define protected 1 #define public 2 #define WeaponNoSlot 0 // dummy weapons #define WeaponSlotPrimary 1 // primary weapons #define WeaponSlotSecondary 16 // secondary weapons #define WeaponSlotHandGun 2 // HandGun #define WeaponSlotHandGunItem 32 // HandGun magazines #define WeaponSlotItem 256 // items #define WeaponSlotBinocular 4096 // binocular #define WeaponHardMounted 65536 // START CONFIGS class CfgPatches { class myweaponsx { weapons[]={"AK47S"}; requiredVersion = 1.90; requiredAddons[] = {"BIS_Resistance","BIS_WeaponPack"}; }; }; class CfgWeapons { //BIS ADDONS CLASS TREE class Default {}; class MGun: Default {}; class Riffle: MGun {}; class AK47: Riffle {}; //New Weapons class AK47S: AK47 { model = "AK_47_proxy"; modelOptics = "optika_ak47"; optics = 1; opticsZoomMin = 0.35; opticsZoomMax = 0.35; displayName = "Ak47 Single Shot"; displayNameMagazine = $STR_MN_AK47; shortNameMagazine = $STR_SN_AK47; drySound[] = {"weapons\AK74Dry",0.01,1}; magazines[]={"AK47S"}; modes[] = {Single}; class Single { ammo = BulletSingleG; multiplier = 1; burst = 1; displayName = $STR_DN_AK47; dispersion = 0.0002; sound[] = {"Weapons\AK74Single",1,1}; soundContinuous = 0; reloadTime = 0.15; ffCount = 1; recoil = riffleSingle; autoFire = 0; aiRateOfFire = 5; aiRateOfFireDistance = 500; useAction = 0; useActionTitle = ""; }; }; }; You don't need so much of "/" (two slashes make line "un-readable", more may broke this), and magazine should use the same modes as weapon. You had AK47S weapon with Single mode, but made it use AK47 magazine with Single, Burst, FullAuto mode (in other words: setting weapon to just use one mode, with multi-mode magazine won't work). Good luck! ;) PS. For OFP weapon and magazine are the same. BIS decided to use just one class (AK47) for both weapon and magazine, but most addons use separate class for weapon and magazine (like: myclass_ak47 and myclass_ak47_mag). PPS. CfgPatches class-name (like Yours myweaponsx) is used only to make dependancies. Mission made with Your addon will search addons for one with myweaponsx class, and You can set in addon requiredAddons[]={"myweaponsx"} (so addon would need Your addon to run). Edited April 3, 2014 by krzychuzokecia Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 3, 2014 (edited) Thanks heaps krzychuzokecia, I feel I know a lot more now than I did. I will tinker with this later on today, I have to go to work soon. One question that has already come to my mind is about the 'magazines[]={"AK47S"};' line. Where does the game get the info about that. Does it inherit info from its AK47 parent? If I wanted to change how many bullets the magazine holds, how would I do that? edit - P.S you are most likely 100% correct about having an odd number of '/' being the problem with this. The first line of my code has only one / :p Edited April 3, 2014 by FriendlyIntentions Share this post Link to post Share on other sites
guziczek101 11 Posted April 3, 2014 class CfgAmmo this is your answer :) Share this post Link to post Share on other sites
Macser 776 Posted April 3, 2014 (edited) Does it inherit info from its AK47 parent? Yes.It does.That's class inheritance. To increase ammunition count for a magazine use the entry count= in your weapon class. As in: count=20; As krzychuzokecia said,in OFP magazines are weapons. Edited April 4, 2014 by Maczer Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 4, 2014 (edited) Awesome!! Thanks for all the help. I feel I know enough to get me started. I shall play around and un-pbo some bis addons, see what else I can learn. I'll no doubt be back in about 5 minutes asking for help :) One last thing, I want to change something in the original config only when my mod is loaded. How do I do this (I get a class already defined error or something similar). I want to change this in "class GrenadeLauncher: Default" that all grenade launchers inherit from. weaponType = WeaponNoSlot; magazineType = 2 * WeaponSlotItem; // <- change to WeaponSlotItem or 256 ??? difference ammo=Grenade; It has always annoyed me how soldiers in full combat gear can only carry 3 grenades. Why??? So stupid in my opinion. Anyway, am I on the right lines and can this be done without the user having to re-paste the config back into bin folder to play online on no addon servers. Surely can be done :D Edited April 4, 2014 by FriendlyIntentions Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 4, 2014 (edited) I've got as far as de-binerizing the config file with EliteNess, changing the above to 256, then packing it back to .bin format. I've figured I can place it in "@mymod\bin" and it will be loaded instead of BIS config. When I load the game it says no entry "config.bin.cfgaddons" but loads to the menus etc. I re packed it instead of using .cpp format because the .cpp errors when loaded (instead of error). My original config.bin is from a scratchless GOTY disk I bought new last year and my cd drive is fine. I tried it from a brand new from cd, never played online config.bin and had same problems. When re-packed the new config.bin is smaller than original. I am using EliteNess 2.32 at the moment could that be the problem? What is a good program for unpacking .bin files, or do I need to define something in the file before the configs start? p.s The AK47 with 12 round mag config works well!!! Still has no pictures in briefing/gear but I guess that wouldn't be hard to fix, not too worried right now. Thanks heaps guys!!! EDIT- I reckon my problem has to be with the eliteness program. If i unpack the BIS config.bin that works fine with the game, do nothing to it, re-pack it then place it back in the root BIS bin folder it behaves exactly the same as one in my mod folder. What am I missing here? :confused: Whats you favourite program for the .bin files or am I doing something silly?:) Edited April 4, 2014 by FriendlyIntentions Share this post Link to post Share on other sites
zulu1 145 Posted April 4, 2014 I've never used Eliteness to unbin, just de-rap. I'm guessing it's just a simple mistake like too few or too many { , or a misplaced ; . Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 5, 2014 I've never used Eliteness to unbin, just de-rap. Hey Zulu, What would you use to unbin? The first few lines of the config.cpp I get from eliteness are... //class config.bin { class CfgExperience { access = 1; destroyUnit[] = {unit1,unit2,unit3,unit4}; If I look at the config for WW4 mod there is all this before it gets to class CfgExperience. I read somewhere I will have to put the enums in myself. ...Lots more defines before this ^^^ #define manactladderonup 59 #define destructbuilding 1 #define brownie {0.8,0.8,0.8,0} enum { DestructNo, DestructBuilding, DestructEngine, DestructTree, DestructTent, DestructMan, DestructDefault }; enum { ManPosDead, ManPosWeapon, ManPosBinocLying, ManPosLyingNoWeapon, ManPosLying, ManPosHandGunLying, ManPosCrouch, ManPosHandGunCrouch, ManPosCombat, ManPosHandGunStand, ManPosStand, ManPosNoWeapon, ManPosBinoc, ManPosBinocStand }; enum { CPDriver, CPGunner, CPCommander, CPCargo }; enum { UnitInfoSoldier, UnitInfoTank, UnitInfoCar, UnitInfoShip, UnitInfoAirplane, UnitInfoHelicopter }; enum { ManActStop, ManActStopRelaxed, ManActTurnL, ManActTurnR, ManActTurnLRelaxed, ManActTurnRRelaxed, ManActReloadMagazine, ManActReloadMGun, ManActReloadAT, ManActReloadMortar, ManActThrowGrenade, ManActWalkF, ManActWalkLF, ManActWalkRF, ManActWalkL, ManActWalkR, ManActWalkLB, ManActWalkRB, ManActWalkB, ManActSlowF, ManActSlowLF, ManActSlowRF, ManActSlowL, ManActSlowR, ManActSlowLB, ManActSlowRB, ManActSlowB, ManActFastF, ManActFastLF, ManActFastRF, ManActFastL, ManActFastR, ManActFastLB, ManActFastRB, ManActFastB, ManActDown, ManActUp, ManActLying, ManActStand, ManActCombat, ManActCrouch, ManActCivil, ManActCivilLying, ManActFireNotPossible, ManActDie, ManActWeaponOn, ManActWeaponOff, ManActDefault, ManActJumpOff, ManActStrokeFist, ManActStrokeGun, ManActSitDown, ManActSalute, ManActBinocOn, ManActBinocOff, ManActPutDown, ManActMedic, ManActTreated, ManActLadderOnDown, ManActLadderOnUp, ManActLadderOff, ManActLadderOffTop, ManActLadderOffBottom, ManActGetInCar, ManActGetOutCar, ManActGetInTank, ManActGetOutTank, ManActTakeFlag, ManActHandGunOn, ManActN }; P.s. I'm guessing it's just a simple mistake like too few or too many { , or a misplaced ; . I dont get why my re packed config.bin should have any mistakes. All I did was unbin then rebin, didnt change a thing. The original config.bin is from a mint condition cd and my cd drive is good so the file isn't the problem. Does anyone know where I can get a bog standard config.cpp file, or could someone put one up somewhere? Or what is a good tool to unbin. I tried one from Chain of Command but all it did was dump a heap of files in my windows\system32 then didnt work :p Thanks in advance. ---------- Post added at 00:57 ---------- Previous post was at 23:43 ---------- Ok getting there... I got BinView working, made a config.cpp and added this code after the defines and before the configs start... enum { DestructNo, DestructBuilding, DestructEngine, DestructTree, DestructTent, DestructMan, DestructDefault }; enum { ManPosDead, ManPosWeapon, ManPosBinocLying, ManPosLyingNoWeapon, ManPosLying, ManPosHandGunLying, ManPosCrouch, ManPosHandGunCrouch, ManPosCombat, ManPosHandGunStand, ManPosStand, ManPosNoWeapon, ManPosBinoc, ManPosBinocStand }; enum { CPDriver, CPGunner, CPCommander, CPCargo }; enum { UnitInfoSoldier, UnitInfoTank, UnitInfoCar, UnitInfoShip, UnitInfoAirplane, UnitInfoHelicopter }; enum { ManActStop, ManActStopRelaxed, ManActTurnL, ManActTurnR, ManActTurnLRelaxed, ManActTurnRRelaxed, ManActReloadMagazine, ManActReloadMGun, ManActReloadAT, ManActReloadMortar, ManActThrowGrenade, ManActWalkF, ManActWalkLF, ManActWalkRF, ManActWalkL, ManActWalkR, ManActWalkLB, ManActWalkRB, ManActWalkB, ManActSlowF, ManActSlowLF, ManActSlowRF, ManActSlowL, ManActSlowR, ManActSlowLB, ManActSlowRB, ManActSlowB, ManActFastF, ManActFastLF, ManActFastRF, ManActFastL, ManActFastR, ManActFastLB, ManActFastRB, ManActFastB, ManActDown, ManActUp, ManActLying, ManActStand, ManActCombat, ManActCrouch, ManActCivil, ManActCivilLying, ManActFireNotPossible, ManActDie, ManActWeaponOn, ManActWeaponOff, ManActDefault, ManActJumpOff, ManActStrokeFist, ManActStrokeGun, ManActSitDown, ManActSalute, ManActBinocOn, ManActBinocOff, ManActPutDown, ManActMedic, ManActTreated, ManActLadderOnDown, ManActLadderOnUp, ManActLadderOff, ManActLadderOffTop, ManActLadderOffBottom, ManActGetInCar, ManActGetOutCar, ManActGetInTank, ManActGetOutTank, ManActTakeFlag, ManActHandGunOn, ManActN }; The game loads, no 'intead of errors'. I still get a 'no entry config.cpp.cfgaddons' error and I cant play a mission, but I can load to the menus and the editor. What am I doing wrong, how do I define the addons? Thanks. p.s. For anyone that looks at this that is interested in the original topic I am going to make a civilian ak47 addon using bis models. I'm thinking 3 types, all single shot. One poor condition, one average and one worked. All will be able to use 7, 12 and 30 round mags. To simulate the different conditions of the weapons I'm going to define new recoils, slightly change the zooms and subtly change the sounds. Also I'm going to play with dispersion and see what I get. I will post the code up with instructions how to make it into an addon, noob tutorial style :) Pay it forward I say. 2 days ago I knew nothing about configs or the technicalities of inheritence Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 5, 2014 I added this. It seemed to help slightly :)... I can now preview in editor... YAY :) class CfgAddons { access=2; class PreloadBanks { class WeaponBIStudio { list[]={"LaserGuided\","ABox\","6G30\","Kozl\","G36A\","MM-1\","Steyr\","Bizon\","XMS\","M41a\"}; }; class MiscBIStudio { list[]={"Flags\","VoiceRH\"}; }; }; class PreloadAddons { class WeaponBIStudio { list[]={"LaserGuided","6G30","Kozlice","G36A","MM1","Steyr","Bizon","XMS","M41a"}; }; class MiscBIStudio { list[]={"Flags1","VoiceRH"}; }; class ResistanceBIStudio { list[]={"Noe"}; }; }; }; Should there be a CfgAddons section when the config.bin is first decrypted? Could someone please post what it should look like with all the BIS addons, and how do I tell it to load everything in the BIS addons folder and also the mod addon folder. When I play with this config an m16 solder has no weapon model and looks kind of like he's doing the animation for holding an AT weapon. Thanks Share this post Link to post Share on other sites
FriendlyIntentions 10 Posted April 5, 2014 I have more of an idea of what my problem is. It's getting off topic so I'm gonna start a new thread. For anyone thats interested I will post the civilian ak47 here when I make it. To the same addon code, I also may add some clones of the "rapid" sports cars (small turbo, large turbo, worked suspension etc..) This is next on the agenda Thanks for your help everyone :) Share this post Link to post Share on other sites