Shop Home

Computer Games

Coming Soon

Tabletop Wargames
News

Downloads

Beta Test
Login

Advanced search
  • Board index ‹ Latest Releases ‹ Battle Academy ‹ Battle Academy : Modders Corner
  • Change font size
  • Print view
  • FAQ
  • Register
  • Login

BETA randomised maps PLUGIN

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post a reply
83 posts • Page 1 of 5 • 1, 2, 3, 4, 5

BETA randomised maps PLUGIN

Postby Amaris » Wed Jul 13, 2011 3:24 pm

I'm working on a plugin for the editor using the scripts already.

The plugin generates only the map: no victory points, no troops.

Image

Just click on Map button:
Image

Wait a little:
Image

It works also for large maps:
Image

I had to change the method to generate the tiles (using GetTileID).
There is still a bug with the river...
But the advantage of the plugin is that you can change what you want.
And with other plugins (Random Ennemy and Victory Point) it should be easy to make a scenario.
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby pipfromslitherine » Wed Jul 13, 2011 3:35 pm

Plus plugins give you an easy way to hook in your UI elements to make it all nice and friendly to tinker.

There isn't any way to currently do 'user' plugins, and it would certainly add some pain to the game, as people might need to grab a plugin to make a mission work - but we can certainly make it part of the core install if you and the guys decide you are happy with it to work that way.

Cheers

Pip
pipfromslitherine
Site Admin
Site Admin
 
Posts: 5662
Joined: Wed Mar 23, 2005 10:35 pm
Top

Postby Merr » Thu Jul 14, 2011 9:32 am

Very Nice! I tried this with my map but I couldn't get it to work. :(

Good to see you back in production ... We haven't seen you in awhile.
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
 
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm
Top

Postby Amaris » Thu Jul 14, 2011 10:26 am

I used the plugin Slith_Edging as a working base. That can be see at the UI :wink:

I have to debug first generation of river :? before release.
I will also look more specifically the UI. It will great if i could integrate some parameter into UI, like the presence of river, number of town, etc. :P
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby Merr » Thu Jul 14, 2011 11:25 am

Amaris wrote:I will also look more specifically the UI. It will great if i could integrate some parameter into UI, like the presence of river, number of town, etc. :P


I think you can!

Look at the code for Slith_RandomEnemy ... allows you to change values, but I couldn't figure out how to make them apply in the Editor. :(

It's a lot work ... I'm glad you figured it out!
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
 
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm
Top

Postby pipfromslitherine » Thu Jul 14, 2011 3:37 pm

You would need to either have an 'apply' button to hit once you have set up the values you want, or have a 'refresh' function you call whenever a number is changed in the UI to rebuild the map.

Specifically, this would all happen in the UI_OBJ_HANDLE function of your plugin script. In the Slith_RandomEnemy.bsf you see we go through all the up/down controls and see whether they are pressed. If you wanted (and the update was fast enough) you would call your map rebuild inside there, if not, you would add a new button that people would hit to rebuild the map once they had the params set up.

One thing to note - if your plugin needs to pass its values into the game (rather than being a handy way to give the user new editor functionality) you need a unique script id in the UI TXT file for the plugin, but it doesn't look like this is the case here - but just in case you started seeing very odd bugs because plugins were interfering with each other :).

Cheers

Pip
pipfromslitherine
Site Admin
Site Admin
 
Posts: 5662
Joined: Wed Mar 23, 2005 10:35 pm
Top

Postby Amaris » Fri Jul 15, 2011 4:13 pm

Thanks Merr and Pip :D

I understand how to get values of the buttons. And how works UI :P

Image

River button: ON or OFF - for the presence (or not) of a river along y-axis.
Roads x: 0 to 6 - the number of x-axis' roads.
Roads y: 0 to 4 - the number of y-axis' roads.

And when River = ON the number of x-axis' roads is limited between 0 and 1. Otherwise it becomes too complex to manage for now :lol:

This allowed me to detect some bugs on the roads. :?

I'll try to fix that and continuing to add options in the UI.
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby pipfromslitherine » Fri Jul 15, 2011 4:45 pm

Very cool!

There seem to have been a number of new things from you and Merr over the last couple of weeks. Just wanted to remind you to poke me if you get to the point where you think anything is ready for primetime - as I often lose track of things (old age...) :).

Cheers

Pip
pipfromslitherine
Site Admin
Site Admin
 
Posts: 5662
Joined: Wed Mar 23, 2005 10:35 pm
Top

Postby Amaris » Tue Jul 19, 2011 8:58 am

