Members | Sign In
All Forums > Mission Scripting
avatar

Scripting Challenge: Catclysmic wave of destruction

posted Jan 29, 2013 18:41:17 by JSpaced
Hey clever people,
I've been scratching my head over this for a while and I can't figure it out.
I want to have a race against time mission that ends with a supernova sending a wave of explosive destruction across the map, destroying everything in its path. Is it possible to at least simulate that?
Cookie for the clever coder who can script this one!
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
page   1 2 next last
17 replies
avatar
RussJudge said Jan 29, 2013 19:24:04
Use expressions.

Hints: for named objects, use if_inside_sphere, and set each objects damage level to zero. CenterX, centerY, and centerZ will use the supernova center, and steadily increase radius as follows:

<event>
<set_variable name="radius_of_destruction" value="radius_of_destruction+5" />
</event>

for unnamed objects, you can use the destroy_near.
[Last edited Jan 29, 2013 19:27:12]
Russ
Author of Artemis Mod Loader.

Sign up for a free Dropbox account.
avatar
MarkBell said Jan 29, 2013 19:46:21
Additionally, you could create an arc of nebulae that updates every second or two - this could represent the wave on the science screen as well as a visual wave of fire sweeping through the sector for the main viewscreen.

eg:

<create count="300" type="nebulas" startAngle="0" endAngle="180" startX="100000.0" startY="0.0" startZ="50000.0" radius="10000" randomRange="1000" randomSeed="0" />

Keep the radius outside of your radius of distruction and recreate the arc of nebulae with a larger radius every second or so - just as the wave of destruction destroys the previous arc. I don't know what the server tick speed is (1ms?), but with a little finagling you could probably time it right. (This might work better for a radius of destruction sweeping somewhat slower than the one that Russ suggests, although I've never tried it :) )

Alternately, if a ring is desired instead of an arc:

<create count="300" type="nebulas" startX="80000.0" startY="0.0" startZ="50000.0" radius="10000" randomRange="1000" randomSeed="0" />
avatar
KatoKatonian said Jan 29, 2013 20:32:04
I was going to suggest a mesh object that expanded, but I really like Mark's suggestion (and it looks like a mesh object wouldn't work anyway as the artscale property doesn't seem let you continually update it).
[Last edited Jan 29, 2013 20:37:35]
avatar
JSpaced said Jan 29, 2013 22:04:57
See I knew you guys would have something. I was thinking of playing with the nebula radii too, in order to create a visible wave of energy. I'll take a look at the "Destroy Near" command and let you know what I come up with.
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
bleep751 said Jan 29, 2013 22:06:37
Hey,

So this is just off the top of my head, so it might need a little tweaking, but why not try something like this?

<event>
<if_timer_finished name="Supernova"/>
<create type="blackHole" x="50000" y="0" z="50000" name=" "/>
<set_variable name="blackholecircle" value="0"/>
<set_timer name="bhtime" seconds="2"/>
</event>
<event>
<if_timer_finished name="bhtime"/>
<set_variable name="blackholecircle" value="blackholecircle + 50"/>
<set_timer name="bhtime2" seconds="1"/>
</event>
<event>
<if_timer_finished name="bhtime2"/>
<create type="blackHole" x="50000 + blackholecircle" y="0" z="50000" name=" "/>
<create type="blackHole" x="50000 - blackholecircle" y="0" z="50000" name=" "/>
<create type="blackHole" x="50000" y="0" z="50000 + blackholecircle" name=" "/>
<create type="blackHole" z="50000" y="0" z="50000 - blackholecirecle" name=" "/>
<create type="blackHole" z="50000 + blackholecircle" y="0" z="50000 - blackholecirecle" name=" "/>
<create type="blackHole" z="50000 - blackholecircle" y="0" z="50000 - blackholecirecle" name=" "/>
<create type="blackHole" x="50000 + blackholecircle" y="0" z="50000 + blackholecircle" name=" "/>
<create type="blackHole" x="50000 - blackholecircle" y="0" z="50000 + blackholecircle" name=" "/>
<set_timer name="bhtime" seconds="2"/>
</event>

