Author Topic: Level design demystification / scripting guide - XML  (Read 17961 times)

0 Members and 1 Guest are viewing this topic.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Level design demystification / scripting guide - XML
« on: December 07, 2008, 09:21:01 PM »
This thread pertains to the old XML level design functionality - all still present, just completely superceded.

Here is a breakdown of the current level design abilities given to levellers :)
Currently supported tokens (some are overloaded and have the same function, just choose a word and stick with it):
  • "after", "begin":
    Followed by a number, this sets the starting time for the event. Failure to specify this results in the event being triggered as soon as the level begins. Time is measured in seconds from the start of a level.
  • "team":
    Followed by an integer number, this sets the team to which this event applies. See above (asteroid "owner") for team designations.
  • "until","before","end":
    Set the end time for the event. Set this to a negative number to have the event continue forever. I am unsure what happens if the number is positive but before the starting time; if it doesn't do so already, this ought to cause the event to be a one-shot event. I will fix this if it isn't the case.
  • "every":
    Sets the frequency of the event for the duration for which it is active. The value is measured in seconds and may contain a decimal point. The event will trigger every X seconds after the start time and it will do this until the end time is reached.
  • "spawnseedling","spawnseedlings":
    These set the event type to spawn a seedling from a random Dyson tree in the empire of the given team.
