Repository navigation
Expand file tree
/
Copy pathPlayerInitialization.cpp
More file actions
159 lines (129 loc) · 5.64 KB
/
Copy pathPlayerInitialization.cpp
File metadata and controls
159 lines (129 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "PlayerInitialization.h"
#include "OP2Helper/OP2Helper.h"
#include <array>
#include <vector>
void InitializePlayer(const PlayerNum playerNumber, const LOCATION& startLoc);
void CreateInitialVech(Unit& unit, map_id unitType, const LOCATION& loc, PlayerNum playerNumber, map_id cargo);
const std::array<LOCATION, 5> playerStartLocs{
LOCATION(165 + X_, 1 + Y_),
LOCATION(170 + X_, 1 + Y_),
LOCATION(175 + X_, 1 + Y_),
LOCATION(180 + X_, 1 + Y_),
LOCATION(185 + X_, 1 + Y_)};
const ResourceSet resourceSet {
{
// Kids, Adults, Scientist, Food, Common, Rare
{ 27, 18, 22, 4000, 0, 0 }, // Easy
{ 24, 15, 20, 3500, 0, 0 }, // Medium
{ 21, 13, 19, 3250, 0, 0 }, // Hard
}
};
void CreateWinVechs(PlayerNum playerNumber, PlayerNum aiPlayerIndex);
void InitializePlayers(int humanPlayerCount, PlayerNum aiPlayerIndex)
{
std::vector<LOCATION> initStartLocs(playerStartLocs.size());
std::copy(playerStartLocs.begin(), playerStartLocs.end(), initStartLocs.begin());
#if _DEBUG
CreateWinVechs(PlayerNum::Player0, aiPlayerIndex);
Player[0].MarkResearchComplete(TechID::techRareOreProcessing);
#endif
for (int i = 0; i < humanPlayerCount; ++i)
{
InitPlayerResources(i, resourceSet);
const int locationIndex = TethysGame::GetRand(initStartLocs.size());
InitializePlayer(static_cast<PlayerNum>(i), initStartLocs[locationIndex]);
initStartLocs.erase(initStartLocs.begin() + locationIndex);
}
}
void InitializePlayer(const PlayerNum playerNumber, const LOCATION& startLoc)
{
Player[playerNumber].CenterViewOn(startLoc.x, startLoc.y);
LOCATION currentLoc = startLoc;
Unit unit;
CreateInitialVech(unit, map_id::mapEarthworker, currentLoc, playerNumber, map_id::mapNone);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapConVec, currentLoc, playerNumber, map_id::mapStructureFactory);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapConVec, currentLoc, playerNumber, map_id::mapCommonOreSmelter);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapConVec, currentLoc, playerNumber, map_id::mapAgridome);
currentLoc.x = startLoc.x;
currentLoc.y++;
CreateInitialVech(unit, map_id::mapConVec, currentLoc, playerNumber, map_id::mapTokamak);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapConVec, currentLoc, playerNumber, map_id::mapCommandCenter);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapConVec, currentLoc, playerNumber, map_id::mapBasicLab);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapRoboMiner, currentLoc, playerNumber, map_id::mapNone);
currentLoc.x = startLoc.x;
currentLoc.y++;
CreateInitialVech(unit, map_id::mapEvacuationTransport, currentLoc, playerNumber, map_id::mapNone);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapEvacuationTransport, currentLoc, playerNumber, map_id::mapNone);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapCargoTruck, currentLoc, playerNumber, map_id::mapNone);
unit.SetTruckCargo(Truck_Cargo::truckCommonMetal, 1000);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapCargoTruck, currentLoc, playerNumber, map_id::mapNone);
unit.SetTruckCargo(Truck_Cargo::truckCommonMetal, 1000);
currentLoc.x = startLoc.x;
currentLoc.y++;
CreateInitialVech(unit, map_id::mapCargoTruck, currentLoc, playerNumber, map_id::mapNone);
unit.SetTruckCargo(Truck_Cargo::truckFood, 1000);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapCargoTruck, currentLoc, playerNumber, map_id::mapNone);
unit.SetTruckCargo(Truck_Cargo::truckFood, 1000);
currentLoc.x++;
CreateInitialVech(unit, map_id::mapRoboSurveyor, currentLoc, playerNumber, map_id::mapNone);
map_id cargo = map_id::mapMicrowave;
if (Player[playerNumber].IsEden()) {
cargo = map_id::mapLaser;
}
for (int i = 0; i < TethysGame::InitialUnits(); ++i)
{
currentLoc.x = startLoc.x + i % 4;
currentLoc.y = startLoc.y + 5 + i / 4;
CreateInitialVech(unit, map_id::mapLynx, currentLoc, playerNumber, cargo);
}
}
void CreateInitialVech(Unit& unit, map_id unitType, const LOCATION& loc, PlayerNum playerNumber, map_id cargo)
{
const UnitDirection rotation = UnitDirection::South;
TethysGame::CreateUnit(unit, unitType, loc, playerNumber, cargo, rotation);
unit.DoSetLights(true);
LOCATION moveLoc(unit.Location().x, unit.Location().y + 5);
unit.DoMove(moveLoc);
}
void CreateWinVechs(PlayerNum playerNumber, PlayerNum aiPlayerIndex)
{
Unit unit;
LOCATION enemyLoc(200 + X_, 5 + Y_);
LOCATION CCLoc(150 + X_, 100 + Y_);
LOCATION CCLoc2(165 + X_, 100 + Y_);
LOCATION smelterLoc(160 + X_, 125 + Y_);
LOCATION mineLoc(120 + X_, 150 + Y_);
LOCATION empLoc(152 + X_, 100 + Y_);
LOCATION rpgLoc(155 + X_, 100 + Y_);
for (int i = 0; i < 40; ++i)
{
LOCATION loc(176 + X_, 25 + Y_);
CreateInitialVech(unit, map_id::mapCargoTruck,loc, playerNumber, map_id::mapNone);
unit.SetTruckCargo(Truck_Cargo::truckCommonMetal, 1000);
}
for (int i = 0; i < 20; ++i)
{
LOCATION loc(160 + X_, 25 + Y_);
CreateInitialVech(unit, map_id::mapCargoTruck, loc, playerNumber, map_id::mapNone);
unit.SetTruckCargo(Truck_Cargo::truckRareMetal, 1000);
}
for(int i = 0;i < 5; i++)
CreateInitialVech(unit, map_id::mapLynx, empLoc, playerNumber, map_id::mapEMP);
for (int i = 0; i < 5; i++)
CreateInitialVech(unit, map_id::mapLynx, rpgLoc, playerNumber, map_id::mapRPG);
CreateInitialVech(unit, map_id::mapScout, enemyLoc, aiPlayerIndex, map_id::mapNone);
TethysGame::CreateUnit(unit, map_id::mapCommandCenter, CCLoc, playerNumber, map_id::mapNone, East);
TethysGame::CreateUnit(unit, map_id::mapCommandCenter, CCLoc2, Player1, map_id::mapNone, East);
TethysGame::CreateUnit(unit, map_id::mapCommonOreSmelter, smelterLoc, playerNumber, map_id::mapNone, East);
TethysGame::CreateUnit(unit, map_id::mapRareOreSmelter, mineLoc, Player1, map_id::mapNone, East);
}