Space 4X Strategy Game - Devember 2019

DAY 19.5:

Late night / Early morning tinkering:

  • Made the Previous and Next buttons functional. (For selecting the next object of same type that needs orders)
  • Made the ‘Orders Given’ check box functional. (Removes from Previous / Next List)
  • Added a summary above the End Turn button to show how many things need orders, and quickly be able to select the first one.
  • Added some ‘fancy’ camera movement when going to next object.

DAY 20:

So, finally settled on getting Colonizing Planets implemented and waiting to do Star Bases. Was tossing around the idea on how I wanted to populate worlds. In VGA Planets, you would transfer down some colonists and on the next turn they would take ownership. There was also a ship mission of landing and disassembling which basically does the same thing but you lose a ship. I am thinking that the logic for transferring to/from non-owned things is going to be overly complicated and am leaning more towards a Ship Mission. I want to have a specific Mission for Colonizing that does not involve losing a Ship, if selected it will unload Colonists/Supplies/Credits when reaching a Planet.

To start off I am going to skip the UI for now and just have Ships assume they are on a Colonizing mission for the time being. During the turn processing, I need to check the Ships Mission (Colonize) then check if the Ship is at an unowned Planet and if it is, unload Colonists/Supplies/Credits and set ownership. Adding a few comment lines in the code at this section to remind myself that later on when there are other players doing things, it would be possible to have more than one player trying to Colonize at the same time. In that situation there would be a “ground battle” before determining ownership.

Not sure what is going on with the credits, probably some issue with the Planetary Revenue Service freezing assets, but credits are not leaving with the Ships. I’ll have to track down where that is getting messed up. Probably some silly oversight, since everything else seems to be working.

Have one more night of very cold temperatures before getting back to generally cold, so will likely get the boring UI work done later on and make it possible to select the Ship Mission.

9 Likes

Making good progress. I’m impressed.

2 Likes

DAY 20.5:

  • Found the bug for why credits were not transferring (it was actually affecting fuel as well), it was an issue of assigning a reference to an array instead of copying it. Glad I found it quickly, mistakes like that can be a nightmare to track down. The side effect of this was making it so the rest of the cargo was working correctly, so I did not realize there was an issue at first. Anyways, the fix broke the cargo briefly and had to actually copy the data correctly during the End Turn phase. :slight_smile:

  • Added the UI for Ships to be assigned a Mission. Currently can be set to None and Colonize.

  • Added the UI for Ships to be assigned Orders. Currently can be set to None and Beam up Fuel. Beam up Fuel will attempt to transfer to the Ship any fuel available, including from unowned Planets. Good to use when Colonizing to refuel without having to wait a turn for ownership.


DAY 21 - We’re Whalers on the Moon:

Looks like Star Bases are the next component that is needed and can finally put all this hard earned cargo to use. Since this is going to be another part of the Selected Object UI, going to use this opportunity to start the splitting up process, will implement Star Bases as a separate object from the get go. This will give the benefit of knowing what will be involved with separating everything else and any potential problems without touching what it currently in place.

The main task for today was to get the Star Base class and the Star Base Data class written so can start connecting them in to the system. Also getting some preliminary work done on the UI for building them.


Happy Winter/Summer Solstice.

7 Likes

DAY 22:

Continuing along with Starbases. Mostly a lot of tweaking things that are already there to allow for Starbases. Primary example is the Selected Object UI takes a generic ‘object’ type, it determines what the actual type is (Planet/Starbase/Ship) and displays the appropriate information. In every function that does one of those checks, need to add in a check for Starbases and create the equivalent code paths to handle them.

In hindsight, could have created some sort of SelectableObject base class that Planet, Starbase, and Ship derive from. In that setup the Selected Object UI could have been a bit more efficient. Making a few notes about this for myself as I may want to revisit this later and make that modification.

For the most part have everything in place, just need to build the UI to actually interact with it. So far have it so the Tile View will show a blank Starbase icon when there is no Starbase, when clicked on, it will open the Build Starbase UI. After manually setting a Starbase on the players home world, it will show a normal Starbase icon and open the Starbase Management Panel (Blank, empty at the moment). Tomorrow will likely be another heavy UI day.

devember_day_22_01

devember_day_22_02

8 Likes

DAY 23:

Want to get the Build Starbase portion done first so do not need to keep toggling it built/not built in code.

  • Got the ‘Build’ and ‘Cancel’ buttons doing what they need to do. Build will create a new Starbase class and Cancel will destroy it.
  • During the end turn phase when planets are being processed, a check is done to see if Starbase is not null and if it has been toggled built yet. If it has not been built then it will be toggled built at this point.

With the ability to build Starbases now implemented fully, I can set the home world to have a Starbase during Galaxy creation.

Got a lot of the UI in place for the Starbase Management for today, still a bunch more to do though.

devember_day_23


Realized I put a bug in the ID system for Ships and Starbases :smiley:

