Jump to content
Sign in to follow this  
domcho

ArmA 2 make AI use an added action

Recommended Posts

Hi guys. I downloaded the script which makes planes do carpet bombing. To make the bombs fall you must click on the action called "Bombs away!" on the action menu. I just wanted to know how can I make an AI use this action when it enters a trigger. I tried with Plane action ["Bombs away!" Plane] but it did not work. I checked the action list of ArmA 2 and it did not help me. Thanks. :yay:

Share this post


Link to post
Share on other sites

You can't do this by getting the AI to perform an Action. What you may be able to do is run the script that the action runs when your AI plane enters the trigger area. However this will depend on how the script is written - if it uses the position of the player to calculate anything then it may not work.

Basically you will have to study the script and see how it works and then work out how to script it into your trigger.

Share this post


Link to post
Share on other sites

I don't think you can get them to do user added action. You can, however, just run the script directly. Eg. if you addAction looks like this:

myUnit addAction ["ACTIONTITLE", "SCRIPT.sqf", PARAMS, .............];

You can just run script like this:

0 = [] execVM "SCRIPT.sqf";

If you need everything to behave exactly like as if it was called as an action start the script like this:

[myUnit, TheAIUnit, nil, PARAMS] execVM "SCRIPT.sqf";

Where myUnit is the unit you would have attached the action to, TheAIUnit the unit which performs the action, and PARAMS any params you would have passed to the action if you use that.

Share this post


Link to post
Share on other sites
I don't think you can get them to do user added action. You can, however, just run the script directly. Eg. if you addAction looks like this:

myUnit addAction ["ACTIONTITLE", "SCRIPT.sqf", PARAMS, .............];

You can just run script like this:

0 = [] execVM "SCRIPT.sqf";

If you need everything to behave exactly like as if it was called as an action start the script like this:

[myUnit, TheAIUnit, nil, PARAMS] execVM "SCRIPT.sqf";

Where myUnit is the unit you would have attached the action to, TheAIUnit the unit which performs the action, and PARAMS any params you would have passed to the action if you use that.

:confused:

Share this post


Link to post
Share on other sites

@Domcho - if you don't understand the above, then you are going to find it difficult. You are going to have to script your way out of this if you want the solution you desire.

Which script did you download?

Share this post


Link to post
Share on other sites
@Domcho - if you don't understand the above, then you are going to find it difficult. You are going to have to script your way out of this if you want the solution you desire.

Which script did you download?

This is the script: http://www.armaholic.com/page.php?id=6554

Thanks for the help! Sorry, I was really good at scripting in Operation Flashpoint but ArmA 2 seems to be a problem for me :D

Share this post


Link to post
Share on other sites
Try this...

Carpet Bomb

Let me know if you need help to understand what I did.

It says:

You cannot play/edit this mission; it is dependent on downloadable content that has been deleted.caair_e

I just wanted to say that I am not playing ArmA 2 OA, I am playing the normal ArmA 2, if that is the problem why I can't load the mission in the editor. :(

Share this post


Link to post
Share on other sites
It says:

You cannot play/edit this mission; it is dependent on downloadable content that has been deleted.caair_e

I just wanted to say that I am not playing ArmA 2 OA, I am playing the normal ArmA 2, if that is the problem why I can't load the mission in the editor. :(

Lol - OK - I assumed you were playing OA. I'll do another for just Arma 2 - give me a few minutes...

Share this post


Link to post
Share on other sites
Lol - OK - I assumed you were playing OA. I'll do another for just Arma 2 - give me a few minutes...

If I played OA I'd put OA in the thread tittle :) never mind :D

Share this post


Link to post
Share on other sites
If I played OA I'd put OA in the thread tittle :) never mind :D

Ok, fair enough - most people tend to play OA these days and Arma 2 has become synonymous with Arma 2 OA. My assumption, my fault.

Anyway if you check the previous link I have replaced the OA version with an Arma2 version.

Share this post


Link to post
Share on other sites

You can order AI to use addAction. Select the AI, press 6 for Action menu then nearby addActions will be listed there and you can order an AI unit to execute it.

As for making a non-player controlled AI do so, there's no reason to. Simply script whatever you wanted them to do. addAction is basically just for players.

Share this post


Link to post
Share on other sites
Ok, fair enough - most people tend to play OA these days and Arma 2 has become synonymous with Arma 2 OA. My assumption, my fault.

Anyway if you check the previous link I have replaced the OA version with an Arma2 version.

Works great :eek: Thank you!!! :yay::yay::yay:

---------- Post added at 06:28 PM ---------- Previous post was at 06:27 PM ----------

You can order AI to use addAction. Select the AI, press 6 for Action menu then nearby addActions will be listed there and you can order an AI unit to execute it.

As for making a non-player controlled AI do so, there's no reason to. Simply script whatever you wanted them to do. addAction is basically just for players.

Yes, I wanted to make a fight and when we get overrun the plane to come and drop bombs on top of the enemy's heads :D and the plane was just AI controlled.

Share this post


Link to post
Share on other sites

Ahh, yeah, you could use an addAction on the player for that for sure. I'd only skimmed the thread and thought you wanted AI to use an addAction. That'll teach me to read the forums after waking up!

Share this post


Link to post
Share on other sites

Yes, I wanted to make a fight and when we get overrun the plane to come and drop bombs on top of the enemy's heads :D and the plane was just AI controlled.

Well, my example didn't do that exactly! You are going to have to do something slightly more whizzy to get that done...

Write a script that is called from an addaction that;

1. Spawns a C130J

2. Creates a waypoint to where the enemy is (perhaps via a mapclick event).

3. When the plane gets near the enemy, run the carpetbomb script. (You will need to take into account that the bombs have some forward velocity).

4. When the plane gets a bit of distance away, delete it.

That's your evening sorted then ;-)

Share this post


Link to post
Share on other sites
Well, my example didn't do that exactly! You are going to have to do something slightly more whizzy to get that done...

Write a script that is called from an addaction that;

1. Spawns a C130J

2. Creates a waypoint to where the enemy is (perhaps via a mapclick event).

3. When the plane gets near the enemy, run the carpetbomb script. (You will need to take into account that the bombs have some forward velocity).

4. When the plane gets a bit of distance away, delete it.

That's your evening sorted then ;-)

My bigger problem is that we actually hold the enemy and drive them back lol. And I don't know how to spawn vehicles.

Share this post


Link to post
Share on other sites
1: spawn the vehicle using BIS_fnc_spawnVehicle.

2: create a waypoint on the mapclicked position.

3: waitUntil so and so distance away from getWPPos from currentWaypoint, run bomb script, or just run code directly in waypoint on act.

4: doMove or create a new waypoint and deleteVehicle when unitready or in on act of wp.

;)

Can I spawn vehicles from addons or mods?

Share this post


Link to post
Share on other sites

You can spawn anything as long as the addon it's from is active and you have the proper class name. If you ran the mission without the addon active you'd get an error.

Share this post


Link to post
Share on other sites
You can spawn anything as long as the addon it's from is active and you have the proper class name. If you ran the mission without the addon active you'd get an error.

Can you explain more about the http://community.bistudio.com/wiki/BIS_fnc_spawnVehicle

I tried to use the example

[getPos mySpawnPos, 180, "BMP3", EAST] call bis_fnc_spawnvehicle

in a trigger activated by radio alpha but nothing happened

Share this post


Link to post
Share on other sites

http://www.kylania.com/ex/?p=24

Make sure you have the functions module on the map. also make sure mySpawnPos is a valid position there, I'm guessing that's the name of a Game Logic? Additionally remember that for multiplayer if you spawn things on a trigger it'll spawn for each connected client and the server.

Share this post


Link to post
Share on other sites
http://www.kylania.com/ex/?p=24

Make sure you have the functions module on the map. also make sure mySpawnPos is a valid position there, I'm guessing that's the name of a Game Logic? Additionally remember that for multiplayer if you spawn things on a trigger it'll spawn for each connected client and the server.

OK. Thanks!!! :yay::yay::bounce3:

Share this post


Link to post
Share on other sites
OK. Thanks!!! :yay::yay::bounce3:

You also need to make sure there is already an EAST unit on the map. If not you can use the command;

createcenter EAST;

Alternatively stick any EAST unit on the map in the editor and make it's probability of existance zero.

Share this post


Link to post
Share on other sites

You have to wonder why all maps can't just come with the center's created already? :)

Share this post


Link to post
Share on other sites
You also need to make sure there is already an EAST unit on the map. If not you can use the command;

createcenter EAST;

Alternatively stick any EAST unit on the map in the editor and make it's probability of existance zero.

Actually I am using the Wings of Russia mod which adds 3 Russian planes to the game. My goal was to put myself as a Russian soldier in Novy Sobor (Chernarus) and hold the USMC as long as we can. When all people from my squad die, the Russian plane comes and bombs :eek: BOOOOOOOOOOOOM!!! What I did is I made the plane go around waypoints using the cycle waypoint and used

({alive _x} count units mygroup) == 1

on a trigger with type switch which makes the plane stop his dumb patroling and head to Novy Sobor. Unfortunately he doesn't follow the waypoint exactly and bombs behind the enemy lol. Also it takes him a loooooooooooooooot of time to come. Before Novy Sobor I put like 10 triggers that you used for the C130J to bomb 1 after another so he drops lots of bombs, unfortunately misses lol. My problem is that he comes really late and misses the target. :butbut::butbut: Thanks.

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  

×