Repository navigation
Expand file tree
/
Copy pathUnit.cpp
More file actions
260 lines (232 loc) · 5.14 KB
/
Copy pathUnit.cpp
File metadata and controls
260 lines (232 loc) · 5.14 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
* Copyright 2010 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Unit.h"
namespace OpenXcom
{
void operator>> (const YAML::Node& node, UnitStats& stats)
{
node["tu"] >> stats.tu;
node["stamina"] >> stats.stamina;
node["health"] >> stats.health;
node["bravery"] >> stats.bravery;
node["reactions"] >> stats.reactions;
node["firing"] >> stats.firing;
node["throwing"] >> stats.throwing;
node["strength"] >> stats.strength;
node["psiStrength"] >> stats.psiStrength;
node["psiSkill"] >> stats.psiSkill;
node["melee"] >> stats.melee;
}
YAML::Emitter& operator<< (YAML::Emitter& out, const UnitStats& stats)
{
out << YAML::BeginMap;
out << YAML::Key << "tu" << YAML::Value << stats.tu;
out << YAML::Key << "stamina" << YAML::Value << stats.stamina;
out << YAML::Key << "health" << YAML::Value << stats.health;
out << YAML::Key << "bravery" << YAML::Value << stats.bravery;
out << YAML::Key << "reactions" << YAML::Value << stats.reactions;
out << YAML::Key << "firing" << YAML::Value << stats.firing;
out << YAML::Key << "throwing" << YAML::Value << stats.throwing;
out << YAML::Key << "strength" << YAML::Value << stats.strength;
out << YAML::Key << "psiStrength" << YAML::Value << stats.psiStrength;
out << YAML::Key << "psiSkill" << YAML::Value << stats.psiSkill;
out << YAML::Key << "melee" << YAML::Value << stats.melee;
out << YAML::EndMap;
return out;
}
/**
* Creates a certain type of unit.
* @param type String defining the type.
* @param race String defining the race.
* @param rank String defining the rank.
*/
Unit::Unit(const std::string &type, std::string race, std::string rank) : _type(type), _race(race), _rank(rank), _armor(""), _standHeight(0), _kneelHeight(0), _loftemps(0), _value(0), _deathSound(0), _intelligence(0), _aggression(0)
{
}
/**
*
*/
Unit::~Unit()
{
}
/**
* Returns the language string that names
* this unit. Each unit type has a unique name.
* @return Unit name.
*/
std::string Unit::getType() const
{
return _type;
}
/**
* Sets the unit's stats data object.
* @param Stats.
*/
void Unit::setStats(struct UnitStats stats)
{
_stats = stats;
}
/**
* Sets the unit's armor type.
* @param string.
*/
void Unit::setArmor(const std::string &armor)
{
_armor = armor;
}
/**
* Set the unit's height at standing, kneeling and 3D template.
* @param string.
*/
void Unit::setVoxelParameters(int standHeight, int kneelHeight, int loftemps)
{
_standHeight = standHeight;
_kneelHeight = kneelHeight;
_loftemps = loftemps;
}
/**
* Set the unit's intelligence and aggression.
* @param string.
*/
void Unit::setAIParameters(int intelligence, int aggression)
{
_intelligence = intelligence;
_aggression = aggression;
}
/**
* Set the unit's special ability.
* @param specab.
*/
void Unit::setSpecialAbility(SpecialAbility specab)
{
_specab = specab;
}
/**
* Returns the unit's stats data object.
* @return Stats.
*/
UnitStats *Unit::getStats()
{
return &_stats;
}
/**
* Returns the unit's height at standing.
* @return height.
*/
int Unit::getStandHeight() const
{
return _standHeight;
}
/**
* Returns the unit's height at kneeling.
* @return height.
*/
int Unit::getKneelHeight() const
{
return _kneelHeight;
}
/**
* Returns the unit's 3D template ID.
* @return template ID.
*/
int Unit::getLoftemps() const
{
return _loftemps;
}
/**
* Gets the unit's armor type.
* @return string.
*/
std::string Unit::getArmor() const
{
return _armor;
}
/**
* Gets the alien's race.
* @return string.
*/
std::string Unit::getRace() const
{
return _race;
}
/**
* Gets the alien's rank.
* @return string.
*/
std::string Unit::getRank() const
{
return _rank;
}
/**
* Set the unit's value - for scoring.
* @param value.
*/
void Unit::setValue(int value)
{
_value = value;
}
/**
* Get the unit's value - for scoring.
* @return value.
*/
int Unit::getValue() const
{
return _value;
}
/**
* Set the unit's death sound.
* @param id.
*/
void Unit::setDeathSound(int id)
{
_deathSound = id;
}
/**
* Get the unit's death sound.
* @return id.
*/
int Unit::getDeathSound() const
{
return _deathSound;
}
/**
* Get the intelligence. This is the number of turns AI remembers your troops position.
* @return intelligence.
*/
int Unit::getIntelligence() const
{
return _intelligence;
}
/**
* Get the aggression. Determines the chance of revenge and taking cover.
* @return intelligence.
*/
int Unit::getAggression() const
{
return _aggression;
}
/**
* Get the unit's special ability.
* @return specab.
*/
int Unit::getSpecialAbility() const
{
return (int)_specab;
}
}