Skip to content

Commit

Permalink
0.0.006 -> 0.0.007
Browse files Browse the repository at this point in the history
Add Tribe_Elf. Elven tribes can now spawn into the game.
Add Elf Tribe texture.
Fix some Tribe spawning rules. Tribes are now less likely to be unable to spawn.
Minor dependency cleanup.
  • Loading branch information
RyanBabij committed Jul 11, 2018
1 parent 71c83e7 commit a2357ea
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CompileCount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
*/
#include <string>

const std::string COMPILE_COUNT = "4199";
const std::string COMPILE_COUNT = "4222";
#endif
5 changes: 5 additions & 0 deletions Driver_LoadTextures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const std::string PATH_TEX_WORLD_UNIT_NOMAD_01 = "Textures/World/Unit/Nomad/00.p
Texture TEX_WORLD_UNIT_DWARF_01;
const std::string PATH_TEX_WORLD_UNIT_DWARF_01 = "Textures/World/Unit/Dwarf/00.png";

Texture TEX_WORLD_UNIT_ELF_01;
const std::string PATH_TEX_WORLD_UNIT_ELF_01 = "Textures/World/Unit/Elf/00.png";

Texture TEX_WORLD_SETTLEMENT_DWARFFORT_01;
const std::string PATH_TEX_WORLD_SETTLEMENT_DWARFFORT_01 = "Textures/World/Settlement/DwarfFort/01.png";

Expand Down Expand Up @@ -135,6 +138,8 @@ void loadTextures()
// LOAD WORLD OBJECT TEXTURES
loadTextureVerbose(PATH_TEX_WORLD_UNIT_NOMAD_01,&TEX_WORLD_UNIT_NOMAD_01);
loadTextureVerbose(PATH_TEX_WORLD_UNIT_DWARF_01,&TEX_WORLD_UNIT_DWARF_01);
loadTextureVerbose(PATH_TEX_WORLD_UNIT_ELF_01,&TEX_WORLD_UNIT_ELF_01);

loadTextureVerbose(PATH_TEX_WORLD_SETTLEMENT_DWARFFORT_01,&TEX_WORLD_SETTLEMENT_DWARFFORT_01);
loadTextureVerbose(PATH_TEX_WORLD_SETTLEMENT_TOWN_URBAN01,&TEX_WORLD_SETTLEMENT_TOWN_URBAN01);

Expand Down
12 changes: 6 additions & 6 deletions Driver_Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ volatile const std::string devmessage = "HEY THIS IS GARO WADDUP.";
/* DEBUG MENU SHORTCUTS */
//bool AUTO_GENERATE_WORLD = false;
//bool AUTO_NEW_SIMULATION = true;
bool QUICKSTART = true; // Skip menu stuff and jump right into the game. (Will use defaults).
bool QUICKSTART = false; // Skip menu stuff and jump right into the game. (Will use defaults).
//Quickly go straight into the simulator.
bool QUICKSTART_SIMULATOR = true; // Skip menu stuff and jump right into the game. (Will use defaults).
bool QUICKSTART_SIMULATOR = false; // Skip menu stuff and jump right into the game. (Will use defaults).
// DEFAULT WORLD WHICH IS AUTO-GENERATED.
int QUICKSTART_WORLD_SIZE = 129; /* Please set to (power of 2)+1. */


long long int INITIAL_YEARS_SIMULATE = 0;

// Default setting on the GUI
int DEFAULT_WORLD_SIZE_SLOT = 1; /* 0 = 129, 1 = 257, 513, 1025, 2049, 4097. You can set it lower for easier debugging. */
int DEFAULT_WORLD_SIZE_SLOT = 2; /* 0 = 129, 1 = 257, 513, 1025, 2049, 4097. You can set it lower for easier debugging. */

int DEFAULT_NUMBER_TRIBES_DWARVEN = 10;
int DEFAULT_NUMBER_TRIBES_HUMAN = 0;
int DEFAULT_NUMBER_TRIBES_ELVEN = 0;
int DEFAULT_NUMBER_TRIBES_DWARVEN = 12;
int DEFAULT_NUMBER_TRIBES_HUMAN = 12;
int DEFAULT_NUMBER_TRIBES_ELVEN = 12;
int DEFAULT_NUMBER_CIVS = 0;

