Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
ryleyra

Registered:
Posts: 3,009
Reply with quote  #1 
I have taken the Solo Siege Mode mission I wrote and restructured it into a Sector Generator, using various initialization variables to control the terrain and enemy generation code. This enables my mission to be re-used to create either random or static sectors, or even to implement a Sandbox. There are some limitations in my code, although it could be fleshed out to give it more functionality, or to handle more objects. (Although more objects could also be handled by triggering two or three generation steps)

This is just a bare bones prototype, and I don't intend to put the work into it to make it a true Sandbox. Rather, I give permission for other Sandbox designers to use it. What this mission does do is create four sectors, two which are static (in regards to terrain, anyway) and two of which implement my original random Siege Mode and an additional Double Front Mode. The four sectors can be selected between by pressing the 1-4 keys on the GM screen, or if the mission is left alone for ten seconds, it will select a sector randomly.

My original Siege Mode code has been improved with the ability to select which direction the enemy comes from. You can select between a wave from the left, a wave from the right, a double front attack, or attack from all sides. The GM has full control over when enemies attack, and can choose any of the above. In automatic mode, each sector has a default direction. (Obviously, Siege and Double Front use those modes)

The important thing is that you can go into the code, and using my sectors as an example, write your own sectors. The generation code is separate, and it should be easy to edit or add sectors without accidently messing up the generation code. The mission is designed to add enemies randomly, not at predefined locations, although those can be added directly with the usual commands. This mission also implements a GM interface similar to Module_3_bases.

Most importantly of all, however (at least to me) this mission is only about twice the size of the original Siege Mode mission, even with the added sectors. It's my guess that this can significantly reduce the size of the Sandbox Scripts, since most of the redundant code can be reduced to variable declarations.

 
Attached Files
zip SectorGenerator.zip (25.00 KB, 24 views)

janx

Registered:
Posts: 460
Reply with quote  #2 
ponder this:

if your script is mostly static, except for variable declarations, and you can write to a log file, I can tell you how to make a saveable environment...

step 1:
take your script and replace the values for your variables with some distinctive tag (ex __SHIP1_X and __SHIP1_Y)
modify the script to emit those variables to the log file in a distinctive and parseable way (ex __SHIP_X=123.56)

Step2: write a program to replace those tags with default values, or values it parses from the latest log file (the log file being your "save file")

step 3: run the program to initialize your working script from your template script)

step 4: load the game with the Working Script, play around, move the ship

step 5: trigger updating to the log file so those vars are saved

step 6: quit the game and re-run the program to merge the log file data into the template to create a new working script

step 7: load the game with the Working Script

step 8: you should find that things have been put back where you left them (in sofar as all the variables you created and logged)

Arrew

Avatar / Picture

Registered:
Posts: 2,737
Reply with quote  #3 
Can you tell it what to save in the log file?

Can you tell it to recall specific info from the log file?

I was under the understanding that these things were impossible with current Artemis?
janx

Registered:
Posts: 460
Reply with quote  #4 
Quote:
Originally Posted by Arrew
Can you tell it what to save in the log file? Can you tell it to recall specific info from the log file? I was under the understanding that these things were impossible with current Artemis?


From some other recent thread, somebody mentioned being able to write to the log file.  If that's true, that's the part the script writer has to take care of.  Obviously, if that's not true, this idea is stuck... [smile]

After that, because Ry organized his script to have all the variables in one place, the trick is to do macro replacement on a template copy of the script to replace those macro tags with actual values.

From there, it's just a matter of parsing the previous game's log file to get the values for the variables.

It's all basic text file parsing, which is pretty much entry-level college programming problems (writing filters to import a file, and produce another file is rudimentary homework).


Arrew

Avatar / Picture

Registered:
Posts: 2,737
Reply with quote  #5 
The idea of a sort of SAVED GAME option is something that's been asking for for a while... Perhaps one of the more talented programming members of the community might be able to whip up something?

Here's to hoping [wink]
ryleyra

Registered:
Posts: 3,009
Reply with quote  #6 
You can write generic messages to a log file, but you cannot write VARIABLES to a log file, which is the important point. You could do something like "If A is 1, then write 'A=1' to the file, if A is 2, then write 'A=2' to the file" and so on, but that's tedious.

In my mission script, I actually log messages to the file when certain things are created (mainly enemies) so I can debug any odd behavior and see if the script isn't working as intended. But I can't save the coordinates of that object from the variable that defines them.

I am hoping that in the future, Thom adds some sort of functionality that will allow us to load variables or commands from a file. That would make this script much more powerful. I might be able to define the generation code as a supplemental file, for instance, and embed it in a mission instead of having to copy and paste it into a mission.

I'll also note that as hard as I tried to make the location variables take up as little space as possible, it probably is still just as efficient to just create the item, in most cases. The generator code works much better at generating random terrain, since you have to generate a random variable to make the location random.

What one MIGHT do is write a python script or the like, that takes a configuration file with various coordinates listed, parses it, and generates the mission code. (Or plugs the values into the appropriate place in the mission code)

That's just one idea. I look forward to seeing what others are able to do with the idea. As I said, this is just an experiment.
janx

Registered:
Posts: 460
Reply with quote  #7 
Quote:
Originally Posted by ryleyra
What one MIGHT do is write a python script or the like, that takes a configuration file with various coordinates listed, parses it, and generates the mission code. (Or plugs the values into the appropriate place in the mission code)

That's just one idea. I look forward to seeing what others are able to do with the idea. As I said, this is just an experiment.


That's basically what I'm saying.  Write code to produce a mission script.

With your current script, it's likely somebody could make a front end to build a mission (by choosing variables in a GUI) and have it save a mission script following your design pattern for a script.

If logging was more powerful, that's where a game save mechanism could be worked out.
ryleyra

Registered:
Posts: 3,009
Reply with quote  #8 
I meant to mention this, but this script isn't really designed for Artemis 2.2. I have included a 2.2 version, but all it does is eliminate the ability to create space monsters. ANY monsters in a script crash 2.2, so the script can't be made to work until that bug is fixed.

If you try to run the 2.1 script in 2.2, it will crash if it tries to generate a space monster. So again, the script file ending in _v22 just doesn't generate monsters at all.

I just noticed, there is a bug in the Monster code anyway. One variable uses the name "MOnster", with a capital O. This results in BioMechs being created at the top of the screen and moving down. I'll try to fix it and repost.

Edit: Okay, it's fixed

Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.