Welcome, Guest Saturday 19th April 2014, 18:01:59
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: Indirect Fire Attack Simulation  (Read 898 times)
0 Members and 1 Guest are viewing this topic.
Shadow.D. ^BOB^
*
Offline Offline


« 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  Cheesy grateful.

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


"Behold a pale horse"


« 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... Don't Know
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:
[] exec "IDF.sqs"

IDF.sqs
Code:
#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  Wink

Laggy

* IDF_attack.Intro.rar (1.18 KB - downloaded 31 times.)
« Last Edit: 16 Feb 2009, 15:29:32 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Shadow.D. ^BOB^
*
Offline Offline


« 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.  Embarrassed

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


"Behold a pale horse"


« Reply #3 on: 16 Feb 2009, 16:32:11 »

init.sqs

Code:
[] 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:  Embarrassed Embarrassed Embarrassed 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 » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Shadow.D. ^BOB^
*
Offline Offline


« Reply #4 on: 16 Feb 2009, 17:40:29 »

First of all let me reiterate what i said about this community being the best.  Cheesy

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^ » Logged
laggy
*
Offline Offline


"Behold a pale horse"


« Reply #5 on: 16 Feb 2009, 17:47:30 »

 Smiley 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
Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Shadow.D. ^BOB^
*
Offline Offline


« 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.
Logged
laggy
*
Offline Offline


"Behold a pale horse"


« 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:
[] exec "IDF.sqs"
[] exec "alarmsound.sqs"

? ! (isServer) : exit

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


IDF.sqs
Code:
#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:
#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 Tongue
Some .SQF master could make a much more elegant solution  Confused
« Last Edit: 16 Feb 2009, 19:29:07 by laggy » Logged

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


« Reply #8 on: 16 Feb 2009, 19:14:01 »

Laggy is a good scripter, but he should learn SQF syntax  Cheesy
Logged

How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!
laggy
*
Offline Offline


"Behold a pale horse"


« Reply #9 on: 16 Feb 2009, 19:15:35 »

 Weeping I'm trying for heavens sake...
Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Shadow.D. ^BOB^
*
Offline Offline


« Reply #10 on: 16 Feb 2009, 19:39:01 »

