Jump to content
Astrild

ALIVE mod dynamic AI spawner how do i put scripts on spawned ai???

Recommended Posts

I want to put hoverguys kill reward system on ai's that will be spawned by alive mod is this possible because alive doesn't have expression line.

 

Share this post


Link to post
Share on other sites

It is possible, since arma requires cba 3 you can use cba s custom events to spawn scripts when the unit is created. But I'm not familiar with the kill reward script you ask for so I can't give you a more specific answer.

Share this post


Link to post
Share on other sites

@Mr H. thank you for your reply. Kill reward system is getting money and exp for every enemy ai I kill. it is used for the shop script that mr.hoverguy made. this is the code that I want to be in the units that will be spawned by alive mod. {[_x] call HG_fnc_aiUnitSetup;} forEach units (_this select 0); it worked on vanilla spawner I typed it in expression line. I tried putting it on init of the alive spawner and nothing happens. I have a very littlle knowledge of scripting and coding pls help me thanks.

Share this post


Link to post
Share on other sites
class Extended_Init_EventHandlers {
    class CAManBase {
        class My_Soldier_init_eh {
            init = "[_this] call HG_fnc_aiUnitSetup;}";
        };
    };
};

Try to put this in your description.ext (untested)

Share this post


Link to post
Share on other sites

@Mr H. It didn't work sir but Hoverguy helped me out and it worked. I think he found idea on your code so still I'm thankful to both of you. and for the people who will also need this just paste this on your init.sqf to make exp work on alive AI spawners.

 

if(isServer) then
{
    [] spawn
    {
        waitUntil{time > 10};
        while{true} do
        {
            {
                if(!(isPlayer _x) AND !(_x getVariable["EVH_Added",false])) then
                {
                    [_x] call HG_fnc_aiUnitSetup;
                    _x setVariable["EVH_Added",true,false];
                };
            } forEach allUnits;
            uiSleep 5;
        };
    };
};

Share this post


Link to post
Share on other sites
11 hours ago, Mr H. said:

(untested)

jup

 

11 hours ago, Mr H. said:

"[_this] call HG_fnc_aiUnitSetup;}"

Can't work. Syntax error. The } at the end, also you don't need a semicolon.

 

I would STRONGLY recommend everyone NOT to use that while true loop there if you have something like CBA eventhandlers available.

  • Like 1

Share this post


Link to post
Share on other sites
14 minutes ago, Dedmen said:

 

 

Can't work. Syntax error. The } at the end, also you don't need a semicolon. 

 

 

Yeah copy paste error sorry.

Share this post


Link to post
Share on other sites
58 minutes ago, Dedmen said:
12 hours ago, Mr H. said:

(untested)

jup

BTW @Dedmen what does "jup" mean?

Share this post


Link to post
Share on other sites

so @Astrild try this instead
 

class Extended_Init_EventHandlers {
    class CAManBase {
        class My_Soldier_init_eh {
            init = "if !(isplayer _this) then {[_this] call HG_fnc_aiUnitSetup}";
        };
    };
};

Dedmen is right, this while loop is horrible!

Share this post


Link to post
Share on other sites

A while loop keeps cluttering the scheduler and a forEach inside makes it even more resource consuming. Plus you have no guarantee that after a while the script will execute properly. An event handler on the other hand only fires its code once. 

Share this post


Link to post
Share on other sites

@Mr H. thank you for explaining but again the script didn't work. i tried pasting it on the description.ext

 

Share this post


Link to post
Share on other sites

Change Extended_Init_EventHandlers to Extended_PostInit_EventHandlers

Share this post


Link to post
Share on other sites

Also if it doesn't work try:

_this call HG_fnc_aiUnitSetup

Instead of

[_this] call HG_fnc_aiUnitSetup

EDIT: yeah do definitely do that

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

×