Home   Help Search Login Register  

Author Topic: AI Flying plane  (Read 1474 times)

0 Members and 1 Guest are viewing this topic.

GavinP

  • Guest
AI Flying plane
« on: 12 Jun 2006, 22:49:49 »


I'm having a little trouble with my CAS script, in that my flaming tornado keeps flying into trees. My script is as follows
Code: [Select]
p1 moveindriver _Support
p2 moveingunner _Support
_Support flyinheight 150

_Support move getmarkerpos "mkrTarget"
_support selectweapon "CRP_Mk82HD_Launcher_5_RAF"

p1 setskill 1
p2 setskill 1
;_support setcombatmode "BLUE"
_support setbehaviour "CARELESS"

I've tried changing the flyinheight to 500+, but he still buys the farm. The trouble I have is that rather than level flight and dropping bombs, he seems to be diving as if he was firing his cannon causing him to be far too low.

Is this an addon related issue, or a poor script, or poor AI, and is it possible to overcome?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: AI Flying plane
« Reply #1 on: 12 Jun 2006, 23:22:19 »
I assume _Support is your plane, you may try changing your commands to the plane by the corresponding commands to the crew.

p1 move getMarker ....
p2 selectweapon ...
p1 setBehaviour ...

(flyInHeight should keep as command for the plane)

GavinP

  • Guest
Re: AI Flying plane
« Reply #2 on: 13 Jun 2006, 09:42:58 »
Hi. Thanks for the reply. Will try that out tonight. Not really sure it will make much difference though, as the plane moves ok apart from the tree intervention!

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: AI Flying plane
« Reply #3 on: 13 Jun 2006, 13:32:09 »
It won't. AI pilots are totally retarded. Especially when they're flying fast jets.

Do you need the Tornado buzzing around?
Could you allow a script where it just flys by and drops some bombs on a map click?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

GavinP

  • Guest
Re: AI Flying plane
« Reply #4 on: 13 Jun 2006, 15:58:30 »
Ah.

Quote
Do you need the Tornado buzzing around?
Could you allow a script where it just flys by and drops some bombs on a map click?

I guess not, but I was trying to work as simply as possible, by taking advantage of the inbuilt features. Also, I want the airstrike to be a little more dynamic than simply hitting the click.

I'm not really an advanced scripter having only really got started with it. I'm going to persist with the script as it is, as I could do with the experience of getting some loops etc to run through. Once I can get the script to work using the AI, I will go back, and have another go by camcreating the bombs which is I believe the solution you are discussing?

GavinP

  • Guest
Re: AI Flying plane
« Reply #5 on: 13 Jun 2006, 17:22:56 »
Just had a thought, whether you could start a check altitude loop, which when below the hard deck for want of better term, set the velocity of the plane to a 0 degree angle,ie level flight and maintained it for say 5-6 seconds(Taking the x&y coordinates from its current state) , which is probably enough to take it from where the tornado begins its death dive to past the target where the AI will fly the plane again normally?

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: AI Flying plane
« Reply #6 on: 13 Jun 2006, 17:36:30 »
I have a script ready made for the Tonka.

It appears in this mission if you want to see it in action.
First Light
http://www.freewebs.com/ofpbob/mymissionspart2.htm

Code: [Select]
;Airstrike (map click) v1.2
;by Skumball (simongoddard4@yahoo.co.uk)
;Modified by The-Architect (The_arch@hotmail.com)
;Needs listed sounds to work with audio.
;
;Thanks to Viriato for making the bombs fall correctly and LCD for incorporating the script into the radio
;
;Requires:
;OFP v1.85
;1 Pilot named "strikePilot"
;3 Markers ("spawn","safe","target" all set to 'empty')
;1 Trigger (Activation: Radio Alpha, Repeatedly. Text: Air Strike. On Activation: onMapSingleClick {[_pos] exec "airstrike.sqs"}; strikePilot sideChat "Give me a target.")
;
;Have a look at the sample mission to see how it works
;Change the value of _num, *0.2 and ~0.2 for different results


?(airstrikecounter >= 3): exit
; more than three [air]strikes and you're out - just an insurance policy

airstrikecounter = airstrikecounter + 1
; use up a strike

onMapSingleClick {}
1 setRadioMsg "Null"

_pos = _this select 0

"target" setMarkerPos _pos
"target" setMarkerType "destroy"