Laggy i could kiss you  Kiss (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^ » Logged
laggy
*
Offline Offline


"Behold a pale horse"


« 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 Chin
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 » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Shadow.D. ^BOB^
*
Offline Offline


« 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^ » Logged
Rommel92
*
Offline Offline


« 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.  Tongue

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

Shadow.D. ^BOB^
*
Offline Offline


« 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.
Logged
Rommel92
*
Offline Offline


« Reply #15 on: 16 Feb 2009, 20:57:47 »

Code: (init.sqf)
execVM "IDFattack.sqf";

Code: (IDFattack.sqf)
see below...

Problem line:
Code:
speaker setvehicleinit format["this say %1", IDFalarm];

This was the only line I could see as being a problem as I've forgotten the notation with talking marks, if that doesn't work try these solutions (sorry for the screw around, I really need to get ArmA re-installed.)
Code:
solved...
« Last Edit: 16 Feb 2009, 21:42:00 by Rommel92 » Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #16 on: 16 Feb 2009, 21:02:53 »

The only script that needs publicvariable is the IDF.sqs.

The other scripts are simply waiting for the publicvariable command  Cool2

Might be:

alarmsound.sqs
Code:
#loop
if (IDFattack) then {speaker say "IDFalarm"}
~12
goto "loop"

I would go with Rommels script though, when it doesn't report errors  Wink
« Last Edit: 16 Feb 2009, 21:16:28 by laggy » Logged

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


« Reply #17 on: 16 Feb 2009, 21:18:56 »

(Just installed ArmA - Installing Patches  Tongue)

In future Laggy, try a addPublicEventHandler

Its better then having a constant loop.
Logged

Shadow.D. ^BOB^
*
Offline Offline


« Reply #18 on: 16 Feb 2009, 21:22:37 »

Rommel, i have used the original script again:-

Code:
if (not isserver) exitwith {};

waituntil {IDF_attack};

while {true} do {
private"_w";
_w = time + 1;
while {_w < time} do {sleep 1};
_w = time + 6 + random 2;
[_w] spawn {
while {_this select 0 < time} do {
sleep 12;
speaker setvehicleinit format["this say %1", IDFAlarm];
processinitcommands;
};
};
while {_w < time} do {
sleep (5 + random 5);
private"_b";
_b = "Sh_120_HE" createVehicle [(getpos IDFCenter select 0) + 50 - random 100,(getpos IDFCenter select 1) + 50 - random 100, 50];
};
};


I've just changed the sound file name to IDFAlarm (to match the sound file) and gamelogic to IDFCenter to tie in with my mission.  I have also changed the time so that i can test if it works.  Although i dont get any errors, the script doesnt seem to start. No sound and no spawning shells.

I hope i've not changed anything i should'nt have with the time stuff, if so what should i enter so i can test it works.  I figured the values i have entered would get the script to start soon after mission start.


Thanks again to everyone for takin an interest in this.

« Last Edit: 17 Feb 2009, 00:37:19 by Shadow.D. ^BOB^ » Logged
laggy
*
Offline Offline


"Behold a pale horse"


« Reply #19 on: 16 Feb 2009, 21:31:16 »

(Just installed ArmA - Installing Patches  Tongue)

In future Laggy, try a addPublicEventHandler

Its better then having a constant loop.

I never got my head around how the addPublicVariableEventHandler is used.
Could you give a quick example Rommel?
Logged

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


« Reply #20 on: 16 Feb 2009, 21:35:16 »

Code: (IDFAttack.sqf)
if (not isserver) exitwith {};

waituntil {IDF_attack};

while {true} do {
private"_w";
_w = time + 1;
waituntil {time > _w};
_w = time + 6 + random 2;
[_w] spawn {
while {time < _this select 0} do {
sleep 12;
speaker setvehicleinit format["this say %1", IDFAlarm];
processinitcommands;
};
};
while {time < _w} do {
sleep (5 + random 5);
private"_b";
_b = "Sh_120_HE" createVehicle [(getpos IDFCenter select 0) + 50 - random 100,(getpos IDFCenter select 1) + 50 - random 100, 50];
};
};

Positive Results! - Works a beauty.

Logic failure, I had _w < time instead of time < _w ... atleast I think.

Quote from: Laggy
I never got my head around how the addPublicVariableEventHandler is used.
Could you give a quick example Rommel?

Code: (example)
"IDFAttack" addPublicVariableEventHandler {
hint ((_this select 0) + " has been updated to: " + str (_this select 1));
if (_this select 1) then { //boolean true
while {IDFAttack} do {
sleep 12;
speaker say "IDFalarm";
};
};
};

EXAMPLE FOR LAGGY.
« Last Edit: 16 Feb 2009, 21:58:03 by Rommel92 » Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #21 on: 16 Feb 2009, 21:57:10 »

Ughhh  Blink

What does it do?

What is the "//boolean true" thingy?

EDIT:

Awesome, must try it out  Good
Thanks for taking the time to explain it  Smiley

Laggy
« Last Edit: 16 Feb 2009, 22:13:06 by laggy » Logged

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


« Reply #22 on: 16 Feb 2009, 22:02:19 »

Code: (init)
"Laggyexample" addPublicVariableEventHandler {
player sidechat "I'm a little bit laggy today. Damn latency.";
};

Alpha Radio Trigger:
Code: (onAct)
laggyexample = "test"; publicVariable "laggyexample";

This however will not show on your computer:
Quote from: BIS
Note that the EH is only fired on clients where the publicVariable command has not been executed, as publicVariable does not change the variable where it has been executed.

So if tested on a dedicated server, it will come up on your computer saying "I'm a little bit laggy today. Damn Latency".

_this select 0 being the variable itself as a string "Laggyexample" and _this select 1 being the variables new value as a value: "test".
Logged

Shadow.D. ^BOB^
*
Offline Offline


« Reply #23 on: 16 Feb 2009, 22:10:46 »

Hmmm tried that script again Rommel, but i cant hear the alarm and no shells.  I have waited a couple of minutes for it to start (just incase).  Any chance you could repost the last template i uploaded with it working?  Just incase i'm missing something.  How long does it take generally to sound when you try the script using the above time numbers?

Cheers.

Edit:- This can be tested from the editor right? Or does it need to be on a dedicated server?
« Last Edit: 16 Feb 2009, 22:14:14 by Shadow.D. ^BOB^ » Logged
Rommel92
*
Offline Offline


« Reply #24 on: 16 Feb 2009, 22:31:51 »

Make sure you have the Radio trigger working correctly.

Code: (OnAct)
IDF_attack = true

I tested it with a wolf sound and the shells, and my first (and only) error was that I had:

Code: (onAct)
IDFattack = true

So maybe double check that.

Note: it should be IDFattack, but I made a mistake in the script, so whichever one you chose, make sure they are consistent.
Logged

Shadow.D. ^BOB^
*
Offline Offline


« Reply #25 on: 16 Feb 2009, 23:55:52 »

ah i see, i wasnt setting the IDFattack to true via the radio.

EDIT:- Ok tested this, i get an error once its started. 

Code:
'this say scalar |#|bool array string 0xe0ffffef'
Error Missing ;

The shells come in fine, so im guessing the error is sound related.

Sorry if it sounds like im nagging you.  Cheesy

I've attached the example mission again as it stands now.

* IDF_attackSQF.Intro.rar (84.64 KB - downloaded 39 times.)
« Last Edit: 17 Feb 2009, 00:18:12 by Shadow.D. ^BOB^ » Logged
Rommel92
*
Offline Offline


« Reply #26 on: 17 Feb 2009, 01:23:05 »

Code:
speaker setvehicleinit format["this say %1", "IDFAlarm"];

Hopefully that works. I'd test it, but I'm now at a different computer 30km away from ArmA.  Whistle
Your not nagging me at all; I just needed to test these before posting solutions Tongue.
Logged

Shadow.D. ^BOB^
*
Offline Offline


« Reply #27 on: 17 Feb 2009, 01:37:32 »

Getting there  Cheesy

The error has gone, the shells come in, but no sound plays.  Huh?

You gotta love this game, definatly keeps you busy.
« Last Edit: 17 Feb 2009, 01:39:42 by Shadow.D. ^BOB^ » Logged
Rommel92
*
Offline Offline


« Reply #28 on: 17 Feb 2009, 06:29:57 »

All fixed and working, you forgot to set up the sound in the description.ext. You were missing \sound\ for the file path and it was also really quiet, but you can modify that.

There also appears to be a loop in the sound that powers down, and it the sound lasts about 26 seconds, so I made a 2s crossover period instead of about four sounds at once.  Whistle

* IDF_attackSQF.zip (85.01 KB - downloaded 21 times.)
Logged

Shadow.D. ^BOB^
*
Offline Offline


« Reply #29 on: 17 Feb 2009, 14:06:42 »

Well what can i say, you guys are top notch.  Thankyou to Laggy for the original scipt and Rommel for his super "pimped" version.  Cool2 This is the reason, OFP/ArmA has the best community out there.

Before I call this one as complete, can i just verify the values to change:-

1. The length of the random time in which the attack begins.

2. The length of time the attack continues.

3. The length of time before the sound file replays, during the attack.

I will get testing this in my template asap, it really is gonna add something special.

Once again, you boys have far exceeded my expectations.  THANKYOU!!  Clapping
« Last Edit: 17 Feb 2009, 14:08:13 by Shadow.D. ^BOB^ » Logged
Pages: 1 2 [All]   Go Up
  Send this topicPrint  
 
Jump to: