Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: [1] 2  All

Author Topic: Strategy game in WME  (Read 8344 times)

0 Members and 1 Guest are viewing this topic.

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Strategy game in WME
« on: April 14, 2013, 04:44:15 PM »

Hi

I know that WME it's not the engine for strategy games. I know it. However, I think that I could make strategy turn based game very easily in WME. I got full concept of world, rules, some algorithms. All I need to do is to sit down with computer and make it happen. But I've found a problem. I think about space strategy turn based game. One of the core elements are planets where the player can have a base. Every base can mine some resources, bulid ships, train pilots etc. - this kind of stuff. Problem is that universe is huge. There will be 50 solar systems, each solar system has own planets with moons. Every single planet or moon can have base. There is some limitations (game rules). You cannot have more bases than 5 per every solar system. So... 50 solar systems * 5 bases = 250 bases. It looks like madness but it's not. Believe me. Every base has it's own properties (resources, factory status, units, people...) So every base can have some 50 properties. It gives us 250 bases * 50 properties = 12500 and it's only ground bases. Same story is with fleets, orbital bases etc. Normally I could use some array to story this data but I've find out that if I'll do this WME has some serious issues with load and save game.  Look I know that WME has a great potential and I know that it can be done. I need some tips, advices... :)
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Strategy game in WME
« Reply #1 on: April 14, 2013, 08:10:31 PM »

Of course it can be done, someone even made a RPG using WME.

One advantage of Wintermute regarding object manipulation is its dynamic nature. What I mean:

Code: WME Script
  1. var Base;
  2. Base.FactoryStatus = "something";
  3. var Units = array();
  4. var Unit;
  5. Unit.Type = "infantry";
  6. Unit.Number = 100;
  7. Units.push(Unit);
  8. Unit.Type = "armored";
  9. Unit.Number = 20;
  10. Units.push(Unit);
  11. Base.Units = Units;
  12.  

As you can see, you can declare a var of a generic type and then add any properties you wish. If you query a property that does not exist, you will simply get null:

Code: WME Script
  1. var aVariable;
  2. var aProperty = aVariable.property1;
  3. Game.Msg(aProperty); //Will print "null"
  4. aVariable.property1 = "something";
  5. aProperty = aVariable.property1;
  6. Game.Msg(aProperty); //Will print "something"
  7.  

So it is quite easy to create your game objects at will and store them in arrays. Regarding the memory size and the save/load functionality, as far as I know "Save" will save everything that is stored in memory at the moment of the save. So, your Base variables (like all variables you use) that are stored in some array will be saved in full, which is of course desired. I am not certain what else this implies, I believe a more experienced member or Mnemonic will be able to help you.

Btw, how do you plan to implement the zoom in/out? Or will you not offer such functionality? You will also have to implement the screen scrolling when the mouse enters the edge of the screen yourself.
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: Strategy game in WME
« Reply #2 on: April 14, 2013, 11:04:30 PM »

I know what you mean (i think I know :) ) and it's ok with one base. But how will you do this for 100 or more bases? How will you store data about resources on every planet without reading this info each time from a file? I've tried this with some big array filled with zero and WME was saving game for few minutes... Maybe I don't understand you then please explain this :)
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Strategy game in WME
« Reply #3 on: April 15, 2013, 02:35:49 PM »

As for saving game - do you tried the old build, or the newest (1.10)? Seems that in the 1.10 the process of saving games (when using quick save flag) is much more quicker.
And as for strategy game - why not? Here ia some thought about it. For global map you can use one scene with dynamically generated solar systems.
When you zoom in to solar system - you load next scene and dynamically generate there the whole solar system. When (and if) you need to zoom in on of the planets/bases - you opens the next scene and generates planet/base there etc.

All data you need to store in global arrays and sub arrays: Universe <- Consists of N Solar Systems <- Each system consists of M Planets/Bases etc <- Each Planet/Base have K parameters.
12500 items even with amount of each is about 1Kb (it's very big assumtion) give you only 12.5 Mb of memory occupied by this data. It's not so much as you think. Moreover - some data may be static and unchanged during the game. This data best of all you need to store in text files (it's a pity that WME can't work with xml, but never mind) and by this way exclude it from saving procedure.
« Last Edit: April 15, 2013, 02:51:30 PM by 2.0 »
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Strategy game in WME
« Reply #4 on: April 15, 2013, 04:39:45 PM »

Of course files can be deployed to store the information you need. What worries me though, which depends on how your game works, is that all your bases will need to continue doing what you set them to do, regardless of whether your are watching or not. This means that, for each bases update you will need to read all the information from the hard disk. Bear in mind that in programming, wherever you have I/O operations, they are the bottleneck of your game's performance.

Of course, I have never worked on such a large scale project and I am not sure how the multi-base functionality is implemented in AAA games. Probably there are multiple threads, one for each base that constantly update their state.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Strategy game in WME
« Reply #5 on: April 15, 2013, 05:18:40 PM »

As for the saving speed, WME 1.10 doesn't seem to have a problem with 12500 items.
I tried this script:

Code: WME Script
  1. var xxx;
  2.  
  3. ////////////////////////////////////////////////////////////////////////////////
  4. on "LeftClick"
  5. {
  6.   var startTime = Game.WindowsTime;
  7.   for (var i = 0; i < 12500; i = i + 1)
  8.   {
  9.         xxx[i] = i;
  10.   }
  11.   Game.LOG(Game.WindowsTime - startTime);
  12.  
  13.   startTime = Game.WindowsTime;
  14.   Game.SaveGame(0, "blah");
  15.   Game.LOG(Game.WindowsTime - startTime);
  16. }
  17.  

On my machine it takes 247 milliseconds to fill the array and 177 milliseconds to save the game.

Interestingly, though, if I store the array in global variable, it takes a long time for every window to display. Not really sure why. It works fine with var.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Strategy game in WME
« Reply #6 on: April 15, 2013, 09:20:20 PM »

For the Base.FactoryStatus, Where is FactoryStatus defined ? A sample project would be great
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Strategy game in WME
« Reply #7 on: April 15, 2013, 09:56:08 PM »

If I correctly understand the question, in the

Code: WME Script
  1. Base.FactoryStatus = "UberPowerPlant";

you defines FactoryStatus parameter right here, in this string of code :)

