[Orxonox-commit 6258] r10915 - in code/branches/campaignHS15: data/levels src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Wed Dec 2 10:31:23 CET 2015
Author: gania
Date: 2015-12-02 10:31:23 +0100 (Wed, 02 Dec 2015)
New Revision: 10915
Modified:
code/branches/campaignHS15/data/levels/AITest.oxw
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
Log:
little fix
Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/data/levels/AITest.oxw 2015-12-02 09:31:23 UTC (rev 10915)
@@ -36,6 +36,7 @@
?>
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
<TeamSpawnPoint team=0 position="2000, 2000, 2000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
<!--
<PickupSpawner pickup=largedamageboostpickup position="0,0,0" triggerDistance="20" respawnTime="30" maxSpawnedItems="10" />
@@ -90,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">
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-12-02 09:31:23 UTC (rev 10915)
@@ -39,6 +39,8 @@
ActionpointController::ActionpointController(Context* context) : FightingController(context)
{
+ this->bPatrolling_ = false;
+
this->actionCounter_ = 0;
this->bInLoop_ = false;
this->bLoop_ = false;
@@ -99,6 +101,8 @@
}
void ActionpointController::tick(float dt)
{
+ if (!this->getControllableEntity())
+ return;
if (stop_)
return;
if (this->timeout_ > 0 && this->bFiredRocket_)
@@ -108,7 +112,7 @@
if (this->bStartedDodging_)
{
this->timeDodged_ += dt;
- if (this->timeDodged_ > 2.0f)
+ if (this->timeDodged_ > 4.0f)
{
this->bStartedDodging_ = false;
this->timeDodged_ = 0;
@@ -118,7 +122,7 @@
if (maneuverCounter_ > 6.0f)
maneuverCounter_ = 0;
this->timeOffset_ += dt;
- if (this->timeOffset_ >= 2.0f)
+ if (this->timeOffset_ >= 2.4f)
this->timeOffset_ = 0.0f;
if (timeout_ <= 0)
this->bFiredRocket_ = false;
@@ -132,7 +136,8 @@
this->lookAtTarget(dt);
}
-
+ if (!this->getControllableEntity())
+ return;
if (this->bShooting_)
{
this->doFire();
@@ -156,16 +161,23 @@
// ", speed spawners size = " << this->speedSpawners_.size() << endl;
this->bFirstTick_ = false;
}
-
+ if (!this->getControllableEntity())
+ return;
//maneuver every 0.25 sec ->
- float currentPeriodTime = this->timeOffset_ - static_cast<int>(this->timeOffset_);
- if (this->hasTarget() && ((currentPeriodTime >= 0.25f && currentPeriodTime <= 0.5f) || (currentPeriodTime >= 0.75 && currentPeriodTime <= 0.999f)) && !this->bManeuverCalled_)
+ if (this->hasTarget() &&
+ ((this->timeOffset_ >= 0.4f && this->timeOffset_ < 0.8f) ||
+ (this->timeOffset_ >= 1.2f && this->timeOffset_ < 1.6f) ||
+ (this->timeOffset_ >= 1.8f && this->timeOffset_ < 2.0f) ||
+ (this->timeOffset_ >= 2.2f && this->timeOffset_ < 2.4f)) && !this->bManeuverCalled_)
{
this->bManeuverCalled_ = true;
this->maneuver();
this->bShooting_ = this->canFire();
}
- if ((currentPeriodTime >= 0.0f && currentPeriodTime <= 0.25f) || (currentPeriodTime >= 0.5f && currentPeriodTime <= 0.75f))
+ if ((this->timeOffset_ >= 0.0f && this->timeOffset_ < 0.4f) ||
+ (this->timeOffset_ >= 0.8f && this->timeOffset_ < 1.2f) ||
+ (this->timeOffset_ >= 1.6f && this->timeOffset_ < 1.8f) ||
+ (this->timeOffset_ >= 2.0f && this->timeOffset_ < 2.2f))
this->bManeuverCalled_ = false;
SUPER(ActionpointController, tick, dt);
}
@@ -182,7 +194,6 @@
{
this->startAttackingEnemiesThatAreClose();
}
-
this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
@@ -216,18 +227,13 @@
if (newTarget)
{
this->setAction (Action::FIGHTALL, newTarget);
- this->action();
+ //this->action();
}
else
{
this->nextActionpoint();
- if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
- {
- this->action();
- }
- else
- {
- }
+ this->executeActionpoint();
+
}
}
}
@@ -243,12 +249,12 @@
CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
{
this->setAction (Action::FIGHT, newTarget);
- this->action();
+ //this->action();
}
else
{
this->nextActionpoint();
- this->action();
+ this->executeActionpoint();
}
}
else if (this->hasTarget())
@@ -268,7 +274,7 @@
else
{
this->nextActionpoint();
- this->action();
+ this->executeActionpoint();
}
}
}
@@ -278,7 +284,7 @@
if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
{
this->nextActionpoint();
- this->action();
+ this->executeActionpoint();
}
}
else if (this->action_ == Action::PROTECT)
@@ -286,7 +292,7 @@
if (!this->getProtect())
{
this->nextActionpoint();
- this->action();
+ this->executeActionpoint();
}
this->stayNearProtect();
}
@@ -296,7 +302,7 @@
if (!this->hasTarget())
{
this->nextActionpoint();
- this->action();
+ this->executeActionpoint();
}
}
@@ -598,8 +604,13 @@
return;
if (this->bLoop_)
{
- if (!this->loopActionpoints_.empty())
+ if (this->bPatrolling_)
{
+ this->loopActionpoints_.pop_back();
+ this->bPatrolling_ = false;
+ }
+ else if (!this->loopActionpoints_.empty())
+ {
this->moveBackToTop();
}
}
@@ -688,17 +699,19 @@
CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
<= this->attackRange_ )
{
- if (this->bLoop_)
+ this->setTarget(newTarget);
+ if (this->bLoop_ && !this->bPatrolling_)
{
- Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, true };
+ Point p = { Action::FIGHT, "", Vector3::ZERO, true };
this->loopActionpoints_.push_back(p);
}
- else
+ else if (!this->bPatrolling_)
{
//orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
- Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
+ Point p = { Action::FIGHT, "", Vector3::ZERO, false };
this->parsedActionpoints_.push_back(p);
}
+ this->bPatrolling_ = true;
this->executeActionpoint();
}
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h 2015-12-02 09:31:23 UTC (rev 10915)
@@ -86,6 +86,7 @@
class _OrxonoxExport ActionpointController : public FightingController, public Tickable
{
public:
+
ActionpointController(Context* context);
virtual ~ActionpointController();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-12-02 09:31:23 UTC (rev 10915)
@@ -67,12 +67,12 @@
if (!this->isActive())
return;
SUPER(DivisionController, tick, dt);
- if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.5f && !this->bActionCalled_)
+ if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
{
this->action();
this->bActionCalled_ = true;
}
- if (this->timeOffset_ > 1.0f)
+ if (this->timeOffset_ > 1.6f)
{
this->bActionCalled_ = false;
}
@@ -98,6 +98,7 @@
this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
}
}
+
}
//I wanted to do it different here, but at this point I think nothing will change if I delete that method
@@ -153,4 +154,5 @@
return false;
}
+
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-12-02 09:31:23 UTC (rev 10915)
@@ -66,6 +66,7 @@
private:
//----private variables-----
Timer actionTimer_; //<! Regularly calls action().
+
};
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-12-02 09:31:23 UTC (rev 10915)
@@ -73,15 +73,16 @@
return;
SUPER(SectionController, tick, dt);
- if (this->timeOffset_ >= 0.5f && this->timeOffset_ <= 1.0f && !this->bActionCalled_)
+ if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
{
this->action();
this->bActionCalled_ = true;
}
- if (this->timeOffset_ > 1.5f)
+ if (this->timeOffset_ > 2.0f)
{
this->bActionCalled_ = false;
}
+
}
void SectionController::action()
@@ -153,6 +154,7 @@
}
}
}
+
this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
}
@@ -293,6 +295,7 @@
}
return 0;
}
+
bool SectionController::setWingman(ActionpointController* newWingman)
{
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-12-02 09:31:23 UTC (rev 10915)
@@ -68,8 +68,7 @@
//----private variables-----
Timer actionTimer_; //<! Regularly calls action().
bool bFirstAction_;
-
-
+
};
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-12-02 09:31:23 UTC (rev 10915)
@@ -67,15 +67,47 @@
return;
SUPER(WingmanController, tick, dt);
- if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.5f && !this->bActionCalled_)
+ if (!this->myLeader_)
{
- this->action();
- this->bActionCalled_ = true;
+ if (this->actionTime_ == 2.0f)
+ {
+ if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
+ {
+ this->action();
+ this->bActionCalled_ = true;
+ }
+ if (this->timeOffset_ > 1.6f)
+ {
+ this->bActionCalled_ = false;
+ }
+ }
+ else
+ {
+ if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
+ {
+ this->action();
+ this->bActionCalled_ = true;
+ }
+ if (this->timeOffset_ > 2.0f)
+ {
+ this->bActionCalled_ = false;
+ }
+ }
}
- if (this->timeOffset_ <= 0.5f)
+ else
{
- this->bActionCalled_ = false;
+ if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.4f && !this->bActionCalled_)
+ {
+ this->action();
+ this->bActionCalled_ = true;
+ }
+ if (this->timeOffset_ <= 0.5f)
+ {
+ this->bActionCalled_ = false;
+ }
}
+
+
}
//----action for hard calculations----
@@ -239,11 +271,11 @@
{
if (closestLeader->getIdentifier()->getName() == "SectionController")
{
- this->actionTime_ = 1.0f;
+ this->actionTime_ = 1.6f;
}
else
{
- this->actionTime_ = 1.5f;
+ this->actionTime_ = 2.0f;
}
return closestLeader;
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-12-02 08:23:00 UTC (rev 10914)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-12-02 09:31:23 UTC (rev 10915)
@@ -70,6 +70,8 @@
Timer actionTimer_; //<! Regularly calls action().
bool bFirstAction_;
float actionTime_;
+
+
};
}
More information about the Orxonox-commit
mailing list