Work on UI is well advanced:

Image

Image

I added an option to change the width of the stream. And rewrite the river's script.
And you can play on the density of the various elements with the associated buttons.
Each time the button Create Map is pressed, a new map is generated based on parameters set in the UI.

It still remains a minor bug: occasionally, a bridge is not properly oriented (visible on the first screen) :shock: It is very curious, and this does not happen all the time...

I also have to work on the generation of mud and rough, for the larger set on the map. The same for the ponds.

See also if it's possible to adapt the plugin to other tilesets. :P
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby Merr » Tue Jul 19, 2011 1:46 pm

Amaris wrote:It still remains a minor bug: occasionally, a bridge is not properly oriented (visible on the first screen) :shock: It is very curious, and this does not happen all the time...


If this is your only bug, you are doing well! We know you can squash the bug.

I also have to work on the generation of mud and rough, for the larger set on the map. The same for the ponds.


Don't forget the FORD!

See also if it's possible to adapt the plugin to other tilesets. :P


Can you make a theater button toggle? e.g, Desert/Normandy/Bulge ?
Duplicate your scripts but use other tilesets. Biggest task is dropping all the snow/desert tiles first, since Normandy default ground tile is tile#1.

Great job! I'm sure this will make it into Slitherine plugin.
Thank you for working on this project. This will help players make a map from scratch very easily!
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
 
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm
Top

Postby Amaris » Tue Jul 19, 2011 2:33 pm

Yes the 'bridge's bug' is the only one :P
The rest seems ok.
Specially roads 8)

Don't forget the FORD!


Ford is already present, only for a 1 case wide river. Against I uses buggy version for maximum compatibility... I hope it will be fix :wink:

Can you make a theater button toggle? e.g, Desert/Normandy/Bulge ?
Duplicate your scripts but use other tilesets. Biggest task is dropping all the snow/desert tiles first, since Normandy default ground tile is tile#1.


Yes a theater button toggle Normandy/Bulge/Desert. I imagine it will not be very difficult to do. At least for Bulge tileset as it is very similar to Normandy Tileset. Desert tileset will be more complex: no field and forest for example...
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby Amaris » Wed Jul 20, 2011 3:33 pm

The tileset's button is operational :P

French tileset:

Image

Bulge Tileset:

Image

Desert tileset:

Image

Only the orientation of the bridge does not always work :roll:

There are still some minor adjustments on the generator itself. As the adjustment variables to the size of the map.

Then it will clean up the code and how to improve it. There are over 4.500 lines of code :shock:
On my (little) laptop, it takes between 10 and 20 seconds to generate a map... :roll:
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby pipfromslitherine » Wed Jul 20, 2011 4:47 pm

Well colour me impressed! I think this is a pretty staggering bit of work. I would love to get this added as an official plugin once you are happy with it for release. But it's pretty incredible.

Cheers

Pip
pipfromslitherine
Site Admin
Site Admin
 
Posts: 5662
Joined: Wed Mar 23, 2005 10:35 pm
Top

Postby Merr » Thu Jul 21, 2011 3:38 pm

Amaris wrote:Only the orientation of the bridge does not always work :roll:


Maybe I can help ... Let me know.

For my map, I had to run two loops, checking if road was located at (x+1) and (x-1), and (y+1) and (y-1).
If the road was at (x+1) and (x-1), then bridge was SetObjectRotation(id, 314).
If the road was at (y+1) and (y-1), then bridge was SetObjectRotation(id, 157).
Last edited by Merr on Thu Jul 21, 2011 4:47 pm, edited 1 time in total.
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
 
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm
Top

Postby Amaris » Thu Jul 21, 2011 3:49 pm

Well, once the plugin finished I'd be happy if it is approved and added as official.

The generator works only with river on y-axis, so the road is always on x-axis.
For bridge, here the code:
Code: Select all
FUNCTION DrawBridge()
{
   int x ;
   int y ;
   int yd ;
   int large ;
   int i ;
   int bridge ;
   
   x = GetGlobal("BridgeX") ;
   y = GetGlobal("BridgeY") ;          
   x = x * 100 ;
   x = x + 50 ;   
   large = GetGlobal("riverL") + 1 ;   
   
   for (i = 0 ; i < large ; i++)
   {
      SetTileData(x, y, 1, 8);   
      yd = y * 100 ;
      yd = yd + 50 ;
      bridge = PlaceObject(x, yd, "Test", "metal_bridge") ;
      SetObjectRotation(bridge, 157) ;
      y++ ;
   }
}