For the Base.FactoryStatus, Where is FactoryStatus defined ? A sample project would be great
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Strategy game in WME
« Reply #8 on: April 15, 2013, 10:27:00 PM »

Im sorry if I dont understand, but is FactoryStatus definat as a var ? Or is it a method? That type of thing
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: Strategy game in WME
« Reply #9 on: April 15, 2013, 10:58:30 PM »

Thank you all for your tips :)

anarchist: Performance with update of all bases is not a problem. You're not doing it all the time. For instance mines on planet surface. All you need to do is to save mine level (how much per hour), how many resources is in store and at what time it was saved. That's it. You don't have to update it until you will need to buy something or check store or whatever. So if you need this data then you'll just do this (resources in store) + (((current time - (at what time it was saved)) * (how much per hour) = and now you know everything you need, save new data and that's it.

I've tried new version of WME 1.10 and it's really fast saving :) That's good but one thing still worries me. As Mnemonic said there is issue with global variables. I've just did really really fast assumption how big and how many arrays I will need. I want them to be global because I can have a problem with local variables. So with global it's not looking good. WME can save game very quickly but I can't quit the game because windows are drawing very slowly. I can't load the game. For me it's a critical show stopper. I don't know what to do. Here is the code:

Code: [Select]
var i;
global ground_base, orbital_base, fleet, planet_res, enemy_base, enemy_fleet;
 
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
var startTime = Game.WindowsTime;
for (i = 0; i < 10500; i = i + 1)
{
ground_base[i] = i;
}
for (i = 0; i < 6000; i = i + 1)
{
orbital_base[i] = i;
}
for (i = 0; i < 2500; i = i + 1)
{
fleet[i] = i;
}
for (i = 0; i < 18000; i = i + 1)
{
planet_res[i] = i;
}
for (i = 0; i < 10500; i = i + 1)
{
enemy_base[i] = i;
}
for (i = 0; i < 1500; i = i + 1)
{
enemy_fleet[i] = i;
}

Game.LOG(Game.WindowsTime - startTime);
 
startTime = Game.WindowsTime;
Game.SaveGame(0, "blah");
Game.LOG(Game.WindowsTime - startTime);

}
« Last Edit: April 15, 2013, 11:00:30 PM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Strategy game in WME
« Reply #10 on: April 15, 2013, 11:05:44 PM »

Piagent, Base is a var. After you define it, you can add to it as many properties you wish, without needing to declare them. So:

Code: WME Script
  1. //First declare the variable
  2. var Base;
  3. //Add to it as many properties as you wish, of any type you wish
  4. Base.Variable1 = "a";
  5. Base.Variable2 = 10;
  6. Base.Variable3 = new Array("a", "b", "c");
  7.  
  8. //Below line will print "a"
  9. actor.Talk(Base.Variable1);
  10.  
  11. //You can even query a property you have not defined above.
  12. //The game will not crush and the property will simply be null.
  13. //Below line will print "null"
  14. actor.Talk(Base.Variable4);
  15.  

Edit: hubertMichael, there could be some workarounds if Mnemonic cannot locate and perhaps fix the reason why global variables have this strange after-effect after save.
« Last Edit: April 15, 2013, 11:18:03 PM by anarchist »
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Strategy game in WME
« Reply #11 on: April 15, 2013, 11:48:20 PM »

>>I don't know what to do.

So... use the local variable! :)

In your game.script file define variable and methods to work with it.

Code: WME Script
  1. var ground_base = new Array(10500);
  2.  
  3. method DoSomething (var _index, var _something)
  4. {
  5.   ground_base[_index] = _something;
  6. }

then when you need DoSomething with ground_base, simply call

Code: WME Script
  1. Game.DoSomething(any, anything);

from anywhere you want.
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: Strategy game in WME
« Reply #12 on: April 16, 2013, 10:33:46 PM »

Thank you :) That is exactly what I wanted  ::rock
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Strategy game in WME
« Reply #13 on: April 17, 2013, 11:14:02 AM »

+1 for 2.0's suggestion. The Game object is the only object that will surely never be destroyed or reset by the game. Keeping a local variable in there is as if you have a global one, but without the unwanted side-effects.
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: Strategy game in WME
« Reply #14 on: April 17, 2013, 11:17:30 AM »

It had never occured to me to do that fantastic idea
Logged
Pages: [1] 2  All
 

Page created in 0.225 seconds with 24 queries.