Creates a circle of radiating black holes that expands from the center of the map. Blackholes work your destroy commands for you, and they'll show up on the science and view screens. As the circle gets bigger, it might require that a second create set be made, the creates at positions of "50000 +- blackholecircle +- 25", to fill in gaps, but thats easy enough to add, if you want more blackholes. You can change the timers to change the rate of expansion, if you want to give your ship a chance to run away or something
avatar
Mike_Substelny said Jan 30, 2013 00:05:21
I hade something like this once that worked. I made a ring of generic objects and had them move outward from the central explosion at a constant speed in straight lines. Moving at a constant speed is good because the consoles will represent the expanding ring in positions matching what is shown on the server.

Mark's idea of creating and destroying nebulae will work, but there will be lag between sever and consoles. If the script is just for you and your crew you can probably set up your bridge to minimize this, but if you want anyone in the world to play it then you should code to prevent lagginess.

My advice is to make a ring of dozens of generic objects and have them move outward toward destinations on the edge of the sector. As they move outward create nebulae to fill the expanding donut hole. If you want to distribute the game then I further suggest that you use DXS and PNG files that come packed with the game. For example take asteroid.dxs and blow it up to a gigantic artscale, then paint it with a really bright PNG to it appears to be glowing plasma.

Leave an anomaly or other named object in the center of the explosion. Constantly check the distance between the generic object and the anomaly. Also check the distance between other objects (ships, stations, etc.) and the anomaly. Once the generic is farther out than any object it's bye-bye object. I believe the new math interpreter will allow this now.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
JSpaced said Jan 30, 2013 09:52:05

Hi guys,
Thank you for your time on this, I'm trying to get it to work in the fashion Mark said, before I look at lag. Unfortunately I've clearly done something wrong because it's not making an expanding ring of anything. It IS making a small splodge in the middle of the science map.
What have I done wrong?
So this bit sets off our supernova from the middle of the map, starting with a cluster of nebulas.

<event id_arme="a00ac493-2824-4c08-9e91-e257b5f2e071">
<if_distance name1="USS Shackleton" name2="Azure G-13" comparator="LESS_EQUAL" value="5000.0" />
<if_variable name="supernova" comparator="NOT" value="1.0" />
<set_variable name="supernova" value="1.0" />
<warning_popup_message message="Oh no! KABOOM!" consoles="MS" />
<create count="20" type="nebulas" startX="50000.0" startY="0.0" startZ="50000.0" radius="novaradius" randomRange="1000" />
<set_timer name="novaradiusexpand" seconds="1" />
</event>


THIS bit is supposed to update the variable "Novaradius" once a second by 1000 metres.

<event id_arme="ad93262d-d3eb-48d7-9464-1fe5c22433e9">
<if_timer_finished name="novaradiusexpand" />
<set_variable name="novaradius" value="novaradius + 1000" />
<set_timer name="createsupernova" seconds="1" />
</event>

This even applies the ring of destruction and creates our bigger ring of nebulas, then calls the event above via the timer (in theory) - I'm certain my syntax is wrong here somewhere.

