[Orxonox-commit 7715] r12308 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox

ahuwyler at orxonox.net ahuwyler at orxonox.net
Thu Apr 18 15:44:10 CEST 2019


Author: ahuwyler
Date: 2019-04-18 15:44:09 +0200 (Thu, 18 Apr 2019)
New Revision: 12308

Removed:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.h
Modified:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
Log:
Bats are gone

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt	2019-04-18 13:44:09 UTC (rev 12308)
@@ -3,7 +3,6 @@
   OrxoBlox.cc
   OrxoBloxWall.cc
   OrxoBloxBall.cc
-  OrxoBloxBat.cc
   OrxoBloxBot.cc
   OrxoBloxCenterpoint.cc
   OrxoBloxStones.cc

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-04-18 13:44:09 UTC (rev 12308)
@@ -32,19 +32,24 @@
 */
 
 #include "OrxoBlox.h"
+#include "Highscore.h"
 
 #include "core/CoreIncludes.h"
 #include "core/EventIncludes.h"
 #include "core/command/Executor.h"
-#include "core/config/ConfigValueIncludes.h"
 
+
+#include "core/config/ConfigValueIncludes.h"//Remove??
+
 #include "gamestates/GSLevel.h"
-#include "chat/ChatManager.h"
 
+
+#include "chat/ChatManager.h"//Remove?
+
 #include "OrxoBloxCenterpoint.h"
 #include "OrxoBloxBall.h"
-#include "OrxoBloxBat.h"
-#include "OrxoBloxBot.h"
+// #include "OrxoBloxBat.h"//Remove??
+#include "OrxoBloxBot.h"//Remove??
 #include "OrxoBloxStones.h"
 #include "OrxoBloxWall.h"
 
@@ -51,9 +56,7 @@
 
 namespace orxonox
 {
-    // Events to allow to react to scoring of a player, in the level-file.
-    CreateEventName(OrxoBloxCenterpoint, right);
-    CreateEventName(OrxoBloxCenterpoint, left);
+    
 
     RegisterUnloadableClass(OrxoBlox);
 
@@ -147,23 +150,8 @@
             this->ball_->setBatLength(this->center_->getBatLength());
 
 
-
-
-
-            // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
-            for (WeakPtr<orxonox::OrxoBloxBat>& bat : this->bat_)
-            {
-                if (bat == nullptr)
-                {
-                    bat = new OrxoBloxBat(this->center_->getContext());
-                    bat->addTemplate(this->center_->getBattemplate());
-                }
-            }
-
-
             // Create the first Wall.
             this->createWall();
-            orxout()<< "helloo"<< endl;
 
         }
         else // If no centerpoint was specified, an error is thrown and the level is exited.
@@ -256,24 +244,7 @@
         this->futureWall_->setGame(this);
     }
 
-    // void OrxoBlox::createWall(void)             //TODO: random rotation offset between 0 and 3 (times 90°)
-    // {
-    //     // create new futureBrick_
-    //     this->futureWall_ = new TetrisBrick(this->center_->getContext());
 
