[Orxonox-commit 4952] r9621 - in code/branches/formationupdate: data/levels src/orxonox/controllers src/orxonox/worldentities/pawns
maxima at orxonox.net
maxima at orxonox.net
Tue May 7 15:58:33 CEST 2013
Author: maxima
Date: 2013-05-07 15:58:33 +0200 (Tue, 07 May 2013)
New Revision: 9621
Modified:
code/branches/formationupdate/data/levels/maxim.oxw
code/branches/formationupdate/src/orxonox/controllers/FormationController.cc
code/branches/formationupdate/src/orxonox/controllers/FormationController.h
code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
Log:
Modified: code/branches/formationupdate/data/levels/maxim.oxw
===================================================================
--- code/branches/formationupdate/data/levels/maxim.oxw 2013-04-30 14:04:26 UTC (rev 9620)
+++ code/branches/formationupdate/data/levels/maxim.oxw 2013-05-07 13:58:33 UTC (rev 9621)
@@ -19,7 +19,7 @@
<Level
gametype = "Mission"
->
+>
<templates>
<Template link=lodtemplate_default />
</templates>
@@ -48,12 +48,15 @@
<!-- TRIGGERS -->
<DistanceTrigger name="FormationInit" position="800,700,600" target="Pawn" distance=60 stayActive="true" delay=0.1 />
+ <DistanceTrigger name="LetsGo" position="200,-200,1000" target="Pawn" distance=180 stayActive="true" delay=0.1 />
<BlinkingBillboard colour="1,1,0.05"position="200,-200,1000" frequency=0.6 amplitude=3 material="Flares/lensflare" >
</BlinkingBillboard>
+ <DistanceTrigger name="Fight" position="-600,3000,-2000" target="Pawn" distance=180 stayActive="true" delay=0.1 />
+ <BlinkingBillboard colour="0,0,1"position="-600,3000,-2000" frequency=0.6 amplitude=3 material="Flares/lensflare" >
+ </BlinkingBillboard>
-
<Script code="formationcontroller formationflight true" onLoad="false">
<events>
<trigger>
@@ -62,34 +65,69 @@
</events>
</Script> <!-- !!! activates formation behaviour !!! -->
+ <Script code="artificialcontroller setbotlevel 3" onLoad="false">
+ <events>
+ <trigger>
+ <EventListener event=FormationInit />
+ </trigger>
+ </events>
+ </Script>
- <!-- ADDING FORMATION: 5 Swallows -->
- <?lua for i=0,1,1 do
- ?>
- <SpaceShip position="<?lua print(800+i*200) ?>,700,600" lookat="-1300,-600,900" visible="true">
- <templates>
- <Template link=spaceshipswallow />
- </templates>
- <controller>
- <AIController team=0/>
- </controller>
- </SpaceShip>
- <?lua end ?>
-
-
- <!-- ADDING ENEMY FORMATION: 5 Swallows -->
+ <SimpleNotification message="Let's go!">
+ <events>
+ <trigger>
+ <EventListener event="LetsGo" />
+ </trigger>
+ </events>
+ </SimpleNotification>
- <?lua for i=0,1,1 do
- ?>
- <SpaceShip position="<?lua print(5000+i*200) ?>,-200,1000" lookat="-1300,-600,900" visible="true">
- <templates>
- <Template link=spaceshipswallow />
- </templates>
- <controller>
- <AIController team=1/>
- </controller>
- </SpaceShip>
- <?lua end ?>
+
+
+
+<!-- ADDING FORMATION: 2 Swallows -->
+<?lua for i=0,1,1 do
+?>
+ <SpaceShip position="<?lua print(400+i*200) ?>,-200,1000" lookat="-1300,-600,900" visible="true">
+ <!--events>
+ <visibility>
+ <EventListener event="ondock" />
+ </visibility>
+ </events-->
+ <templates>
+ <Template link=spaceshipswallow /> <!--spaceshipTransporter spaceshippirate-->
+ </templates>
+ <controller>
+ <AIController team=0>
+ <events>
+ <activity>
+ <EventListener event="LetsGo" />
+ </activity>
+ </events>
+ </AIController>
+ </controller>
+ </SpaceShip>
+<?lua end ?>
+
+<?lua for i=0,2,1 do
+?>
+
+
+<!-- ENEMY SWALLOWS -->
+ <SpaceShip position="<?lua print(-400+i*200) ?>,3000,-2000" lookat="-1300,-600,900" visible="true">
+ <templates>
+ <Template link=spaceshipswallow />
+ </templates>
+ <controller>
+ <AIController team=1>
+ <events>
+ <activity>
+ <EventListener event="Fight" />
+ </activity>
+ </events>
+ </AIController>
+ </controller>
+ </SpaceShip>
+<?lua end ?>
+
</Scene>
-</Level>
-
+</Level>
\ No newline at end of file
Modified: code/branches/formationupdate/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/controllers/FormationController.cc 2013-04-30 14:04:26 UTC (rev 9620)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.cc 2013-05-07 13:58:33 UTC (rev 9621)
@@ -534,6 +534,7 @@
}
+ // Sets newMaster as the new master within the formation. Called by the master.
void FormationController::setNewMasterWithinFormation(FormationController* newMaster)
{
if(this->state_ != MASTER || newMaster->myMaster_ != this) return;
@@ -564,7 +565,7 @@
/**
- @brief Frees all slaves form a master. Initiated by a master.
+ @brief Frees all slaves from a master. Initiated by a master.
*/
void FormationController::freeSlaves()
{
Modified: code/branches/formationupdate/src/orxonox/controllers/FormationController.h
===================================================================
--- code/branches/formationupdate/src/orxonox/controllers/FormationController.h 2013-04-30 14:04:26 UTC (rev 9620)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.h 2013-05-07 13:58:33 UTC (rev 9621)
@@ -58,7 +58,6 @@
static void followme();
static void passivebehaviour(const bool passive);
static void formationsize(const int size);
- void setNewMasterWithinFormation();
void setNewMasterWithinFormation(FormationController* newMaster);
inline void setFormationFlight(bool formation)
@@ -99,9 +98,8 @@
virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
- /* Just for testing purposes: report the master. */
FormationController* getMaster( void ) { return myMaster_; }
- FormationController* getThis( void ) { return this; }
+ FormationController* getController( void ) { return this; }
FormationController* getSlave( void ) { return this->slaves_.back(); }
protected:
@@ -135,6 +133,7 @@
void commandSlaves();
void takeLeadOfFormation();
void loseMasterState();
+ void setNewMasterWithinFormation();
void freeSlaves();
void forceFreeSlaves();
Modified: code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc 2013-04-30 14:04:26 UTC (rev 9620)
+++ code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc 2013-05-07 13:58:33 UTC (rev 9621)
@@ -308,29 +308,28 @@
}
- /* Two functions to find the slaves of a Pawn
- *
- */
+ // A function to check if this pawn's controller is the master of any formationcontroller
bool Pawn::hasSlaves()
{
for (ObjectList<FormationController>::iterator it =
ObjectList<FormationController>::begin();
it != ObjectList<FormationController>::end(); ++it )
{
- // checks if the Pawn has a slave
+ // checks if the pawn's controller has a slave
if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
return true;
}
return false;
}
+ // A function that returns a slave of the pawn's controller
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 it->getController();
}
return 0;
}
@@ -352,8 +351,7 @@
if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
{
-
- // Do different things if Pawn is the Master of a Formation
+ // Start to control a new entity if you're the master of a formation
if(this->hasSlaves())
{
Controller* slave = this->getSlave();
@@ -362,21 +360,11 @@
// delete the AIController
slave->setControllableEntity(0);
-
- // set new Master
+ // set a new master within the formation
orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave));
- //orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation();
-
- /* TO DO: - setNewMasterWithinFormation() with an argument.
- * - set slave as the new master within the formation
- *
- */
-
// start to control a slave
this->getPlayer()->startControl(entity);
-
-
}
else
{
More information about the Orxonox-commit
mailing list