bool FOG_OF_WAR = true;
Expand Down
2 changes: 1 addition & 1 deletion Tribe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ bool Tribe::spawn()
worldX=spawnTile->x;
worldY=spawnTile->y;

world->putObject(this);
world->putObject(this,worldX, worldY);
world->vTribe.push(this);

return true;
Expand Down
15 changes: 9 additions & 6 deletions Tribe_Dwarven.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ bool Tribe_Dwarven::spawn()
{

if ( world == 0 )
{ return false; }

HasXY* spawnTile = world->getRandomTileOfType(World::MOUNTAIN);

if ( spawnTile == 0 )
{
return false;
spawnTile = world->getRandomTileOfType(World::GRASSLAND);
}

HasXY* spawnTile = world->getRandomTileOfType(World::MOUNTAIN);


if ( spawnTile == 0 )
{
std::cout<<"ABORT: Couldn't find mountain tile.\n";
std::cout<<"ABORT: Dwarf couldn't find tile to spawn into.\n";
return false;
}

Expand All @@ -49,7 +52,7 @@ bool Tribe_Dwarven::spawn()
worldX=spawnTile->x;
worldY=spawnTile->y;

world->putObject(this);
world->putObject(this,worldX,worldY);
world->vTribe.push(this);

return true;
Expand Down
161 changes: 161 additions & 0 deletions Tribe_Elf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#pragma once
#ifndef WORLDSIM_TRIBE_ELF_CPP
#define WORLDSIM_TRIBE_ELF_CPP

/* WorldSim: Tribe_Elf.hpp
#include "Tribe_Elf.hpp"
Description:
Tribes are nomadic groups. They wander the map trying to survive until they develop enough to become a civilization. Elven tribes live in forests and jungles. They know a lot about the magic arts.
*/

#include "Tribe_Elf.hpp"

#include "Character.hpp"

class World;

#include "GuildCalendar.hpp"
#include "WorldObjectGlobal.hpp"

#include <Container/Table/TableInterface.hpp>

Tribe_Elf::Tribe_Elf()
{
race = ELVEN;
}


bool Tribe_Elf::spawn()
{

if ( world == 0 )
{
return false;
}

HasXY* spawnTile = 0;
if (Random::oneIn(3) )
{
spawnTile = world->getRandomTileOfType(World::FOREST);
}
else
{
spawnTile = world->getRandomTileOfType(World::JUNGLE);
}
if ( spawnTile == 0 )
{
spawnTile = world->getRandomTileOfType(World::GRASSLAND);
}

if ( spawnTile == 0 )
{
std::cout<<"ABORT: Elf couldn't find tile to spawn into.\n";
return false;
}

name = globalNameGen.generateName();
nFood = 10;

worldX=spawnTile->x;
worldY=spawnTile->y;

world->putObject(this,worldX,worldY);
world->vTribe.push(this);

return true;

}

/* SIMULATE X TURNS OF THE CIV. */
void Tribe_Elf::incrementTicks ( int nTicks )
{
actionPoints+=nTicks;
dailyCounter+=nTicks;
monthlyCounter+=nTicks;

while (monthlyCounter >= 2592000)
{
for ( int i=0;i<30;++i)
{


if ( foundSettlement == false )
{
if ( world->getTileType(worldX,worldY) == "forest" && random.oneIn(10) )
{
//foundSettlement = true;
//world->evolveToCiv(this);
break;
}
else
{
wander();
}
}


}

monthlyCounter-=2592000;
}

while ( dailyCounter >= 86400 )
{
if ( foundSettlement == false )
{
if ( world->getTileType(worldX,worldY) == "forest" && random.oneIn(10) )
{
//foundSettlement = true;
//world->evolveToCiv(this);
break;
}
else
{
wander();
}
}
dailyCounter-=86400;
}


}

void Tribe_Elf::wander()
{
if (world==0 || foundSettlement) { return; }

int destinationX = worldX + random.randomIntRange(-1,1);
int destinationY = worldY + random.randomIntRange(-1,1);

// Moving options:
// Move to food
// Move to unexplored territory

//aTerrain.getNeighborVector(_x,_y,&vTerrain,false /* DON'T INCLUDE SELF */);
//Vector <HasXY*> * vXY = world->aTerrain.getNeighbors(worldX, worldY, false);
//vXY->shuffle();

//HasXY* xyDestination = 0;

/* If all else fails, move randomly. */
if (world->isSafe(destinationX,destinationY) && world->isLand(destinationX,destinationY))
{
// MOVE THE TRIBE TO THE LOCATION.
worldX=destinationX;
worldY=destinationY;
}
}


Texture* Tribe_Elf::currentTexture()
{
if (foundSettlement)
{
return &TEX_WORLD_SETTLEMENT_DWARFFORT_01;
}
return &TEX_WORLD_UNIT_ELF_01;
}

#endif
41 changes: 41 additions & 0 deletions Tribe_Elf.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once
#ifndef WORLDSIM_TRIBE_ELF_HPP
#define WORLDSIM_TRIBE_ELF_HPP

/* WorldSim: Tribe_Elf.hpp
#include "Tribe_Elf.hpp"
Description:
Tribes are nomadic groups. They wander the map trying to survive until they develop enough to become a civilization. Elven tribes live in forests and jungles. They know a lot about the magic arts.
*/

#include "Character.hpp"

class World;

#include "GuildCalendar.hpp"
#include "WorldObjectGlobal.hpp"

#include <Container/Table/TableInterface.hpp>


class Tribe_Elf: public Tribe
{
public:

//RandomNonStatic random;

Tribe_Elf();

bool spawn();

/* SIMULATE X TURNS OF THE CIV. */
void incrementTicks ( int /* nTicks */ );

void wander();

Texture* currentTexture();
};

#endif
6 changes: 3 additions & 3 deletions Tribe_Human.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ bool Tribe_Human::spawn()
return false;
}

