forked from OpenXcom/OpenXcom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit.cpp
More file actions
233 lines (209 loc) · 5.02 KB
/
Copy pathUnit.cpp
File metadata and controls
233 lines (209 loc) · 5.02 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
/*
* Copyright 2010-2013 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
{
/**
* 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), _stats(), _armor(""), _standHeight(0), _kneelHeight(0), _floatHeight(0),
_value(0), _deathSound(0), _aggroSound(-1), _moveSound(-1), _intelligence(0), _aggression(0), _specab(SPECAB_NONE),
_zombieUnit(""), _spawnUnit(""), _livingWeapon(false)
{
}
/**
*
*/
Unit::~Unit()
{
}
/**
* Loads the unit from a YAML file.
* @param node YAML node.
*/
void Unit::load(const YAML::Node &node)
{
_type = node["type"].as<std::string>(_type);
_race = node["race"].as<std::string>(_race);
_rank = node["rank"].as<std::string>(_rank);
_stats = node["stats"].as<UnitStats>(_stats);
_armor = node["armor"].as<std::string>(_armor);
_standHeight = node["standHeight"].as<int>(_standHeight);
_kneelHeight = node["kneelHeight"].as<int>(_kneelHeight);
_floatHeight = node["floatHeight"].as<int>(_floatHeight);
_value = node["value"].as<int>(_value);
_deathSound = node["deathSound"].as<int>(_deathSound);
_aggroSound = node["aggroSound"].as<int>(_aggroSound);
_moveSound = node["moveSound"].as<int>(_moveSound);
_intelligence = node["intelligence"].as<int>(_intelligence);
_aggression = node["aggression"].as<int>(_aggression);
_specab = (SpecialAbility)node["specab"].as<int>(_specab);
_zombieUnit = node["zombieUnit"].as<std::string>(_zombieUnit);
_spawnUnit = node["spawnUnit"].as<std::string>(_spawnUnit);
_livingWeapon = node["livingWeapon"].as<bool>(_livingWeapon);
}
/**
* Returns the language string that names
* this unit. Each unit type has a unique name.
* @return The unit's name.
*/
std::string Unit::getType() const
{
return _type;
}
/**
* Returns the unit's stats data object.
* @return The unit's stats.
*/
UnitStats *Unit::getStats()
{
return &_stats;
}
/**
* Returns the unit's height at standing.
* @return The unit's height.
*/
int Unit::getStandHeight() const
{
return _standHeight;
}
/**
* Returns the unit's height at kneeling.
* @return The unit's kneeling height.
*/
int Unit::getKneelHeight() const
{
return _kneelHeight;
}
/**
* Returns the unit's floating elevation.
* @return The unit's floating height.
*/
int Unit::getFloatHeight() const
{
return _floatHeight;
}
/**
* Gets the unit's armor type.
* @return The unit's armor type.
*/
std::string Unit::getArmor() const
{
return _armor;
}
/**
* Gets the alien's race.
* @return The alien's race.
*/
std::string Unit::getRace() const
{
return _race;
}
/**
* Gets the unit's rank.
* @return The unit's rank.
*/
std::string Unit::getRank() const
{
return _rank;
}
/**
* Gets the unit's value - for scoring.
* @return The unit's value.
*/
int Unit::getValue() const
{
return _value;
}
/**
* Gets the unit's death sound.
* @return The id of the unit's death sound.
*/
int Unit::getDeathSound() const
{
return _deathSound;
}
/**
* Gets the unit's move sound.
* @return The id of the unit's move sound.
*/
int Unit::getMoveSound() const
{
return _moveSound;
}
/**
* Gets the intelligence. This is the number of turns the AI remembers your troop positions.
* @return The unit's intelligence.
*/
int Unit::getIntelligence() const
{
return _intelligence;
}
/**
* Gets the aggression. Determines the chance of revenge and taking cover.
* @return The unit's aggression.
*/
int Unit::getAggression() const
{
return _aggression;
}
/**
* Gets the unit's special ability.
* @return The unit's specab.
*/
int Unit::getSpecialAbility() const
{
return (int)_specab;
}
/**
* Gets the unit that the victim is morphed into when attacked.
* @return The unit's zombie unit.
*/
std::string Unit::getZombieUnit() const
{
return _zombieUnit;
}
/**
* Gets the unit that is spawned when this one dies.
* @return The unit's spawn unit.
*/
std::string Unit::getSpawnUnit() const
{
return _spawnUnit;
}
/**
* Gets the unit's war cry.
* @return The id of the unit's aggro sound.
*/
int Unit::getAggroSound() const
{
return _aggroSound;
}
/**
* Checks if this unit is a living weapon. (ie: chryssalid).
* @return True if this unit is a living weapon.
*/
bool Unit::isLivingWeapon() const
{
return _livingWeapon;
}
}