Home   Help Search Login Register  

Author Topic: Indirect Fire Attack Simulation  (Read 4308 times)

0 Members and 1 Guest are viewing this topic.

Offline Shadow.D. ^BOB^

  • Members
  • *
Indirect Fire Attack Simulation
« on: 16 Feb 2009, 13:41:50 »
Hey guys, i was hoping someone would be able to help me develop an IDF Attack simulation.  Basically i have a recording of an IDF Alarm, i would like to try and simulate an attack for my Afghan Village template.

The idea would be to have the alarm sound at random times throughout the day/night from a certain point, then have a spawned shells (possibly grenades) drop randomly in say a 500m radius around that point or another defined point (game logic or whatever). Having the attack last for say 1-5 minutes, i know there would be alot of random variables in this and I hope that it makes sense. I think it would really add something different for people making missions based on current military operations.

I'm a complete noob when it comes to making scripts, if anyone could help me with this i would be very very very  :D grateful.

Thankyou in advance for any help.
« Last Edit: 16 Feb 2009, 13:48:18 by Shadow.D. ^BOB^ »

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Indirect Fire Attack Simulation
« Reply #1 on: 16 Feb 2009, 15:19:53 »
Hi,

Made a simple .sqs file, could make a .sqf, but since I'm slower with that... :dunno:
This script is so simple that .sqf won't make a performance difference anyway.

Solution:
An object called speaker (in my mission a roadcone).
A gameLogic called attackcenter.
A Radio alpha trigger that sets varable IDFattack to "true".

If you want to alter the "area size" being attacked, just change the "+ 50 - random 100" numbers to i.e "+ 500 - random 1000".

init.sqs
Code: [Select]
[] exec "IDF.sqs"
IDF.sqs
Code: [Select]
#start

@ IDFattack

speaker say "IDFalarm"

? ! (isServer) : IDFattack = false; goto "start"

_attacklength = 60 + random 240
_time = 0

#loop

? _time >= _attacklength : goto "end"
_delay = 5 + random 5
~ _delay
_boom = "Sh_120_HE" createVehicle [(getpos attackcenter select 0) + 50 - random 100,(getpos attackcenter select 1) + 50 - random 100, 50]
_time = _time + _delay
goto "loop"

#end

IDFattack = false
goto "start"

Use the trigger and see the effect. If you really want to have random attack times all through the day you could easily accomplish that with a looping script that sets IDFattack = true at random times. Don't forget to use publicVariable if you want it to work in MP.

Since I don't have a sound called "IDFalarm" you get an error message, but I hope you know how to define sounds in .ext and sound folder.

Example mission included.

Hope it's good enough  ;)

Laggy
« Last Edit: 16 Feb 2009, 15:29:32 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #2 on: 16 Feb 2009, 15:59:45 »
M8 the fact that you have taken the time to do this, is just a prime example of the OFP/ArmA community.  :good:

Thanks alot, i will try this out asap.

EDIT:- This is near perfect Laggy, just a couple of questions.  How exactly would i go about making this MP compatible and looping randomly throughout the day?  Also could it be activated via the init.sqf at mission start, rather that on a radio trigger?

