Home   Help Search Login Register  

Author Topic: working smoking damaged aircraft script  (Read 1654 times)

0 Members and 1 Guest are viewing this topic.

SSG Plazmoid

  • Guest
working smoking damaged aircraft script
« on: 03 Jan 2003, 01:17:39 »
Thought it would be cool to see smoke and fire tralling from damaged aircraft. Like most of what goes on in multiplayer it's not as simple as you first think. As each client needs to draw the smoke each client needs to know what the vehicle object name is, that objects position, etc. Also, vehicle respawn is handled server side only to avoid multiple respawns so how would clients run a script called only by server?




So, using Tact's suggestion to my other question of how to do things with respawned vehicles I've gotten smoke working. Need to test it on a dedicated server but I think I've done the scripts in a way that they'll work on dedicated server correctly.

First, we need to know all of the vehicles that we'll want smoke added to. For each one you'll need a global variable that is associated with that vehicle in some way Let's say you add 3 choppers to your map - your variable names need to be different than the object names to keep things from getting confusing.

on your map you have these named units:
chopper1 - in init: [this,"chopper1"] exec "vrs.sqs"
chopper2
chopper3

in init.sqs you could have:
mychop1 = chopper1
mychop2 = chopper2
mychop3 = chopper3

in vehicle respawn vrs.sqs in addition to reading in the object you need to also read in the other paremter we passed which was a text name of the object name. after the vehicle has been created a call is made to "smoke_master.sqs":
Code: [Select]
[_vcl,_vehicle] exec "smoke_master.sqs"where _vcl is the vehicle object that was just respawned using _vcl = _type createvehicle [_respawn_xpos,_respawn_ypos,0]
and _vehicle is the text name of the original object name.

in smoke_master.sqs we need to reassociate the object name back with the text name:
Code: [Select]
_vcl = _this select 0
_vehicle = _this select 1

?(_vehicle == "chopper1"): mychop1 = _vcl
?(_vehicle == "chopper2"): mychop2 = _vcl
?(_vehicle == "chopper3"): mychop3 = _vcl
and now we can track that respawned vehicle by using one of our known object names (mychop1, mychop2, mychop3, etc) regardless of being respawned because each time it is respawned the new _vcl object is reassociated with our known object names.

Anyhow next trick is for all the clients to watch for some different things like damage. Each client needs a script so we call "smoke_client.sqs" from init (with no parameters).

In smoke_client.sqs we have a loop that looks for values to be true or false for each vehicle and if conditions are met to do something. For smoking damaged vehicles each vehicle needs to meet the following conditions:
vehicle is damaged more than some amount you specify (I used .5)
vehicle is in the air (for aircraft)
vehicle is not going backwards (for choppers) to keep smoke out of pilots view
smoke isn't already turned on for this vehicle otherwise we would keep launching smoke scripts.
Code: [Select]
#start
~1
?(getdammage mychop1 >= .5)&&(getpos mychop1 select 2 > 10)&&!(mychop1_smoke):[mychop1] exec "smoke_damage.sqs"

once "smoke_damage.sqs" is called we have to set the smoke variable to true for the appropriate vehicle (to keep smoke_client from launching more smoke scripts). Now we get to the actual drop stuff. For each vehicle type you'll want the smoke to be in a different position depending on the effect you are going for. I wanted it to look like it's coming from the engines so on the biplane the engine is forward of center, on a chopper it's rear and above center, etc. Also on the A10 and SU25 there are two engines so I did dual trails of smoke.

next in same file we define the starting and ending color of the smoke or fire. then we loop very quickly drawing the smoke and fire over and over. In the loop we watch for some conditions to be true like if the vehicle has been destroyed or the altitude is below 1 (it landed) or in the case of choppers the speed is equal or less than zero. In any of those cases the script exits after returning the vehicle smoke variable to false so it can work again when conditions are met in smoke_client.

Finally it's just a matter of playing with the drop command, your colors, and the offsets to get the look you want. For the fire I wanted little puffs of fire every now and then but not continuously. So in the loop I have a random variable and if it's above a certain value the fire gets drawn in addition to the smoke. For the dual engine aircraft I used a 2nd random variable to randomly select which engine the fire puff came from.

It's hard to explain clearly how this all works but hopefully have given a good idea for you. I'll add another message soon with all the source code(s).

Plaz
« Last Edit: 03 Jan 2003, 01:21:24 by SSG Plazmoid »

Offline Colonel_Klink

  • Members
  • *
  • Independent Addon Creator
    • DC3D Game Modelling Zone
Re:working smoking damaged aircraft script
« Reply #1 on: 05 Jan 2003, 08:38:15 »
About time someone gave a reply: Here goes. that is a very cool effect, matey. Well done.
Rebel without a pause...D.I.L.L.I.G.A.F.

SSG Plazmoid

  • Guest
Re:working smoking damaged aircraft script
« Reply #2 on: 06 Jan 2003, 05:26:42 »
thank you. have played around and gotten nicer looking fire. There's so many settings to tweak.

A big question, for all clients in a multiplayer game to see the fire/smoke does drop need to be executed on each client? Or if I execute once on server will the clients see it. I assume I must execute on clients so I've set it up that way.

thanks,
Plaz

thedragon

  • Guest
Re:working smoking damaged aircraft script
« Reply #3 on: 07 Jan 2003, 08:49:11 »
How can you do so itÂ's so perfect smoke on a aircraft? can you plz send me the full script to me  ;)

/dragon

Dirtman

  • Guest
