Members | Sign In
All Forums > Mission Scripting
avatar

Mission scripting help

posted May 07, 2012 22:17:02 by edmundrw
I've been trying to start on a mission script using Hissatsu's Mission Script Editor but I could use some general scripting advice.

I'm trying to create a mission in which 'subspace disturbances' (black holes) are appearing for short periods of time, then vanishing, after which ever increasing enemy fleets appear - having jumped in through transwarp conduits.
I'm having trouble, in the first instance, just getting something to be destroyed after a timer. In the mission file I was originally working on, I could get something to create after a timer had ended but couldn't seem to get it to destroy again later. Then I noticed in some other missions, the conditions for some statements involving timers also tested for whether a variable was != 1 and then set that variable as 1 in the event, presumably to prevent the event from repeatedly triggering? I tried creating a basic mission file to test this theory, which I've posted below. For one, I can't even get this to run, I get an message saying "failed to load mission, directory and file name mismatch?". I can get the mission file I originally started to work on loaded up, but the objects I create don't seem to destroy when I want them.

Am I using timers incorrectly? Any advice would be much appreciated.

<mission_data version="1.65" background_id_arme="">
<start name_arme="Start">
<create type="player" x="50000" y="0" z="50000" name="Artemis" />
<set_difficulty_level value="5" />
<set_skybox_index index="9" />
<big_message title="Unnamed mission" subtitle1="by Unknown Author" subtitle2="adventure for Artemis 1.65" />
<set_timer name="start_mission_timer_1" seconds="10" />
<set_timer name="test" seconds="30" />
<set_variable name="chapter_1" value="1" />
</start>
<event name_arme="Wave1" id_arme="0d940cab-58b1-4897-8352-2ce5c1d818eb">
<if_variable name="test" comparator="NOT" value="1.0" />
<if_timer_finished name="test" />
<set_timer name="destroy" seconds="10" />
<set_variable name="test" value="1.0" />
<create type="blackHole" x="10000.0" y="0.0" z="10000.0" name="Subspace Disturbance" />
</event>
<event name_arme="W1arrives" id_arme="5ec3dd30-f990-42d0-8d8b-b3844b63e0c4">
<if_variable name="destroy" comparator="NOT" value="1.0" />
<if_timer_finished name="destroy" />
<destroy name="Subspace Disturbance" />
<set_timer name="test2" seconds="30" />
<create type="enemy" x="10000.0" y="0.0" z="10000.0" angle="180" name="Kralien Cruiser" hullID="2000" fleetnumber="1" />
<set_variable name="destroy" value="1.0" />
</event>
<event name_arme="Wave2" id_arme="84753c91-b0b5-4753-a964-f0f3ad9b9330">
<if_variable name="test2" comparator="NOT" value="1.0" />
<if_timer_finished name="test2" />
<set_timer name="destroy2" seconds="10" />
<set_variable name="test2" value="1.0" />
<create type="blackHole" x="32000.0" y="0.0" z="24000.0" name="Subspace Disturbance" />
</event>
<event name_arme="W2arrives" id_arme="3ab55768-e26d-479f-9eff-24a7d9ae7860">
<if_variable name="destroy2" comparator="NOT" value="1.0" />
<if_timer_finished name="destroy2" />
<destroy name="Subspace Disturbance" />
<set_timer name="test2" seconds="30" />
<create type="enemy" x="10000.0" y="0.0" z="10000.0" angle="180" name="Kralien Cruiser" hullID="2000" fleetnumber="1" />
<set_variable name="destroy2" value="1.0" />
</event>
</mission_data>
page   1
12 replies
avatar
Mike_Substelny said May 08, 2012 13:54:06
edmundrw, what is the name of your file and what is the name of the folder it's in? They need to be exactly the same except for the .xml on the file.

Your logic looks good, but I'm not sure about the comparators. I haven't tried the "NOT" comparator used in the Mission Editor. I suggest opening it in a text editor and changing "NOT" to "!=" and see if the objects behave as you expect.
"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
edmundrw said May 08, 2012 14:10:18
Thanks Mike, I had a look to check if the folder name and file matched and I could have sworn they did. I'll check again tonight, as my mind may have just turned to mush yesterday after an afternoon getting to grips with script editing.

So I am right in my assumption that the condition of checking a variable value is not 1 and then setting it to 1 as part of the event is necessary to get timers to work once and only once? Are all variables defined in the script set to 0 by default?

