[Orxonox-commit 6215] r10872 - in code/branches/campaignHS15: data/levels src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Fri Nov 27 09:45:24 CET 2015
Author: gania
Date: 2015-11-27 09:45:24 +0100 (Fri, 27 Nov 2015)
New Revision: 10872
Modified:
code/branches/campaignHS15/data/levels/AITest.oxw
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
Log:
fixed a bug when loop wouldn't transfer to a slave when master died, shortened executeActionpoint method
Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-27 08:25:52 UTC (rev 10871)
+++ code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-27 08:45:24 UTC (rev 10872)
@@ -34,7 +34,7 @@
<TeamSpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
<!-- HERE STARTS DEMO FOR THE "WAYPOINTS" -->
- <!--
+ <!--
<Model mesh="cube.mesh" scale=8 position=" 0,2000,-600" />
<Model mesh="cube.mesh" scale=8 position=" 0,2000,-800" />
<Model mesh="cube.mesh" scale=8 position="200,2000,-800" />
@@ -61,7 +61,7 @@
<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS.
P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped -->
-
+ <!--
<Model mesh="cube.mesh" scale=8 position="0,0,0" />
<SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
@@ -123,7 +123,7 @@
</templates>
</SpaceShip>
-
+ -->
<!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
<!-- HERE STARTS DEMO FOR FIGHTING -->
<!--
@@ -209,7 +209,7 @@
-->
<!-- HERE ENDS DEMO FOR FIGHTING -->
<!-- HERE STARTS DEMO FOR FORMATIONS -->
- <!--
+
<Model mesh="cube.mesh" scale=8 position=" 0,2000, 0" />
<Model mesh="cube.mesh" scale=8 position=" 0,2000,-2000" />
<Model mesh="cube.mesh" scale=8 position="2000,2000,-2000" />
@@ -258,7 +258,7 @@
</WingmanController>
</controller>
</SpaceShip>
- -->
+
<!-- HERE ENDS DEMO FOR FORMATIONS -->
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-11-27 08:25:52 UTC (rev 10871)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-11-27 08:45:24 UTC (rev 10872)
@@ -228,218 +228,126 @@
//if last element was failed to be parsed, next element will be executed.
void ActionpointController::executeActionpoint()
{
- if (this->bLoop_)
+ Point p;
+ if (this->bLoop_ && !loopActionpoints_.empty())
{
- if (!this->loopActionpoints_.empty())
+ p = loopActionpoints_.back();
+ }
+ else if (this->bLoop_)
+ {
+ this->bLoop_ = false;
+ return;
+ }
+ else if (!this->bLoop_ && !parsedActionpoints_.empty())
+ {
+ p = parsedActionpoints_.back();
+ }
+ else
+ {
+ this->setTarget(0);
+ this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
+ this->action_ = Action::NONE;
+ return;
+ }
+ if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop)
+ {
+ //MOVES all points that are in loop to a loop vector
+ this->fillLoop();
+ this->bLoop_ = true;
+ executeActionpoint();
+ return;
+ }
+ this->action_ = p.action;
+ switch ( this->action_ )
+ {
+ case Action::FIGHT:
{
- this->action_ = this->loopActionpoints_.back().action;
- switch ( this->action_ )
+ std::string targetName = p.name;
+ if (targetName == "")
{
- case Action::FIGHT:
+ break;
+ }
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == targetName)
{
- std::string targetName = this->loopActionpoints_.back().name;
- if (targetName == "")
- {
- break;
- }
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- break;
+ this->setTarget (static_cast<ControllableEntity*>(*itP));
}
- case Action::FLY:
+ }
+ break;
+ }
+ case Action::FLY:
+ {
+ this->setTargetPosition( p.position );
+ if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ case Action::PROTECT:
+ {
+
+ std::string protectName = p.name;
+ if (protectName == "reservedKeyword:human")
+ {
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
{
- this->setTargetPosition( this->loopActionpoints_.back().position );
- if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+ if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
{
- this->nextActionpoint();
- this->executeActionpoint();
+ this->setProtect (static_cast<ControllableEntity*>(*itP));
}
- break;
}
- case Action::PROTECT:
+ }
+ else
+ {
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
{
- std::string protectName = this->loopActionpoints_.back().name;
- if (protectName == "reservedKeyword:human")
+ if (CommonController::getName(*itP) == protectName)
{
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
+ this->setProtect (static_cast<ControllableEntity*>(*itP));
}
- else
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == protectName)
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- if (!this->getProtect())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::NONE:
- {
- break;
- }
- case Action::FIGHTALL:
- {
- break;
- }
- case Action::ATTACK:
- {
- std::string targetName = this->loopActionpoints_.back().name;
-
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- if (!this->hasTarget())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- default:
- {
- break;
- }
-
+ }
}
+ if (!this->getProtect())
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
}
- else
+ case Action::NONE:
{
- this->bLoop_ = false;
+ break;
}
- }
- else
- {
- if (!this->parsedActionpoints_.empty())
+ case Action::FIGHTALL:
{
- if (this->parsedActionpoints_.back().inLoop)
+ break;
+ }
+ case Action::ATTACK:
+ {
+ std::string targetName = p.name;
+
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
{
- //MOVES all points that are in loop to a loop vector
- this->fillLoop();
- this->bLoop_ = true;
- executeActionpoint();
- return;
- }
- this->action_ = this->parsedActionpoints_.back().action;
- switch ( this->action_ )
- {
- case Action::FIGHT:
+ if (CommonController::getName(*itP) == targetName)
{
- std::string targetName = this->parsedActionpoints_.back().name;
- if (targetName == "")
- {
- break;
- }
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- break;
+ this->setTarget (static_cast<ControllableEntity*>(*itP));
}
- case Action::FLY:
- {
- this->setTargetPosition( this->parsedActionpoints_.back().position );
- if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::PROTECT:
- {
-
- std::string protectName = this->parsedActionpoints_.back().name;
- if (protectName == "reservedKeyword:human")
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- else
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == protectName)
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- if (!this->getProtect())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::NONE:
- {
- break;
- }
- case Action::FIGHTALL:
- {
- break;
- }
- case Action::ATTACK:
- {
- std::string targetName = this->parsedActionpoints_.back().name;
-
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- if (!this->hasTarget())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- default:
- break;
}
+ if (!this->hasTarget())
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
}
-
- else
- {
- this->setTarget(0);
- this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
- this->action_ = Action::NONE;
- }
+ default:
+ break;
}
- }
+
+ }
void ActionpointController::stayNearProtect()
@@ -612,7 +520,7 @@
{
this->parsedActionpoints_ = vector;
this->loopActionpoints_ = loop;
- this->bLoop_ = this->bLoop_;
+ this->bLoop_ = b;
this->bTakenOver_ = true;
// orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
}
More information about the Orxonox-commit
mailing list