So i have no idea what's wrong :shock:
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Postby pipfromslitherine » Thu Jul 21, 2011 3:58 pm

You're multiplying x into 100ths, and yet still using it in the SetTileData function, so not sure if that could cause things to go wierd?

I'm not sure exactly what the side effects are, but that looks odd to me!

Hope that helps!

Cheers

Pip
pipfromslitherine
Site Admin
Site Admin
 
Posts: 5662
Joined: Wed Mar 23, 2005 10:35 pm
Top

Postby Merr » Thu Jul 21, 2011 4:38 pm

I think I know why too .... You might need to reset the X and Y back to tile coordinates. You'll note that in one screen shot, your 2nd bridge is broke, your first bridge is fine.

This is my code for placing a bridge ... You'll note at the end how I'm resetting X/Y values back to tile coordinates (not 100ths)

Code: Select all
   for (y=0;y<GetMapHeight();y++)
   {   
      for (x=0;x<GetMapWidth();x++)
      {   
         if ( ( IsWaterTile(x,y) == 1 ) && (( IsRoadTile(x,y+1) == 1 ) && ( IsRoadTile(x,y-1) == 1 )) && ( x == GetGlobal("roadx") ) )
         {
            x *= 100 ;
            x += 50 ;         
            y *= 100 ;
            y += 50 ;

            id = PlaceObject(x, y, "test", "metal_bridge") ;
            SetObjectRotation(id, 157) ; // radians
            SetObjectScale(id, 95);
            
            y -= 50 ;
            y /= 100 ;
            x -= 50 ;
            x /= 100 ;
         }   
      }
   }
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
 
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm
Top

Postby Merr » Thu Jul 21, 2011 5:01 pm

maybe something like this ?

Code: Select all
FUNCTION DrawBridge()
{
   int x ;
   int y ;
   int yd ;
   int large ;
   int i ;
   int bridge ;
   
   x = GetGlobal("BridgeX") ;
   y = GetGlobal("BridgeY") ;          
   
   large = GetGlobal("riverL") + 1 ;   
   
   for (i = 0 ; i < large ; i++)
   {
      SetTileData(x, y, 1, 8);
      x *= 100 ;
      x += 50 ;
      yd = y * 100 ;
      yd = yd + 50 ;
      
      bridge = PlaceObject(x, yd, "Test", "metal_bridge") ;
      SetObjectRotation(bridge, 157) ;
      
      x -= 50 ;
      x /= 100 ;
      yd -= 50;
      yd /= 100;
      
      y++ ;
   }
}
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
 
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm
Top

Postby pipfromslitherine » Thu Jul 21, 2011 6:10 pm

Without wanting to get into programming style debate (the horror! ;) ) I would suggest:

Code: Select all
FUNCTION DrawBridge()
{
   int x ;
   int y ;
   int yd ;
   int xd ;
   int large ;
   int i ;
   int bridge ;
   
   x = GetGlobal("BridgeX") ;
   y = GetGlobal("BridgeY") ;           
   large = GetGlobal("riverL") + 1 ;   
   
   for (i = 0 ; i < large ; i++)
   {
      SetTileData(x, y, 1, 8);   

      xd = x * 100 ;
      xd = xd + 50 ;
      yd = y * 100 ;
      yd = yd + 50 ;

      bridge = PlaceObject(xd, yd, "Test", "metal_bridge") ;
      SetObjectRotation(bridge, 157) ;

      y++ ;
   }
}
pipfromslitherine
Site Admin
Site Admin
 
Posts: 5662
Joined: Wed Mar 23, 2005 10:35 pm
Top

Postby Amaris » Fri Jul 22, 2011 11:10 am

Thanks for your help.
I tried your scripts but bridge is always bugged :shock:

I think there was a side effect somewhere...
The bridge is the first object placed on map.

If I generate a map with only a river and a road, the bridge is buggy.
And if I generate a map with only a river, a road and forest, the bridge is ok :roll:
While the forest is generated after the bridge...

So I think the script needs some corrections in deep core :wink:
Amaris
Sergeant First Class - Panzer IIIL
Sergeant First Class - Panzer IIIL
 
Posts: 365
Joined: Fri Jul 23, 2010 11:08 am
Location: France
  • Website
Top

Next

Post a reply
83 posts • Page 1 of 5 • 1, 2, 3, 4, 5

Return to Battle Academy : Modders Corner

Who is online

Users browsing this forum: No registered users and 1 guest

  • Board index
  • The team • Delete all board cookies • All times are UTC
Powered by phpBB® Forum Software © phpBB Group