strikePlane = "ITA_TRD_RAF_BHD14_KEY" camCreate (getMarkerPos "spawn")
strikePlane setPos [(getPos strikePlane select 0),(getPos strikePlane select 1),(getPos strikePlane select 2)+800]
strikePlane setDir 180
strikeplane flyinheight 75

strikePilot assignAsDriver strikePlane
strikePilot moveInDriver strikePlane
strikePilot doMove _pos
strikePilot sideChat "Roger. On the way."
playsound "onway"

@ unitReady strikePilot
strikePilot sideChat "Bombs gone."
playsound "gone"

_num = 4
_i = 0

#loop
_bomb = "ITA_Mk82HD_RAF" camCreate [(getPos strikePlane select 0)+((random 10)-5),(getPos strikePlane select 1)+((random 10)-5),(getPos strikePlane select 2)-3]
_bomb setDir (getDir strikePlane)
_bomb setVelocity [(velocity strikePlane select 0)*0.1,(velocity strikePlane select 1)*0.1,(velocity strikePlane select 2)*0.1]
_i = _i + 1
~0.15
? _i < _num : goto "loop"

strikePilot doMove (getMarkerPos "spawn")
~3
strikePilot sideChat "Heading back. Over."
playsound "heading"

"target" setMarkerType "empty"

@ unitReady strikePilot
deleteVehicle strikePlane
strikePilot setVelocity [0,0,0]
strikePilot setPos (getMarkerPos "safe")

?(airstrikecounter >= 3): goto "nomorestrikes"
; three or more [air]strikes we jump over the SetRadioMsg so it's NOT reset making further airstrikes unavailable
; if less than three, carry on . . .

strikePilot sideChat "I'm ready for another run. Over."
playsound "run"

1 setRadioMsg "Air Strike"

exit

#nomorestrikes
strikePilot sideChat "Heading back. Over."
playsound "heading"
~5
hint "Tornado has Returned to base."

exit


Put this line in the init of your player.
Code: [Select]
; airstrikecounter = 0
Put the sound files in your mission folder in another folder you've created called Sound.
Add all the sound files to your Description.ext

How to use the script.

Create a pilot. Call him,

StrikePilot

Create an empty marker called Spawn. Place it on the map a distance from your mission area. The Tornado will fly from this point.
Create an empty marker called Safe. Place it near the Spawn marker. This is where the Tornado will go after the run.
Create an empty marker called Target. This is the marker which will appear when you click on the map.

Create a Trigger with these settings.

Activation: Radio Alpha, Repeatedly.
Text: Air Strike.
On Activation: onMapSingleClick {[_pos] exec "airstrike.sqs"}; strikePilot sideChat "Give me a target."
In the effects tab select the sound file called "Target"

Save it and preview the mission. You should then be able to call an airstrike.

[attachment deleted by admin]
« Last Edit: 13 Jun 2006, 17:39:14 by The-Architect »
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

GavinP

  • Guest
Re: AI Flying plane
« Reply #7 on: 14 Jun 2006, 13:37:22 »
Interesting, Cheers.

Just looking though the code, i understand pretty much all of it, apart from how the script knows when to drop the bombs, how does the unitready command work in this instance? If I'm guessing correctly, it registers when the pilot has reached the _pos of the target? Doesn't this mean that the bombs fall past the target?

I notice that you use a different tornado to me. Any reason why?

as an aside, I did manage to get my tornado to stop crashing using the method I posed yesterday, setvelocity'ing the z component. It works rather well, ie I haven't had a loss yet, but the appearance sometimes can be a little 'jumpy' and once the loop has commenced, for some reason it stops dropping bombs,(controlled by a different loop.)

Anyway, I will have a look at incorporating this into my script and see what happens. I'll post my entire script tomorrow for discussion of where I'm perhaps going the long way around.

Cheers once again for the help.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: AI Flying plane
« Reply #8 on: 15 Jun 2006, 11:45:29 »
I use the Grey Green RAF Tornado if I remember. Just check the addon's config and adjust accordingly. Same for the bombs if they are different.

As for when the pilot drops his bombs, that's hit and miss. With your three runs, you can get it about right by trying different clicks on the map. It's not perfect I know but they drop more or less in the right area. Really only a little way out.

Perhaps your Tornado doesn't drop it's bombs because the AI pilot doesn't get the opportunity to line up the target. I don't know as I havn't seen it in action. I always figured though, that the reason the AI crashes a lot is because he needs ages to line himself up for the run.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: AI Flying plane
« Reply #9 on: 17 Jun 2006, 20:33:18 »
High accuracy bomb attacks

It doesnt work well against moving targets