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":
[_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:
_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.
#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