[Orxonox-commit 7798] r12390 - in code/branches/Boxhead_FS19: data/levels data/levels/templates src/modules/hover src/orxonox/scriptablecontroller
cwaupoti at orxonox.net
cwaupoti at orxonox.net
Thu May 16 16:53:45 CEST 2019
Author: cwaupoti
Date: 2019-05-16 16:53:45 +0200 (Thu, 16 May 2019)
New Revision: 12390
Modified:
code/branches/Boxhead_FS19/data/levels/Hover.oxw
code/branches/Boxhead_FS19/data/levels/templates/spaceshipzombie.oxt
code/branches/Boxhead_FS19/src/modules/hover/Hover.cc
code/branches/Boxhead_FS19/src/modules/hover/Hover.h
code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.h
Log:
Zombie can now approach, tried to add waves
Modified: code/branches/Boxhead_FS19/data/levels/Hover.oxw
===================================================================
--- code/branches/Boxhead_FS19/data/levels/Hover.oxw 2019-05-16 14:37:19 UTC (rev 12389)
+++ code/branches/Boxhead_FS19/data/levels/Hover.oxw 2019-05-16 14:53:45 UTC (rev 12390)
@@ -24,11 +24,9 @@
MAZE_SIZE = MAZE_NUM_CELLS*MAZE_CELL_SIZE
?>
-<Level
+<Level
plugins = hover
gametype = Hover
-
-
>
<templates>
<Template link=lodtemplate_default />
@@ -83,20 +81,12 @@
/>
<SpaceShip position="500,20,500" lookat="50,20,50" name="enemy" health="200" maxhealth="200" initialhealth="200" >
- <templates>
- <Template link=spaceshipzombie />
- </templates>
- <controller>
- <WaypointPatrolController alertnessradius=2000 attackradius=1 team=1 >
- <waypoints>
- <Model mesh="cube.mesh" scale=0 position="15500,15500,15500" />
+ <templates>
+ <Template link=spaceshipzombie />
+ </templates>
+ </SpaceShip>
- </waypoints>
-
- </WaypointPatrolController>
- </controller>
- </SpaceShip>
Modified: code/branches/Boxhead_FS19/data/levels/templates/spaceshipzombie.oxt
===================================================================
--- code/branches/Boxhead_FS19/data/levels/templates/spaceshipzombie.oxt 2019-05-16 14:37:19 UTC (rev 12389)
+++ code/branches/Boxhead_FS19/data/levels/templates/spaceshipzombie.oxt 2019-05-16 14:53:45 UTC (rev 12390)
@@ -6,9 +6,9 @@
spawnparticleduration = 3
explosionchunks = 6
- health = 60
+ health = 200
maxhealth = 200
- initialhealth = 60
+ initialhealth = 100
shieldhealth = 25
initialshieldhealth = 0
@@ -33,8 +33,8 @@
collisionType = "dynamic"
mass = 100
- linearDamping = 0.2
- angularDamping = 0.9999999
+ linearDamping = 0
+ angularDamping = 0
>
@@ -67,6 +67,17 @@
<!-- <?lua
include("../includes/weaponSettingsHover.oxi")
?> -->
+ <controller>
+ <WaypointPatrolController alertnessradius=2000 attackradius=1 team=1 >
+ <waypoints>
+ <Model mesh="cube.mesh" scale=0 position="15500,15500,15500" />
+
+ </waypoints>
+
+ </WaypointPatrolController>
+
+ </controller>
+
</SpaceShip>
</Template>
@@ -112,3 +123,4 @@
</EffectContainer>
</MultiStateEngine>
</Template>
+
Modified: code/branches/Boxhead_FS19/src/modules/hover/Hover.cc
===================================================================
--- code/branches/Boxhead_FS19/src/modules/hover/Hover.cc 2019-05-16 14:37:19 UTC (rev 12389)
+++ code/branches/Boxhead_FS19/src/modules/hover/Hover.cc 2019-05-16 14:53:45 UTC (rev 12390)
@@ -38,9 +38,18 @@
#include "MazeGenerator.h"
#include "core/CoreIncludes.h"
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/pawns/ScriptableControllerDrone.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "tools/Timer.h"
+#include "infos/Bot.h"
+#include "worldentities/pawns/ModularSpaceShip.h"
+#include "graphics/Model.h"
+
+
namespace orxonox
{
RegisterUnloadableClass(Hover);
@@ -54,7 +63,80 @@
this->setHUDTemplate("HoverHUD");
}
+ // void Hover::spawnZombie(std::string id)
+ // {
+ // Identifier *identifier = ClassByString("SpaceShip");
+ // if(!identifier)
+ // {
+ // orxout(user_error) << "Script tried to spawn unknown object" << std::endl;
+ // return;
+ // }
+
+ // if(!identifier->isLoadable())
+ // {
+ // orxout(user_error) << "Script tried to spawn unloadable object" << std::endl;
+ // return;
+ // }
+
+
+ // WorldEntity *entity;
+ // Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext());
+
+
+
+ // orxout(user_status) << "First hit!" << std::endl;
+
+ // if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier()))
+ // {
+ // orxout(user_status) << "Is WorldEntity!" << std::endl;
+ // entity = orxonox_cast<WorldEntity*>(obj);
+ // }
+ // else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier()))
+ // {
+ // // TODO This does not work yet because somehow the controllable entity is not set
+ // // yet at this stage.
+ // // entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity();
+
+ // orxout(user_status) << "Is PlayerInfo!" << std::endl;
+
+ // //use TEMPLATES in the map to define objects that are not present on the map yet
+ // return;
+ // }
+ // else
+ // {
+ // orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl;
+
+ // return;
+ // }
+
+ // if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier())) {
+ // orxout(user_status) << "Is MobileEntity!" << std::endl;
+ // this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity));
+ // }
+
+
+
+ // if(entity->isA(ClassIdentifier<Pawn>::getIdentifier())) {
+ // orxout(user_status) << "Is Pawn!" << std::endl;
+ // this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity));
+ // }
+
+ // this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity));
+
+
+ // ///////////////GOLD!!!!!!!!!!!!!!!////////////////////////
+ // Pawn* pawn = this->controller_->getPawnByID(id);
+
+ // //Attach to pawn
+ // SpaceShip* drone = new SpaceShip(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
+
+ // drone->addTemplate("spaceshipzombie"); //ScriptableControllerDroneTemplate spaceshipescort
+
+ // Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(500,20,500);
+ // drone->setPosition(spawnPosition);
+ // }
+
void Hover::tick(float dt)
{
SUPER(Hover, tick, dt);
@@ -94,8 +176,10 @@
// }
// }
+
+
//Generate 5 flags randomly
// for ( int i = 0; i < 5; i++ )
// {
@@ -116,5 +200,10 @@
// }
// }
// numberOfFlags_ = flags_.size();
+
+ //Spawn Zombies
+ //spawnZombie(z1);
+
+
}
}
Modified: code/branches/Boxhead_FS19/src/modules/hover/Hover.h
===================================================================
--- code/branches/Boxhead_FS19/src/modules/hover/Hover.h 2019-05-16 14:37:19 UTC (rev 12389)
+++ code/branches/Boxhead_FS19/src/modules/hover/Hover.h 2019-05-16 14:53:45 UTC (rev 12390)
@@ -44,6 +44,10 @@
namespace orxonox
{
+
+
+
+
class _HoverExport Hover : public Gametype
{
public:
@@ -57,6 +61,16 @@
inline int getNumberOfFlags() const
{ return this->numberOfFlags_; }
+ void spawnZombie(std::string id);
+
+ /**
+ * @brief Set the position of an object
+ * @param id The ID of the object
+ * @param x The position on the x-axis
+ * @param y The position on the y-axis
+ * @param z The position on the z-axis
+ */
+
private:
WeakPtr<HoverOrigin> origin_;
std::vector<HoverFlag*> flags_;
@@ -65,4 +79,5 @@
};
}
+
#endif /* _Hover_H__ */
Modified: code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
===================================================================
--- code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.cc 2019-05-16 14:37:19 UTC (rev 12389)
+++ code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.cc 2019-05-16 14:53:45 UTC (rev 12390)
@@ -9,8 +9,10 @@
//#include "../modules/objects/collisionshapes/SphereCollisionShape.h"
#include "graphics/Model.h"
#include "worldentities/pawns/ScriptableControllerDrone.h"
+#include "worldentities/pawns/SpaceShip.h"
+
namespace orxonox
{
@@ -41,9 +43,9 @@
LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawn)>::registerFunction<&ScriptableControllerAPI::spawn>(this, lua, "spawn");
LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawnTest)>::registerFunction<&ScriptableControllerAPI::spawnTest>(this, lua, "spawnTest");
+ LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawnZombie)>::registerFunction<&ScriptableControllerAPI::spawnZombie>(this, lua, "spawnZombie");
-
LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::myTestFunction)>::registerFunction<&ScriptableControllerAPI::myTestFunction>(this, lua, "mytestfunction");
LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::moveControllableEntity)>::registerFunction<&ScriptableControllerAPI::moveControllableEntity>(this, lua, "moveControllableEntity");
@@ -288,11 +290,82 @@
orxout(user_status) << "Final hit!" << std::endl;
}
+ void ScriptableControllerAPI::spawnZombie(std::string id)
+ {
+ Identifier *identifier = ClassByString("SpaceShip");
+ if(!identifier)
+ {
+ orxout(user_error) << "Script tried to spawn unknown object" << std::endl;
+ return;
+ }
+ if(!identifier->isLoadable())
+ {
+ orxout(user_error) << "Script tried to spawn unloadable object" << std::endl;
+ return;
+ }
+
+
+ WorldEntity *entity;
+ Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext());
+ orxout(user_status) << "First hit!" << std::endl;
+
+ if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier()))
+ {
+ orxout(user_status) << "Is WorldEntity!" << std::endl;
+ entity = orxonox_cast<WorldEntity*>(obj);
+ }
+ else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier()))
+ {
+ // TODO This does not work yet because somehow the controllable entity is not set
+ // yet at this stage.
+ // entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity();
+
+ orxout(user_status) << "Is PlayerInfo!" << std::endl;
+
+ //use TEMPLATES in the map to define objects that are not present on the map yet
+ return;
+ }
+ else
+ {
+ orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl;
+
+ return;
+ }
+
+ if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier())) {
+ orxout(user_status) << "Is MobileEntity!" << std::endl;
+ this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity));
+ }
+
+
+
+ if(entity->isA(ClassIdentifier<Pawn>::getIdentifier())) {
+ orxout(user_status) << "Is Pawn!" << std::endl;
+ this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity));
+ }
+
+ this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity));
+
+
+ ///////////////GOLD!!!!!!!!!!!!!!!////////////////////////
+ Pawn* pawn = this->controller_->getPawnByID(id);
+
+ //Attach to pawn
+ SpaceShip* drone = new SpaceShip(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
+
+ drone->addTemplate("spaceshipzombie"); //ScriptableControllerDroneTemplate spaceshipescort
+
+ Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(500,20,500);
+ drone->setPosition(spawnPosition);
+ }
+
+
+
void ScriptableControllerAPI::setPosition(std::string id, double x, double y, double z)
{
WorldEntity *entity = this->controller_->getWorldEntityByID(id);
Modified: code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.h
===================================================================
--- code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.h 2019-05-16 14:37:19 UTC (rev 12389)
+++ code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.h 2019-05-16 14:53:45 UTC (rev 12390)
@@ -160,6 +160,18 @@
* @param y The position on the y-axis
* @param z The position on the z-axis
*/
+
+ void spawnZombie(std::string id);
+
+ /**
+ * @brief Set the position of an object
+ * @param id The ID of the object
+ * @param x The position on the x-axis
+ * @param y The position on the y-axis
+ * @param z The position on the z-axis
+ */
+
+
void setPosition(std::string id, double x, double y, double z);
/**
More information about the Orxonox-commit
mailing list