When starting this project and first made Planets I just assigned them an ID of the current size of the Planets array. When adding Ships (and now Starbases) I did the same thing not really thinking about it. The issue is that Ships and Starbases can be destroyed (Discovered this while messing with Cancel button), so every time something is destroyed the ID’s are going to get wonky and start overlapping. Solution for this is fairly simple, need a function(s) that gets the next available ID. Need to loop through the array to see if there is an empty slot to re-use, if not then use the size of the array.

I am not going to side track myself on fixing this quite yet, for now will disable the Cancel button since that is currently the only way to destroy something. This will be the next thing to work on after the Starbase Management UI is in place.

8 Likes

DAY 24 - Now with 10% more Jolly Seeking Missiles:

Not a very big update today, continued with the Starbase Management UI.

  • Added Tech Level upgrade panel.
  • Connected the resource values to UI elements.
  • Added a basic Starbase model (stretched image was bothering me)

devember_day_24


DAY 24.5:

Had some time and decided to do a few things.

  • Fixed the ID bug.
  • Re-enabled the ability to cancel Starbase construction.
  • Fixed setting a waypoint on the opposite side of the galactic center.
  • Started planning for Ship building at Starbases
7 Likes

DAY 25 - I’ve got a flying machine!:

  • Got the basic skeleton of the Build Ship portion of the Starbase Management UI in place.
  • Can Build a generic ship.

There are still a few more things to do with the Starbase Management UI, will put that on hold for a bit. Tomorrow will start to focus on expanding Ships beyond the generic starter Ship.

7 Likes

DAY 26 - One Ship, Two Ship, Red Ship, Blue Ship:

The goal for today is to be able to have different types of ships. Not going to go too overboard with this right now, but would like to be able to create a basic cargo Ship, a basic carrier (fighter) Ship, and a basic bomber (torpedo) Ship.

Decided on creating a struct for a ShipType which will hold all the needed information that Starbases can use to build Ships. Also decided on using JSON to create the template data file, which will make loading them in to a ShipType nice and simple. Had to make a few minor modifications to the existing Ship and ShipData classes to handle the new information.

{"name":"Small Freighter","races":["all"],"hull_level":1,"hull_mass":30,"hull_cost":[50,30,20,10,10],"num_engines":1,"num_beams":0,"num_torpedoes":0,"num_fighters":0,"num_crew":10,"fuel_capacity":100,"cargo_capacity":70,"available_missions":["Colonize"],"available_orders":["Beam up Fuel"]}
{"name":"Medium Freighter","races":["all"],"hull_level":3,"hull_mass":50,"hull_cost":[100,50,30,20,20],"num_engines":2,"num_beams":0,"num_torpedoes":0,"num_fighters":0,"num_crew":30,"fuel_capacity":250,"cargo_capacity":200,"available_missions":["Colonize"],"available_orders":["Beam up Fuel"]}
{"name":"Light Carrier","races":["all"],"hull_level":5,"hull_mass":100,"hull_cost":[100,120,50,40,30],"num_engines":2,"num_beams":4,"num_torpedoes":0,"num_fighters":2,"num_crew":80,"fuel_capacity":300,"cargo_capacity":40,"available_missions":["Try to Intercept","Mine Sweep"],"available_orders":["Beam up Fuel"]}
{"name":"Light Bomber","races":["all"],"hull_level":5,"hull_mass":100,"hull_cost":[100,120,50,40,30],"num_engines":2,"num_beams":4,"num_torpedoes":2,"num_fighters":0,"num_crew":80,"fuel_capacity":300,"cargo_capacity":40,"available_missions":["Try to Intercept","Lay Mines","Mine Sweep"],"available_orders":["Beam up Fuel"]}

Can now manually make different Ship types. Need a way to be able to select the different components now, so can go back to the Build Ship UI to add in the remaining pieces.

  • Can select a Hull if tech level is high enough.
  • Can select which level Engines the Ship will have.
  • Can select which level Beam Weapons the Ship will have. (if available to that Hull type)
  • can select which level Torpedo Launchers the Ship will have. (if available to that Hull type)

At the moment everything is just hard coded in. Will need to dynamically add in the available Hulls and only have options for Engines/Beams/Torpedoes up to the available tech level. Need to add in some new icons/models as well. Also need to add in the Ship costs, currently !!FREE!!.

7 Likes

DAY 27:

Finishing off some remaining details.

  • Showing costs when constructing Ships.
  • Tweaking a few things to allow for arbitrary icons/models for Ships.
  • Populating Hull selection with only Hulls available to selected race.
  • Greying out selections that have a tech level that is higher than the Starbases tech level
  • Added more information to the Ship Management UI to show the specific details of a Ship (Mass/Engines/Beams/Torpedoes)
  • Added panel on Ship Management UI for setting and viewing speed, viewing fuel consumption to destination, and turns remaining to destination.

devember_day_27_01
devember_day_27_02
devember_day_27_03

7 Likes

Lol at my shitty devember website. You and @Shecks are doing real work.

Super impressive. If y’all have a Patreon I’ll contribute.

6 Likes

Coding anything, whether simple, complex or even complete epic failures are learning experiences and have value. I wish you all could see the biblical pile of unfinished projects that allowed this project to do as well as it has.

