[Orxonox-commit 4541] r9213 - in code/branches/newlevel2012: data/levels data/levels/includes data/levels/templates src/modules/towerdefense
weigeltm at orxonox.net
weigeltm at orxonox.net
Fri May 18 16:07:37 CEST 2012
Author: weigeltm
Date: 2012-05-18 16:07:37 +0200 (Fri, 18 May 2012)
New Revision: 9213
Added:
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.cc
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.h
Modified:
code/branches/newlevel2012/data/levels/includes/towerWeaponSettings.oxi
code/branches/newlevel2012/data/levels/templates/spaceshipPirate.oxt
code/branches/newlevel2012/data/levels/templates/tower.oxt
code/branches/newlevel2012/data/levels/towerDefense.oxw
code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt
code/branches/newlevel2012/src/modules/towerdefense/Tower.cc
Log:
tried to fix towers. failed.
Modified: code/branches/newlevel2012/data/levels/includes/towerWeaponSettings.oxi
===================================================================
--- code/branches/newlevel2012/data/levels/includes/towerWeaponSettings.oxi 2012-05-18 14:04:16 UTC (rev 9212)
+++ code/branches/newlevel2012/data/levels/includes/towerWeaponSettings.oxi 2012-05-18 14:07:37 UTC (rev 9213)
@@ -1,7 +1,7 @@
<weaponslots>
<WeaponSlot position="-15.0,-1.5,0" />
- <!--WeaponSlot position=" 15.0,-1.5,0" /-->
- <!--WeaponSlot position=" 0, 0,0" /-->
+ <WeaponSlot position=" 15.0,-1.5,0" />
+ <WeaponSlot position=" 0, 0,0" />
</weaponslots>
<weaponsets>
<WeaponSet firemode=0 />
@@ -19,16 +19,16 @@
</links>
<Weapon>
<attached>
- <Model mesh="LightningGun.mesh" pitch="100" roll="90" yaw="90" position="0,-1.3,0" scale=1/>
- <Model mesh="LightningGun-s.mesh" pitch="78" roll="90" yaw="90" position="0.2,-1.3,0" scale=1 />
- <Model mesh="hs-w01_reduced.mesh" roll="45" pitch="-76" yaw="-45" position="-1.5,1,0.3" scale=100 />
+ <Model mesh="LightningGun.mesh" pitch="100" roll="90" yaw="90" position="0,-1.3,0" scale=20/>
+ <Model mesh="LightningGun-s.mesh" pitch="78" roll="90" yaw="90" position="0.2,-1.3,0" scale=20 />
+ <Model mesh="hs-w01_reduced.mesh" roll="45" pitch="-76" yaw="-45" position="-1.5,1,200" scale=20 />
</attached>
- <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" />
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" />
+ <HsW01 mode=0 munitionpershot=0 delay=0.005 damage=31.4159 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 damage=314.159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" />
<LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20 />
</Weapon>
- <!--Weapon>
+ <Weapon>
<attached>
<Model mesh="LightningGun.mesh" pitch="103" roll="90" yaw="90" position="0,-1.35,0" />
<Model mesh="LightningGun-s.mesh" pitch="103" roll="90" yaw="90" position="0.2,-1.35,0" />
@@ -37,11 +37,11 @@
<HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 1.6, 1.3, -2.0" />
<HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.1, 1.6, -2.0" />
<LightningGun mode=1 muzzleoffset="0,0,0" damage=23 />
- </Weapon-->
- <!--Weapon>
+ </Weapon>
+ <Weapon>
<SimpleRocketFire mode=2 muzzleoffset="0,0,0" damage=30 shielddamage=20 />
<RocketFire mode=3 muzzleoffset="0,0,0" damage=30 healthdamage=50 shielddamage=20 />
- </Weapon-->
+ </Weapon>
</WeaponPack>
<WeaponPack>
Modified: code/branches/newlevel2012/data/levels/templates/spaceshipPirate.oxt
===================================================================
--- code/branches/newlevel2012/data/levels/templates/spaceshipPirate.oxt 2012-05-18 14:04:16 UTC (rev 9212)
+++ code/branches/newlevel2012/data/levels/templates/spaceshipPirate.oxt 2012-05-18 14:07:37 UTC (rev 9213)
@@ -34,11 +34,12 @@
linearDamping = 0.7
angularDamping = 0.9999999
>
+
<engines>
<MultiStateEngine position=" 0, 0, 0" template=spaceshippirateengine />
</engines>
<attached>
- <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="pirate.mesh" />
+ <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=20 mesh="pirate.mesh" />
<BlinkingBillboard position=" 12.7,-3.8,0" material="Examples/Flare" colour="1.0, 1.0, 1" amplitude=0.04 frequency=1 quadratic=1 />
<BlinkingBillboard position="-12.7,-3.8,0" material="Examples/Flare" colour="1.0, 1.0, 1" amplitude=0.04 frequency=1 quadratic=1 phase="90"/>
<BlinkingBillboard position=" 8.7,-0.5,2.5" material="Examples/Flare" colour="1.0, 1.0, 1" amplitude=0.04 frequency=1 quadratic=1 phase="30"/>
Modified: code/branches/newlevel2012/data/levels/templates/tower.oxt
===================================================================
--- code/branches/newlevel2012/data/levels/templates/tower.oxt 2012-05-18 14:04:16 UTC (rev 9212)
+++ code/branches/newlevel2012/data/levels/templates/tower.oxt 2012-05-18 14:07:37 UTC (rev 9213)
@@ -8,19 +8,24 @@
reloadwaittime = 1
collisionType = "dynamic"
- team = 13
+ team = 2
+
>
- <controller>
+
+
+ <controller>
<WaypointPatrolController alertnessradius=10000 team=5>
-
+ <waypoints>
+ <Model mesh="cube.mesh" scale=20 position=" 700, 200, 100" />
+ </waypoints>
</WaypointPatrolController>
</controller>
<attached>
- <Model position="0,0,0" scale=50 mesh="Tower_ME.mesh" />
+ <Model position="0,0,0" scale=45 mesh="Tower.mesh" />
</attached>
<!--collisionShapes>
Modified: code/branches/newlevel2012/data/levels/towerDefense.oxw
===================================================================
--- code/branches/newlevel2012/data/levels/towerDefense.oxw 2012-05-18 14:04:16 UTC (rev 9212)
+++ code/branches/newlevel2012/data/levels/towerDefense.oxw 2012-05-18 14:07:37 UTC (rev 9213)
@@ -75,12 +75,12 @@
<!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
<!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
- <SpaceShip position="-700,-500, 100" lookat="0,0,0" scale=10>
+ <SpaceShip position="-700,-500, 100" lookat="0,0,0" scale=2 team=1 >
<templates>
<Template link=spaceshipassff />
</templates>
<controller>
- <WaypointController accuracy=40>
+ <WaypointController accuracy=60>
<waypoints>
<!-- 1,3 10,3 10,11, 13,11 -->
<Model mesh="cube.mesh" scale=20 position="-700,-500, 100" />
Modified: code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt 2012-05-18 14:04:16 UTC (rev 9212)
+++ code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt 2012-05-18 14:07:37 UTC (rev 9213)
@@ -4,6 +4,7 @@
TowerDefenseCenterpoint.cc
TowerDefenseHUDController.cc
TowerDefensePlayerStats.cc
+
)
ORXONOX_ADD_LIBRARY(TowerDefense
Modified: code/branches/newlevel2012/src/modules/towerdefense/Tower.cc
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/Tower.cc 2012-05-18 14:04:16 UTC (rev 9212)
+++ code/branches/newlevel2012/src/modules/towerdefense/Tower.cc 2012-05-18 14:07:37 UTC (rev 9213)
@@ -27,8 +27,8 @@
this->setCollisionType(WorldEntity::Dynamic);
+ //this->removeAllEngines();
-
/*
this->size_ = 10.0f;
this->delay_ = false;
Added: code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.cc
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.cc (rev 0)
+++ code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.cc 2012-05-18 14:07:37 UTC (rev 9213)
@@ -0,0 +1,144 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#include "TowerDefenseController.h"
+
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateFactory(TowerDefenseController);
+
+ TowerDefenseController::TowerDefenseController(BaseObject* creator) : WaypointController(creator)
+ {
+ RegisterObject(TowerDefenseController);
+
+ this->alertnessradius_ = 500;
+
+ this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&TowerDefenseController::searchEnemy, this)));
+ }
+
+ void TowerDefenseController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(TowerDefenseController, XMLPort, xmlelement, mode);
+
+ XMLPortParam(TowerDefenseController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
+ }
+
+ void TowerDefenseController::tick(float dt)
+ {
+ if (!this->isActive())
+ return;
+
+ if (this->target_)
+ {
+ this->aimAtTarget();
+
+ if (this->bHasTargetPosition_)
+ this->moveToTargetPosition();
+
+ if (this->getControllableEntity() && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
+ this->getControllableEntity()->fire(0);
+ }
+ else
+ {
+ SUPER(TowerDefenseController, tick, dt);
+ }
+ }
+
+
+ bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
+ {
+ if (entity1 == entity2)
+ return true;
+
+ int team1 = -1;
+ int team2 = -1;
+
+ Controller* controller = 0;
+ if (entity1->getController())
+ controller = entity1->getController();
+ else
+ controller = entity1->getXMLController();
+ if (controller)
+ {
+ FormationController* ac = orxonox_cast<FormationController*>(controller);
+ if (ac)
+ team1 = ac->getTeam();
+ }
+
+ if (entity2->getController())
+ controller = entity2->getController();
+ else
+ controller = entity2->getXMLController();
+ if (controller)
+ {
+ FormationController* ac = orxonox_cast<FormationController*>(controller);
+ if (ac)
+ team2 = ac->getTeam();
+ }
+
+
+
+ return (team1 == team2 && team1 != -1);
+ }
+
+
+
+
+
+ void TowerDefenseController::searchEnemy()
+ {
+ this->patrolTimer_.setInterval(rnd());
+
+ if (!this->getControllableEntity())
+ return;
+
+ Vector3 myposition = this->getControllableEntity()->getPosition();
+ float shortestsqdistance = (float)static_cast<unsigned int>(-1);
+
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+ {
+ if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
+ continue;
+
+ float sqdistance = it->getPosition().squaredDistance(myposition);
+ if (sqdistance < shortestsqdistance)
+ {
+ shortestsqdistance = sqdistance;
+ this->target_ = (*it);
+ }
+ }
+
+ if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_))
+ this->target_ = 0;
+ }
+}
Added: code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.h
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.h (rev 0)
+++ code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseController.h 2012-05-18 14:07:37 UTC (rev 9213)
@@ -0,0 +1,61 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _TowerDefenseController_H__
+#define _TowerDefenseController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "tools/Timer.h"
+#include "WaypointController.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport TowerDefenseController : public WaypointController
+ {
+ public:
+ TowerDefenseController(BaseObject* creator);
+ virtual ~TowerDefenseController() {}
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+
+ inline void setAlertnessRadius(float radius)
+ { this->alertnessradius_ = radius; }
+ inline float getAlertnessRadius() const
+ { return this->alertnessradius_; }
+
+ protected:
+ void searchEnemy();
+
+ float alertnessradius_;
+ Timer patrolTimer_;
+ };
+}
+
+#endif /* _TowerDefenseController_H__ */
More information about the Orxonox-commit
mailing list