[Orxonox-commit 4944] r9613 - in code/branches/formationupdate: data/levels src/orxonox/controllers src/orxonox/worldentities/pawns
maxima at orxonox.net
maxima at orxonox.net
Tue Apr 9 15:49:06 CEST 2013
Author: maxima
Date: 2013-04-09 15:49:06 +0200 (Tue, 09 Apr 2013)
New Revision: 9613
Modified:
code/branches/formationupdate/data/levels/maxim.oxw
code/branches/formationupdate/src/orxonox/controllers/FormationController.h
code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.h
Log:
A few changes to find the slaves of a pawn.
Modified: code/branches/formationupdate/data/levels/maxim.oxw
===================================================================
--- code/branches/formationupdate/data/levels/maxim.oxw 2013-04-01 12:41:07 UTC (rev 9612)
+++ code/branches/formationupdate/data/levels/maxim.oxw 2013-04-09 13:49:06 UTC (rev 9613)
@@ -2,7 +2,6 @@
name = "Maxim's Test"
description = "Intelligent Formation"
tags = "test"
- screenshot = "presentationxi.png"
/>
<?lua
Modified: code/branches/formationupdate/src/orxonox/controllers/FormationController.h
===================================================================
--- code/branches/formationupdate/src/orxonox/controllers/FormationController.h 2013-04-01 12:41:07 UTC (rev 9612)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.h 2013-04-09 13:49:06 UTC (rev 9613)
@@ -99,6 +99,7 @@
/* Just for testing purposes: report the master. */
FormationController* getMaster( void ) { return myMaster_; }
+ FormationController* getThis( void ) { return this; }
protected:
bool formationFlight_;
Modified: code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc 2013-04-01 12:41:07 UTC (rev 9612)
+++ code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc 2013-04-09 13:49:06 UTC (rev 9613)
@@ -307,26 +307,42 @@
}
}
- void Pawn::death()
+ // Two functions to find the slaves of a Pawn
+ bool Pawn::hasSlaves()
{
- /* TEST TEST This is used to find out if the current pawn is also
- * the master of the formation.
- *
- * NOTE: This does not yet check if the current pawn is actually
- * the humanplayer or not!
- */
- for (ObjectList<FormationController>::iterator it =
- ObjectList<FormationController>::begin();
- it != ObjectList<FormationController>::end(); ++it )
- {
- orxout(user_warning) << "Test! Master: " << it->getMaster()
- << " My controller: " << this->getPlayer()->getController() << endl;
- }
- /* TEST TEST */
+ /* TEST TEST This is used to find out if the current pawn is also
+ * the master of the formation and to find his slaves.
+ *
+ */
+ for (ObjectList<FormationController>::iterator it =
+ ObjectList<FormationController>::begin();
+ it != ObjectList<FormationController>::end(); ++it )
+ {
+ // checks if the dying Pawn has a slave
+ if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
+ {
+ orxout(user_warning) << "This is a Slave of the HumanController: " << it->getThis() << endl;
+ return true;
+ }
+ }
+ return false;
+ /* TEST TEST */
+ }
-
+ Controller* Pawn::getSlave(){
+ for (ObjectList<FormationController>::iterator it =
+ ObjectList<FormationController>::begin();
+ it != ObjectList<FormationController>::end(); ++it )
+ {
+ if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
+ return it->getThis();
+ }
+ return 0;
+ }
+ void Pawn::death()
+ {
this->setHealth(1);
if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
{
@@ -338,14 +354,21 @@
if (this->getGametype())
this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
+
if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
+ {
+ if(this->hasSlaves())
+ {
+ // start to control a slave
+ this->getPlayer()->startControl(this->getSlave()->getControllableEntity());
+ }
this->getPlayer()->stopControl();
-
- if (GameMode::isMaster())
+ }
+ /*if (GameMode::isMaster())
{
// this->deathEffect();
this->goWithStyle();
- }
+ }*/
}
}
void Pawn::goWithStyle()
Modified: code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.h 2013-04-01 12:41:07 UTC (rev 9612)
+++ code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.h 2013-04-09 13:49:06 UTC (rev 9613)
@@ -184,6 +184,8 @@
virtual void removePlayer();
virtual void death();
+ virtual bool hasSlaves();
+ virtual Controller* getSlave();
virtual void goWithStyle();
virtual void deatheffect();
virtual void spawneffect();
More information about the Orxonox-commit
mailing list