Home   Help Search Login Register  

Author Topic: Skumball's Airstrike.  (Read 1748 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Skumball's Airstrike.
« on: 12 Nov 2004, 16:26:35 »
I've posted the whole thing so you can see. What I need to do is make it so that the script can only be called three times. I don't want

Airstrike 1
Airstrike 2
Airstrike 3

in my radio messages list. Any ideas?


;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


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")
strikePilot sideChat "I'm ready for another run. Over."
playsound "run"

1 setRadioMsg "Air Strike"

exit
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 ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:Skumball's Airstrike.
« Reply #1 on: 12 Nov 2004, 17:16:13 »
Initialise a global variable, say airstrikecounter = 0

In the script, increment airstrikecounter every time the script runs.

Check airstrikecounter < 3, if not exit, before resetting the pilot and the radiomessage. Could also have an 'out of ammo' message.

You could also have a first line in the script that exits if airstrikecounter >= 3, just to be sure.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re:Skumball's Airstrike.
« Reply #2 on: 12 Nov 2004, 22:47:09 »
I dont understand i cant script
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."

psyichic

  • Guest
Re:Skumball's Airstrike.
« Reply #3 on: 12 Nov 2004, 23:15:55 »
What type of language does OFP use? it looks somewhat like C but im not really sure. hmmmmmmmm  ???

Korax

  • Guest
Re:Skumball's Airstrike.
« Reply #4 on: 12 Nov 2004, 23:30:54 »
It uses its own language, only slightly similar to C

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Skumball's Airstrike.
« Reply #5 on: 12 Nov 2004, 23:31:26 »
OFP uses OFP.....simple as that.

OFP scripting language is in a class all of its own.

I think it has elements of various languages mixed in there.....at least it seems that way, but, it is definitely not based on any one language type.


Planck
I know a little about a lot, and a lot about a little.

psyichic

  • Guest
Re:Skumball's Airstrike.
« Reply #6 on: 12 Nov 2004, 23:44:14 »
Oops sry about the mistake oh and can anyone point me towards a good tutorial on the OFP language? Ive searched around but nothing so far.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Skumball's Airstrike.
« Reply #7 on: 12 Nov 2004, 23:46:27 »
Try here.......Tutorials section:

http://www.ofpec.com/editors/index.php


Planck
I know a little about a lot, and a lot about a little.

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:Skumball's Airstrike.
« Reply #8 on: 13 Nov 2004, 00:16:05 »
Ooh - OK then . . .

In any unit's init field stick:

airstrikecounter = 0

That initialises your counter variable. Because it's not _airstrikecounter it's a global variable that is available to any script or, in this case, the same script run three times.

Now to the script itself - add the bold bits:


?(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"
exit



Think I got them all.

All the new bits do is count each time the script is run. Once it's run three times the radio message is not reset so you can't call another airstrike.  It's a simple concept so I hope I've not made a stupid error somewhere!  Only one way for you to find out . . .

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Skumball's Airstrike.
« Reply #9 on: 13 Nov 2004, 23:53:48 »
What type of language does OFP use? it looks somewhat like C but im not really sure. hmmmmmmmm  ???

I don't understand why people say that. The only way OFP is like C or C++ or Java, from what I know, is that it uses If/then statements and while loops. But EVERY language uses these, so I don't understand the connection... To me, OFP seems way closer to BASIC or other simpler, non-object oriented languages. Only not nearly as logical and way more difficult to use...

Sry for getting off topic  :P
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Skumball's Airstrike.
« Reply #10 on: 14 Nov 2004, 01:27:09 »
I think most people get the C++ comparison from the .ext files, which have the same sort of:

{
       blah blah blah;
}


I've always thought the scripting was a lot like basic myself, but I think it's wrong to compare it to any language. It's definately it's own thang ;D

psyichic

  • Guest
Re:Skumball's Airstrike.
« Reply #11 on: 14 Nov 2004, 12:26:00 »
Yea sorry about the confusion. But Sui I kinda see where your comming from when you say it looks something like basic now that Ive read more about its commands. But it indeed is its own language. And luckily it isn't like C needing a ; to end a line

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Skumball's Airstrike.
« Reply #12 on: 14 Nov 2004, 15:35:55 »
actually in functions it does, so maybe thats where people see the similarity

Robinhansen

  • Guest
Re:Skumball's Airstrike.
« Reply #13 on: 01 Jan 2005, 18:22:15 »
A hell of a script 8) 8) BUT how do I change the OnMapSingleClick funktion so I can send the grid coordinates by useing the LaserDesignator insteat?? (Just like The Chain Of Command - Unified Artillery)
 :P :P

Tnx in advance