[Orxonox-commit 6268] r10925 - in code/branches/campaignHS15: data/levels src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Mon Dec 7 09:41:38 CET 2015
Author: gania
Date: 2015-12-07 09:41:38 +0100 (Mon, 07 Dec 2015)
New Revision: 10925
Modified:
code/branches/campaignHS15/data/levels/AITest.oxw
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
Log:
synchronized AI with a static tick counter
Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw 2015-12-07 08:04:38 UTC (rev 10924)
+++ code/branches/campaignHS15/data/levels/AITest.oxw 2015-12-07 08:41:38 UTC (rev 10925)
@@ -91,7 +91,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">
@@ -152,11 +152,11 @@
<Template link=spaceshipassff />
</templates>
</SpaceShip>
-
+ -->
<!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
<!-- HERE STARTS DEMO FOR FIGHTING -->
- <!--
+
<SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
<templates>
@@ -201,7 +201,7 @@
<Template link=spaceshipassff />
</templates>
<controller>
- <DivisionController team=1 formationMode="WALL">
+ <DivisionController team=1 formationMode="DIAMOND">
</DivisionController>
</controller>
@@ -233,7 +233,7 @@
</WingmanController>
</controller>
</SpaceShip>
- -->
+
<!-- HERE ENDS DEMO FOR FIGHTING -->
<!-- HERE STARTS DEMO FOR FORMATIONS -->
<!--
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-12-07 08:04:38 UTC (rev 10924)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-12-07 08:41:38 UTC (rev 10925)
@@ -109,6 +109,9 @@
++ActionpointController::sTicks_;
}
+ if (!this || !this->getControllableEntity())
+ return;
+
if (this->ticks_ == 1)
{
@@ -142,10 +145,7 @@
{
this->lookAtTarget(dt);
}
- if (this->bShooting_)
- {
- this->doFire();
- }
+
if (!this || !this->getControllableEntity())
return;
@@ -158,54 +158,60 @@
this->timeOffset_ = 0.0f;
if (timeout_ <= 0)
this->bFiredRocket_ = false;
- if (!this || !this->getControllableEntity())
- return;
+
if (!this || !this->getControllableEntity())
return;
if (this->timeout_ > 0 && this->bFiredRocket_)
- {
- this->timeout_ -= dt;
- }
- if (this->bStartedDodging_)
- {
- this->timeDodged_ += dt;
- }
- maneuverCounter_ += dt;
+ {
+ this->timeout_ -= dt;
+ }
+ if (this->bStartedDodging_)
+ {
+ this->timeDodged_ += dt;
+ }
+ maneuverCounter_ += dt;
+
if (!this || !this->getControllableEntity())
return;
//maneuver every 0.25 sec ->
int step = 4;
- if (this->hasTarget() && ActionpointController::sTicks_ % 100 == step * (this->actionpointControllerId_))
- {
-
- }
if (ActionpointController::sTicks_ % 100 == step * this->actionpointControllerId_ + 1)
{
+ //orxout (internal_error) << "Team " << this->getControllableEntity()->getTeam() << (this->hasTarget() ? ", got " : ", don't have") << " target" << endl;
this->action();
}
+
+
if (!this || !this->getControllableEntity())
return;
-
- if (this->hasTarget() && ActionpointController::sTicks_ % ActionpointController::nextActionpointControllerId_ == (this->actionpointControllerId_))
+ if (this->hasTarget() && ActionpointController::sTicks_ % (ActionpointController::nextActionpointControllerId_ + 1) == (this->actionpointControllerId_))
{
if (maneuverCounter_ > 6.0f)
- maneuverCounter_ = 0;
+ this->maneuverCounter_ = 0;
if (this->bStartedDodging_ && this->timeDodged_ > 4.0f)
{
this->bStartedDodging_ = false;
this->timeDodged_ = 0;
}
if (!this || !this->getControllableEntity())
- return;
+ return;
this->maneuver();
if (!this || !this->getControllableEntity())
- return;
+ return;
this->bShooting_ = this->canFire();
+
+ if (!this || !this->getControllableEntity())
+ return;
+
+ if (this->bShooting_)
+ {
+ this->doFire();
+ }
+ this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
+ this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
}
- if (!this || !this->getControllableEntity())
- return;
SUPER(ActionpointController, tick, dt);
@@ -226,8 +232,7 @@
if (!this || !this->getControllableEntity())
return;
- this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
- this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
+
if (!this || !this->getControllableEntity())
return;
@@ -513,6 +518,9 @@
return;
}
this->setAction (p.action);
+ if (!this || !this->getControllableEntity())
+ return;
+
switch (this->action_)
{
case Action::FIGHT:
@@ -653,6 +661,9 @@
}
void ActionpointController::moveBackToTop()
{
+ if (!this || !this->getControllableEntity())
+ return;
+
Point temp = loopActionpoints_.back();
loopActionpoints_.pop_back();
std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc 2015-12-07 08:04:38 UTC (rev 10924)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc 2015-12-07 08:41:38 UTC (rev 10925)
@@ -210,6 +210,8 @@
Vector3 newPositionOfTarget = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),
hardcoded_projectile_speed, this->target_->getWorldPosition(),
this->target_->getVelocity());
+ if (!this->target_ || !this->getControllableEntity())
+ return false;
//Vector3.isNaN() is what I used on my machine and it worked...
if (!(std::isnan(newPositionOfTarget.x) || std::isnan(newPositionOfTarget.y) || std::isnan(newPositionOfTarget.z)))
{
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-12-07 08:04:38 UTC (rev 10924)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-12-07 08:41:38 UTC (rev 10925)
@@ -94,6 +94,9 @@
if (!myDivisionLeader_)
{
ActionpointController* newDivisionLeader = findNewDivisionLeader();
+ if (!this || !this->getControllableEntity())
+ return;
+
this->myDivisionLeader_ = newDivisionLeader;
//spread copyOrientation called equally among the division
@@ -127,6 +130,9 @@
}
else if (!this->myDivisionLeader_->bKeepFormation_)
{
+ if (!this || !this->getControllableEntity())
+ return;
+
if (!this->hasTarget())
{
this->chooseTarget();
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-12-07 08:04:38 UTC (rev 10924)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-12-07 08:41:38 UTC (rev 10925)
@@ -119,6 +119,9 @@
if (!this->myLeader_)
{
ActionpointController* newLeader = (findNewLeader());
+ if (!this || !this->getControllableEntity())
+ return;
+
this->myLeader_ = newLeader;
if (this->myLeader_)
{
@@ -146,6 +149,9 @@
}
else if (!this->myLeader_->bKeepFormation_)
{
+ if (!this || !this->getControllableEntity())
+ return;
+
if (!this->hasTarget())
{
this->setTarget(this->myLeader_->getTarget());
@@ -174,6 +180,8 @@
Vector3 WingmanController::getFormationPosition ()
{
+
+
this->setFormationMode( this->myLeader_->getFormationMode() );
Vector3* targetRelativePosition;
this->spread_ = this->myLeader_->getSpread();
More information about the Orxonox-commit
mailing list