HasXY* spawnTile = world->getRandomTileOfType(World::MOUNTAIN);
HasXY* spawnTile = world->getRandomTileOfType(World::GRASSLAND);

if ( spawnTile == 0 )
{
std::cout<<"ABORT: Couldn't find mountain tile.\n";
std::cout<<"ABORT: Human couldn't find tile to spawn into.\n";
return false;
}

Expand All @@ -46,7 +46,7 @@ bool Tribe_Human::spawn()
worldX=spawnTile->x;
worldY=spawnTile->y;

world->putObject(this);
world->putObject(this,worldX,worldY);
world->vTribe.push(this);

return true;
Expand Down
30 changes: 26 additions & 4 deletions World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@
#include "Civ.cpp"
#include "Civ_Dwarven.cpp"

#include "Tribe.cpp"
#include "Tribe_Human.cpp"
#include "Tribe_Dwarven.cpp"
#include "Tribe_Elf.cpp"

#include "Settlement.cpp"

#include "WorldObjectGlobal.hpp"

World::World(): seaLevel(0), mountainLevel(0)
{
// aHeightMap.init(1,1,0);
Expand Down Expand Up @@ -183,10 +190,17 @@ void World::generateTribes( int nTribesHuman = DEFAULT_NUMBER_TRIBES_HUMAN, int
{
std::cout<<"Generate tribes\n";

if (nTribesHuman < 1 || nTribesHuman > 999)
{
std::cout<<"WARNING: Excessive tribes.\n";
}
if (nTribesHuman < 0 ) { nTribesHuman = 0; }
if (nTribesDwarven < 0 ) { nTribesDwarven = 0; }
if (nTribesElven < 0 ) { nTribesElven = 0; }

if (nTribesHuman < 0 || nTribesHuman > 999)
{ std::cout<<"WARNING: Unexpected number of human tribes.\n"; }
if (nTribesDwarven < 0 || nTribesDwarven > 999)
{ std::cout<<"WARNING: Unexpected number of human tribes.\n"; }
if (nTribesElven < 0 || nTribesElven > 999)
{ std::cout<<"WARNING: Unexpected number of human tribes.\n"; }


for (int i=0;i<nTribesHuman;++i)
{
Expand All @@ -208,6 +222,14 @@ void World::generateTribes( int nTribesHuman = DEFAULT_NUMBER_TRIBES_HUMAN, int
t->spawn();
t->generateCouples(7);
}

for (int i=0;i<nTribesElven;++i)
{
Tribe_Elf * t = new Tribe_Elf;
t->init(this);
t->spawn();
t->generateCouples(7);
}


std::cout<<"END Generate tribes\n";
Expand Down
Loading

0 comments on commit a2357ea

Please sign in to comment.