I do not have a Patreon. Almost created one for my last attempt at a project, but did not think it would have enough interest. Only got about 2 weeks into it when life got in the way and had to focus on other things. By the time I got back to it had lost my motivation. Almost chose to go back to that project as my Devember challenge.

other project

for anyone interested the last project was ‘CivSim’ basically an attempt at dwarf fortress style civilization managment with a 3D interface. It started off as more of an experiment to see how fast I could build dynamic meshes composed of multiple materials.
https://www.youtube.com/playlist?list=PL-GDoN9Xs3cm-MaRyvak7WVJXmJ8lESyF

5 Likes

I can… I’m still adding up to the pile, so I can imagine it have quite a room to grow.
Still super impressive how well this project is going for you.

So you made gnomoria without the gnomes…

1 Like

DAY 28 - The reports of my assimilation were greatly exaggerated:

Finishing off remaining details for Natives on Planets.

Can now Tax the Native Population.

All the Player races can exist as Natives, with the exception of Cyborg and Robot. Cyborg and Xenomorph races have the ability to assimilate any Native race. All other races can absorb their Native counterparts (same race) into regular population. Robots have the unique ability to construct population with supplies. Finally, Xenomorph Natives can assimilate regular population, which will make those worlds more difficult to colonize.

Added in some dummy functions to the End Turn phase which will handle AI Players in the future.

4 Likes

DAY 29:

There are several things I would like to accomplish for the last few days of Devember.

  • A messages/reports system to notify the Player of what happened during the last turn phase. Ships performing their missions and orders, Planets gained/lost, battles, etc.
  • I would like to get at least the bare bones of combat in place. This will likely be just checking if a combat ship is present with enemies for the time being.
  • Also would like a very simple AI. this will most likely just be flying to closest un-visited Planets and trying to build a Ship if they have the resources. Very simple, mostly just want to have the AI framework in place to be expanded on later with more advanced formulas.

Going to start with the Reports system.

Will make a simple Report class. Will store type/category, what object created the report, and the actual message. During the end turn phase, for every event that happens will create a Report and add it to the Players Reports Array/List. Will need another UI to show the reports after they are generated, going to be make it as simple as possible to just keep moving forward. At some point in the future will be able to sort the categories. Can click on a Report and it will select the object that created it, and go to that location.

Another thing to consider here is if the Player the report is getting generated for is an AI Player, it could generate some different data instead which will make handling AI logic easier when that time arrives. For now just doing a check if the Player is an AI or not and calling an empty function if it is instead of creating a Report.

5 Likes

DAY 30 - Some people just want to watch the world burn:

Dealing with combat today.

Adding a new chunk to the End Turn phase. This portion comes after everything is processed and will cycle through all the Tiles in the Galaxy. If there are Ships on the Tile then it cycles through each one. First it checks if there are other Ships and for every enemy Ship a battle occurs. If there are no enemy Ships another check is done for a Planet/Starbase and a battle occurs if they are an enemy.

Created a Calculate Battle function which takes 2 generic objects (Planet / Starbase / Ship) and calculates the results of a battle. For now it just rolls some random numbers based on how many weapons/defense posts are present, whoever has the higher result from the rolls wins. I will need to add more to this later for dealing with Fighters, Torpedoes, Beams, Mass, overall damage, etc. and have it be less random.

5 Likes

DAY 31 - Never give up, never surrender:

Getting the framework for the AI in place.

AI is really not my strongest subject when it comes to coding, so this is probably going to be the messiest of the days. :smiley:

Going to cycle through each AI Player and going to check each Ship they own. If it is a cargo Ship (no beams/fighter bays/torpedoes) and it is at their home world then pick up some colonists. Next thing will be to find the closest un-visited Planet and set the Ships destination to it. If the Planet does not have a owner, then set the Colonize mission and head back to home world. If the Planet does have a owner, will find the next closest un-visited Planet and do the cycle again until it either colonizes or there are no more un-visited Planets.

Next thing want to do is cycle through each Starbase they own and try to build a Ship. Not entirely sure how I want this logic to work, but for now will have it try to build a cargo Ship for each Planet they own. If there is at least 1 cargo Ship for each Planet then try to build a combat Ship. Trying to determine costs and whether to build is posing to be more of a problem than I want to deal with at the moment, for now will just charge the AI a flat rate 200 of each ore and 1000 credits regardless of ship. If it has those resources than it will build otherwise it will not.

Going back to the first cycle of checking each Ship. For each combat Ship will attempt to go to closest enemy Planet and try to capture it.

Several things are a little wonky. Removed the galactic center since there was some path issues happening. There is still tons that can be done and improved upon, overall fairly happy with where this is at right now.

Set the ‘Current Player’ to be AI so it can just go on auto pilot for the test run video.


	// End of Devember related tasks.

	if (Date.GetMonth () == "January" && Date.GetDay () == 1) { Devember.isDevember = false; }

}

HappyNewYear ();
7 Likes

Happy new year, buddy :slight_smile:

2 Likes

Is it Devuary time now?

1 Like

Devember is in overtime!

2 Likes