Jump to content
Sign in to follow this  
Wiki

[Solved] AI infinite magazine

Recommended Posts

Hello there.

 

I'm trying to create a firing range for my new mission.

I want the AI to have infinite magazines but reload when the mag is empty.

 

Is it possible?

If yes, how can I do that?

 

Thanks

Share this post


Link to post
Share on other sites
[] spawn
{
    while {alive unit} do
    {
        if ((count magazines unit) < 5) then
        {
            unit addMagzine "xxxx";
        };
        sleep 5;
    };
};

 

Maybe like so?

Share this post


Link to post
Share on other sites

Easiest way is to use the "reloaded" eventhandler and simple add magazine of current weapon.. so every time they reload and discard empty mag they are give a new one.

Share this post


Link to post
Share on other sites
17 minutes ago, R3vo said:

[] spawn
{
    while {alive unit} do
    {
        if ((count magazines unit) < 5) then
        {
            unit addMagzine "xxxx";
        };
        sleep 5;
    };
};

 

Maybe like so?

Thanks, gonna try this :-)

 

2 minutes ago, nimrod_z said:

Easiest way is to use the "reloaded" eventhandler and simple add magazine of current weapon.. so every time they reload and discard empty mag they are give a new one.

Good to know.

Do you have the command?

Share this post


Link to post
Share on other sites
8 minutes ago, nimrod_z said:

Easiest way is to use the "reloaded" eventhandler and simple add magazine of current weapon.. so every time they reload and discard empty mag they are give a new one.

 

I didn't even think about the reloaded EH. Good idea!

Share this post


Link to post
Share on other sites

Probably like this:

this addEventHandler ["Reloaded",{
	_unit = _this select 0 ;
	_mag = _this select 4 select 0 ;
	_unit addMagazine _mag ;
}] ;

Not tested yet.

  • Like 1

Share this post


Link to post
Share on other sites

Works great! Thanks a lot!

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
Sign in to follow this  

×