-
-    //     // Apply the stone template to the stone.
-    //     this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
-
-    //     // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
-    //     this->center_->attach(this->futureBrick_);
-    //     float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
-    //     float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
-        
-    //     this->futureBrick_->setPosition(xPos, yPos, 0.0f);
-    //     this->futureBrick_->setGame(this);
-    // }
-
     /**
     @brief
         Starts the ball with some default speed.

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h	2019-04-18 13:44:09 UTC (rev 12308)
@@ -95,7 +95,7 @@
 
             WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field.
             WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball.
-            WeakPtr<OrxoBloxBat> bat_[0]; //!< The two bats.
+            
             PlayerInfo* player_;
 
             Timer starttimer_; //!< A timer to delay the start of the game.

Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.cc	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.cc	2019-04-18 13:44:09 UTC (rev 12308)
@@ -1,385 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file OrxoBloxAI.cc
-    @brief Implementation of the OrxoBloxAI class.
-*/
-
-#include "OrxoBloxAI.h"
-
-#include "core/CoreIncludes.h"
-#include "core/config/ConfigValueIncludes.h"
-#include "core/command/Executor.h"
-#include "tools/Timer.h"
-
-#include "worldentities/ControllableEntity.h"
-
-#include "OrxoBloxBall.h"
-
-namespace orxonox
-{
-    RegisterUnloadableClass(OrxoBloxAI);
-
-    const static float MAX_REACTION_TIME = 0.4f;
-
-    /**
-    @brief
-        Constructor. Registers and initializes the object.
-    */
-    OrxoBloxAI::OrxoBloxAI(Context* context) : Controller(context)
-    {
-        RegisterObject(OrxoBloxAI);
-
-        this->ball_ = nullptr;
-        this->ballDirection_ = Vector2::ZERO;
-        this->ballEndPosition_ = 0;
-        this->randomOffset_ = 0;
-        this->bChangedRandomOffset_ = false;
-        this->relHysteresisOffset_ = 0.02f;
-        this->strength_ = 0.5f;
-        this->movement_ = 0;
-        this->oldMove_ = 0;
-        this->bOscillationAvoidanceActive_ = false;
-
-        this->setConfigValues();
-    }
-
-    /**
-    @brief
-        Destructor. Cleans up the list fo reaction timers.
-    */
-    OrxoBloxAI::~OrxoBloxAI()
-    {
-        for (std::pair<Timer*, char>& pair : this->reactionTimers_)
-            delete pair.first;
-    }
-
-    /**
-    @brief
-        Sets config values.
-    */
-    void OrxoBloxAI::setConfigValues()
-    {
-        // Sets the strength of the OrxoBloxAi as a config value.
-        SetConfigValue(strength_, 0.5).description("A value from 0 to 1 where 0 is weak and 1 is strong.");
-    }
-
-    /**
-    @brief
-        Is called each tick.
-        Implements the behavior of the OrxoBloxAI (i.e. its intelligence).
-    @param dt
-        The time that has elapsed since the last tick.
-    */
-    void OrxoBloxAI::tick(float dt)
-    {
-        // If either the ball, or the controllable entity (i.e. the bat) don't exist (or aren't set).
-        if (this->ball_  == nullptr || this->getControllableEntity() == nullptr)
-            return;
-
-        Vector3 mypos = this->getControllableEntity()->getPosition();
-        Vector3 ballpos = this->ball_->getPosition();
-        Vector3 ballvel = this->ball_->getVelocity();
-        float hysteresisOffset = this->relHysteresisOffset_ * this->ball_->getFieldDimension().y;
-
-        char move = 0;
-        bool delay = false;
-
-        // Check in which direction the ball is flying
-        if ((mypos.x > 0 && ballvel.x < 0) || (mypos.x < 0 && ballvel.x > 0))
-        {
-            // The ball is flying away
-            this->ballDirection_.x = -1;
-            this->ballDirection_.y = 0;
-            this->bOscillationAvoidanceActive_ = false;
-
-            // Move to the middle
-            if (mypos.z > hysteresisOffset)
-                move = 1;
-            else if (mypos.z < -hysteresisOffset)
-                move = -1;
-        }
-        else if (ballvel.x == 0)
-        {
-            // The ball is standing still
-            this->ballDirection_.x = 0;
-            this->ballDirection_.y = 0;
-            this->bOscillationAvoidanceActive_ = false;
-        }
-        else
-        {
-            // The ball is approaching
-            if (this->ballDirection_.x != 1)
-            {
-                // The ball just started to approach, initialize all values
-                this->ballDirection_.x = 1;
-                this->ballDirection_.y = sgn(ballvel.z);
-                this->ballEndPosition_ = 0;
-                this->randomOffset_ = 0;
-                this->bChangedRandomOffset_ = false;
-
-                this->calculateRandomOffset();
-                this->calculateBallEndPosition();
-                delay = true;
-                this->bOscillationAvoidanceActive_ = false;
-            }
-
-            if (this->ballDirection_.y != sgn(ballvel.z))
-            {
-                // The ball just bounced from a bound, recalculate the predicted end position
-                this->ballDirection_.y = sgn(ballvel.z);
-
-                this->calculateBallEndPosition();
-                delay = true;
-                this->bOscillationAvoidanceActive_ = false;
-            }
-
-            // If the ball is close enough, calculate another random offset to accelerate the ball
-            if (!this->bChangedRandomOffset_)
-            {
-                float timetohit = (-ballpos.x + this->ball_->getFieldDimension().x / 2 * sgn(ballvel.x)) / ballvel.x;
-                if (timetohit < 0.05)
-                {
-                    this->bChangedRandomOffset_ = true;
-                    if (rnd() < this->strength_)
-                        this->calculateRandomOffset();
-                }
-            }
-
-            // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat)
-            if (!this->bOscillationAvoidanceActive_)
-            {
-                float desiredZValue = this->ballEndPosition_ + this->randomOffset_;
-
-                if (mypos.z > desiredZValue + hysteresisOffset * (this->randomOffset_ < 0))
-                    move = 1;
-                else if (mypos.z < desiredZValue - hysteresisOffset * (this->randomOffset_ > 0))
-                    move = -1;
-            }
-
-            if (move != 0 && this->oldMove_ != 0 && move != this->oldMove_ && !delay)
-            {
-                // We had to correct our position because we moved too far
-                // (and delay is false, so we're not in the wrong place because of a new end-position prediction)
-                if (fabs(mypos.z - this->ballEndPosition_) < 0.5 * this->ball_->getBatLength() * this->ball_->getFieldDimension().y)
-                {
-                    // We're not at the right position, but we still hit the ball, so just stay there to avoid oscillation
-                    move = 0;
-                    this->bOscillationAvoidanceActive_ = true;
-                }
-            }
-        }
-
-        this->oldMove_ = move;
-        this->move(move, delay);
-        this->getControllableEntity()->moveFrontBack(this->movement_);
-    }
-
-    /**
-    @brief
-        Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
-        The higher the strength of the AI, the smaller the (expected value of the) error.
-        The result of this method is stored in this->randomOffset_.
-    */
-    void OrxoBloxAI::calculateRandomOffset()
-    {
-        // Calculate the exponent for the position-formula
-        float exp = pow(10.0f, 1.0f - 2.0f*this->strength_); // strength: 0   -> exp = 10
-                                                             // strength: 0.5 -> exp = 1
-                                                             // strength: 1   -> exp = 0.1
-
-        // Calculate the relative position where to hit the ball with the bat
-        float position = pow(rnd(), exp); // exp > 1 -> position is more likely a small number
-                                          // exp < 1 -> position is more likely a large number
-
-        // The position shouldn't be larger than 0.5 (50% of the bat-length from the middle is the end)
-        position *= 0.48f;
-
-        // Both sides are equally probable
-        position *= rndsgn();
-
-        // Calculate the offset in world units
-        this->randomOffset_ = position * this->ball_->getBatLength() * this->ball_->getFieldDimension().y;
-    }
-
-    /**
-    @brief
-        Calculate the end position the ball will be in.
-        The result of this calculation is stored in this->ballEndPosition_.
-    */
-    void OrxoBloxAI::calculateBallEndPosition()
-    {
-        Vector3 position = this->ball_->getPosition();
-        Vector3 velocity = this->ball_->getVelocity();
-        Vector3 acceleration = this->ball_->getAcceleration();
-        Vector2 dimension = this->ball_->getFieldDimension();
-
-        // Calculate bounces. The number of predicted bounces is limited by the AIs strength
-        for (float limit = -0.05f; limit < this->strength_ || this->strength_ > 0.99f; limit += 0.4f)
-        {
-            // calculate the time until the ball reaches the other side
-            float totaltime = (-position.x + dimension.x / 2 * sgn(velocity.x)) / velocity.x;
-
-            // calculate wall bounce position (four possible solutions of the equation: pos.z + vel.z*t + acc.z/2*t^2 = +/- dim.z/2)
-            float bouncetime = totaltime;
-            bool bUpperWall = false;
-
-            if (acceleration.z == 0)
-            {
-                if (velocity.z > 0)
-                {
-                    bUpperWall = true;
-                    bouncetime = (dimension.y/2 - position.z) / velocity.z;
-                }
-                else if (velocity.z < 0)
-                {
-                    bUpperWall = false;
-                    bouncetime = (-dimension.y/2 - position.z) / velocity.z;
-                }
-            }
-            else
-            {
-                // upper wall
-                float temp = velocity.z*velocity.z + 2*acceleration.z*(dimension.y/2 - position.z);
-                if (temp >= 0)
-                {
-                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
-                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
-                    if (t1 > 0 && t1 < bouncetime)
-                    {
-                        bouncetime = t1;
-                        bUpperWall = true;
-                    }
-                    if (t2 > 0 && t2 < bouncetime)
-                    {
-                        bouncetime = t2;
-                        bUpperWall = true;
-                    }
-                }
-                // lower wall
-                temp = velocity.z*velocity.z - 2*acceleration.z*(dimension.y/2 + position.z);
-                if (temp >= 0)
-                {
-                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
-                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
-                    if (t1 > 0 && t1 < bouncetime)
-                    {
-                        bouncetime = t1;
-                        bUpperWall = false;
-                    }
-                    if (t2 > 0 && t2 < bouncetime)
-                    {
-                        bouncetime = t2;
-                        bUpperWall = false;
-                    }
-                }
-            }
-
-            if (bouncetime < totaltime)
-            {
-                // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
-                float randomErrorX = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / OrxoBloxBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
-                float randomErrorZ = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / OrxoBloxBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
-
-                // ball bounces after <bouncetime> seconds, update the position and continue
-                velocity.z = velocity.z + acceleration.z * bouncetime;
-
-                if (bUpperWall)
-                {
-                    position.z = dimension.y / 2;
-                    velocity.z = -fabs(velocity.z) + fabs(randomErrorZ);
-                }
-                else
-                {
-                    position.z = -dimension.y / 2;
-                    velocity.z = fabs(velocity.z) - fabs(randomErrorZ);
-                }
-
-                position.x = position.x + velocity.x * bouncetime + randomErrorX;
-                this->ballEndPosition_ = position.z;
-            }
-            else
-            {
-                // ball doesn't bounce, calculate the end position and return
-                // calculate end-height: current height + slope * distance incl. acceleration
-                this->ballEndPosition_ = position.z + velocity.z * totaltime + acceleration.z / 2 * totaltime * totaltime;
-                return;
-            }
-        }
-    }
-
-    /**
-    @brief
-        Determine the movement the AI will undertake. (Either -1, 0 or 1)
-        The result of this calculation is stored in this->movement_;
-    @param direction
-        The current direction of movement.
-    @param bUseDelay
-        The time by which this move is delayed. (Again, to make the AI less efficient)
-    */
-    void OrxoBloxAI::move(char direction, bool bUseDelay)
-    {
-        // The current direction is either what we're doing right now (movement_) or what is last in the queue
-        char currentDirection = this->movement_;
-        if (this->reactionTimers_.size() > 0)
-            currentDirection = this->reactionTimers_.back().second;
-
-        // Only add changes of direction
-        if (direction == currentDirection)
-            return;
-
-        if (bUseDelay)
-        {
-            // Calculate delay
-            float delay = MAX_REACTION_TIME * (1 - this->strength_);
-
-            // Add a new Timer
-            Timer* timer = new Timer(delay, false, createExecutor(createFunctor(&OrxoBloxAI::delayedMove, this)));
-            this->reactionTimers_.emplace_back(timer, direction);
-        }
-        else
-        {
-            this->movement_ = direction;
-        }
-    }
-
-    /**
-    @brief
-        Is called, when a delayed move takes effect.
-    */
-    void OrxoBloxAI::delayedMove()
-    {
-        // Get the new movement direction from the timer list
-        this->movement_ = this->reactionTimers_.front().second;
-
-        // Destroy the timer and remove it from the list
-        delete this->reactionTimers_.front().first;
-        this->reactionTimers_.pop_front();
-    }
-}

Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.h	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxAI.h	2019-04-18 13:44:09 UTC (rev 12308)
@@ -1,98 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file OrxoBloxAI.h
-    @brief Declaration of the OrxoBloxAI class.
-    @ingroup OrxoBlox
-*/
-
-#ifndef _OrxoBloxAI_H__
-#define _OrxoBloxAI_H__
-
-#include "OrxoBlox/OrxoBloxPrereqs.h"
-
-#include <list>
-
-#include "util/Math.h"
-#include "tools/interfaces/Tickable.h"
-
-#include "controllers/Controller.h"
-#include "OrxoBloxBall.h"
-
-namespace orxonox
-{
-
-    /**
-    @brief
-        The OrxoBloxAI is an artificial intelligence for the @ref orxonox::OrxoBlox "OrxoBlox" gametype.
-
-    @author
-        Fabian 'x3n' Landau
-
-    @ingroup OrxoBlox
-    */
-    class _OrxoBloxExport OrxoBloxAI : public Controller, public Tickable
-    {
-        public:
-            OrxoBloxAI(Context* context); //!< Constructor. Registers and initializes the object.
-            virtual ~OrxoBloxAI();
-
-            void setConfigValues();
-
-            virtual void tick(float dt) override; //!< Implements the behavior of the OrxoBloxAI (i.e. its intelligence).
-
-            /**
-            @brief Set the ball for the AI.
-            @param ball A pointer to the ball.
-            */
-            void setOrxoBloxBall(OrxoBloxBall* ball)
-                { this->ball_ = ball; }
-
-        protected:
-            void calculateRandomOffset(); //!< Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
-            void calculateBallEndPosition(); //!< Calculate the end position the ball will be in.
-            void move(char direction, bool bUseDelay); //!< Determine the movement the AI will undertake.
-            void delayedMove(); //!< Is called, when a delayed move takes effect.
-
-            WeakPtr<OrxoBloxBall> ball_; //!< A weak pointer to the ball.
-            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
-            float ballEndPosition_; //!< The calculated end position of the ball.
-            float randomOffset_; //!< A random offset to introduce random errors (weighted by the strength of the AI) into the AI's behavior.
-            bool bChangedRandomOffset_; //!< Helper boolean, to change the random offset more often.
-            float relHysteresisOffset_; //!< A hysteresis offset.
-            float strength_; //!< The strength of the AI. Ranging from 0 to 1.
-
-            std::list<std::pair<Timer*, char>> reactionTimers_; //!< A list of reaction timers and the directions that take effect when their timer expires.
-            char movement_; //!< The planned movement.
-            char oldMove_; //!< The previous movement.
-            bool bOscillationAvoidanceActive_; //!< Boolean, to avoid oscillations.
-    };
-}
-
-#endif /* _OrxoBloxAI_H__ */

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-04-18 13:44:09 UTC (rev 12308)
@@ -38,7 +38,6 @@
 
 #include "gametypes/Gametype.h"
 