Re:working smoking damaged aircraft script
« Reply #4 on: 07 Jan 2003, 23:07:28 »
Hey SSG Plazmoid do us a faver and post a demo mission with the script.  Dying to try this out. :)

SSG Plazmoid

  • Guest
Re:working smoking damaged aircraft script
« Reply #5 on: 10 Jan 2003, 21:21:01 »
Here's the scripts and a demo mission. In the demo just hit radio charlie (0 0 3) which will put some damaged planes in the air flown by AI so you can see the smoke trails and fire.

http://www.soldbuysam.com/ofp/drop/smoke_stuff.zip


I've added a few things since my first post. Damaged aircraft lose fuel continuously until they run out. You can set the amount of time it takes for fuel to go to zero, I think I used 60 seconds.

dual engine aircraft like the A10 and SU25 make dual smoke trails.

There are two sets of smoke scripts. One set for destroyed vehicles that makes a fire and smoke where the vehicle was destroyed. Another set that attaches smoke to flying aircraft. The destroyed scripts all start with "destroyed_" and the smoking aircraft scripts start with "smoke_". The main difference between them is the smoking aircraft script gets a vehicle object passed to it and the destroyed vehicle script gets a 2 dimensional position passed to it. The other difference is the destroyed smoke/fire lasts for an amount of time you specify while the aircraft smoke lasts as long as the aircraft is flying or alive.

*note: I use x and y for horizontal and z for vetical.

For the destroyed smoke/fire I make use of the elapsed time to gradually phase out the smoke and fire rather than seeing a visible line flow up when the smoke stops. As time progresses the fire gets smaller and smaller with the particles lasting a shorter amount of time and the transparency going toward zero.

Added a cpubenchmark check in the "smoke_client.sqs" and "destroyed_client.sqs" files. This will force the client script to exit if the cpubenchmark is below some number (I think I used 1500). IF YOU DON'T SEE SMOKE CHECK YOUR CPUBENCHMARK and change the value in those two scripts to something lower than your benchmark. Please let me know what benchmarks can handle the smoke scripts - would be handy to know. Mine is 3800.

You may be wondering why is there a server script and client script and actual smoke script? The trouble is how to pass the ID of a respawned vehicle to all the clients since you don't know beforehand what the object ID will be. The trick I made use of is to have the server start a server side script whenever a vehicle is respawned. The server script then waits for @(getdammage _vcl > .5) in the case of the smoking aircraft. The server script for destroyed vehicles waits for @(!alive). If the destroyed condition is true the server script does the following: mydestroyed = mydestroyed + [_vcl]; publicvariable mydestroyed. If the damaged condition is true the server similary does the following: mydamaged = mydamaged + [getpos _vcl select 0, getpos _vcl select 1] and makes the variable public.

Meanwhile there's the destroyed and damaged client scripts that are waiting for the count on mydamaged or mydestroyed to be > 0. Once the count is 1 or more the appropriate script springs into action and creates smoke/fire.

If anyone has a suggestion how I can improve anything or speed anything up please let me know!

Also included in the zip I think is an arty.sqs script which has some experimental formulas for artillery given start and end coordinates.

regards,
Plaz
« Last Edit: 10 Jan 2003, 21:31:39 by SSG Plazmoid »

beowulf2014

  • Guest
Re:working smoking damaged aircraft script
« Reply #6 on: 29 Jan 2003, 05:03:58 »
I have tested your mission on a server and after respawn only I the server can see the effect....also it was actually very difficult to figure out how to set it up because your mission is quite different then the first post and how to on this page.....but was able to get vehicles to respawn and work with the script only prob was others connected to my server could not see the effect after respawn like me....also i noticed that it works great on helos and slow planes but on f18s and f15s they go to fast for the smoke to keep up and so you only see traces everynow and then...other than that if you could make it a global array so everyone can see the smoke after respawn then this would be perfect...I would request a very easy to understand Tut on putting your scripts into any generic mission as to let beginners understand what they need to do...I myself use the awsome Karrilion (sorry if spelled wrong) vrs.sqs script and would love a basic readme included in a mission that lets us all use them in any mission...thanx again and i hope this helps you

Offline Capt Ryan

  • Members
  • *
  • Heil Myself !
    • Capt Ryans World War II Adventures
Re:working smoking damaged aircraft script
« Reply #7 on: 30 Jan 2003, 13:51:26 »
This script is so great and very cool looking ,  for some days now i have tryed  to make it work with a Daktoa C47 skytrain  in a Normandy airborne mission ( ww2 1944 ) .

but i stil cant singel out the sqs to use sole , all i need is the part of the script who makes the smoke/ fire and sets position on plane engine or tail and the posibility to execute it from a trigger . Is it posible someone can help me with a quick easy version to do this - ;o)

I need one version wich atctually " kills " plane  and one who jst smoke and flames of engine without casuing damage ( plane keeps flying )

Someone  - Please

Capt Ryan WW2 Adventures

http://www.ofpww2.dk
Capt Ryans WWII Adventures -  http://www.ofpww2.dk

Offline Capt Ryan

  • Members
  • *
  • Heil Myself !
    • Capt Ryans World War II Adventures
Re:working smoking damaged aircraft script
« Reply #8 on: 30 Jan 2003, 14:16:43 »

Ive fiddel a bit more on this amazing script , and i figured out how to work it like i wanted it as described above - so no need to help .

Thanx again for this wonderfull script .

Capt Ryan

 
Capt Ryans WWII Adventures -  http://www.ofpww2.dk