Fantastic job tho m8, wish i could get me head around scripting.  :-[

« Last Edit: 16 Feb 2009, 16:17:38 by Shadow.D. ^BOB^ »

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Indirect Fire Attack Simulation
« Reply #3 on: 16 Feb 2009, 16:32:11 »
init.sqs

Code: [Select]
[] exec "IDF.sqs"

? ! (isServer) : exit

#loop
_timetowait = 3600 + random 3600
~ _timetowait
IDFattack = true
publicVariable "IDFattack"
goto "loop"


Unless I'm stupid (quite busy right now) this should make it start every 1-2 hours, (3600 sec = 1 hour) and work in MP.

EDIT:  :-[ :-[ :-[ 6000 sec != 1 hour  :whistle: :whistle: :whistle:

Also about scripting, It's not much more complicated than triggers as long as you study what all the commands can do, vacuum clean the COMREF! I am not a really good scripter (suck at math and logic), have to bother this forum a lot with my questions, but you learn a lot from copying and pasting as well as starting of with smaller self made scripts, where you work on them until they work as you want them to. Look at scripts that you like and try to figure out how they work. I am just starting off with .SQF and find myself as a newbee, compared to working in .SQS, so just get started mate.

Laggy
« Last Edit: 16 Feb 2009, 17:29:47 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #4 on: 16 Feb 2009, 17:40:29 »
First of all let me reiterate what i said about this community being the best.  :D

Laggy this script works perfectly, just what i was looking for.  I have tested it with a lower time randomness and it all seems great.  Will do some more testing in MP once its implemented into my template, but i cannot thank you enough for this.

I will definatly look into scripting a bit more, like u say its spending the time and starting small. (All my free time is going into making missions atm.)

Once again thankyou for this, i will make sure you are credited once the template is complete.
« Last Edit: 16 Feb 2009, 17:44:34 by Shadow.D. ^BOB^ »

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Indirect Fire Attack Simulation
« Reply #5 on: 16 Feb 2009, 17:47:30 »
 :) Mission making is really what it's all about Eh?  :good:
Script making is just one way of trying to make better missions.

In OFPres the original missions didn't include many complicated scripts, but were still some of the best missions to play in my opinion.

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #6 on: 16 Feb 2009, 18:31:45 »
I agree Laggy simplicity generally works best.

Just another question, could it be possible to replay the sound file say repeated every 10 seconds for the duration of the IDF attack?

At the moment it works as intended, in RL though the IDF alarm keeps playing while there are still rockets/shells are in the air.  If this could be implemented it would finish the script off nicely.

Cheers.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Indirect Fire Attack Simulation
« Reply #7 on: 16 Feb 2009, 19:12:58 »
Not a very slimmed solution, but quick to implement, is to have a third script:

init.sqs
Code: [Select]
[] exec "IDF.sqs"
[] exec "alarmsound.sqs"

? ! (isServer) : exit

#loop
_timetowait = 3600 + random 3600
~ _timetowait
IDFattack = true
publicVariable "IDFattack"
goto "loop"


IDF.sqs
Code: [Select]
#start
? ! (isServer) : exit

@ IDFattack

_attacklength = 60 + random 240
_time = 0

#loop

? _time >= _attacklength : goto "end"
_delay = 5 + random 5
~ _delay
_boom = "Sh_120_HE" createVehicle [(getpos attackcenter select 0) + 50 - random 100,(getpos attackcenter select 1) + 50 - random 100, 50]
_time = _time + _delay
goto "loop"

#end

IDFattack = false
publicvariable "IDFattack"
goto "start"

alarmsound.sqs
Code: [Select]
#loop
? IDFattack : speaker say "IDFalarm"
~12
goto "loop"

Just make sure the ~ delay in alarmsound.sqs is not shorter than your soundfile, as that might "pile up" your sounds, so that it continues to play long after the attack is over. At least I believe so.
Like I said, not beautiful, but should work well :P
Some .SQF master could make a much more elegant solution  :confused:
« Last Edit: 16 Feb 2009, 19:29:07 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Ext3rmin4tor

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #8 on: 16 Feb 2009, 19:14:01 »
Laggy is a good scripter, but he should learn SQF syntax  :D
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Indirect Fire Attack Simulation
« Reply #9 on: 16 Feb 2009, 19:15:35 »
 :weeping: I'm trying for heavens sake...
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #10 on: 16 Feb 2009, 19:39:01 »
Laggy i could kiss you  :-* (Maybe not, lol).   How about a night with my missus instead?  :whistle:

Working like a charm, gives a fantastic atmosphere.  Still need to do a bit of tweaking with the sound file, but here's an example mission, i've shortened the time to 1/2 minutes for testing.

Once again m8, thankyou so much.

« Last Edit: 17 Feb 2009, 00:04:34 by Shadow.D. ^BOB^ »

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Indirect Fire Attack Simulation
« Reply #11 on: 16 Feb 2009, 19:53:01 »
Cool, keep up the good work mate  :good:

Maybe add some sound of the shells whizzing through the air before impact too  :scratch:
I'm too busy packing right now though, travelling for a week without PC  :weeping:
« Last Edit: 16 Feb 2009, 20:01:39 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #12 on: 16 Feb 2009, 20:15:17 »
Hey laggy slight problem, do i need to add a publicvariable to the looping sound script? (If so could you give me an example of what it would look like).  I have just tested this on my dedicated server and the sound only plays once.
« Last Edit: 16 Feb 2009, 20:19:16 by Shadow.D. ^BOB^ »

Offline Rommel92

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #13 on: 16 Feb 2009, 20:33:41 »
Thanks to laggy for the original scripts, I just optimized them into one with simpler execution and hopefully better use. If theres errors please tell me, and sorry for the inconvience.  :P

<see newer post>
« Last Edit: 16 Feb 2009, 20:54:53 by Rommel92 »

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Indirect Fire Attack Simulation
« Reply #14 on: 16 Feb 2009, 20:47:04 »
Hi Rommel, thanks for taking a look at this.  Any other input on Laggy's fantastic work, is greatly appreciated.

I have tried the script but currently get an error regarding a missing ";" on line 13.