Author Topic: New Colony Game, no name, not much for desc yet, lookin for suggestions.  (Read 1654 times)

Offline dave_erald

  • Sr. Member
  • ****
  • Posts: 263
So thanks to Hoomans help, and a light bulb nudge from g2 (if he shows up, I think he wanted to help out with this, or try something on his own) I am trying to make a Colony Game myself.

A lot of this is from help by everyone else around here (SirBomber's tutorials mostly) and the resident coding Monk Hooman (it was either that description or a robot ie: knows everything, always helpful, no emotion, like zero) , I prefer a Monk, stoic, relaxed, knowledgeable, but easily distracted, anyways I digress...

However, this would be using an entirely newly structured Tech Tree. Providing a favorable response I am hoping to take this new tree and cut it down into something easier to use for multiplayer games. (Also, I hope to add some thievery tech and coding in as well!)


What I am stuck on is how wildly different should the tech tree be?
  • I want something that feels more linear**, uses all three lab buildings (which incurs consequences for losing the Basic Lab as you only get to build it once, it's immediately replaced with the Standard Lab once it becomes available per OP2 coding)
  • It can't be so foreign that switching back to the regular tech tree is frustrating, all though I may not entirely care so much as change should be good
  • I am stuck on weapons balancing, is it types of weapons, when there available or distance/damage inflicted that seems to be the problem?
  • More tech to research, like a lot more or just a little?

Here's the code that allows some of the tech tree to function ie: you can choose to follow two different broad scope Weapons Research paths

Code: [Select]
//Create Research Triggers for the different paths of weapons tech
CreateResearchTrigger(1, 1, 6101, 0, "VisibleAResearched");
CreateResearchTrigger(1, 1, 6102, 0, "VisibleBResearched");

Code: [Select]
//This saves the research choice for Weapons Tech and exports the
//saved variable when in a colony game
struct ScriptGlobal
{
int researchChoice;
} scriptGlobal;
ExportSaveLoadData(scriptGlobal);


Hooman could give me crap for this one as I haven't changed it yet, It's simpler for me to read even if the code itself could be cleaner.
But...whatever, that's me.

Code: [Select]
Export void VisibleAResearched()
{
// Exit if a choice has already been made
if (scriptGlobal.researchChoice != 0) return;

// Mark the choice as having been made, never to be changed again
scriptGlobal.researchChoice = 1;

// Make visible tech B disappear as a research option
// because tech 'A' was chosen
Player[0].MarkResearchComplete(6102);

// Unlock the chosen tech tree
Player[0].MarkResearchComplete(6103);
};

Export void VisibleBResearched()
{
// Exit if a choice has already been made
if (scriptGlobal.researchChoice != 0) return;

// Mark the choice as having been made, never to be changed again
scriptGlobal.researchChoice = 2;

// Make visible tech A disappear as a research option
// because tech 'B' was chosen
Player[0].MarkResearchComplete(6101);

// Unlock the chosen tech tree
Player[0].MarkResearchComplete(6104);
};



** when I say linear, some of the way tech tree direction is in the current multitek file makes it more of a headache rather than usable, for instance I felt Efficiency Engineering should be done BEFORE Advanced structure and unit designs ie: Advanced Res, Advanced Armoring, etc etc, but that's me.



Anywho... thoughts?


p.s. - I now realize I posted this in the coding section, it's part Colony game, part tech tree rewriting, part coding. If there is a better place for it please throw it in there.
« Last Edit: December 29, 2015, 11:28:50 PM by dave_erald »
-David R.V.

-GMT400 fan
-OPU Influencer

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4751
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #1 on: December 30, 2015, 07:52:11 AM »
Excellent idea. We need more colony games.

I'm going to suggest adding the code to SVN. It makes it easier for other people to help out with it, since they can just checkout a copy and try it, or provide feedback on the code. They might even contribute too. Plus, too many projects have been lost or forgotten about, which could be prevented if they were in a public repository during their development. Keep in mind everything is always in development. Nothing is every really finished. No need to wait for something to be finished to release it, since that might mean it never gets released.

Oh, and no need to indent the CreateResearchTrigger calls.

You actually did a good job cleaning up the code and comments at the end, no need to worry about it.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 865
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #2 on: December 30, 2015, 12:03:47 PM »
Dave,

A new colony game sounds great! I'm happy to beta test when you need it. My only suggestion would be, try and keep obtainable goals. Feature creep kills many good projects that could otherwise be completed.

Offline dave_erald

  • Sr. Member
  • ****
  • Posts: 263
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #3 on: December 30, 2015, 01:35:12 PM »
I kinda think it will just be a build and launch a starship game.

It will just be everything else making it a pain in the arse to play.

  • For one, the map is very constricted (128x64),
  • there are cliffs all over, and a volcano that is going to wipe out an old AI settlement (which, plan is, you have to steal tech from the Advanced lab sitting there before the volcano mows it down, timing will be an issue,
  • and random AI patrols will force you to have to watch over your base over a larger area, Easy some patrols, Medium more patrols bigger guys, Hard and you get the idea,
  • start with one 2 bar and 2 1 bar common mines, another 3 bar is other side of map,
  • rare ore mines are middle top of map and not near starting location,
  • and do I make colony type and color random? ie: one day your eden and blue, next plymouth and yellow?

Thoughts?

-David R.V.

-GMT400 fan
-OPU Influencer

Offline dave_erald

  • Sr. Member
  • ****
  • Posts: 263
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #4 on: December 30, 2015, 04:27:07 PM »
I'm having trouble with randomizing Player Start Colony, c++ and OP2 coding are not cooperating

add this to top of main.cpp

#include <cstdlib>


and then use this code

Code: [Select]
//Set player base type ie: random pick eden or plymouth

{   int colonyStart = rand() % 2;
   if (colonyStart != 0)
       { Player[0].GoEden; }
   else
       { Player[0].GoPlymouth; }

return 0;
}


regardless of what I do, as soon as I put the Player[0].GoEden statement in anything or based off something I keep getting error statements

Code: [Select]
1>Main.cpp(81): error C3867: '_Player::GoEden': non-standard syntax; use '&' to create a pointer to member
1>Main.cpp(85): error C3867: '_Player::GoPlymouth': non-standard syntax; use '&' to create a pointer to member


The hell am I doing wrong?
-David R.V.

-GMT400 fan
-OPU Influencer

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3205
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #5 on: December 30, 2015, 07:36:08 PM »
GoEden() and GoPlymouth()
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2186
    • LairWorks Entertainment
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #6 on: December 30, 2015, 10:22:57 PM »
Code: cpp [Select]

//Set player base type ie: random pick eden or plymouth
{
srand (time(NULL));
int colonyStart = rand() % 2;
if (colonyStart != 0)
{
Player[0].GoEden();
}
else
{
Player[0].GoPlymouth();
}

return 0;
}


Should stick with typical C++ code design paradigms.

Alternatively this code could be reduced to this:

Code: cpp [Select]

//Set player base type ie: random pick eden or plymouth
{
srand (time(NULL));
int colonyStart = rand() % 2;

colonyStart != 0 ? Player[0].GoEden() : Player[0].GoPlymouth();

return 0;
}


Note that I am seeding the random number generator (RNG) from within what appears to be a smaller code block. Generally I wouldn't do this, I'm simply illustrating why you're getting the same result time and time again.

I would instead seed the RNG from the entry point function (the first function/method called in your program). I don't remember which one that is in the OP2 SDK.

Also make sure you're including the time.h library at the beginning of your code (usually top of the file) if it hasn't already been included:

Code: [Select]
#include <time.h>
« Last Edit: December 30, 2015, 10:24:56 PM by leeor_net »

Offline dave_erald

  • Sr. Member
  • ****
  • Posts: 263
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #7 on: December 30, 2015, 10:56:00 PM »
Done and done. Works mint.

Code I currently got in int InitProc()

Code: [Select]
//Set player, random as either Eden or Plymouth

{       srand(time(NULL));
int colonyStart = rand() % 2;

if (colonyStart != 0)

          Player[0].GoEden();

else

  Player[0].GoPlymouth();

}


though I do get this error message

Code: [Select]
1>Main.cpp(81): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data

Builds and plays fine. Oh well. On to the next problem...which will be Hooman might kill me if I don't at least start to help with the parser. I get distracted...


Thanks @Leeor and @SirBomber!
-David R.V.

-GMT400 fan
-OPU Influencer

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4751
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #8 on: December 31, 2015, 01:43:18 AM »
Use TethysGame::GetRand for random numbers.

Code: [Select]
int colonyStart = TethysGame::GetRand(2);

Details can be found in the Outpost2DLL SDK package in TethysGame.h:
Code: [Select]
	static int __fastcall GetRand(int range);					// Returns a number from 0..(range-1)

Using the built in pseudo random number generator has a few benefits:
  • The built-in generator is already seeded before DLL code is called, so you don't need to seed it yourself.
  • The state of the built-in generator is saved to saved game files, so results are consistent when you load.
  • The seed is shared between all clients in a multiplayer game, ensuring consistent results between machines.
That last point is really the key one. Do not use srand(time(NULL)) and rand() in a multiplayer game DLL. The game will almost certainly desync. You might get away with it in single player, but you should just stick to using the built in random number generator in all cases.


As for that error message, it's confusing the first and last cases when you give it the middle case:
Code: [Select]
Player[0].GoEden()  // Function call
Player[0].GoEden  // Name of a function, useless on it's own, grammatically incomplete
&Player[0].GoEden  // Address of a function

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2186
    • LairWorks Entertainment
Re: New Colony Game, no name, not much for desc yet, lookin for suggestions.
« Reply #9 on: January 01, 2016, 11:13:27 PM »
All good points. I had no idea the API offered a RNG. Would have offered that as a much better option if I knew it was there. :D