[Orxonox-commit 6278] r10935 - code/branches/campaignHS15/src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Mon Dec 7 15:14:40 CET 2015
Author: gania
Date: 2015-12-07 15:14:40 +0100 (Mon, 07 Dec 2015)
New Revision: 10935
Modified:
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/FightingController.cc
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:
cleaned source up a bit
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-12-07 14:14:40 UTC (rev 10935)
@@ -53,7 +53,6 @@
this->bTakenOver_ = false;
this->action_ = Action::NONE;
this->squaredaccuracy_ = 2500;
- this->bFirstTick_ = true;
this->bStartedDodging_ = false;
this->bDefaultPatrol_ = true;
this->bDefaultFightAll_ = true;
@@ -64,43 +63,23 @@
void ActionpointController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
{
SUPER( ActionpointController, XMLPort, xmlelement, mode );
- // XMLPortEventSink(ActionpointController, BaseObject, "stop", stop, xmlelement, mode);
- // XMLPortEventSink(ActionpointController, BaseObject, "go", stop, xmlelement, mode);
XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint, xmlelement, mode);
XMLPortParam(ActionpointController, "defaultFightAll", setDefaultFightAll, getDefaultFightAll, xmlelement, mode).defaultValues(true);
XMLPortParam(ActionpointController, "defaultPatrol", setDefaultPatrol, getDefaultPatrol, xmlelement, mode).defaultValues(true);
}
- // void ActionpointController::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
- // {
- // SUPER(ActionpointController, XMLEventPort, xmlelement, mode);
- // XMLPortEventSink(ActionpointController, BaseObject, "stop", stop, xmlelement, mode);
- // XMLPortEventSink(ActionpointController, BaseObject, "go", stop, xmlelement, mode);
- // }
- // bool ActionpointController::stop(bool bTriggered, BaseObject* trigger)
- // {
- // this->stop_ = true;
- // return true;
- // }
- // bool ActionpointController::go(bool bTriggered, BaseObject* trigger)
- // {
- // this->stop_ = false;
- // return true;
- // }
ActionpointController::~ActionpointController()
{
loopActionpoints_.clear();
parsedActionpoints_.clear();
actionpoints_.clear();
this->actionpointControllerId_ = 0;
- /*ActionpointController::nextActionpointControllerId_--;
- if (ActionpointController::nextActionpointControllerId_ < 0)
- ActionpointController::nextActionpointControllerId_ = 0;*/
+
}
void ActionpointController::tick(float dt)
{
- if (!this || !this->getControllableEntity() || !this->isActive())
+ if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_)
return;
++this->ticks_;
// orxout (internal_error) << "this id = " << this->actionpointControllerId_ << endl;
@@ -125,16 +104,7 @@
}
//orxout (internal_error) << "first tick was called by id = " << this->actionpointControllerId_ << ", total = " << ActionpointController::nextActionpointControllerId_ << endl;
}
- if (ActionpointController::sTicks_ == 1)
- {
- this->bActionCalled_ = false;
-
- this->bFirstTick_ = false;
- }
-/* if (ActionpointController::sTicks_ % (ActionpointController::nextActionpointControllerId_+1) != this->actionpointControllerId_)
- {
- return;
- }*/
+
if (!this || !this->getControllableEntity())
return;
@@ -150,10 +120,6 @@
if (!this || !this->getControllableEntity())
return;
-
- if (stop_)
- return;
-
if (timeout_ <= 0)
this->bFiredRocket_ = false;
@@ -222,8 +188,7 @@
{
if (!this || !this->getControllableEntity())
return;
- if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
- return;
+
if (this->bDefaultPatrol_ || (this->action_ != Action::FLY && this->action_ != Action::NONE))
{
this->startAttackingEnemiesThatAreClose();
@@ -231,11 +196,6 @@
if (!this || !this->getControllableEntity())
return;
-
- if (!this || !this->getControllableEntity())
- return;
-
- // if (this->actionCounter_ % 2 == 0)
//No action -> pop one from stack
if (this->action_ == Action::NONE || this->bTakenOver_)
{
@@ -246,7 +206,6 @@
}
this->executeActionpoint();
this->bTakenOver_ = false;
- // this->action();
}
if (!this || !this->getControllableEntity())
return;
@@ -261,7 +220,6 @@
if (newTarget)
{
this->setAction (Action::FIGHTALL, newTarget);
- //this->action();
}
else
{
@@ -283,7 +241,6 @@
CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
{
this->setAction (Action::FIGHT, newTarget);
- //this->action();
}
else
{
@@ -759,6 +716,6 @@
}
}
}
- int ActionpointController::nextActionpointControllerId_ = 0;
- int ActionpointController::sTicks_ = 0;
+ unsigned int ActionpointController::nextActionpointControllerId_ = 0;
+ unsigned int ActionpointController::sTicks_ = 0;
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h 2015-12-07 14:14:40 UTC (rev 10935)
@@ -169,10 +169,7 @@
{ this->bDefaultPatrol_ = value; }
bool getDefaultPatrol ()
{ return this->bDefaultPatrol_; }
- // Trigger interface
- // bool stop(bool bTriggered, BaseObject* trigger);
- // bool go(bool bTriggered, BaseObject* trigger);
- // virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+
virtual void stayNearProtect();
virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
@@ -242,27 +239,17 @@
*/
void nextActionpoint();
//----[Actionpoint methods]----
- bool bFirstTick_;
- /* void setSpawners();
- Vector3 bestHealthPickup (float searchRadius);
- // Point closestPickup(PickupType::Value pickupType);
- std::multimap <int, std::pair<PickupSpawner*, bool> > healthSpawners_;
- std::multimap <int, std::pair<PickupSpawner*, bool> > damageSpawners_;
- std::multimap <int, std::pair<PickupSpawner*, bool> > speedSpawners_;
-*/
- bool bActionCalled_;
- bool bManeuverCalled_;
bool bDefaultFightAll_;
- bool bActive_;
bool bPatrolling_;
bool bDefaultPatrol_;
bool stop_;
- static int sTicks_;
- static int nextActionpointControllerId_;
- int actionpointControllerId_;
- int ticks_;
+ static unsigned int sTicks_; //<! a hack? I don't want action() and maneuver() to be called multiple times in a tick, so I keep
+ //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action()
+ static unsigned int nextActionpointControllerId_; //<! if level has 16 ActionpointControllers, than this variable equals to 17 after first tick
+ unsigned int actionpointControllerId_; //<! integer from 0 to nextActionpointControllerId_, different for every ActionpointController in level
+ unsigned int ticks_; //<! local tick counter
private:
Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-12-07 14:14:40 UTC (rev 10935)
@@ -42,7 +42,6 @@
this->target_ = 0;
this->myFollower_ = 0;
this->myWingman_ = 0;
- //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
}
DivisionController::~DivisionController()
@@ -60,23 +59,12 @@
{
SUPER(DivisionController, XMLPort, xmlelement, mode);
- //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
}
void DivisionController::tick(float dt)
{
if (!this->isActive())
return;
SUPER(DivisionController, tick, dt);
- /*if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
- {
- this->action();
- this->bActionCalled_ = true;
- }
- if (this->timeOffset_ > 1.6f)
- {
- this->bActionCalled_ = false;
- }*/
-
}
void DivisionController::action()
Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc 2015-12-07 14:14:40 UTC (rev 10935)
@@ -148,7 +148,6 @@
if (!this || !this->getControllableEntity())
return;
- // if (this->actionCounter_ % 3 == 0)
if (!this->bDodge_)
{
// orxout(internal_error) << "attacking" << endl;
@@ -285,15 +284,12 @@
Pawn* pawn = orxonox_cast<Pawn*> (this->getControllableEntity());
if (pawn)
pawn->setAimPosition (this->positionOfTarget_);
- // if (pawn->getHealth() < 100)
- // orxout(internal_error) << "not full, hp = " << pawn->getHealth() << endl;
+
int firemode;
float distance = CommonController::distance (this->getControllableEntity(), this->target_);
- // firemode = distance < 1500 ? (distance > 800 && distance < 1200 ?
- // (this->rocketsLeft_ > 0 && !this->bFiredRocket_ ? getFiremode("RocketFire") : getFiremode ("HsW01"))
- // : getFiremode("HsW01")) :
- // (distance < 2500 ? getFiremode("LightningGun") : getFiremode("HsW01"));
+
+
if (distance < 1500)
{
if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
@@ -309,17 +305,8 @@
}
}
- // else if (distance < 1000)
- // {
- // if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
- // {
- // firemode = getFiremode ("RocketFire");
- // }
- // else
- // {
- // firemode = getFiremode ("HsW01");
- // }
- // }
+
+
else if (distance < 2000)
{
firemode = getFiremode ("HsW01");
@@ -376,7 +363,6 @@
}//pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
}
- //orxout (internal_error) << this->rocketsLeft_ << " rockets left" << endl;
}
int FightingController::getFiremode(std::string name)
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-12-07 14:14:40 UTC (rev 10935)
@@ -27,11 +27,7 @@
*/
#include "SectionController.h"
-//TODO: formation vectors are wrong, fix it.
-// split classes.
-// weaponsystem.
-//-> Math ?
-
+
namespace orxonox
{
@@ -43,11 +39,9 @@
RegisterObject(SectionController);
this->setFormationMode(FormationMode::FINGER4);
- //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
this->myWingman_ = 0;
this->myDivisionLeader_ = 0;
this->bFirstAction_ = true;
- //orxout(internal_error) << this << "Was created" << endl;
}
@@ -73,16 +67,7 @@
return;
SUPER(SectionController, tick, dt);
- /*if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
- {
- this->action();
- this->bActionCalled_ = true;
- }
- if (this->timeOffset_ > 2.0f)
- {
- this->bActionCalled_ = false;
- }*/
-
+
}
void SectionController::action()
@@ -136,25 +121,8 @@
if (!this->hasTarget())
{
this->chooseTarget();
- //orxout (internal_error) << "Section ain't got no target" << endl;
}
- if (this->hasTarget())
- {
- // this->maneuver();
- // this->bShooting_ = this->canFire();
- // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
- // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
- // {
- // //----choose where to go----
- // this->maneuver();
- // }
- // else
- // {
- // this->dodgeTowards(healthPosition);
- // }
- // //----fire if you can----
- // this->bShooting_ = this->canFire();
- }
+
}
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-12-07 14:14:40 UTC (rev 10935)
@@ -66,7 +66,6 @@
void keepFormation();
private:
//----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-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-12-07 14:14:40 UTC (rev 10935)
@@ -38,7 +38,6 @@
WingmanController::WingmanController(Context* context) : ActionpointController(context)
{
RegisterObject(WingmanController);
- //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
this->myLeader_ = 0;
this->bFirstAction_ = true;
@@ -67,46 +66,6 @@
return;
SUPER(WingmanController, tick, dt);
- if (!this->myLeader_)
- {
- /*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;
- }
- }*/
- }
- else
- {
- /* 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;
- }*/
- }
-
}
@@ -156,23 +115,7 @@
{
this->setTarget(this->myLeader_->getTarget());
}
- if (this->hasTarget())
- {
- // this->maneuver();
- // this->bShooting_ = this->canFire();
- // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
- // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
- // {
- // //----choose where to go----
- // this->maneuver();
- // }
- // else
- // {
- // this->dodgeTowards(healthPosition);
- // }
- // //----fire if you can----
- // this->bShooting_ = this->canFire();
- }
+
}
}
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-12-07 13:49:46 UTC (rev 10934)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-12-07 14:14:40 UTC (rev 10935)
@@ -67,7 +67,6 @@
private:
//----private variables-----
WeakPtr<ActionpointController> myLeader_;
- Timer actionTimer_; //<! Regularly calls action().
bool bFirstAction_;
float actionTime_;
More information about the Orxonox-commit
mailing list