* Saves the soldier to a YAML file. * @return YAML node. */
| 233 | * @return YAML node. |
| 234 | */ |
| 235 | YAML::Node BattleUnit::save() const |
| 236 | { |
| 237 | YAML::Node node; |
| 238 | |
| 239 | node["id"] = _id; |
| 240 | node["faction"] = (int)_faction; |
| 241 | node["soldierId"] = _id; |
| 242 | node["genUnitType"] = _type; |
| 243 | node["genUnitArmor"] = _armor->getType(); |
| 244 | node["name"] = Language::wstrToUtf8(getName(0)); |
| 245 | node["status"] = (int)_status; |
| 246 | node["position"] = _pos; |
| 247 | node["direction"] = _direction; |
| 248 | node["directionTurret"] = _directionTurret; |
| 249 | node["tu"] = _tu; |
| 250 | node["health"] = _health; |
| 251 | node["stunlevel"] = _stunlevel; |
| 252 | node["energy"] = _energy; |
| 253 | node["morale"] = _morale; |
| 254 | node["kneeled"] = _kneeled; |
| 255 | node["floating"] = _floating; |
| 256 | for (int i=0; i < 5; i++) node["armor"].push_back(_currentArmor[i]); |
| 257 | for (int i=0; i < 6; i++) node["fatalWounds"].push_back(_fatalWounds[i]); |
| 258 | node["fire"] = _fire; |
| 259 | node["expBravery"] = _expBravery; |
| 260 | node["expReactions"] = _expReactions; |
| 261 | node["expFiring"] = _expFiring; |
| 262 | node["expThrowing"] = _expThrowing; |
| 263 | node["expPsiSkill"] = _expPsiSkill; |
| 264 | node["expMelee"] = _expMelee; |
| 265 | node["turretType"] = _turretType; |
| 266 | node["visible"] = _visible; |
| 267 | node["turnsSinceSpotted"] = _turnsSinceSpotted; |
| 268 | node["rankInt"] = _rankInt; |
| 269 | node["moraleRestored"] = _moraleRestored; |
| 270 | if (getCurrentAIState()) |
| 271 | { |
| 272 | node["AI"] = getCurrentAIState()->save(); |
| 273 | } |
| 274 | node["killedBy"] = (int)_killedBy; |
| 275 | if (_originalFaction != _faction) |
| 276 | node["originalFaction"] = (int)_originalFaction; |
| 277 | if (_kills) |
| 278 | node["kills"] = _kills; |
| 279 | if (_faction == FACTION_PLAYER && _dontReselect) |
| 280 | node["dontReselect"] = _dontReselect; |
| 281 | node["specab"] = (int)_specab; |
| 282 | if (!_spawnUnit.empty()) |
| 283 | node["spawnUnit"] = _spawnUnit; |
| 284 | node["motionPoints"] = _motionPoints; |
| 285 | |
| 286 | return node; |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Returns the BattleUnit's unique ID. |