<event id_arme="3fbcf1f0-811d-42cb-b9d8-b3e1ff727c5b">
<if_timer_finished name="createsupernova" />
<destroy_near type="mines" radius="novaradius" centerX="50000.0" centerY="0.0" centerZ="50000.0" />
<destroy_near type="asteroids" radius="novaradius" centerX="50000.0" centerY="0.0" centerZ="50000.0" />
<destroy_near type="nebulas" radius="novaradius" centerX="50000.0" centerY="0.0" centerZ="50000.0" />
<create count="300" type="nebulas" startX="50000.0" startY="0.0" startZ="50000.0" radius="novaradius + 1000" randomRange="1000" randomSeed="0" />
<set_timer name="novaradiusexpand" seconds="1" />
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
JSpaced said Feb 04, 2013 13:19:48
Hi guys,
So: quick update on how this is getting on:
I can't get variables to work as the radius of created objects. It doesn't work with my code, or Bleep's.
I've experimented with manually copying and updating events so that it creates an ever expanding ring of nebulae and blackholes. My play test ship however, survived this "cataclysm" and could even navigate between the black holes. I think a denser field is going to be needed.
The black holes have no effect on nebulae, asteroids or generic meshes, so the planets have to be destroyed "by hand".
Chuck in some suitable kabooms and it's starting to look pretty cool.
Thanks for the help so far guys. Will keep you updated.
Any new ideas, please post!
J
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
MarkBell said Feb 04, 2013 13:25:56
I think the problem with the radius is that it is looking for an integer value and the variables are floats. Incompatible types would make for undesirable behavior :)
avatar
RussJudge said Feb 04, 2013 14:04:40
Assuming MarkBell is correct, this may be a bug that Thom needs to address, as it is difficult in the mission script to control the difference between floats and integers. You might try simply changing the "1.0" value to "1" and see if that fixes the issue.
Russ
Author of Artemis Mod Loader.

Sign up for a free Dropbox account.
avatar
MarkBell said Feb 04, 2013 14:08:46
Ah, where do you initially set your novaradius? What is it's initial value? The mission editor will set it to 0.0 upon initialization, so as RussJudge mentioned you may need to go into Notepad or your xml editor of choice and fix it upon its initial declaration.
avatar
JSpaced said Feb 04, 2013 22:23:24
Ah, that's done it! I forgot that 1000.0 is not the same as 1000 so thank you for that.
A searing fog of death now streams across the sector, annihilating everything including my poor graphics card! I may have to increase the size of the sphere of destruction just to make sure my laptop can handle it.
Thank you Russ and Mark, I knew it'd be something simple.
J
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
JSpaced said Feb 05, 2013 09:16:50
Hmm, the problems continue. I have my wave. I also have brakes on my wave that stop it (hopefully) before it crashes the server.
It looks beautiful, by the way, flowing across the science screen and the main viewer.
I set it to cause 100% damage to all systems as it passes over the player ship but that's all it does. Every node red-lines and then the damage crews happily set about fixing it. It didn't cause the big bang I was hoping for.
I can use "Destroy object" but that just removes it from the game and ends the mission.
I thought about using a mine, but my players could be anywhere when the supernova occurs and you can't move unnamed objects!
At the moment I'm going to use the Destroy Object script command and couple it with a ship explosion noise, but something visual would be cool. Any thoughts?
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
MarkBell said Feb 05, 2013 13:15:53
Nice! That's awesome :) What really needs to be available is to use the copy_object_property to copy info to a variable; those variables could then be used to do most anything.

You could kill off the entire damcon crew, set energy to zero, set all their torps to zero, shields to zero, top speed and turn rates to zero, etc - if that doesn't blow 'em up, not much will :P

Maybe they need to actually hit something to get blown up? Can you have an enemy spawn, fire a drone and vanish again? You could have them spawn 200 meters at 180° from the player ship (maybe offset on the y axis too), fire off a drone and a few beams then vanish again. Not great for immersion, but if they don't have the viewscreen set to rear it shouldn't matter too much.
avatar
RussJudge said Feb 05, 2013 13:28:49
@MarkBell: Yeah, I was thinking the same of thing, now that I've started messing around with mission scripting.

Being specific, this is what I think should be added to the mission scripting, as it would not only solve JSpaced's issue, but would also open a whole new world to what could be done:

Modify copy_object_property so that name2 can be either a named object or a variable.

If this worked, then you could do:

<copy_object_property name1="Artemis" name2="ArtemisX" property="positionx" />
<copy_object_property name1="Artemis" name2="ArtemisZ" property="positionz" />
<create type="mine" startX="ArtemisX" startZ="ArtemisZ" />
Russ
Author of Artemis Mod Loader.

Sign up for a free Dropbox account.
Login below to reply: