[Orxonox-commit 6249] r10906 - in code/branches/campaignHS15: data/levels src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Mon Nov 30 21:34:54 CET 2015
Author: gania
Date: 2015-11-30 21:34:54 +0100 (Mon, 30 Nov 2015)
New Revision: 10906
Modified:
code/branches/campaignHS15/data/levels/AITest.oxw
code/branches/campaignHS15/data/levels/shuttleRetaliation.oxw
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
Log:
tried to fix fighting whn fps is low
Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-30 20:34:54 UTC (rev 10906)
@@ -156,7 +156,7 @@
<!-- 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>
<Template link=spaceshipassff />
@@ -194,7 +194,44 @@
</WingmanController>
</controller>
</SpaceShip>
+ <SpaceShip position="-5000, 1500, -1000" lookat="0,0,0" team=0 name="d1s1d1">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <DivisionController team=0 formationMode="WALL">
+ </DivisionController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="-5000, 1900, -1000" lookat="0,0,0" team=0 name="d1s1s1">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <SectionController team=0>
+ </SectionController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="-5000, 2100, -1000" lookat="0,0,0" team=0 name="d1s1w1">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=0>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="-5000, 2400, -1000" lookat="0,0,0" team=0 name="d1s1w2">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=0>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
+
<SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 name="d2sd1">
<templates>
<Template link=spaceshipassff />
@@ -232,6 +269,43 @@
</WingmanController>
</controller>
</SpaceShip>
+ <SpaceShip position="1000, -1500, 1000" lookat="0,0,0" team=1 name="d2s1d1">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <DivisionController team=1 formationMode="WALL">
+
+ </DivisionController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="1000, -1900, 1000" lookat="0,0,0" team=1 name="d2s1s1">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <SectionController team=1>
+ </SectionController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="1000, -2100, 1000" lookat="0,0,0" team=1 name="d2s1w1">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=1>
+ </WingmanController>
+ </controller>
+ </SpaceShip> -->
+ <SpaceShip position="1000, -2400, 1000" lookat="0,0,0" team=1 name="d2s1w2">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=1>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
<!-- <SpaceShip position="2000, -1500, 3000" lookat="0,0,0" team=1>
<templates>
<Template link=spaceshipassff />
Modified: code/branches/campaignHS15/data/levels/shuttleRetaliation.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/shuttleRetaliation.oxw 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/data/levels/shuttleRetaliation.oxw 2015-11-30 20:34:54 UTC (rev 10906)
@@ -41,8 +41,8 @@
<!-- GLOBAL LUA VARIABLES -->
<?lua
- enemies = 4
- allies = 4
+ enemies = 2
+ allies = 2
radSector = 12000
Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-11-30 20:34:54 UTC (rev 10906)
@@ -52,7 +52,8 @@
this->action_ = Action::NONE;
this->squaredaccuracy_ = 2500;
this->bFirstTick_ = true;
-
+ this->bStartedDodging_ = false;
+ this->timeDodged_ = 0;
RegisterObject(ActionpointController);
}
@@ -77,6 +78,18 @@
{
this->timeout_ -= dt;
}
+ if (this->bStartedDodging_)
+ {
+ this->timeDodged_ += dt;
+ if (this->timeDodged_ > 2.0f)
+ {
+ this->bStartedDodging_ = false;
+ this->timeDodged_ = 0;
+ }
+ }
+ maneuverCounter_ += dt;
+ if (maneuverCounter_ > 6.0f)
+ maneuverCounter_ = 0;
if (timeout_ <= 0)
this->bFiredRocket_ = false;
@@ -109,7 +122,12 @@
// ", speed spawners size = " << this->speedSpawners_.size() << endl;
this->bFirstTick_ = false;
}
-
+ if (this->hasTarget())
+ {
+ this->maneuver();
+ if (static_cast<int>(this->maneuverCounter_*100) % 3 == 0)
+ this->bShooting_ = this->canFire();
+ }
SUPER(ActionpointController, tick, dt);
}
void ActionpointController::action()
@@ -122,6 +140,7 @@
this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
+
// if (this->actionCounter_ % 2 == 0)
//No action -> pop one from stack
if (this->action_ == Action::NONE || this->bTakenOver_)
@@ -235,10 +254,7 @@
this->action();
}
}
- 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_)
// {
@@ -251,7 +267,7 @@
// }
// //----fire if you can----
// this->bShooting_ = this->canFire();
- }
+
this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc 2015-11-30 20:34:54 UTC (rev 10906)
@@ -117,17 +117,15 @@
{
if ( !this->target_ || !this->getControllableEntity())
return;
- maneuverCounter_++;
- if (maneuverCounter_ > 5)
- maneuverCounter_ = 0;
+
Vector3 thisPosition = this->getControllableEntity()->getWorldPosition();
this->setPositionOfTarget(this->target_->getWorldPosition());
//this->setOrientationOfTarget(this->target_->getOrientation());
Vector3 diffVector = this->positionOfTarget_ - thisPosition;
float diffLength = diffVector.length();
Vector3 diffUnit = diffVector/diffLength;
- bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/15.0f)
+ bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/10.0f)
|| this->deltaHp < 0;
//too far? well, come closer then
@@ -139,16 +137,52 @@
this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
}
- //too close? How do u expect to dodge anything? Just attack!
+ else
+ {
+ this->bKeepFormation_ = false;
+ // if (this->actionCounter_ % 3 == 0)
+ if (maneuverCounter_ <= 1.2)
+ {
+ // orxout(internal_error) << "attacking" << endl;
+ this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f);
+ return;
+ }
+ else if (bTargetIsLookingAtThis || diffLength < 700.0f)
+ {
+ // orxout(internal_error) << "dodging" << endl;
+ if (!this->bStartedDodging_)
+ {
+ this->bStartedDodging_ = true;
+ dodge(thisPosition, diffLength, diffUnit);
+ }
+ }
+ else
+ {
+ if (diffLength < 1000)
+ {
+ // orxout(internal_error) << "looking" << endl;
+ this->stopMoving();
+ this->startLookingAtTarget();
+
+ }
+ else
+ {
+ // orxout(internal_error) << "closing up" << endl;
+ this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
+ }
+ }
+ }
+ /*//too close? How do u expect to dodge anything? Just attack!
else if (diffLength < 1000)
{
this->bKeepFormation_ = false;
//at this point, just look and shoot
- if (diffLength < 500)
+ if (diffLength < 1000)
{
this->stopMoving();
this->startLookingAtTarget();
+
}
else
{
@@ -159,7 +193,7 @@
else if (!bTargetIsLookingAtThis)
{
this->bKeepFormation_ = false;
- this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
+ this->setTargetPosition(this->positionOfTarget_ - diffUnit * 900.0f);
}
//That's unfortunate, he is looking and probably shooting... try to dodge what we can...
else
@@ -167,12 +201,12 @@
this->bKeepFormation_ = false;
if (maneuverCounter_ == 0)
{
- this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
+ this->setTargetPosition(this->positionOfTarget_ - diffUnit * 900.0f);
return;
}
if (this->actionCounter_ % 3 == 0)
- dodge(thisPosition, diffUnit);
- }
+ dodge(thisPosition, diffLength, diffUnit);
+ }*/
}
void FightingController::dodgeTowards (Vector3& position)
{
@@ -199,14 +233,23 @@
// orxout(internal_error) << "Dodging towards " << Vector3(x,y,z) << endl;
this->boostControl();
}
- void FightingController::dodge(const Vector3& thisPosition, Vector3& diffUnit)
+ void FightingController::dodge(const Vector3& thisPosition, float diffLength, Vector3& diffUnit)
{
//d.x*x + d.y*y + d.z*z == 0
//z = 1/d.z * (-d.y*y - d.x * x)
- float x = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
- float y = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
+ float x = CommonController::randomInRange (300, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
+ float y = CommonController::randomInRange (300, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
float z = diffUnit.z == 0 ? 0 : (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y);
- this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : diffUnit * 100.0f));
+ if (diffLength < 150.0f)
+ {
+ this->setTargetPosition(this->positionOfTarget_ + Vector3(z,x,y));
+ }
+ else
+ {
+ this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f :
+ (diffLength < 700.0f ? -diffUnit*700.0f : diffUnit * 50.0f)));
+
+ }
this->boostControl();
}
@@ -224,7 +267,7 @@
this->setPositionOfTarget(newPositionOfTarget);
}
- return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 20.0f);
+ return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 10.0f);
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.h 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.h 2015-11-30 20:34:54 UTC (rev 10906)
@@ -66,7 +66,7 @@
void maneuver(); //<! sets this->targetPosition_, which is a Vector3 of where this ship flies. Decision is made based on
//<! the distance to enemy, if being attacked, dodge() is called, otherwise ship just flies towards this->target_.
- void dodge(const Vector3& thisPosition, Vector3& diffUnit); //<! choose a random Vector3 perpendicular to the difference vector between
+ void dodge(const Vector3& thisPosition, float diffLength, Vector3& diffUnit); //<! choose a random Vector3 perpendicular to the difference vector between
//<! this and target_ plus or minus some amount in difference vector direction,
//<! depending on whether it is better to close up or survive.
void dodgeTowards (Vector3& position); //fly towards position and awoid being hit
@@ -83,10 +83,12 @@
int attackRange_;
bool bShooting_;
- int maneuverCounter_;
+ float maneuverCounter_;
bool bLookAtTarget_;
float deltaHp;
float previousHp;
+ bool bStartedDodging_;
+ float timeDodged_;
//WEAPONSYSTEM DATA
int rocketsLeft_;
float timeout_;
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-30 20:34:54 UTC (rev 10906)
@@ -124,8 +124,8 @@
}
if (this->hasTarget())
{
- this->maneuver();
- this->bShooting_ = this->canFire();
+ // this->maneuver();
+ // this->bShooting_ = this->canFire();
// Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
// if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
// {
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-30 19:31:31 UTC (rev 10905)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-30 20:34:54 UTC (rev 10906)
@@ -111,8 +111,8 @@
}
if (this->hasTarget())
{
- this->maneuver();
- this->bShooting_ = this->canFire();
+ // this->maneuver();
+ // this->bShooting_ = this->canFire();
// Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
// if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
// {
More information about the Orxonox-commit
mailing list