jwllorens 43 Posted February 18, 2015 This is a long post so skip to the end to see my two questions if you don't want to read much. I am trying to create a "general purpose airburst" function that I can run off a "fired" event handler. So far, I have "emulated" a radio proximity fuze for AAA guns, but I would like to modify the script a bit to also "detonate" artillery rounds at a specific altitude, and also detonate 25mm, 30mm, and 40mm grenades and shells at a specific range. This is my first script, and here it is: this addEventHandler ["Fired", { _null = _this spawn { _allowedType = "B_35mm_AA"; _proj = _this select 6; _projType = typeOf _proj; if (_projType isKindOf _allowedType) then { _dmgRange = random 0.1; _explo = "SmallSecondary"; _perSecondChecks = 15; _checkTimer = 1 / _perSecondChecks; while (!(isNull _proj)) do { _veh = (nearestObjects [_proj, ["Helicopter", "Plane"], 15]) select 0; if (!(isNull _veh)) then { _projPos = getPos _proj; _boom =_explo createVehicle _projPos; sleep 0.2; if (!(isNull _proj)) then { deleteVehicle _proj; _veh setDamage ((damage _veh) + _dmgRange); }; }; sleep _checkTimer; }; }; }; }]; It works well. Basically, every time the unit that this event handler is run on fires, it will first check to see if the projectile is a 35mm AA shell. If it is, then it sets up some variables defining the damage range from 0-X, explosion "vehicle," and number of times to run the while loop per second. Then it starts a loop, with each iteration it searches for helicopter and plane objects within 15m of the projectile and if the first object in this returned array (which should be the closest) is not null, then it creates a "SmallSecondary" explosion at the position of the projectile and then waits a short amount of time (so the projectile can continue on and hit the vehicle if it is on a collision course so that we can do the normal vanilla amount of damage to the vehicle) and then, if the projectile still exists after this amount of time it "missed" the vehicle and gets deleted and the random damage gets applied to the vehicle. The effect looks cool with shells bursting all around the aircraft, and 35mm AA guns become a force to be reckoned with. Without the script they could almost be ignored as long as you didn't fly straight. But I have some problems with the script if I want to update it and turn it into a function that can also do airburst artillery explosions based on shell altitude and HEAB grenades and shells. The first problem is that by using createVehicle to spawn an explosion effect is a pretty poor way to make an explosion, because by default I have access to three explosions that I know of (SmallSecondary, HelicopterExploSmall, HelicopterExploLarge). Two of these are devastating to anything within a certain radius, but the radius is small. This is contrary to how I want airburst explosions to work as I would like them to have an increased radius with less anti-armor effect. The second problem is that my method of applying damage to the helicopters and planes works in this instance because it is assumed that the helicopters and planes will be airborne and there won't be anything else in the area, such as buildings or wheels on vehicles or infantry, that also need to be damaged (and also damaged in different ways than the helicopter/plane because they have different amounts of armor). But for an artillery shell, for example, I might want to randomly knock out a turret or engine or take out the wheels on light vehicles in the area, do some very light damage to heavier armor, maybe damage some buildings partially, but I would want to do this while doing significant damage to infantry in the area. setDamage 0.5 would simulate a pretty dramatic armor penetrating effect on heavy armor, but a mere flesh wound on an infantryman. So my questions are as follows: 1) Can anyone explain how to create custom particle effects via script to simply create the visual effect of an explosion, or is this even possible? 2) Can anyone explain how to apply varying amounts of damage to all objects within a radius, based on armor values from the object's config? Preferably, I would like to also do more damage to wheels and light turrets on vehicles than their hulls, as hulls are armored, is this possible? 3) Any optimization tips? For 35mm AA or a GMG, this script is looping for each projectile so I imagine it would be pretty CPU heavy. A way to create realistic looking airburst visuals and damage effects without hogging too much CPU would be great. Share this post Link to post Share on other sites
eggbeast 3684 Posted February 19, 2015 we have this working in A2, using 10 different forms of secondary explosion (radius, effect, damage, penetration etc) which are called randomly for every 2nd or 4th shell depending on the AAA weapon. we don't check for a target but explode it when the shell reached 250m high, as this is a common attack height. as you say, tracking the target is what can wreck the performance ours works great, but it would be nice to be able to vary the height, and we never got around to finishing that yet. even so its pretty devastating. Share this post Link to post Share on other sites
jshock 513 Posted February 19, 2015 Just a concept, but couldn't you put in a system (similar to zeroing a sniper rifle) to allow the user to change the "timing" of the airburst round, so it will explode around the specified height or after "x" seconds as selected by the user? Share this post Link to post Share on other sites
x3kj 1247 Posted February 20, 2015 (edited) that would be extremely unhandy to use against jets for example, you wouldnt be able to keep up with the range changes... As for optimisation... i think a bit of a different concept could be better in that regard. I would try to rely on vanilla damage handling (indirect explosion of bullets/missiles), because then you dont have to find vehicles in the radius. The information "when do i explode" could propably also be "outsourced" to a script that runs on the vehicle itself. Proximity fuses are not intelligent (they don't sense aircrafts...), they require the vehicle to track the target and program the time into them. Therefore, using only the locked on target for calculation gets rid of vehicle searching. So the script on the vehicle checks the distance to the locked target and writes down the distance (or time) into a variable on the vehicle in certain intervalls. The ammo, on firing grabs the variable and continuously checks for distance between the shooting vehicle (or time) and compares it with the variable. Once the distance (or time) is >= variable the ammo is deleted and something to create the damage is spawned. Not sure if missiles with 0 time to live work and explode immediately. Alternatively you could spawn an invisible box with just fire geoemty around the ammo so it collides with the fire geometry and explodes. A third possibility might be to spawn a mine, with large activation radius so that it immediately explodes (hopefully, havent tested that...) The box method would have the advantage that it definitely produces correct eventhandler stuff, creating proper responses for AI and so on. Not sure if this can be achieved by the other 2 methods. 2) Can anyone explain how to apply varying amounts of damage to all objects within a radius, based on armor values from the object's config? Preferably, I would like to also do more damage to wheels and light turrets on vehicles than their hulls, as hulls are armored, is this possible? That's why i would want to rely on vanilla damage handling. It includes damage falloff and armor resistance/armor values etc without checking everything manually. Edited February 20, 2015 by Fennek Share this post Link to post Share on other sites
eggbeast 3684 Posted February 21, 2015 (edited) yeah thats what we do, using secondary explosion ammo, the only thing we don't do is spawn exploding ammo at heights other than 250m. this is what it looks like (it also sounds horrifying) Edited February 21, 2015 by eggbeast Share this post Link to post Share on other sites
da12thMonkey 1943 Posted February 21, 2015 (edited) Proximity fuses are not intelligent (they don't sense aircrafts...), they require the vehicle to track the target and program the time into them. That's a programmable fuse. You use range-finding and ballistic data from the launch-vehicle's Fire Control System to program the delay fuse on the munition, based on how long it will take the projectile to reach the target range. It's used on purely ballistic munitions. However, there are indeed true proximity fuses that do actively detect their distance from a target. Back when they were first developed (WW2), you did get artillery and AA shells with proximity fuses but nowadays they're mostly used on guided or autonomous munitions that have an indeterminate flight time. Since many vehicles carry their own ballistic fire control system anyway these days, it's easier and cheaper to use a programmable delay fuse on ballistic weapon systems. Most proximity weapons use an onboard radar (mmw doppler antenna) or optical sensors (lasers) to detect their proximity to objects before detonating. Magnetic proximity sensors that pick up on the presence of large ferromagnetic objects such as metal in tanks and ships are often used in surface warfare proximity weapons, either as the primary sensor or acting as sort of fail-safe coupled to a radar, IR or optical sensor. Examples of some modern guided weapons with proximity fuses include MBDA's ASRAAM (optical) and SAAB's NLAW (optical + magnetic). Edited February 21, 2015 by da12thMonkey Share this post Link to post Share on other sites
eggbeast 3684 Posted February 21, 2015 hcpookie and I were working on a system for unsung where the puazo target height detector would communicate the height of ITS target to the surrounding AAA, using setvariable, but it wouldn't work well in MP. we haven't really revisited it yet, as 250m +/- 30m was perfect for most planes doing line-of-sight attack runs in nam jungle ---------- Post added at 01:55 PM ---------- Previous post was at 01:54 PM ---------- the main principle of spawning secondary explosions worked really well though Share this post Link to post Share on other sites
jwllorens 43 Posted February 25, 2015 This is a good idea, can you explain the invisible box method? I don't want to make an addon because I don't know how to mess with configs. Is there such an invisible box that has fire geometry that I can spawn? If the ammo collides with this box, it will detonate I assume with its own config explosion (which is great) but wouldn't the box also mean that a portion of the damage "sphere" would also be blocked so if the object was behind the invisible box and the ammo hit the other side of it, the box would actually shield the target from the explosion? Doing damage to the target with setdamage and creating the visuals of an explosion would be fine too but I don't know how to do that, but I am sure you can create particle effects through scripts? Share this post Link to post Share on other sites
eggbeast 3684 Posted February 26, 2015 seems to me it may be the wrong way to do it for MP efficiency, as spawning secondary ammo is much simpler and more efficient. also if you spawn an invisible box with geometry that will require a mod too. and it would need efficient cleanup and group cleanup otherwise the sky would gradually fill with invisible boxes that planes can collide with. Share this post Link to post Share on other sites
jwllorens 43 Posted March 2, 2015 That is easy enough to do by deleting the object shortly after creation. The problem with SmallSecondary is that it does almost no damage. I mean a soldier standing a few meters from this object (the explosion) can take about 15 hits before dying. The visual effect is the appropriate size, but the fragmentation is not emulated by simply spawning the effect itself. Perhaps spawning bullets and flinging them in the direction of the nearest objects will work well, though I would still like to be able to script custom particle effects so I can have different explosion effects for 40mm, 20mm, ect. I really want to fix the 40mm static GL, because in real life it is a 25mm GL that fires HEAB rounds. Would be cool to replace the projectiles with a 20mm (for the balistics) then have a scripted airburst effect. Share this post Link to post Share on other sites
x3kj 1247 Posted March 3, 2015 (edited) no there is no invisible box there by default, it needs a mod. i also havent tested it, it was just an idea... I'm not sure how damage blocking is handled. I would not be surprised if the viewgeometry LOD of an object is checked for, instead of the (alot more complicated) fire geometry LOD. the VBS damage doc suggests this Check for unshielded damage for objects except object with direct damage Object with direct damage can block damage from other objects based on Line of Sight visibility = percent visible from damage point to object Visibility check in Landscape::Visible uses Object::Composition() as object position which is calculated using the center of mass of the object plus a pre-defined offset that would indicate that if the invisible box does have an empty viewGeometry LOD it would not block explosion damage Edited March 3, 2015 by Fennek Share this post Link to post Share on other sites
eggbeast 3684 Posted March 3, 2015 well in A2 we have made a small mod that adds 10 different secondary ammo types, with varying effects and damage intensity and radius. It works perfectly as flak, because you will get hit by the actual bullet fired by the shilka/AAA etc at great heights, but if youre doing an attack run there is a very good chance of being caught in the cloud of flak airburst, which does pretty random damage to your aircraft, and can destroy you quite often. the secondaries cause your plane to shake, and the sound and light and sparks and fireballs makes it an intense experience. something you won't really get from spawning boxes i think. at the end of the day you can make this work in many ways, i'm just explaining the way we did it so you might consider all of the issue before getting started. Share this post Link to post Share on other sites
x3kj 1247 Posted March 4, 2015 something you won't really get from spawning boxes i think. what you get from boxes depends on the explosive/damage/effect properties of the real ammunition. If you want a hollywood effect show instead, then its propably not ideal... Share this post Link to post Share on other sites