1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Fabian 'x3n' Landau |
---|
24 | * Co-authors: |
---|
25 | * Simon Miescher |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #include "Pawn.h" |
---|
30 | |
---|
31 | #include <algorithm> |
---|
32 | |
---|
33 | #include "core/CoreIncludes.h" |
---|
34 | #include "core/GameMode.h" |
---|
35 | #include "core/XMLPort.h" |
---|
36 | #include "network/NetworkFunction.h" |
---|
37 | |
---|
38 | #include "infos/PlayerInfo.h" |
---|
39 | #include "controllers/Controller.h" |
---|
40 | #include "gametypes/Gametype.h" |
---|
41 | #include "graphics/ParticleSpawner.h" |
---|
42 | #include "worldentities/ExplosionChunk.h" |
---|
43 | #include "worldentities/BigExplosion.h" |
---|
44 | #include "weaponsystem/WeaponSystem.h" |
---|
45 | #include "weaponsystem/WeaponSlot.h" |
---|
46 | #include "weaponsystem/WeaponPack.h" |
---|
47 | #include "weaponsystem/WeaponSet.h" |
---|
48 | |
---|
49 | #include "controllers/FormationController.h" |
---|
50 | |
---|
51 | namespace orxonox |
---|
52 | { |
---|
53 | RegisterClass(Pawn); |
---|
54 | |
---|
55 | Pawn::Pawn(Context* context) |
---|
56 | : ControllableEntity(context) |
---|
57 | , RadarViewable(this, static_cast<WorldEntity*>(this)) |
---|
58 | { |
---|
59 | RegisterObject(Pawn); |
---|
60 | |
---|
61 | this->bAlive_ = true; |
---|
62 | this->bReload_ = false; |
---|
63 | |
---|
64 | this->health_ = 0; |
---|
65 | this->maxHealth_ = 0; |
---|
66 | this->initialHealth_ = 0; |
---|
67 | |
---|
68 | this->shieldHealth_ = 0; |
---|
69 | this->initialShieldHealth_ = 0; |
---|
70 | this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max |
---|
71 | this->shieldAbsorption_ = 0.5; |
---|
72 | |
---|
73 | this->reloadRate_ = 0; |
---|
74 | this->reloadWaitTime_ = 1.0f; |
---|
75 | this->reloadWaitCountdown_ = 0; |
---|
76 | |
---|
77 | this->lastHitOriginator_ = 0; |
---|
78 | |
---|
79 | // set damage multiplier to default value 1, meaning nominal damage |
---|
80 | this->damageMultiplier_ = 1; |
---|
81 | |
---|
82 | this->spawnparticleduration_ = 3.0f; |
---|
83 | |
---|
84 | this->aimPosition_ = Vector3::ZERO; |
---|
85 | |
---|
86 | if (GameMode::isMaster()) |
---|
87 | { |
---|
88 | this->weaponSystem_ = new WeaponSystem(this->getContext()); |
---|
89 | this->weaponSystem_->setPawn(this); |
---|
90 | } |
---|
91 | else |
---|
92 | this->weaponSystem_ = 0; |
---|
93 | |
---|
94 | this->setRadarObjectColour(ColourValue::Red); |
---|
95 | this->setRadarObjectShape(RadarViewable::Dot); |
---|
96 | |
---|
97 | this->registerVariables(); |
---|
98 | |
---|
99 | this->isHumanShip_ = this->hasLocalController(); |
---|
100 | |
---|
101 | this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition |
---|
102 | } |
---|
103 | |
---|
104 | Pawn::~Pawn() |
---|
105 | { |
---|
106 | if (this->isInitialized()) |
---|
107 | { |
---|
108 | if (this->weaponSystem_) |
---|
109 | this->weaponSystem_->destroy(); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | void Pawn::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
114 | { |
---|
115 | SUPER(Pawn, XMLPort, xmlelement, mode); |
---|
116 | |
---|
117 | XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); |
---|
118 | XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); |
---|
119 | XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); |
---|
120 | |
---|
121 | XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0); |
---|
122 | XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0); |
---|
123 | XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100); |
---|
124 | XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0); |
---|
125 | |
---|
126 | XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode); |
---|
127 | XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); |
---|
128 | XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); |
---|
129 | |
---|
130 | XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); |
---|
131 | XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); |
---|
132 | XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); |
---|
133 | |
---|
134 | XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0); |
---|
135 | XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); |
---|
136 | |
---|
137 | XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode ); |
---|
138 | } |
---|
139 | |
---|
140 | void Pawn::registerVariables() |
---|
141 | { |
---|
142 | registerVariable(this->bAlive_, VariableDirection::ToClient); |
---|
143 | registerVariable(this->health_, VariableDirection::ToClient); |
---|
144 | registerVariable(this->maxHealth_, VariableDirection::ToClient); |
---|
145 | registerVariable(this->shieldHealth_, VariableDirection::ToClient); |
---|
146 | registerVariable(this->maxShieldHealth_, VariableDirection::ToClient); |
---|
147 | registerVariable(this->shieldAbsorption_, VariableDirection::ToClient); |
---|
148 | registerVariable(this->bReload_, VariableDirection::ToServer); |
---|
149 | registerVariable(this->aimPosition_, VariableDirection::ToServer); // For the moment this variable gets only transfered to the server |
---|
150 | } |
---|
151 | |
---|
152 | void Pawn::tick(float dt) |
---|
153 | { |
---|
154 | SUPER(Pawn, tick, dt); |
---|
155 | |
---|
156 | this->bReload_ = false; |
---|
157 | |
---|
158 | // TODO: use the existing timer functions instead |
---|
159 | if(this->reloadWaitCountdown_ > 0) |
---|
160 | { |
---|
161 | this->decreaseReloadCountdownTime(dt); |
---|
162 | } |
---|
163 | else |
---|
164 | { |
---|
165 | this->addShieldHealth(this->getReloadRate() * dt); |
---|
166 | this->resetReloadCountdown(); |
---|
167 | } |
---|
168 | |
---|
169 | if (GameMode::isMaster()) |
---|
170 | { |
---|
171 | if (this->health_ <= 0 && bAlive_) |
---|
172 | { |
---|
173 | this->fireEvent(); // Event to notify anyone who wants to know about the death. |
---|
174 | this->death(); |
---|
175 | } |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | void Pawn::preDestroy() |
---|
180 | { |
---|
181 | // yay, multiple inheritance! |
---|
182 | this->ControllableEntity::preDestroy(); |
---|
183 | this->PickupCarrier::preDestroy(); |
---|
184 | } |
---|
185 | |
---|
186 | void Pawn::setPlayer(PlayerInfo* player) |
---|
187 | { |
---|
188 | ControllableEntity::setPlayer(player); |
---|
189 | |
---|
190 | if (this->getGametype()) |
---|
191 | this->getGametype()->playerStartsControllingPawn(player, this); |
---|
192 | } |
---|
193 | |
---|
194 | void Pawn::removePlayer() |
---|
195 | { |
---|
196 | if (this->getGametype()) |
---|
197 | this->getGametype()->playerStopsControllingPawn(this->getPlayer(), this); |
---|
198 | |
---|
199 | ControllableEntity::removePlayer(); |
---|
200 | } |
---|
201 | |
---|
202 | |
---|
203 | void Pawn::setHealth(float health) |
---|
204 | { |
---|
205 | this->health_ = std::min(health, this->maxHealth_); //Health can't be set to a value bigger than maxHealth, otherwise it will be reduced at first hit |
---|
206 | } |
---|
207 | |
---|
208 | void Pawn::setShieldHealth(float shieldHealth) |
---|
209 | { |
---|
210 | this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_); |
---|
211 | } |
---|
212 | |
---|
213 | void Pawn::setMaxShieldHealth(float maxshieldhealth) |
---|
214 | { |
---|
215 | this->maxShieldHealth_ = maxshieldhealth; |
---|
216 | } |
---|
217 | |
---|
218 | void Pawn::setReloadRate(float reloadrate) |
---|
219 | { |
---|
220 | this->reloadRate_ = reloadrate; |
---|
221 | } |
---|
222 | |
---|
223 | void Pawn::setReloadWaitTime(float reloadwaittime) |
---|
224 | { |
---|
225 | this->reloadWaitTime_ = reloadwaittime; |
---|
226 | } |
---|
227 | |
---|
228 | void Pawn::decreaseReloadCountdownTime(float dt) |
---|
229 | { |
---|
230 | this->reloadWaitCountdown_ -= dt; |
---|
231 | } |
---|
232 | |
---|
233 | void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) |
---|
234 | { |
---|
235 | // Applies multiplier given by the DamageBoost Pickup. |
---|
236 | if (originator) |
---|
237 | damage *= originator->getDamageMultiplier(); |
---|
238 | |
---|
239 | if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) |
---|
240 | { |
---|
241 | if (shielddamage >= this->getShieldHealth()) |
---|
242 | { |
---|
243 | this->setShieldHealth(0); |
---|
244 | this->setHealth(this->health_ - (healthdamage + damage)); |
---|
245 | } |
---|
246 | else |
---|
247 | { |
---|
248 | this->setShieldHealth(this->shieldHealth_ - shielddamage); |
---|
249 | |
---|
250 | // remove remaining shieldAbsorpton-Part of damage from shield |
---|
251 | shielddamage = damage * this->shieldAbsorption_; |
---|
252 | shielddamage = std::min(this->getShieldHealth(),shielddamage); |
---|
253 | this->setShieldHealth(this->shieldHealth_ - shielddamage); |
---|
254 | |
---|
255 | // set remaining damage to health |
---|
256 | this->setHealth(this->health_ - (damage - shielddamage) - healthdamage); |
---|
257 | } |
---|
258 | |
---|
259 | this->lastHitOriginator_ = originator; |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | // TODO: Still valid? |
---|
264 | /* HIT-Funktionen |
---|
265 | Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte) |
---|
266 | |
---|
267 | */ |
---|
268 | void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage) |
---|
269 | { |
---|
270 | if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) |
---|
271 | { |
---|
272 | this->damage(damage, healthdamage, shielddamage, originator); |
---|
273 | this->setVelocity(this->getVelocity() + force); |
---|
274 | } |
---|
275 | } |
---|
276 | |
---|
277 | |
---|
278 | void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) |
---|
279 | { |
---|
280 | if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) |
---|
281 | { |
---|
282 | this->damage(damage, healthdamage, shielddamage, originator); |
---|
283 | |
---|
284 | if ( this->getController() ) |
---|
285 | this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? |
---|
286 | } |
---|
287 | } |
---|
288 | |
---|
289 | |
---|
290 | void Pawn::kill() |
---|
291 | { |
---|
292 | this->damage(this->health_); |
---|
293 | this->death(); |
---|
294 | } |
---|
295 | |
---|
296 | void Pawn::spawneffect() |
---|
297 | { |
---|
298 | // play spawn effect |
---|
299 | if (!this->spawnparticlesource_.empty()) |
---|
300 | { |
---|
301 | ParticleSpawner* effect = new ParticleSpawner(this->getContext()); |
---|
302 | effect->setPosition(this->getPosition()); |
---|
303 | effect->setOrientation(this->getOrientation()); |
---|
304 | effect->setDestroyAfterLife(true); |
---|
305 | effect->setSource(this->spawnparticlesource_); |
---|
306 | effect->setLifetime(this->spawnparticleduration_); |
---|
307 | } |
---|
308 | } |
---|
309 | |
---|
310 | |
---|
311 | void Pawn::death() |
---|
312 | { |
---|
313 | this->setHealth(1); |
---|
314 | if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) |
---|
315 | { |
---|
316 | // Set bAlive_ to false and wait for PawnManager to do the destruction |
---|
317 | this->bAlive_ = false; |
---|
318 | |
---|
319 | this->setDestroyWhenPlayerLeft(false); |
---|
320 | |
---|
321 | if (this->getGametype()) |
---|
322 | this->getGametype()->pawnKilled(this, this->lastHitOriginator_); |
---|
323 | |
---|
324 | if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) |
---|
325 | { |
---|
326 | // Start to control a new entity if you're the master of a formation |
---|
327 | if(this->hasSlaves()) |
---|
328 | { |
---|
329 | Controller* slave = this->getSlave(); |
---|
330 | ControllableEntity* entity = slave->getControllableEntity(); |
---|
331 | |
---|
332 | |
---|
333 | if(!entity->hasHumanController()) |
---|
334 | { |
---|
335 | // delete the AIController // <-- TODO: delete? nothing is deleted here... should we delete the controller? |
---|
336 | slave->setControllableEntity(0); |
---|
337 | |
---|
338 | // set a new master within the formation |
---|
339 | orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave)); |
---|
340 | |
---|
341 | // start to control a slave |
---|
342 | this->getPlayer()->startControl(entity); |
---|
343 | } |
---|
344 | else |
---|
345 | { |
---|
346 | this->getPlayer()->stopControl(); |
---|
347 | } |
---|
348 | |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | this->getPlayer()->stopControl(); |
---|
353 | } |
---|
354 | } |
---|
355 | if (GameMode::isMaster()) |
---|
356 | { |
---|
357 | // this->deathEffect(); |
---|
358 | this->goWithStyle(); |
---|
359 | } |
---|
360 | } |
---|
361 | } |
---|
362 | void Pawn::goWithStyle() |
---|
363 | { |
---|
364 | this->bAlive_ = false; |
---|
365 | this->setDestroyWhenPlayerLeft(false); |
---|
366 | |
---|
367 | orxout() << "big explosion: " << this->getVelocity() << endl; |
---|
368 | BigExplosion* chunk = new BigExplosion(this->getContext(), this->getVelocity()); |
---|
369 | chunk->setPosition(this->getPosition()); |
---|
370 | // chunk->setVelocity(this->getVelocity()); |
---|
371 | |
---|
372 | } |
---|
373 | void Pawn::deatheffect() |
---|
374 | { |
---|
375 | // play death effect |
---|
376 | { |
---|
377 | ParticleSpawner* effect = new ParticleSpawner(this->getContext()); |
---|
378 | effect->setPosition(this->getPosition()); |
---|
379 | effect->setOrientation(this->getOrientation()); |
---|
380 | effect->setVelocity(this->getVelocity()); |
---|
381 | effect->setDestroyAfterLife(true); |
---|
382 | effect->setSource("Orxonox/explosion2b"); |
---|
383 | effect->setLifetime(4.0f); |
---|
384 | } |
---|
385 | { |
---|
386 | ParticleSpawner* effect = new ParticleSpawner(this->getContext()); |
---|
387 | effect->setPosition(this->getPosition()); |
---|
388 | effect->setOrientation(this->getOrientation()); |
---|
389 | effect->setVelocity(this->getVelocity()); |
---|
390 | effect->setDestroyAfterLife(true); |
---|
391 | effect->setSource("Orxonox/smoke6"); |
---|
392 | effect->setLifetime(4.0f); |
---|
393 | } |
---|
394 | { |
---|
395 | ParticleSpawner* effect = new ParticleSpawner(this->getContext()); |
---|
396 | effect->setPosition(this->getPosition()); |
---|
397 | effect->setOrientation(this->getOrientation()); |
---|
398 | effect->setVelocity(this->getVelocity()); |
---|
399 | effect->setDestroyAfterLife(true); |
---|
400 | effect->setSource("Orxonox/sparks"); |
---|
401 | effect->setLifetime(4.0f); |
---|
402 | } |
---|
403 | for (unsigned int i = 0; i < this->numexplosionchunks_; ++i) |
---|
404 | { |
---|
405 | ExplosionChunk* chunk = new ExplosionChunk(this->getContext()); |
---|
406 | chunk->setPosition(this->getPosition()); |
---|
407 | } |
---|
408 | } |
---|
409 | |
---|
410 | void Pawn::fired(unsigned int firemode) |
---|
411 | { |
---|
412 | if (this->weaponSystem_) |
---|
413 | this->weaponSystem_->fire(firemode); |
---|
414 | } |
---|
415 | |
---|
416 | void Pawn::reload() |
---|
417 | { |
---|
418 | this->bReload_ = true; |
---|
419 | } |
---|
420 | |
---|
421 | void Pawn::postSpawn() |
---|
422 | { |
---|
423 | this->setHealth(this->initialHealth_); |
---|
424 | if (GameMode::isMaster()) |
---|
425 | this->spawneffect(); |
---|
426 | } |
---|
427 | |
---|
428 | /* WeaponSystem: |
---|
429 | * functions load Slot, Set, Pack from XML and make sure all parent-pointers are set. |
---|
430 | * with setWeaponPack you can not just load a Pack from XML but if a Pack already exists anywhere, you can attach it. |
---|
431 | * --> e.g. Pickup-Items |
---|
432 | */ |
---|
433 | void Pawn::addWeaponSlot(WeaponSlot * wSlot) |
---|
434 | { |
---|
435 | this->attach(wSlot); |
---|
436 | if (this->weaponSystem_) |
---|
437 | this->weaponSystem_->addWeaponSlot(wSlot); |
---|
438 | } |
---|
439 | |
---|
440 | WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const |
---|
441 | { |
---|
442 | if (this->weaponSystem_) |
---|
443 | return this->weaponSystem_->getWeaponSlot(index); |
---|
444 | else |
---|
445 | return 0; |
---|
446 | } |
---|
447 | |
---|
448 | void Pawn::addWeaponSet(WeaponSet * wSet) |
---|
449 | { |
---|
450 | if (this->weaponSystem_) |
---|
451 | this->weaponSystem_->addWeaponSet(wSet); |
---|
452 | } |
---|
453 | |
---|
454 | WeaponSet * Pawn::getWeaponSet(unsigned int index) const |
---|
455 | { |
---|
456 | if (this->weaponSystem_) |
---|
457 | return this->weaponSystem_->getWeaponSet(index); |
---|
458 | else |
---|
459 | return 0; |
---|
460 | } |
---|
461 | |
---|
462 | void Pawn::addWeaponPack(WeaponPack * wPack) |
---|
463 | { |
---|
464 | if (this->weaponSystem_) |
---|
465 | { |
---|
466 | this->weaponSystem_->addWeaponPack(wPack); |
---|
467 | this->addedWeaponPack(wPack); |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | void Pawn::addWeaponPackXML(WeaponPack * wPack) |
---|
472 | { |
---|
473 | if (this->weaponSystem_) |
---|
474 | { |
---|
475 | if (!this->weaponSystem_->addWeaponPack(wPack)) |
---|
476 | wPack->destroy(); |
---|
477 | else |
---|
478 | this->addedWeaponPack(wPack); |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | WeaponPack * Pawn::getWeaponPack(unsigned int index) const |
---|
483 | { |
---|
484 | if (this->weaponSystem_) |
---|
485 | return this->weaponSystem_->getWeaponPack(index); |
---|
486 | else |
---|
487 | return 0; |
---|
488 | } |
---|
489 | |
---|
490 | //Tell the Map (RadarViewable), if this is a playership |
---|
491 | void Pawn::startLocalHumanControl() |
---|
492 | { |
---|
493 | // SUPER(ControllableEntity, changedPlayer()); |
---|
494 | ControllableEntity::startLocalHumanControl(); |
---|
495 | this->isHumanShip_ = true; |
---|
496 | } |
---|
497 | |
---|
498 | void Pawn::changedVisibility(void) |
---|
499 | { |
---|
500 | SUPER(Pawn, changedVisibility); |
---|
501 | |
---|
502 | // enable proper radarviewability when the visibility is changed |
---|
503 | this->RadarViewable::settingsChanged(); |
---|
504 | } |
---|
505 | |
---|
506 | |
---|
507 | // A function to check if this pawn's controller is the master of any formationcontroller |
---|
508 | bool Pawn::hasSlaves() |
---|
509 | { |
---|
510 | for (ObjectList<FormationController>::iterator it = |
---|
511 | ObjectList<FormationController>::begin(); |
---|
512 | it != ObjectList<FormationController>::end(); ++it ) |
---|
513 | { |
---|
514 | // checks if the pawn's controller has a slave |
---|
515 | if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController()) |
---|
516 | return true; |
---|
517 | } |
---|
518 | return false; |
---|
519 | } |
---|
520 | |
---|
521 | // A function that returns a slave of the pawn's controller |
---|
522 | Controller* Pawn::getSlave(){ |
---|
523 | for (ObjectList<FormationController>::iterator it = |
---|
524 | ObjectList<FormationController>::begin(); |
---|
525 | it != ObjectList<FormationController>::end(); ++it ) |
---|
526 | { |
---|
527 | if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController()) |
---|
528 | return it->getController(); |
---|
529 | } |
---|
530 | return 0; |
---|
531 | } |
---|
532 | |
---|
533 | |
---|
534 | |
---|
535 | } |
---|