-#include "OrxoBloxBat.h"
 
 #include "sound/WorldSound.h"
 #include "core/XMLPort.h"
@@ -60,11 +59,7 @@
 
         this->speed_ = 0;
         this->accelerationFactor_ = 1.0f;
-        this->bat_ = nullptr;
         this->bDeleteBats_ = false;
-        this->batID_ = new unsigned int[2];
-        this->batID_[0] = OBJECTID_UNKNOWN;
-        this->batID_[1] = OBJECTID_UNKNOWN;
         this->relMercyOffset_ = 0.05f;
 
         this->registerVariables();
@@ -96,7 +91,6 @@
         if (this->isInitialized())
         {
             if (this->bDeleteBats_)
-                delete[] this->bat_;
 
             delete[] this->batID_;
         }
@@ -122,8 +116,6 @@
         registerVariable( this->batlength_ );
         registerVariable( this->speed_ );
         registerVariable( this->relMercyOffset_ );
-        registerVariable( this->batID_[0] );
-        registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBats) );
     }
 
     /**
@@ -216,45 +208,7 @@
         }
     }
 
-    /**
-    @brief
-        Set the bats for the ball.
-    @param bats
-        An array (of size 2) of weak pointers, to be set as the new bats.
-    */
-    void OrxoBloxBall::setBats(WeakPtr<OrxoBloxBat>* bats)
-    {
-        if (this->bDeleteBats_) // If there are already some bats, delete them.
-        {
-            delete[] this->bat_;
-            this->bDeleteBats_ = false;
-        }
 
-        this->bat_ = bats;
-        // Also store their object IDs, for synchronization.
-        this->batID_[0] = this->bat_[0]->getObjectID();
-        this->batID_[1] = this->bat_[1]->getObjectID();
-    }
-
-    /**
-    @brief
-        Get the bats over the network.
-    */
-    void OrxoBloxBall::applyBats()
-    {
-        // Make space for the bats, if they don't exist, yet.
-        if (this->bat_ == nullptr)
-        {
-            this->bat_ = new WeakPtr<OrxoBloxBat>[2];
-            this->bDeleteBats_ = true;
-        }
-
-        if (this->batID_[0] != OBJECTID_UNKNOWN)
-            this->bat_[0] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[0]));
-        if (this->batID_[1] != OBJECTID_UNKNOWN)
-            this->bat_[1] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
-    }
-
     void OrxoBloxBall::setDefScoreSound(const std::string &OrxoBloxSound)
     {
         if( defScoreSound_ )

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h	2019-04-18 13:44:09 UTC (rev 12308)
@@ -120,7 +120,7 @@
             float getBatLength() const
                 { return this->batlength_; }
 
-            void setBats(WeakPtr<OrxoBloxBat>* bats); //!< Set the bats for the ball.
+            
             void applyBats(); //!< Get the bats over the network.
 
             static const float MAX_REL_Z_VELOCITY;
@@ -140,7 +140,6 @@
             float speed_; //!< The speed (in x-direction) of the ball.
             float accelerationFactor_; //!< The acceleration factor of the ball.
             float batlength_; //!< The length of the bats (in z-direction) as percentage of the height of the playing field.
-            WeakPtr<OrxoBloxBat>* bat_; //!< An array with the two bats.
             bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not.
             unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
             float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.

Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.cc	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.cc	2019-04-18 13:44:09 UTC (rev 12308)
@@ -1,155 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file OrxoBloxBat.cc
-    @brief Implementation of the OrxoBloxBat class.
-*/
-
-#include "OrxoBloxBat.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
-    RegisterClass(OrxoBloxBat);
-
-    /**
-    @brief
-        Constructor. Registers and initializes the object.
-    */
-    OrxoBloxBat::OrxoBloxBat(Context* context) : ControllableEntity(context)
-    {
-        RegisterObject(OrxoBloxBat);
-
-        this->movement_ = 0;
-        this->bMoveLocal_ = false;
-        this->speed_ = 60;
-        this->length_ = 0.25;
-        this->fieldHeight_ = 100;
-        this->bSteadiedPosition_ = false;
-
-        this->registerVariables();
-    }
-
-    /**
-    @brief
-        Registers variables to be synchronized over the network.
-    */
-    void OrxoBloxBat::registerVariables()
-    {
-        registerVariable(this->speed_);
-        registerVariable(this->fieldHeight_);
-        registerVariable(this->length_);
-    }
-
-    /**
-    @brief
-        Is called each tick.
-        Moves the bat.
-    @param dt
-        The time since last tick.
-    */
-    void OrxoBloxBat::tick(float dt)
-    {
-        // If the bat is controlled (but not over the network).
-        if (this->hasLocalController())
-        {
-            if (this->movement_ != 0)
-            {
-                // The absolute value of the movement is restricted to be lesser or equal than the speed of the bat.
-                this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_;
-
-                // If moveRightLeft() is used the movement is dependento on wehther it is the right or the left bat, so, it is i.e. dependent on the orientation of the bat.
-                if (this->bMoveLocal_)
-                    this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));
-                else
-                    this->setVelocity(0, 0, this->movement_);
-
-                this->movement_ = 0;
-                this->bSteadiedPosition_ = false;
-            }
-            // If there is no movement but the position has not been steadied, the velocity is set to zero and the position is reaffirmed.
-            else if (!this->bSteadiedPosition_)
-            {
-                // To ensure network synchronicity
-                this->setVelocity(0, 0, 0);
-                this->setPosition(this->getPosition());
-                this->bSteadiedPosition_ = true;
-            }
-        }
-
-        SUPER(OrxoBloxBat, tick, dt);
-
-        // Restrict the position of the bats, for them to always be between the upper and lower delimiters. i.e. the bats stall if they reach the upper or lower boundary.
-        Vector3 position = this->getPosition();
-        if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2)
-            position.z = this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2;
-        if (position.z < -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2)
-            position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2;
-        if (position != this->getPosition())
-        {
-            this->setPosition(position);
-            this->setVelocity( Vector3::ZERO );
-        }
-    }
-
-    /**
-    @brief
-        Overloaded the function to steer the bat up and down.
-    @param value
-        A vector whose first component is the inverse direction in which we want to steer the bat.
-    */
-    void OrxoBloxBat::moveFrontBack(const Vector2& value)
-    {
-        this->bMoveLocal_ = false;
-        this->movement_ = -value.x;
-    }
-
-    /**
-    @brief
-        Overloaded the function to steer the bat up and down.
-    @param value
-        A vector whose first component is the direction in which we wnat to steer the bat.
-    */
-    void OrxoBloxBat::moveRightLeft(const Vector2& value)
-    {
-        this->bMoveLocal_ = true;
-        this->movement_ = value.x;
-    }
-
-    /**
-    @brief
-        Is called when the player changed.
-    */
-    void OrxoBloxBat::changedPlayer()
-    {
-        this->setVelocity(0, 0, 0);
-    }
-}

Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.h	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBat.h	2019-04-18 13:44:09 UTC (rev 12308)
@@ -1,120 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file OrxoBloxBat.h
-    @brief Declaration of the OrxoBloxBat class.
-    @ingroup OrxoBlox
-*/
-
-#ifndef _OrxoBloxBat_H__
-#define _OrxoBloxBat_H__
-
-#include "OrxoBlox/OrxoBloxPrereqs.h"
-
-#include "worldentities/ControllableEntity.h"
-
-namespace orxonox
-{
-
-    /**
-    @brief
-        The OrxoBloxBat class manages the bats for @ref orxonox::OrxoBlox "OrxoBlox", which are the elements controlled by the players.
-
-        It is responsible for the movement (controlled by the players) of the bat.
-
-    @author
-        Fabian 'x3n' Landau
-
-    @ingroup OrxoBlox
-    */
-    class _OrxoBloxExport OrxoBloxBat : public ControllableEntity
-    {
-        public:
-            OrxoBloxBat(Context* context); //!< Constructor. Registers and initializes the object.
-            virtual ~OrxoBloxBat() {}
-
-            virtual void tick(float dt) override;
-
-            virtual void moveFrontBack(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
-            virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
-
-            virtual void changedPlayer() override; //!< Is called when the player changed.
-
-            /**
-            @brief Set the speed of the bat.
-            @param speed The speed to be set.
-            */
-            void setSpeed(float speed)
-                { this->speed_ = speed; }
-            /**
-            @brief Get the speed of the bat.
-            @return Returns the speed of the bat.
-            */
-            float getSpeed() const
-                { return this->speed_; }
-
-            /**
-            @brief Set the height of the playing field.
-            @param height The height of the playing field.
-            */
-            void setFieldHeight(float height)
-                { this->fieldHeight_ = height; }
-            /**
-            @brief Get the height of the playing field.
-            @return Returns the height of the playing field.
-            */
-            float getFieldHeight() const
-                { return this->fieldHeight_; }
-
-            /**
-            @brief Set the length of the bat.
-            @param length The length of the bat (in z-direction) as percentage of the height of the playing field.
-            */
-            void setLength(float length)
-                { this->length_ = length; }
-            /**
-            @brief Get the length of the bat.
-            @return Returns the length of the bat (in z-direction) as percentage of the height of the playing field.
-            */
-            float getLength() const
-                { return this->length_; }
-
-        private:
-            void registerVariables(); //!< Registers variables to be synchronized over the network.
-
-            float movement_; //!< The amount (and direction), in z-direction, of movement of the bat.
-            bool bMoveLocal_; //!< Helper to know whether the movement is caused by moveFrontBack() or moveRightLeft().
-            float speed_; //!< The movement speed of the bat.
-            float length_; //!< The length of the bat (in z-direction) as percentage of the height of the playing field.
-            float fieldHeight_; //!< The height of the playing field.
-            bool bSteadiedPosition_; //!< Helper boolean, to keep track of when to steady the position, to ensure network synchronicity.
-    };
-}
-
-#endif /* _OrxoBloxBat_H__ */

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h	2019-04-18 13:44:09 UTC (rev 12308)
@@ -68,9 +68,8 @@
 namespace orxonox
 {
     class OrxoBlox;
-    class OrxoBloxAI;
     class OrxoBloxBall;
-    class OrxoBloxBat;
+    
     class OrxoBloxCenterpoint;
     class OrxoBloxWall;
     class OrxobloxStones;

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc	2019-04-18 13:00:44 UTC (rev 12307)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc	2019-04-18 13:44:09 UTC (rev 12308)
@@ -41,7 +41,7 @@
             OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
             return orxobloxGametype;
         }
-        else orxout()<<"There is no Gametype! ask Anna"<< endl;
+        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
         return nullptr;
     }
 }
\ No newline at end of file



More information about the Orxonox-commit mailing list