Jump to content
Sign in to follow this  
Monkwarrior

AI not running all events ?

Recommended Posts

Gents,

My goal is adding a delayed startengine effect for our vehicles.

I defined the following eventhandler for that:

(_this select 0) addEventHandler ["engine", {_this execVM "\I44_base_scripts\EH\tank_start.sqf";}];

In the tank_start.sqf we coded the timedelay and the startingsounds for some vehicles.

The problem is when I'm in a tank as a commander and I order the AI driver to move forward the tank starts moving right away. The tank_start.sqf is only played at my client, the AI seems to ignore it.

How can I make sure the AI has to wait too a certain time before they are able to move the tank ?

I'm sure I'm overlooking something, but what ?

Thanks for your time gentlemen, Monk.

Edited by Monkwarrior

Share this post


Link to post
Share on other sites

It's easier to prevent an AI from moving than a human player. I assume that the engine eh is added on all machines (server and clients).

merge this with your 'tank_start.sqf'

private["_veh","_state","_unit"];
_veh = _this select 0;
_state = _this select 1;
_unit = driver _veh;
if(local _unit && _state) then { _unit disableAI "MOVE";};

// play the engine start sound and wait 

if(local _unit) then { _unit enableAI "MOVE";};

Edited by dengibtsschon

Share this post


Link to post
Share on other sites

I've never used forceSpeed before. Just tried it and it doesn't do anything at all (Arma1 1.16beta, maybe its fixed in ArmA2).

Share this post


Link to post
Share on other sites

Merci.

The problem is that the script is not run by the AI.

In the beginning of the script there is a sleep 10 (line 24).

When I am commander and order the AI to drive the tank starts moving right away. So the AI driver ignores the sleep 10 (and the rest of the script).

When I am driver myself the sleep 10 is run and after that the rest of the script.

Here is the script: http://www.pastebin.org/50009

Thanks, Monk.

ps ah there is Dengibtsesschon, I will investigate your suggestions gentlemen

Edited by Monkwarrior

Share this post


Link to post
Share on other sites
I've never used forceSpeed before. Just tried it and it doesn't do anything at all (Arma1 1.16beta, maybe its fixed in ArmA2).

You're right, i firstly thought that you were saying your script didn't work. And the forcespeed command doesn't seem to work for me neither

But the following does work in the init of the tank, with the player as commander.

this addEventHandler ["engine",{driver (_this select 0) disableai "move"}]

So i guess your script should inspire Monkwarrior.

Share this post


Link to post
Share on other sites

this addEventHandler ["engine",{driver (_this select 0) disableai "move"}]

So i guess your script should inspire Monkwarrior.

And it did :)

Works like a shine, thank you gentlemen.

Monk.

Share this post


Link to post
Share on other sites

I'm sorry that I go into this very basic topic, but from these statements ...

AI not running all events ?

The tank_start.sqf is only played at my client, the AI seems to ignore it.

The problem is that the script is not run by the AI.

So the AI driver ignores the sleep 10 (and the rest of the script).

... I take it, that you have a wrong understanding of how this stuff works.

The ai DOES NOT run your script, your game does. And with the script you can order the ai to do or even not to do certain things. But initially your script has nothing to with any ai unit, nor is any ai bound to your script in any way, until you start giving the appropriate orders to these ai units.

As the ai driver hasnt received any orders from your script down to line 24 (sleep 10; ), that unit is still totally independent from your script, and therefore not affected by it.

In other words:

So far, the ai tank driver gives a damn about that new running script. He at most laughs at you suspending its execution for 10s and then puts the pedal to the metal.

Now, what you want is: The ai driver shall not start driving away until the script has finished doing its thing (delay 10s, play a sound, do some engine startup effect).

In order to achieve this, you have to give the appropriate order to the ai driver, like:

UNIT disableAI "MOVE";

which disables the AIs ability to move/drive. After the script has done all the things it is supposed to do, you you need to enable its ability to move/drive again,

UNIT enableAI "MOVE";

as the ai shall now perform the tank commanders orders.

Share this post


Link to post
Share on other sites

Thats exactly what I did.

I disabled AI in the beginning of my script and enabled it right after the moment I ignite the engine.

I now understand that these scripts influence the clients and server, not the AI units. These need separate instructions.

Thanks, Monk.

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  

×