Home   Help Search Login Register  

Author Topic: Help: building AddOn which adds action to Res and BAS units for ALL missions  (Read 2333 times)

0 Members and 1 Guest are viewing this topic.

Offline dow

  • Members
  • *
Hello!
I'm working on AddOn for OFPR, which should add UserAction to all units of Man : Land : AllVehicles class and all it's descendants, including units added by other AddOns, like BAS, KEG etc.
The idea is to avoid patching all released AddOns and missions (too much work and authors' license problems).
This AddOn should be client-side and should work in SP and MP environment, including Human vs AI COOP missions.

As I can guess, this task needs custom config.cpp added to OFPR\my_addon folder. So I wanna put some questions about it.

I need to say, that I use this section of config.cpp to force OFP to add the action needed:

Code: [Select]
class CfgVehicles
{
access=1;
vehicleClass[]={"Men"};
class All {};
class AllVehicles:All {};
class Land:AllVehicles {};
class Man:Land
{
class UserActions
{
class MyAction
{
displayName="My Action";
position=ANY;
radius=0.1;
condition="alive this";
statement="this exec {\my_addon\my_script.sqs}";
};
};
};
};

  • q1: Do you know, how OFP loads config.cpp's? I mean what order OFP uses to load, what reason to exclude, etc.
    OFPR\Bin\config.bin
    OFPR\Res\Bin\config.bin
    OFPR\my_addon\Bin\config.bin
    OFPR\my_addon\config.bin <-- this one will be loaded ONLY if mission wants that addon? (that's out of the scope of my task)
    Am I right?

  • q2: Will OFP merge the entries of several config.cpp's or last config overrides the previous? and how? What if some AddOn has config.cpp too? Like BAS BAS_DeRaD AddOn, it has custom units (and with custom GogglesUp\GogglesDown actions) injected into SoldierBW:Soldier:Man class.

  • q3: When I put config for my addon in my_addon\config.cpp in form of
    class CfgPatches{};
    class CfgVehicles{};
    I can see that no UserActions added to default Res units (and maybe to BAS units too - not sure, maybe other reasons, see below),
    when I put same config to my_addon\Bin\config.cpp - OFP parses it at startup, but I get error "no CfgWorlds entry!"
    when I copy default Res config.cpp to my_addon\Bin\config.cpp and put my overrides there (UserActions at CfgVehicles section, class Man:Land:AllVehicles, whithout adding class CfgPatches{}; section there) - OFP loads it and actions work with all default Res units, but not with BAS units despite the fact that BAS units should (according to BAS_addon\config.cpp) inherit settings from SoldierWB:Soldier:Man class! Why??? What's wrong?

  • q4: My guess is that OFP ignores my_addon\config.cpp if mission doesn't need any unit from my_addon, even if that addon name is included in -mod= option of OFP startup command, but it always loads addon and it's config.cpp if it's placed at my_addon\Bin\config.cpp even if started mission doesn't need this addon.
    Am I right or not?

  • q5: IMHO, OFP skips the load of Res\Bin\config.cpp if there is a my_addon\Bin\config.cpp, that's why OFP needs full config.cpp there, not just overrides as in normal(most) addons, like it can be done with:
    class CfgPatches{};
    class CfgVehicles{};
    or, maybe a little bit different:
    OFP loads default Res config.cpp, then looks in addon folder for Bin\config.cpp and if it's there - wants to re-define all classes using that addon's config.cpp. Is it correct?

Tiny URL of this post: http://tinyurl.com/2dxwkb
P.S.: plz sry for my bad english, my native language is russian :-[
« Last Edit: 29 Aug 2007, 21:18:04 by dow »
Mercenaries Never Die, They Just Go to Hell to Regroup!

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Hello dow,

I will try to answer your questions the best I can from my understanding of them and of the way OFP deals with configs.

q1./  OFPR\Bin\config.bin ..... this is the main game config for loading OFP 1.46, so if you are going to play that version of the game this is the config that is loaded from Bin.

       OFPR\Res\Bin\config.bin ..... likewise this is the main config that is loaded to play OFP Resistance.
       OFPR\my_addon\Bin\config.bin ..... not too sure that an addon needs a bin folder at all, maybe a full mod could use one but I doubt an addon does.
       OFPR\my_addon\config.bin ..... This should actually read OFPR\Addons\my_addon\config.bin, ALL addon configs in the Addons folder are normally read at game start.

2./  For example....class Man in the main game config sets the base qualities for man units, it then goes on to overwrite some or all of those qualities for specific man units, sniper, black ops etc, so the base class man is just the foundation of properties which you can mostly leave and just redefine the ones you need to redefine for any particular unit in your addon.

3./  Adding Useractions to your addon will not add them also to the games base class man definitions, your man addon will inherit all the definitions from the games base man class except those which you specifically change.
BAS units for example DO inherit everything from soldierWB, which in turn inherits everything from class Soldier which itself inherits from class Man, however it only inherits those values that are not specifically changed in the BAS configs.
So copying the Res game config to your addon changes nothing as the above classes are already set by the game config and the copy you add changes nothing.

4./  As I said above, all Addon configs in the games Addon folder are read at game start.
The -mod folder thing is different.
Look at the Res folder, this is a mod folder, it has its own Addons folder, its own Bin folder etc etc.
If you made a mod folder and had all your own folders there, Addon, Bin,dta etc etc, and you start the game using a shortcut which uses your -mod switch to start the game with your mod, then, it should start the game normally and then read from your very own config in your very own Bin folder in your very own mod folder, I hope I didn't lose your there.

5./  I think this is answered as well if you are running your own mod from your own mod folder than I think the normal gabe config is not loaded and instead the config in your mod\Bin is loaded instead.
This must of course be a full config and not a small addon config, it must config everything the game needs like it does in the normal game config, it only changes those bits you want changed.
Addons folder should not contain a Bin folder, only a mod folder should have one of those.


Hope this has helped a bit.


Planck
I know a little about a lot, and a lot about a little.