[/li]
[li]Conditions
These are pretty complicated already. The conditions set winning and losing conditions for the game. They are designated by the tags "win" and "lose" and have one attribute, "if", which contains a script that tells the game about the condition.
Conditions have a source team, a target team, a noun, a verb, and a comparison.
Currently supported tokens:
  • "team":
    If we already parsed the verb, this will refer to the target team. Otherwise it refers to the source team. It must be followed by a team number, which is the same designation as the above team designations.
  • "owns", "own":
    (Verb) Sets the condition to be about posession. It just means "in the empire at the current time". You can set the condition to test if the team owns a certain number of trees, seedlings, or asteroids. You could set it so the player has to acquire a certain number of asteroids, trees, seedlings, or a specific asteroid (e.g. "team 1 owns asteroid 1) for instance. If you specify a number after this, the comparison is set to "exactly" by default (e.g. "team 1 owns 5 asteroids"). Otherwise, you may want to specify your own comparison or a specific entity in the game.
  • "destroy", "destroys", "destroyed", "defeated":
    (Verb) Destruction. This isn't fully implemented as we don't currently tally kills and destriction and asteroid takeover. Essentially this only works against teams at the moment (e.g. "team 1 defeated team 2"). You can also say "team 1 defeated 2 teams" which will count up the remaining enemy AI teams and if it's 2 less than the number that started, the condition will be satisfied.
  • "create", "created", "make", "made", "plant", "planted":
    (Verb) For now, this is the same as "own". Later it will be a tally of created entities.
  • "all":
    (Comparison) Sets the comparison to be "all". The condition will test all the relevant entities. e.g. "team 1 owns all asteroids" will test all the asteroids and if the player owns them all then the condition will be satisfied.
  • "more", "morethan", "more than", ">":
    (Comparison) Sets the comparison to be "more than".
  • "less", "lessthan", "less than", "<":
    (Comparison) Sets the comparison to be "less than".
  • "teams":
    (Noun) Sets the article to be teams. e.g. "team 1 defeated more than 2 teams".
  • "asteroid":
    (Noun) A specific asteroid. Follow this with a number that specifies an asteroid. This is only really useful if you specified some particular asteroids in the level data. The asteroids will have identification numbers starting at 0 and going up by 1 for each asteroid encountered in the file. So the first asteroid you specify will be asteroid 0 and the next one will be asteorid 1 etc.
  • "asteroids":
    (Noun) A number of asteroids. Precede this with a number or "all" e.g. "team 1 owns all asteroids" or "team 2 owns 2 asteroids".
  • "trees":
    (Noun) This is a tricky one as it could refer to any or all types of tree. If you write "Dyson trees" then the game will recognise that as Dyson trees. Same for defense trees. However, if you just write "trees", and haven't written "Dyson" or "defense", then the noun will refer to either type of tree. e.g. "team 2 owns 20 trees".
  • "dyson", "dysontrees":
    (Noun) Refers to Dyson trees.
  • "defense", "defensetrees":
    (Noun) Refers to defense trees.
  • "seedlings":
    (Noun) Refers to seedlings. e.g. "team 2 owns more than 400 seedlings"
These are fairly intuitive to mix and match. Mostly you can just write what you feel. The game will be won if all win conditions are satisfied. The game is similarly lost if all lose conditions are satisfied. If you don't specify any conditions, the game defaults to having the player's team win if all other races are defeated and lose if no asteroids are owned.

[/li]
[li]Teams
Use the "empire" tag to specify a team:
Code: [Select]
 <empire team="2" grace="99000" />
    The team attribute should be self explanatory by now. The grace period refers to the period in seconds from the beginning of a level in which a team is denied the right to move seedlings around the map.[/li]
« Last Edit: October 27, 2009, 10:37:21 AM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Level design demystification / scripting guide
« Reply #1 on: December 07, 2008, 09:38:52 PM »
OK, and if you want to debug your scripting...

WARNING: READING THIS AND ACTING ON THE CONTENTS MAY COMPLETELY RUIN THE GAME EXPERIENCE FOR YOU
or enhance it - hehe

[spoiler:mlfanmmo]Press left Ctrl and D to enter developer mode.

While in debug mode:
Press D to cycle through debug information layers. The conditions should appear in the top right. Also the game will list the log of the level parsing, so maybe you can tell what went wrong if it doesn't work.[/spoiler:mlfanmmo]

[spoiler:mlfanmmo]Not had enough yet huh? Okay.
The +/- keys on the number pad will accelerate and decelerate the passage of time in the game.[/spoiler:mlfanmmo]

[spoiler:mlfanmmo]I can see you want the whole deal. Okay.

Press F2 to open the variable directory. This contains a list of variables sorted into directories. You can change stuff here and load/save them to settings files and level files. It's usually better to edit the levels by hand. Remember to back up your stuff. You can always just reinstall the game if you want to restore defaults.

Press F3 to open the graph window. This will show you various graphs for different things in the game - it's intended to give an idea of how certain elements of the game change with respect to attributes.

Press F4 to open the debug window. This lets you turn off/on visibility of different teams, and lets you spy on entities by clicking on them with the middle mouse button. You can also deactivate the camera limit and the sending limit here.

Some windows are resizable - just drag the edges like you would in other GUIs.[/spoiler:mlfanmmo]

metarinka

  • Guest
Re: Level design demystification / scripting guide
« Reply #2 on: December 08, 2008, 05:39:11 AM »
thanks soooo much!

this gives me the motivation to kick out those remaining levels I've got stored away!

dbltnk

  • Guest
Re: Level design demystification / scripting guide
« Reply #3 on: January 09, 2009, 03:05:32 PM »
I removed the write protection both on the game folder, the ressources folder and all files in them. There level files should be editable now. Still, both edit++ and the windows editor tell me that I can't write there. Using Vista x64. Any suggestions?

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Level design demystification / scripting guide
« Reply #4 on: January 09, 2009, 08:38:01 PM »
That's really odd - and I've had other people note that Dyson crashes or has other bad behaviour on Vista owing to write permission. I've not become familiar with Vista so I don't know where it's appropriate for games to store their data. I'll look it up. Thanks for the info.

dbltnk

  • Guest
Re: Level design demystification / scripting guide
« Reply #5 on: January 09, 2009, 09:39:02 PM »
Somehow the write protection on the folder doesn't get removed, even if Vista says so. I can save the edited level file in another spot with no problems. Maybe you should just get rid of that write protection for your next release.

crazeh.monkeh

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
Re: Level design demystification / scripting guide
« Reply #6 on: January 10, 2009, 04:28:17 AM »
Quote from: "dbltnk"
I removed the write protection both on the game folder, the ressources folder and all files in them. There level files should be editable now. Still, both edit++ and the windows editor tell me that I can't write there. Using Vista x64. Any suggestions?

Hey, I'm running Vista too. It crashes for me sometimes if it is saved in the C: drive (where most apps get installed) because it tries to write or modify files inside of it's folder, and vista won't let it. Alex had me move the folder to my desktop and that fixed it, but your documents folder should be fine, too. I just installed mine on a thumb drive and it is fine. I can even edit levels and everything.

On a side note, I think if you set the planet to static the planet starts exactly there, but the swarm and trees don't. They start slightly off of the planet, and you have the roots of the plants growing off in space, but the trees themselves are on the planet. I THINK it is because they are on static. I could have messed something else up, but I think that is what it was. Yup. I just switched to not static and it fixed it. Idk. Maybe it just happens to me.

Anyway, Alex, you get to see my level soon, lol.

*Edit: also, is there a way to start some kind of a timer? Like "after this event, wait such and such time, them do this". I can think of a few ways that I could use it, but if not, I'll live.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Level design demystification / scripting guide
« Reply #7 on: January 10, 2009, 06:44:18 PM »
Quote from: "crazeh.monkeh"
Quote from: "dbltnk"
I removed the write protection both on the game folder, the ressources folder and all files in them. There level files should be editable now. Still, both edit++ and the windows editor tell me that I can't write there. Using Vista x64. Any suggestions?

Hey, I'm running Vista too. It crashes for me sometimes if it is saved in the C: drive (where most apps get installed) because it tries to write or modify files inside of it's folder, and vista won't let it. Alex had me move the folder to my desktop and that fixed it, but your documents folder should be fine, too. I just installed mine on a thumb drive and it is fine. I can even edit levels and everything.

On a side note, I think if you set the planet to static the planet starts exactly there, but the swarm and trees don't. They start slightly off of the planet, and you have the roots of the plants growing off in space, but the trees themselves are on the planet. I THINK it is because they are on static. I could have messed something else up, but I think that is what it was. Yup. I just switched to not static and it fixed it. Idk. Maybe it just happens to me.

Anyway, Alex, you get to see my level soon, lol.

*Edit: also, is there a way to start some kind of a timer? Like "after this event, wait such and such time, them do this". I can think of a few ways that I could use it, but if not, I'll live.
That sounds like a pretty serious bug - I didn't know that was happening. Could you email me the XML of the file that's showing that happen? Cheers!

There are timers in there, but their only current function is to start spawning seedlings at random. Hopefully we'll expand on this as we add new stuff and get level editing more integral.

ccjav

  • Guest
Re: Level design demystification / scripting guide
« Reply #8 on: January 10, 2009, 10:17:57 PM »
Ya im also running this on vista, and having the write problem... the main issue for me is when you try to change the options and hit done, it crashes the game. A way to get around the fact you cant save scripts than save them, save them somewhere else (desktop perhaps?) and then drag and drop the file to replace it.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Level design demystification / scripting guide
« Reply #9 on: January 11, 2009, 07:31:59 AM »
Vista sounds like it sucks :D

OK, will have to fix this. Cheers guys.

sfericz

  • Guest
Re: Level design demystification / scripting guide
« Reply #10 on: January 11, 2009, 08:44:14 AM »
First, let me say congrats on the IGF submission! I have only played one level and I can say it is well deserved. I also want to thank the developers for this unique game. Having the ability to create community member levels will keep this game alive for awhile I believe.

This thread is a great resource, thanks! Once I get to finish the game :P

I'm glad I found this community before you guys hit big (because you will) I find the best resources to a game can be found in the community members. In example.... metarinka has already made seven new levels?? wOw... People like that are great to have with a new gaming company.

Quote from: "Alex"
Vista sounds like it sucks :D

OK, will have to fix this. Cheers guys.
I will try to reproduce these errors on my vista O/S....I have only been able to reproduce the (Start-up, Maximizing before loading elements) bug. But I think I read where you know what causes that already.

I think these errors might have something to do with the UAC on Vista, I have mine (plus a lot of other stuff) turned off and can not reproduce the Write to folder/file error.

wogan

  • Guest
Re: Level design demystification / scripting guide
« Reply #11 on: February 14, 2009, 12:39:15 AM »
Yeah, Vista. Lovely OS.

You can solve all those write problems by running the game as Administrator (right-click the executable). This means that you'll have to explicity launch it this way every time you run Dyson, which isn't preferable.

But in C#:



I'm not sure what OS you're coding on, but you should be able to explicitly set IO permissions. This will require user authorization when installing on Vista, but that's preferable to having to launch as admin each time. And it shouldn't affect other OSes at all.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Level design demystification / scripting guide
« Reply #12 on: February 14, 2009, 11:30:05 AM »
Ah cheers Wogan, I didn't know about that!

What I've done currently is get the game to move the user-editable files into My Documents/Game data/Dyson (on windows only), but the jury's now out on whether that's preferable to the method you've just described.

crazeh.monkeh

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
Re: Level design demystification / scripting guide
« Reply #13 on: February 14, 2009, 06:45:42 PM »
I'm voting on Wogan's idea if you can get it to work. I like having all of my programs either in Program Files or on a Flash Drive (Which is what I'm doing with it now. It keeps it nice and portable. Lol)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Level design demystification / scripting guide
« Reply #14 on: February 14, 2009, 10:19:00 PM »
I'm inclined to agree, c.m!