Home   Help Search Login Register  

Author Topic: Prevent 'I'm an AI, and will launch all my 4 laws at a truck' script  (Read 3385 times)

0 Members and 1 Guest are viewing this topic.

Offline ryankaplan

  • Members
  • *
  • yeah...
this is a pain in the ass when commanding ai.
all 5 of your law soldiers seem to waste 15 rockets on a truck with one soldier in it, which they miss, when you're required to fight 10 bmps in some distant enemy base.
Hold fire sort of works, but then they don't shoot rifles neither.

 I'd like a script which makes ai not shoot their at AT weapons at less armoured targets. Even better, a few options in your action menu like
*Engage All*
*Engage APCs+Tanks*
*Engage air only*
*Engage none*

This script would be great, and am sure would be used in many missions, including all of mine.

Offline 456820

  • Contributing Member
  • **
im not sure if this would be possible but if it is i dont think it would be all that great

The way i would do it is run a script which checks for trucks and other things depending on those actions you want if you want them not to engage a truck from the script find all the trucks and cars etc and setcaptive them true (this will also mean soldiers wont fire at it but law soldiers will leave it a lone) then you run a little loop checking for a variable to be true which would be something like (engagetruck = true) then once active the truck will be setcaptive false now people will fire at the truck

It would work but may not be that great nor realistic but that way would work

And engage AIR wouldnt work unless you have AA soldiers in the squad but if you dont they wont even try to fire at it even if you tell it too using dotarget and do fire commands

Anyway thats how i would do it there maybe a better and easier way to do it

Offline ryankaplan

  • Members
  • *
  • yeah...
is there any way of detecting what an ai is targeting?

also, i know law soldiers won't engage air, i was thinking it would at least prevent AA soldiers from shooting M1A1s.

Offline 456820

  • Contributing Member
  • **
nope sorry i asked not too long ago if you could find out what a soldier is targetting and sadly nope no way

You can find out if a AA or AT soldier is targetting a tank/aircraft using the target Event handler not sure how it works never used it and i didnt look at it for long so im not sure if it would work in this situation

I think its realistic for an AA soldier to blast and abrams, i know i would in real life but depends how desperate the group is if theyrve got pleanty of laws then nope keep it for air but if theres no one with a law why not  ;D

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
using a fired event handler,
check what weapon the unit fired,
if its a secondary weapon and the AT weapon in question is the secondary weapon,
remove the secondary weapon magazines for say 30 seconds, then give the unit them back, that way, it slows the refire rate down


You could also use the knowsabout command and tie that in with a class of vehicle. removing AT weapons from units in an array
« Last Edit: 03 Jan 2006, 20:28:17 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
I would try something along the lines of what Terox was suggesting.

1) Remove AT/AA ammo from units by way of their init line.

2) Make a trigger with side present and either a) group the trigger to the APC/Aircaft or b) use the vehicle class to activate the trigger

3) Add the appropriate ammo back the the units when either an APC or aircraft enters the trigger area. You could even add some reveal/dotarget/dofire commands to get your units to target the correct enemy units.

4) For engage all, just make a trigger activated by a radio command to return the AT/AA ammo to all/some units.

Posting from work so you are on your own as for the actual command codes/details.

Wadmann
Check out my Camouflage Collection! New items added 31 July 2005.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
if you wanted to go more extreme, you could create a new LAW addon, by just editing the config as the BIS one, there you would be able to keep it from being fired at trucks.


or option 2.

you could put all the trucks in the mission in an array and then use the DirToObj function in the ed depot to find out if the law soldiers are facing a truck(they would face the truck to aim there laws at it) , and if they are the remove their law rockets, and give them back once they are not pointed at the truck.

DirToObj
http://www.ofpec.com/editors/funcref.php?letter=D#DirToObj

« Last Edit: 04 Jan 2006, 02:01:23 by penguinman »

Offline 456820

  • Contributing Member
  • **
you can also use the distance command i think its the exact same as the function not sure what the difference iis too me they both do the same thing

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Quote
i think its the exact same as the function not sure what the difference iis too me they both do the same thing
not really, distance returns the distance between 2 objects and DirToObj returns what direction(0-360)  "unit A" needs to be facing to be looking at "unit B"

distance will not work here, unless the tanks and the trucks were on different sides of the map

Offline 456820

  • Contributing Member
  • **
ooops sorry misread i thought it was a distance function sorry ignore my other post

But function may also come in handy though to check how far the truck is if its out of range theres no need to remove the Law soldiers laws but if its closer then you may need to remove them

Offline hardrock

  • Members
  • *
  • Title? What's that?
    • Operation FlightSim
you could put all the trucks in the mission in an array and then use the DirToObj function in the ed depot to find out if the law soldiers are facing a truck(they would face the truck to aim there laws at it) , and if they are the remove their law rockets, and give them back once they are not pointed at the truck.
I wouldn't do that as they would probably select the AT launcher, now the rockets are removed and they are pretty useless against infantry unless they switch back to primary fast enough by themselves.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
right. i've just had a wee play with the knowsabout command. it seems loons will always fire first at the enemy they know the most about. threat assessment appears to go on too, as well as depending on which direction the loon happens to be facing, when it comes to the loon deciding what to shoot at.

(thinking while typing here...) it follows then that if you have an array of all the enemy units on the map, then go through that array checking the corresponding knowsabout level for each of your law loons, keeping the highest knowsabout level in a variable, you then know what the law loon is likely to be targetting.

stopping the law loon from firing at it is another matter entirely. removing the ammo is the only way i can think of which won't involve disabling the loon altogether. but then, how much ammo do you return to the loon when it's not a truck? you'd need to keep a record of each law loon's ammo count. that coupled with constantly checking arrays would slow the game down to a crawl i suspect.

the golden rule of flashpoint editing i have found, is when in doubt, cheat. setcaptive all of your enemy trucks from the beginning. they'll never be targetted, but then you skip over the law-wasting problem.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Quote
wouldn't do that as they would probably select the AT launcher, now the rockets are removed and they are pretty useless against infantry unless they switch back to primary fast enough by themselves.

you would only be removing the law rockets, not the M16 mags. And Ai dont fire there laws at infantry anyways in the first place. And even if they did fire them at infantry, the script would only remove them if they are pointing at trucks, then give them back as soon as they are not pointing at the trucks.

@Bedges
Your method is good, but then they wouldnt even fire their M16's at the trucks.

I think the easiest method would be the new law addon, it would take about 5 minutes to do and the file would be tiny to include in the zip with the mission.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
why would they fire their m16's at a truck anyway?

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Because the game designers programed them to.

and im sure the starter of this topic still would want the units to fire at the truck.