I'll try changing the 'not' comparator as you suggested. Hissatsu, is this an error in the editor? I only ask because in the 'natural language' drop down this comparator is listed as '!=' but it spits out 'NOT' - is it generating natural language by mistake for some reason?
avatar
Mike_Substelny said May 08, 2012 19:07:23
So I am right in my assumption that the condition of checking a variable value is not 1 and then setting it to 1 as part of the event is necessary to get timers to work once and only once?


Yes, though you can use any value, not just 1.

Are all variables defined in the script set to 0 by default?


Yes again.

Hissatsu, is this an error in the editor?


If this is the problem it may be a peculiarity of Artemis. In that case Hissatsu may be unaware of it. Of course my previous message was just a guess . . . it's possible that the comparator is not the problem.
"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
edmundrw said May 08, 2012 22:22:31
Thanks Mike, I'll investigate further at the weekend and report back
avatar
Hissatsu said May 09, 2012 15:42:40
I am sorry if my program caused you problems. However, this is unavoidable, since its very new and people are just starting to try it out. The more people use it, the faster we get rid of all the bugs.

Regarding the NOT, mission-file-docs says:

ATTRIBUTE: comparator
VALID: =, !=, <, >, <=, >=, EQUALS, NOT, GREATER, LESS, GREATER_EQUAL, LESS_EQUAL

Problem is, you are not allowed to use "<" and ">" inside attributes of Xml file. This is against the standart and no Xml parser should allow that. Therefore, i decided to only use the text-based comparators, and convert the mission that uses signs to text before even trying to parse it. So, even if you write != in your mission using notepad, when you open it in the editor and save, != will get replaced with NOT. I could probably keep those symbolic comparators not using < and >, but i decided to go all-text, just for the sake of consistency.

On the other hand, the editor displays stuff not as it is in xml. This is for the sake of the user - its obviously easier to read "If x >= 0" rather than "If x GREATER_EQUAL 0". So yes, you will see != in the editor, but NOT in the file, and thats 100% intended.

PS: I have tested and NOT is indeed working fine. So this time, it should not be the Mission Editor to blame.

PSS: The code you copied should run fine. I made a mission file out of it and it worked (two black holes appeared at set intervals and two enemies spawned out of them, however second enemy has wrong coordinates to spawn at but thats another story)
[Last edited May 09, 2012 15:49:12]
avatar
edmundrw said May 09, 2012 15:48:01
Hey, Don't apologise Hissatsu - The editor is excellent; it's just that I'm trying to build something without a lot of basic understanding - I figure the best way to learn is to try to build something and then whine to the forums when it's not working :p

If NOT isn't causing the issues then I'm sure it's more to do with my code
avatar
Hissatsu said May 09, 2012 15:50:05
The code is fine. I just made a new folder MISS_DEBUG, pasted this code there as a file MISS_DEBUG.xml, and it ran fine as a mission.
avatar
edmundrw said May 09, 2012 15:53:31
great, I appreciate you checking that out for me, weird it crashed on my machine - must be human error. Did you happen to notice if the black hole appeared and then disappeared? (if you didn't check then don't worry)
avatar
Hissatsu said May 09, 2012 15:56:05
Basically, any mission saved by my editor should never be a misformed Xml file, and should not contain anything incorrect from the point of view of the Artemis inner mission parser - and therefore should never produce an error "failed to load", except if you misname the mission file.

If you misname a mission file, then you should experience nothing at all appear on the screen when you click Start Game - the floating background should hang in place, and in some seconds, this error should pop. This means that you indeed have a misnamed file.

If part of the mission works all right (like, you see your start block executed, or you at least see empty space and camera moving), but then you see this error pop, please send me the whole mission folder in an archive so i could study it. Because that supposedly means that my editor is severely screwed. But that shouldnt be even possible.

Other than that, i supposed something like "file is open in another program" can make this happen - my editor doesnt keep file "open" but maybe you opened it in some other text editor that does - in this case, Artemis sees the file is there, but cannot read your mission file, and spits this error
[Last edited May 09, 2012 19:30:46]
avatar
Hissatsu said May 09, 2012 15:56:39
Yes, as i said, it all works fine, you just mistyped the coordinate of the 2nd wave (enemy appears at ~10k by 10k and BH before appeared at ~30k by 30k)
avatar
edmundrw said May 09, 2012 16:19:29
Ah yeah, I put them in different places intentionally - so I could see if the enemy was getting created. Thanks.
avatar
Hissatsu said May 09, 2012 17:39:10
Well, when you fix it, tell me why that error was popping up for you.
Login below to reply: