Jump to content
Ghost_Warden

[SOLVED] Help required : Execute a script from a PBO file

Recommended Posts

Hi !

 

I searching for a member that can help and explain me how I can make a PBO file with a config.cpp to execute a script for each class Man ingame.

 

I already know how to make a config.cpp, and already own the script file in SQS format.

 

I just need help to know what to write in the config.cpp to define it to execute the SQS script for each class Man in the game.

 

CBA dependency not needed, but that's not a problem to have it if it's better.

 

Thanks a lot !

Share this post


Link to post
Share on other sites

Maybe try an Init Event Handler?

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

 

Here's an example taken from our 3CB BAF Vehicles Merlin Helicopter, using @CBA_A3 for extended event handlers:

 

CONFIG.CPP

class Extended_Init_Eventhandlers {
    class UK3CB_BAF_Merlin_HC3_Base {
        class UK3CB_BAF_Merlin_HC3_Base_init {
            init = "_this call UK3CB_BAF_Vehicles_Merlin_fnc_init_EH_MerlinHC3";
        };
    };
};

class CfgFunctions {
    class UK3CB_BAF_Vehicles_Merlin {
        class UK3CB_BAF_Vehicles_Merlin {
            file = "uk3cb_baf_vehicles\addons\UK3CB_BAF_Vehicles_Merlin\functions";
            class init_EH_MerlinHC3 {};
        };
    };
};

and the script executed on initialisation is in "fn_init_EH_MerlinHC3.sqf".

  • Like 1

Share this post


Link to post
Share on other sites

Ah ! Hi UK_Apollo, thanks for taking some of your time to answering me !

 

I'll look at what you write. I've already try many and many times to make a file based on the Wiki advices, even by searching along the internet, but nothing like I need or I can adapt to my situation and I always failed to do it.

 

Thanks, I'll try that. Maybe I need to rewrite my original script and change the SQS format into SQF ?

 

In the script, usually, I used global values like :

 

_soldier = _this select 0

So, maybe I need to change that to make the script defined for each Man classes ?

 

class Extended_Init_Eventhandlers {
    class UK3CB_BAF_Merlin_HC3_Base {
        class UK3CB_BAF_Merlin_HC3_Base_init {
            init = "_this call UK3CB_BAF_Vehicles_Merlin_fnc_init_EH_MerlinHC3";
        };
    };
};

I understand this part, I've already make many mods using a config.cpp.

 

So, after that, define the base class of the vehicle/object/entity to covered the entire class and subclasses, in this part, I surely can write Man for the class like it's for each entity ingame without exception.

After that, I need to create a class with the classname and adding "_init" at the end.

 

Then I add the "init" line to define the folder and the name file, but here, that's different, apparently,you don't use a line like "\foldername\scriptfilename". So, I don't really understand this last sentence in this class.

 

class CfgFunctions {
    class UK3CB_BAF_Vehicles_Merlin {
        class UK3CB_BAF_Vehicles_Merlin {
            file = "uk3cb_baf_vehicles\addons\UK3CB_BAF_Vehicles_Merlin\functions";
            class init_EH_MerlinHC3 {};
        };
    };
};

Concerning this part, I'm completely lost. I've never ever have to make this class in any of my addon file until then. But it's clear that it's here that you define the folder and script file name.

 

I think I need an example and some explanations.

 

I'm sure it's logical, that's a fact, but like english is not my mother tongue, I try to understand as simpliest as I can.

 

class UK3CB_BAF_Merlin_HC3_Base_init
class UK3CB_BAF_Vehicles_Merlin

Is these two classes create for the file or existing inside other config file ? Because I know that we can sometime create new classes just to be a subclass to an existing parent class, is it the case ?

 

I think I need someone that have the time to explain me with example.

 

Actually, I'll try different things about what I've think understand with your example, thanks for that.

 

I'll come back and post again if I failed, thing that is pretty sure.

Share this post


Link to post
Share on other sites

Hi UK_Apollo,

 

I don't know if you follow this thread or if you will see this message, but I still don't get my mod working.

 

Tried many things from some sources, but still not working.

Like my mod is based on AI attitude, and more precisely on the combat body positions, I don't think that using Event Handlers will do the trick.

 

Maybe by adding an init forthe mod to all Man classes ?

Share this post


Link to post
Share on other sites

Extended Event Handlers are the easiest way to do what you ask; although this does require CBA!

class Extended_Init_EventHandlers
{
  class CAManBase
  {
    class Custom_Init_For_CAManBase
    {
      init = " [_this] exec 'script.sqs'";
    };
  };
};

In your 'script.sqs' you'll find the object as "_this select 0".

Please note that, depending on what you do in the script, you might need to do some other stuff to get for example the player or AI instead of the object itself.

  • Like 1

Share this post


Link to post
Share on other sites

Hi grezvany13,

 

I see ! I don't make the one I already done like that, I will change that immediatly.

 

Unfortunatly, I think that there is a problem in my script. Ca you take a look at this ?

 

I'm sorry, I really try, but never succeed to get theses error messages away, and like I suggest that it's better to make a SQF instead of a SQS, I really need help.

 

Are you available ?

Share this post


Link to post
Share on other sites

Well, there are a couple of things you can do for us to help you:

 

1) share the code which you currently have (especially the SQS file in question), either directly in a post or a link to the source code

2) post the error(s) which you currently get

 

And since ArmA3 is optimized for SQF instead of SQS and it's way easier to debug and maintain, rewriting the script to SQF will make your life much easier.

Share this post


Link to post
Share on other sites

Hey,

 

Here is the SQS script :

 

_unit = _this select 0;

_p = selectRandom ["MIDDLE","UP"];

#loop;

@ (behaviour _unit) in ["COMBAT"];
_unit setUnitPos _p;

@ (behaviour _unit) in ["AWARE"];
_unit setUnitPos "UP";

goto "loop";

exit;

 

The objective of this script is to force the AI to only can get into crouch or stand position while in Combat behaviour.

 

When I use this script in script version, there's no error at all, and it works well.

The problem happened when I integrate the script in the addon.

 

The message always concerned the "behaviour" command, the error message ingame says :

 

Translation (I'm french) : "Error behaviour : type board, object expected"

 

CMjhZwj.jpg

Share this post


Link to post
Share on other sites

I did some testing, although my SQF version of the script doesn't work as expected, and I'm not familiar enough with SQS to debug that.

 

However I did found the reason for your error (which in English is "Error behaviour : type array, object expected").

 

To solve this, all you have to do is change the first line to:

_unit = _this;

 

  • Like 1

Share this post


Link to post
Share on other sites

After testing this solution inside the same script in the mod file and testing, still the same error popping up.

 

Here is what I have now with the changes you mentioned :

 

_unit = _this;

_p = selectRandom ["MIDDLE","UP"];

#loop;

@ (behaviour _unit) in ["COMBAT"];
_unit setUnitPos _p;
hint "COMBAT MODE";

@ (behaviour _unit) in ["AWARE"];
_unit setUnitPos "UP";
hint "AWARE MODE";

goto "loop";

exit;

 

I think I have a little idea on how to convert the first part in SQF, maybe that can help you with the rest ? I can make a little part, but when it's getting more complicated, I just don't know how to do.

I'll try the same solution with the script version.

 

Thanks again for your time helping me to solve that.

 

EDIT : Same error popping with the script version. So, for testing, I made it SQF, I think, at least the extension file is SQF, and here is the content of the file :

 

_unit = _this;

_p = selectRandom ["MIDDLE","UP"];

#loop;

if ((behaviour _unit) == "COMBAT") then { "_unit setUnitPos _p" };

goto "loop";

exit;

 

But even like that, it seems that the engine don't want to let this pass, he's still on the same error, again and again. I take the same example like in the "If" BIWiki page.

 

The thing I find really weird is that the script works nice and without any error in SQS file, but the error appear only when I try to make it executed inside an addon file or in script and addon file with the SQF format.

 

Is it a sign that all scripts inside addon files must be in SQF format and that this "translation" into SQF from SQF is wrong ?

Share this post


Link to post
Share on other sites

Ok, I'm back after a little time about researches.

 

I don't know if it solved anything concerning the "behaviour" command, but now, it seems that the engine is occupied by another "error" after the behaviour command, so it's maybe the sign that it's solved for that.

Like always, when you solved an issue, there's another one that coming. Never happy, this engine.

 

So, here is the code I have now :

_unit = _this;
_p = selectRandom ["MIDDLE","UP"];

#loop;

if ((behaviour (_this select 0)) == ""COMBAT"") then { (_this select 0) setUnitPos _p };

goto "loop";

exit;

I've already try with adding "()" symbols to surrounds the part in the "then" area, but still the same, the engine keep saying it missed a sign. I'm close to send him another sign, made with my hand, and more exactly only with a finger, and I doubt he'll like that. Anyway. I send a screen capture to show the error message he shown now.

 

 

dicq47K.jpg

 

EDIT : It seems it's linked to the double "" signs surrounding the COMBAT word. Letting just two of them, one before and one after, and the error message disappear.

 

Now, I must test to know if it's working.

Share this post


Link to post
Share on other sites

Ok, it seems that every things I posted above isn't working.

 

It's getting to be really tired. Everybody seems to says that SQF is easier and better, but actually, I already see that it's really boring and capricious.

 

EDIT :

 

I just realised that I need to make a loop. So, I must use the "while" command instead.

 

And actually, all my tests for incorporate it is unsuccessfull, no change, it's the habit.

 

Here is the code :

 

_unit = _this;
_p = selectRandom ["MIDDLE","UP"];

while {true} do {{if ((behaviour (_this select 0)) == "STEALTH") then { hint "STEALTH MODE TEST" } else { hint "NOT STEALTH MODE TEST" };}; Sleep 5;};

 

I've already try to add a Sleep command between the last "}" sign and the one before, like in any other scripts, but of course, like it's the mine, it pop an error saying that it's "Generic error in an expression".

 

Normal.

 

I let this in one line, because if I try to do it in multiple lines, it says me that it missed the end of the line where the next line started.

 

Really weird.

 

I'm actually trying the loop command, so, when I have the hint appearing correctly ingame, I can know that the command is correct and can replace by the commands I need for the script, that's why I change the commands.

Share this post


Link to post
Share on other sites

I'm back for the last time :happy:

 

I want to thanks all of those who helped me in this case, UK_Apollo and grezvany13. Thanks again, really !

It finally seems to work correctly.

 

I explain what I've done.

 

In the first step, searching in the file wasn't the real thing to do.

 

So, I find in the config.cpp. And got it.

 

I use the SQS format, and here is the content of the file :

 

_p = selectRandom ["MIDDLE","UP"];

#loop;

@ (behaviour (_this select 0)) in ["COMBAT"];
(_this select 0) setUnitPos _p;

@ (behaviour (_this select 0)) in ["AWARE"];
(_this select 0) setUnitPos "UP";

goto "loop";

exit;

 

With that, I launch the script with the XEH, thanks to you two for theses informations. Here is the content of the config.cpp :

 

class CfgPatches
{ 
    class PosCBTMod
    { 
        units[] = {}; 
        weapons[] = {}; 
        requiredVersion = 0.1; 
        requiredAddons[] = {"A3_Characters_F","Extended_EventHandlers"};
		author = "HellGhost";
    }; 
};

class Extended_Init_EventHandlers
{
  class CAManBase
  {
    class CAManBase_Init
    {
      init = " [_this select 0] exec '\PosCBTMod\PosCbt.sqs'";
    };
  };
};

The issue was with the config.cpp, that's why I have this error message. In fact, I replace the original :

 

init = " [_this] exec '\PosCBTMod\PosCbt.sqs'";

By :

 

init = " [_this select 0] exec '\PosCBTMod\PosCbt.sqs'";

And with that, it works fine, no more error message ingame and the AI correctly take randomly the standing or crouching position.

 

So, I share the content of this mod here, for you if you want explanations and like you searching with me, so I considering I owe you the answer after all the help you give to me to get to this working state.

 

Thanks again, and if I can be helpfull one day, don't hesitate to contact me directly.

 

I've made a little last modification :

 

_p = selectRandom ["MIDDLE","UP"];
_beh = ["COMBAT","STEALTH"];

#loop;

@ (behaviour (_this select 0)) in _beh;
(_this select 0) setUnitPos _p;

@ (behaviour (_this select 0)) in ["AWARE"];
(_this select 0) setUnitPos "UP";

goto "loop";

exit;

Like that, I can finally get ride of all these AI getting down on the floor when an hostile is spotted, it's boring to have ArmA playing as Grass Shooting Simulator, without taking in consideration all these moments when Ai can see throught grass and shoot you when you just can't see it to counter attack.

 

The AI can still be prone if an order is giving to them for that.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×