[Orxonox-commit 3904] r8578 - in code/branches/presentation: data/defaultConfig data/levels data/levels/includes data/levels/templates data/particle src/modules/weapons/projectiles src/modules/weapons/weaponmodes src/orxonox/controllers src/orxonox/graphics src/orxonox/items src/orxonox/weaponsystem src/orxonox/worldentities src/orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Wed May 25 21:22:54 CEST 2011
Author: dafrick
Date: 2011-05-25 21:22:53 +0200 (Wed, 25 May 2011)
New Revision: 8578
Added:
code/branches/presentation/data/levels/includes/weaponSettingsImmTest.oxi
code/branches/presentation/data/levels/shieldTest.oxw
code/branches/presentation/data/levels/templates/spaceshipImmTest.oxt
code/branches/presentation/data/particle/Shield.particle
code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.cc
code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.h
Modified:
code/branches/presentation/data/defaultConfig/keybindings.ini
code/branches/presentation/data/levels/includes/weaponSettingsAssff.oxi
code/branches/presentation/data/levels/templates/spaceshipAssff.oxt
code/branches/presentation/src/modules/weapons/projectiles/CMakeLists.txt
code/branches/presentation/src/modules/weapons/projectiles/Projectile.cc
code/branches/presentation/src/modules/weapons/projectiles/Projectile.h
code/branches/presentation/src/modules/weapons/projectiles/Rocket.cc
code/branches/presentation/src/modules/weapons/projectiles/Rocket.h
code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.cc
code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.h
code/branches/presentation/src/modules/weapons/weaponmodes/EnergyDrink.cc
code/branches/presentation/src/modules/weapons/weaponmodes/FusionFire.cc
code/branches/presentation/src/modules/weapons/weaponmodes/HsW01.cc
code/branches/presentation/src/modules/weapons/weaponmodes/LaserFire.cc
code/branches/presentation/src/modules/weapons/weaponmodes/LightningGun.cc
code/branches/presentation/src/modules/weapons/weaponmodes/RocketFire.cc
code/branches/presentation/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
code/branches/presentation/src/orxonox/controllers/Controller.h
code/branches/presentation/src/orxonox/controllers/HumanController.cc
code/branches/presentation/src/orxonox/controllers/HumanController.h
code/branches/presentation/src/orxonox/graphics/Camera.cc
code/branches/presentation/src/orxonox/graphics/Camera.h
code/branches/presentation/src/orxonox/items/Engine.cc
code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.cc
code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.h
code/branches/presentation/src/orxonox/worldentities/ControllableEntity.cc
code/branches/presentation/src/orxonox/worldentities/ControllableEntity.h
code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.h
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Merging game immersion branch into presentation branch.
Modified: code/branches/presentation/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/presentation/data/defaultConfig/keybindings.ini 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/data/defaultConfig/keybindings.ini 2011-05-25 19:22:53 UTC (rev 8578)
@@ -20,7 +20,7 @@
KeyDivide=
KeyDown="scale -1 moveFrontBack"
KeyE="scale -1 rotateRoll"
-KeyEnd=boost
+KeyEnd="boost"
KeyEquals=
KeyEscape="keyESC"
KeyF="scale -1 moveUpDown"
@@ -118,7 +118,7 @@
KeySemicolon=
KeySlash=
KeySleep=
-KeySpace=boost
+KeySpace="boost"
KeyStop=
KeySystemRequest="printScreen"
KeyT="onpress fire 3"
Modified: code/branches/presentation/data/levels/includes/weaponSettingsAssff.oxi
===================================================================
--- code/branches/presentation/data/levels/includes/weaponSettingsAssff.oxi 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/data/levels/includes/weaponSettingsAssff.oxi 2011-05-25 19:22:53 UTC (rev 8578)
@@ -25,7 +25,7 @@
</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" />
- <LightningGun mode=1 muzzleoffset="0,0,0" damage=23 />
+ <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20 />
</Weapon>
<Weapon>
<attached>
@@ -35,11 +35,11 @@
</attached>
<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 />
+ <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20 />
</Weapon>
<Weapon>
- <SimpleRocketFire mode=2 muzzleoffset="0,0,0" damage=50 />
- <RocketFire mode=3 muzzleoffset="0,0,0" damage=100 />
+ <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>
</WeaponPack>
<WeaponPack>
Copied: code/branches/presentation/data/levels/includes/weaponSettingsImmTest.oxi (from rev 8577, code/branches/gameimmersion/data/levels/includes/weaponSettingsImmTest.oxi)
===================================================================
--- code/branches/presentation/data/levels/includes/weaponSettingsImmTest.oxi (rev 0)
+++ code/branches/presentation/data/levels/includes/weaponSettingsImmTest.oxi 2011-05-25 19:22:53 UTC (rev 8578)
@@ -0,0 +1,57 @@
+ <weaponslots>
+ <WeaponSlot position="-15.0,-1.5,0" />
+ <WeaponSlot position=" 15.0,-1.5,0" />
+ <WeaponSlot position=" 0, 0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ <WeaponSet firemode=1 />
+ <WeaponSet firemode=2 />
+ <WeaponSet firemode=3 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+ <DefaultWeaponmodeLink firemode=2 weaponmode=2 />
+ <DefaultWeaponmodeLink firemode=3 weaponmode=3 />
+ </links>
+ <!-- HsW01 is the standard Weapon, 4 slots => 4 Projectiles spawned at one click -->
+ <!-- LightningGun is the spiral weapon, 2 slots -->
+ <!-- SimpleRocket is the target-following rocket -->
+ <!-- Rocket is the player-guided rocket -->
+ <Weapon>
+ <attached>
+ <Model mesh="LightningGun.mesh" pitch="100" roll="90" yaw="90" position="0,-1.3,0" />
+ <!--Model mesh="LightningGun-s.mesh" pitch="78" roll="90" yaw="90" position="0.2,-1.3,0" /-->
+ <Model mesh="hs-w01_reduced.mesh" roll="90" pitch="-76" yaw="-90" position="-1.5,1,0.3" scale=0.6 />
+ </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" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" shielddamage=5 />
+ </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" /-->
+ <Model mesh="hs-w01_reduced.mesh" roll="90" pitch="-104" yaw="-90" position="0,1.3,0.3" scale=0.6 />
+ </attached>
+ <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" healthdamage=0 shielddamage=500 />
+ </Weapon>
+ <Weapon>
+ <SimpleRocketFire mode=2 muzzleoffset="0,0,0" shielddamage=50 />
+ <RocketFire mode=3 muzzleoffset="0,0,0" healthdamage=80 shielddamage=20 />
+ </Weapon>
+ </WeaponPack>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=1 weaponmode=0 />
+ </links>
+ <!--Weapon>
+ <EnergyDrink mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare"muzzleoffset="2,-0.2,-1" />
+ </Weapon-->
+ </WeaponPack>
+ </weapons>
Copied: code/branches/presentation/data/levels/shieldTest.oxw (from rev 8577, code/branches/gameimmersion/data/levels/shieldTest.oxw)
===================================================================
--- code/branches/presentation/data/levels/shieldTest.oxw (rev 0)
+++ code/branches/presentation/data/levels/shieldTest.oxw 2011-05-25 19:22:53 UTC (rev 8578)
@@ -0,0 +1,85 @@
+<LevelInfo
+ name = "Shield Testlevel"
+ description = "A simple Level with one shielded drone to shoot at"
+ tags = "test"
+/>
+
+<?lua
+ include("HUDTemplates3.oxo")
+ include("stats.oxo")
+ include("templates/spaceshipImmTest.oxt")
+ include("templates/lodInformation.oxt")
+?>
+
+<Level
+ name = "shieldTL"
+ description = "LEVEL-DESCRIPTION"
+>
+
+<templates>
+ <Template link=lodtemplate_default />
+</templates>
+
+<Scene
+ ambientlight = "0.8, 0.5, 0.5"
+ skybox = "Orxonox/Starbox"
+>
+
+
+
+
+<Drone name="meineDrohne"
+ primarythrust= "80"
+ auxilarythrust= "10"
+ rotationthrust= "10"
+ mass= "50"
+ linearDamping= "0.9"
+ angularDamping= "0.7"
+
+ health= 100
+ maxhealth= 150
+ inithealth= 200
+
+ shieldhealth= 100
+ initialshieldhealth= 200
+ maxshieldhealth= 250
+
+ shieldabsorption= 1
+
+ reloadrate= "10"
+ reloadwaittime= 1
+
+>
+ <attached>
+ <Model scale="4" mesh="drone.mesh"/>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
+ </collisionShapes>
+</Drone>
+
+<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+
+
+ <?lua
+ for i = 1, 10, 1 do
+ ?>
+ <SpawnPoint position="<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipimmtest />
+ <?lua end ?>
+
+ <GlobalShader compositor="Bloom" visible=false>
+ <events>
+ <visibility>
+ <DistanceTrigger position="0,0,0" distance=30 target="Spectator" switch=true />
+ </visibility>
+ </events>
+ </GlobalShader>
+ <Model position="0,0,0" scale=8 mesh="ast1.mesh" />
+ <StaticEntity position="0,0,0" collisionType=static>
+ <collisionShapes>
+ <SphereCollisionShape radius="20" />
+ </collisionShapes>
+ </StaticEntity>
+
+ </Scene>
+</Level>
Modified: code/branches/presentation/data/levels/templates/spaceshipAssff.oxt
===================================================================
--- code/branches/presentation/data/levels/templates/spaceshipAssff.oxt 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/data/levels/templates/spaceshipAssff.oxt 2011-05-25 19:22:53 UTC (rev 8578)
@@ -11,10 +11,25 @@
maxhealth = 200
initialhealth = 100
- primaryThrust = 100;
- auxilaryThrust = 30;
- rotationThrust = 25;
+ shieldhealth = 30
+ initialshieldhealth = 30
+ maxshieldhealth = 50
+ shieldabsorption = 0.8
+ reloadrate = 1
+ reloadwaittime = 1
+ primaryThrust = 100
+ auxilaryThrust = 30
+ rotationThrust = 25
+
+ boostPower = 15
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 7
+
collisionType = "dynamic"
mass = 100
linearDamping = 0.7
Copied: code/branches/presentation/data/levels/templates/spaceshipImmTest.oxt (from rev 8577, code/branches/gameimmersion/data/levels/templates/spaceshipImmTest.oxt)
===================================================================
--- code/branches/presentation/data/levels/templates/spaceshipImmTest.oxt (rev 0)
+++ code/branches/presentation/data/levels/templates/spaceshipImmTest.oxt 2011-05-25 19:22:53 UTC (rev 8578)
@@ -0,0 +1,106 @@
+<Template name=spaceshipimmtest>
+ <SpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipassffcameras
+ engine = spaceshipassffengine
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 100
+ maxhealth = 200
+ initialhealth = 100
+
+ primaryThrust = 100;
+ auxilaryThrust = 30;
+ rotationThrust = 25;
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+
+ shakeFrequency = 15
+ >
+ <attached>
+ <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
+ <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
+ <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+<?lua
+ include("includes/weaponSettingsImmTest.oxi")
+?>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipassffcameras defaults=0>
+ <SpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,10, 40" drag=true mouselook=true />
+ <CameraPosition position="0,20, 80" drag=true mouselook=true />
+ <CameraPosition position="0,30,120" drag=true mouselook=true />
+ <!--CameraPosition position="0,150,-25" pitch=-90 drag=true />
+ <CameraPosition position="0,0,-40" yaw=180 drag=true />
+ <CameraPosition position="0,3,-14" yaw=0 />
+ <CameraPosition position="-50,5,-8" yaw=-90 drag=true />
+ <CameraPosition position="50,5,-8" yaw=90 drag=true /-->
+ </camerapositions>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipassffengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 2
+
+ speedfront = 150
+ speedback = 50
+ speedleftright = 50
+ speedupdown = 50
+
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
+ accelerationfront = 500
+ accelerationbrake = 500
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ >
+ <EffectContainer condition="idle">
+ <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+ <FadingBillboard mainstate=activity active=false scale=0.1 position="0, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+<!--
+ <Light mainstate=visibility position=" 8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
+ <Light mainstate=visibility position="-8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
+-->
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+ <EffectContainer condition="brake">
+ <FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.3 position="-8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.15 position=" 8, 0, 6" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.15 position="-8, 0, 6" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ </MultiStateEngine>
+</Template>
+
Copied: code/branches/presentation/data/particle/Shield.particle (from rev 8577, code/branches/gameimmersion/data/particle/Shield.particle)
===================================================================
--- code/branches/presentation/data/particle/Shield.particle (rev 0)
+++ code/branches/presentation/data/particle/Shield.particle 2011-05-25 19:22:53 UTC (rev 8578)
@@ -0,0 +1,49 @@
+
+particle_system Orxonox/Shield
+{
+ quota 2000
+ material PE/lensflare
+ particle_width 25
+ particle_height 25
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter HollowEllipsoid
+ {
+ angle 0
+ colour 0 0.298701 1 0.1
+ colour_range_start 0 0.298701 1 0.1
+ colour_range_end 0 0.298701 1 0.1
+ direction 0 1 0
+ emission_rate 2000
+ position 0 0 0
+ velocity 0
+ velocity_min 0
+ velocity_max 0
+ time_to_live 0.1
+ time_to_live_min 0.1
+ time_to_live_max 0.3
+ duration 0.1
+ duration_min 0.1
+ duration_max 0.2
+ repeat_delay 1000000
+ repeat_delay_min 1000000
+ repeat_delay_max 1000000
+ width 100
+ height 100
+ depth 100
+ inner_width 0.999999
+ inner_height 0.999999
+ inner_depth 0.999999
+ }
+}
Copied: code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.cc (from rev 8577, code/branches/gameimmersion/src/modules/weapons/projectiles/BasicProjectile.cc)
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.cc (rev 0)
+++ code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -0,0 +1,131 @@
+/*
+ * 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:
+ * simonmie
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "BasicProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/GameMode.h"
+#include "core/command/Executor.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
+#include "worldentities/pawns/Pawn.h"
+#include "graphics/ParticleSpawner.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
+ BasicProjectile::BasicProjectile() : OrxonoxClass()
+ {
+ RegisterRootObject(BasicProjectile);// - register the BasicProjectile class to the core
+
+ this->bDestroy_ = false;
+
+ // Default damage must be zero, otherwise it would be above zero if no settings are made in the weaponsettings xml file.
+ // same thing for all weaponmodes files
+ this->damage_ = 0;
+ this->healthdamage_ = 0;
+ this->shielddamage_ = 0;
+ }
+
+ BasicProjectile::~BasicProjectile()
+ {
+ }
+
+ /* The function called when a projectile hits another thing.
+ * calls the hit-function, starts the reload countdown, displays visual effects
+ * hit is defined in src/orxonox/worldentities/pawns/pawn.cc
+ */
+ bool BasicProjectile::basicCollidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint, Pawn* owner, BasicProjectile* this_)
+ {
+ if (!this_->getBDestroy() && GameMode::isMaster())
+ {
+ if (otherObject == owner) //prevents you from shooting yourself
+ return false;
+
+ this_->setBDestroy(true); // If something is hit, the object is destroyed and can't hit something else.
+ // The projectile is destroyed by its tick()-function (in the following tick).
+
+ Pawn* victim = orxonox_cast<Pawn*>(otherObject); //if otherObject isn't a Pawn, then victim is NULL
+
+ WorldEntity* entity = orxonox_cast<WorldEntity*>(this_);
+ assert(entity); //entity must not be null
+
+
+ // if visual effects after destruction cause problems, put this block below the effects code block
+ if (victim)
+ {
+ victim->hit(owner, contactPoint, this_->getDamage(), this_->getHealthDamage(), this_->getShieldDamage());
+ victim->startReloadCountdown();
+ }
+
+ // visual effects for being hit, depending on whether the shield is hit or not
+ if (owner) //if the owner does not exist (anymore?), no effects are displayed.
+ {
+ // damping and explosion effect is only played if the victim is no pawn (see cast above)
+ // or if the victim is a pawn, has no shield left, is still alive and any damage goes to the health
+ if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0 && (this_->getDamage() > 0 || this_->getHealthDamage() > 0)))
+ {
+ {
+ ParticleSpawner* effect = new ParticleSpawner(owner->getCreator());
+ effect->setPosition(entity->getPosition());
+ effect->setOrientation(entity->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/explosion3");
+ effect->setLifetime(2.0f);
+ }
+ // second effect with same condition
+ {
+ ParticleSpawner* effect = new ParticleSpawner(owner->getCreator());
+ effect->setPosition(entity->getPosition());
+ effect->setOrientation(entity->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/smoke4");
+ effect->setLifetime(3.0f);
+ }
+ }
+
+ // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead
+ if (victim && victim->hasShield() && (this_->getDamage() > 0 || this_->getShieldDamage() > 0) && victim->getHealth() > 0)
+ {
+ ParticleSpawner* effect = new ParticleSpawner(owner->getCreator());
+ effect->setPosition(entity->getPosition());
+ effect->setOrientation(entity->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/Shield");
+ effect->setLifetime(0.5f);
+ }
+ }
+
+ }
+ return false;
+ }
+}
Copied: code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.h (from rev 8577, code/branches/gameimmersion/src/modules/weapons/projectiles/BasicProjectile.h)
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.h (rev 0)
+++ code/branches/presentation/src/modules/weapons/projectiles/BasicProjectile.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -0,0 +1,83 @@
+/*
+ * 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:
+ * simonmie
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _BasicProjectile_H__
+#define _BasicProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ class _WeaponsExport BasicProjectile : public virtual OrxonoxClass
+ {
+ public:
+ BasicProjectile();
+
+ virtual ~BasicProjectile();
+
+ static bool basicCollidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint, Pawn* owner, BasicProjectile* this_);
+
+ void basicDestroyObject();
+
+ inline void setDamage(float damage)
+ { this->damage_ = damage; }
+ inline float getDamage() const
+ { return this->damage_; }
+
+ inline void setHealthDamage(float healthdamage)
+ { this->healthdamage_ = healthdamage; }
+ inline float getHealthDamage() const
+ { return this->healthdamage_; }
+
+ inline void setShieldDamage(float shielddamage)
+ { this->shielddamage_ = shielddamage; } //ShieldDamage wird korrekt gesettet vom XML-File
+ inline float getShieldDamage() const
+ { return this->shielddamage_; }
+
+
+ inline void setBDestroy(bool bDestroy)
+ { this->bDestroy_ = bDestroy; }
+ inline float getBDestroy() const
+ { return this->bDestroy_; }
+
+
+ private:
+// WeakPtr<Pawn> owner_; //owner cannot be set in BasicProjectile, because it's already defined in MobileEntity and Movable Entity
+
+ float damage_;
+ float healthdamage_;
+ float shielddamage_;
+
+ bool bDestroy_;
+ };
+}
+
+#endif /* _BasicProjectile_H__ */
Modified: code/branches/presentation/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/CMakeLists.txt 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/CMakeLists.txt 2011-05-25 19:22:53 UTC (rev 8578)
@@ -5,4 +5,5 @@
LightningGunProjectile.cc
Rocket.cc
SimpleRocket.cc
+ BasicProjectile.cc
)
Modified: code/branches/presentation/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/Projectile.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/Projectile.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -40,17 +40,14 @@
{
CreateFactory(Projectile);
- Projectile::Projectile(BaseObject* creator) : MovableEntity(creator)
+ Projectile::Projectile(BaseObject* creator) : MovableEntity(creator), BasicProjectile()
{
RegisterObject(Projectile);
this->setConfigValues();
- this->bDestroy_ = false;
this->owner_ = 0;
- this->damage_ = 15;
// Get notification about collisions
-
if (GameMode::isMaster())
{
this->setMass(1.0);
@@ -83,7 +80,7 @@
if (!this->isActive())
return;
- if (this->bDestroy_)
+ if (this->getBDestroy())
this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick()
}
@@ -93,40 +90,11 @@
this->destroy();
}
+ /* Calls the collidesAgainst function of BasicProjectile
+ */
bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
- if (!this->bDestroy_ && GameMode::isMaster())
- {
- if (otherObject == this->owner_)
- return false;
-
- this->bDestroy_ = true;
-
- if (this->owner_)
- {
- {
- ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
- effect->setPosition(this->getPosition());
- effect->setOrientation(this->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/explosion3");
- effect->setLifetime(2.0f);
- }
- {
- ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
- effect->setPosition(this->getPosition());
- effect->setOrientation(this->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/smoke4");
- effect->setLifetime(3.0f);
- }
- }
-
- Pawn* victim = orxonox_cast<Pawn*>(otherObject);
- if (victim)
- victim->hit(this->owner_, contactPoint, this->damage_);
- }
- return false;
+ return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
}
void Projectile::setOwner(Pawn* owner)
Modified: code/branches/presentation/src/modules/weapons/projectiles/Projectile.h
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/Projectile.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/Projectile.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -34,9 +34,11 @@
#include "tools/Timer.h"
#include "worldentities/MovableEntity.h"
+#include "BasicProjectile.h"
+
namespace orxonox
{
- class _WeaponsExport Projectile : public MovableEntity
+ class _WeaponsExport Projectile : public MovableEntity, public BasicProjectile
{
public:
Projectile(BaseObject* creator);
@@ -48,20 +50,14 @@
virtual void tick(float dt);
virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
- inline void setDamage(float damage)
- { this->damage_ = damage; }
- inline float getDamage() const
- { return this->damage_; }
-
void setOwner(Pawn* owner);
inline Pawn* getOwner() const
{ return this->owner_; }
+
private:
WeakPtr<Pawn> owner_;
float lifetime_;
- float damage_;
- bool bDestroy_;
Timer destroyTimer_;
};
}
Modified: code/branches/presentation/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/Rocket.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/Rocket.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Oliver Scheuss
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -51,12 +51,11 @@
@brief
Constructor. Registers the object and initializes some default values.
*/
- Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator)
+ Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile()
{
RegisterObject(Rocket);// - register the Rocket class to the core
this->localAngularVelocity_ = 0;
- this->bDestroy_ = false;
this->lifetime_ = 100;
if (GameMode::isMaster())
@@ -145,8 +144,8 @@
void Rocket::setOwner(Pawn* owner)
{
this->owner_ = owner;
- this->player_ = this->owner_->getPlayer();
- this->owner_->getPlayer()->startTemporaryControl(this);
+ this->player_ = this->getOwner()->getPlayer();
+ this->getOwner()->getPlayer()->startTemporaryControl(this);
if( GameMode::isMaster() )
{
@@ -174,48 +173,17 @@
if( GameMode::isMaster() )
{
- if( this->bDestroy_ )
+ if( this->getBDestroy() )
this->destroy();
}
}
+ /* Calls the collidesAgainst function of BasicProjectile
+ */
bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
- if (!this->bDestroy_ && GameMode::isMaster())
- {
- if (otherObject == this->owner_)
- return false;
-
- this->bDestroy_ = true;
-
- if (this->owner_)
- {
- {
- ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
- effect->setPosition(this->getPosition());
- effect->setOrientation(this->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/explosion4");
- effect->setLifetime(2.0f);
- }
-
- {
- ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
- effect->setPosition(this->getPosition());
- effect->setOrientation(this->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/smoke4");
- effect->setLifetime(3.0f);
- }
- }
-
- Pawn* victim = orxonox_cast<Pawn*>(otherObject);
- if (victim)
- victim->hit(this->owner_, contactPoint, this->damage_);
-// this->destroy();
- }
- return false;
+ return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
}
void Rocket::destroyObject()
@@ -232,19 +200,16 @@
void Rocket::fired(unsigned int firemode)
{
-// if (this->owner_)
-// {
- this->destroy();
-// }
+ this->destroy();
}
void Rocket::destructionEffect()
{
ParticleSpawner *effect1, *effect2;
- if( this->owner_ )
+ if( this->getOwner() )
{
- effect1 = new ParticleSpawner(this->owner_->getCreator());
- effect2 = new ParticleSpawner(this->owner_->getCreator());
+ effect1 = new ParticleSpawner(this->getOwner()->getCreator());
+ effect2 = new ParticleSpawner(this->getOwner()->getCreator());
}
else
{
Modified: code/branches/presentation/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/Rocket.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/Rocket.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Oliver Scheuss
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -34,6 +34,8 @@
#include "tools/Timer.h"
#include "worldentities/ControllableEntity.h"
+#include "BasicProjectile.h"
+
namespace orxonox
{
class ConeCollisionShape;
@@ -45,7 +47,7 @@
@author
Oli Scheuss
*/
- class _WeaponsExport Rocket : public ControllableEntity
+ class _WeaponsExport Rocket : public ControllableEntity, public BasicProjectile
{
public:
Rocket(BaseObject* creator);
@@ -108,17 +110,11 @@
inline Pawn* getOwner() const
{ return this->owner_; }
- inline void setDamage(float damage)
- { this->damage_ = damage; }
- inline float getDamage() const
- { return this->damage_; }
virtual void fired(unsigned int firemode);
private:
WeakPtr<Pawn> owner_;
Vector3 localAngularVelocity_;
- float damage_;
- bool bDestroy_;
WeakPtr<PlayerInfo> player_;
Timer destroyTimer_;
Modified: code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Oliver Scheuss
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -47,16 +47,15 @@
CreateFactory(SimpleRocket);
- SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator)
+ SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile()
{
RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core
this->localAngularVelocity_ = 0;
- this->bDestroy_ = false;
this->lifetime_ = 120;
this->setMass(15);
- COUT(4) << "simplerocket constructed\n";
+// COUT(4) << "simplerocket constructed\n";
if (GameMode::isMaster())
{
@@ -114,7 +113,7 @@
} else
this->disableFire();
- if( this->bDestroy_ )
+ if( this->getBDestroy() )
this->destroy();
}
@@ -158,51 +157,15 @@
void SimpleRocket::setOwner(Pawn* owner)
{
this->owner_ = owner;
- this->player_ = this->owner_->getPlayer();
+ this->player_ = this->getOwner()->getPlayer();
}
-
-
+ /* Calls the collidesAgainst function of BasicProjectile
+ */
bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
- if (!this->bDestroy_ && GameMode::isMaster())
- {
- if (otherObject == this->owner_)
- return false;
-
- this->bDestroy_ = true;
-
- if (this->owner_)
- {
- {
- ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
- effect->setPosition(this->getPosition());
- effect->setOrientation(this->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/explosion4");
- effect->setLifetime(2.0f);
- }
-
- {
- ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
- effect->setPosition(this->getPosition());
- effect->setOrientation(this->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/smoke4");
- effect->setLifetime(3.0f);
- }
- }
-
- float dmg = this->damage_;
-// if (this->owner_)
-// dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
-
- Pawn* victim = orxonox_cast<Pawn*>(otherObject);
- if (victim)
- victim->hit(this->owner_, contactPoint, dmg);
- }
- return false;
+ return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
}
void SimpleRocket::destroyObject()
Modified: code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/projectiles/SimpleRocket.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Oliver Scheuss
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -35,6 +35,8 @@
#include "worldentities/ControllableEntity.h"
#include "graphics/ParticleSpawner.h"
+#include "BasicProjectile.h"
+
namespace orxonox
{
class ConeCollisionShape;
@@ -45,7 +47,7 @@
@author
Gabriel Nadler (Original file: Oli Scheuss)
*/
- class _WeaponsExport SimpleRocket : public ControllableEntity
+ class _WeaponsExport SimpleRocket : public ControllableEntity, public BasicProjectile
{
public:
SimpleRocket(BaseObject* creator);
@@ -110,20 +112,14 @@
void setOwner(Pawn* owner);
inline Pawn* getOwner() const
{ return this->owner_; }
+
inline bool hasFuel() const
{ return this->fuel_; }
- inline void setDamage(float damage)
- { this->damage_ = damage; }
- inline float getDamage() const
- { return this->damage_; }
-
private:
WeakPtr<Pawn> owner_;
Vector3 localAngularVelocity_;
- float damage_;
- bool bDestroy_;
bool fuel_; //!< Bool is true while the rocket "has fuel"
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/EnergyDrink.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/EnergyDrink.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/EnergyDrink.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Hagen Seifert
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -49,7 +49,7 @@
RegisterObject(EnergyDrink);
this->reloadTime_ = 0.25;
- this->damage_ = 15;
+ this->damage_ = 0; //default 15
this->speed_ = 2500;
this->delay_ = 0;
this->setMunitionName("FusionMunition");
@@ -96,6 +96,8 @@
muzzleFlash->setMaterial(this->material_);
}
+ /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer()
+ */
void EnergyDrink::shot()
{
Projectile* projectile = new Projectile(this);
@@ -111,6 +113,8 @@
projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
EnergyDrink::muendungsfeuer();
}
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/FusionFire.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/FusionFire.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/FusionFire.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Martin Polak
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -47,12 +47,14 @@
this->reloadTime_ = 1.0;
this->bParallelReload_ = false;
- this->damage_ = 40;
+ this->damage_ = 0; //default 40
this->speed_ = 1250;
this->setMunitionName("FusionMunition");
}
+ /* Creates the projectile (BillboardProjectile) object, sets its properties to the FusionFire properties
+ */
void FusionFire::fire()
{
BillboardProjectile* projectile = new BillboardProjectile(this);
@@ -64,6 +66,9 @@
projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f));
}
}
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/HsW01.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/HsW01.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Hagen Seifert
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -50,7 +50,7 @@
RegisterObject(HsW01);
this->reloadTime_ = 0.25;
- this->damage_ = 15;
+ this->damage_ = 0; //default 15
this->speed_ = 2500;
this->delay_ = 0;
this->setMunitionName("LaserMunition");
@@ -108,6 +108,8 @@
muzzleFlash->setMaterial(this->material_);
}
+ /* Creates the projectile object, sets its properties to the HsW01 properties, calls muendungsfeuer()
+ */
void HsW01::shot()
{
assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
@@ -125,6 +127,8 @@
projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
HsW01::muendungsfeuer();
}
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/LaserFire.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/LaserFire.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/LaserFire.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Martin Polak
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -44,12 +44,14 @@
RegisterObject(LaserFire);
this->reloadTime_ = 0.25;
- this->damage_ = 15;
+ this->damage_ = 0; //default 15
this->speed_ = 1250;
this->setMunitionName("LaserMunition");
}
+ /* Creates the projectile object, sets its properties to the LaserFire properties
+ */
void LaserFire::fire()
{
ParticleProjectile* projectile = new ParticleProjectile(this);
@@ -60,5 +62,7 @@
projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
}
}
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/LightningGun.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/LightningGun.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/LightningGun.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Joel Smely
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -44,7 +44,7 @@
RegisterObject(LightningGun);
this->reloadTime_ = 1;
- this->damage_ = 100;
+ this->damage_ = 0; //default 100
this->speed_ = 150;
this->setMunitionName("LaserMunition");
@@ -55,6 +55,8 @@
{
}
+ /* Creates the projectile (LightningGunProjectile) object, sets its properties to the LightningGun properties
+ */
void LightningGun::fire()
{
LightningGunProjectile* projectile = new LightningGunProjectile(this);
@@ -68,5 +70,7 @@
projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
}
}
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/RocketFire.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/RocketFire.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/RocketFire.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Oliver Scheuss
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -47,7 +47,7 @@
this->reloadTime_ = 0.20f;
this->bParallelReload_ = false;
- this->damage_ = 100;
+ this->damage_ = 0;
this->speed_ = 500;
this->setMunitionName("RocketMunition");
@@ -58,6 +58,8 @@
{
}
+ /* Creates the Rocket object, sets its properties to the RocketFire properties
+ */
void RocketFire::fire()
{
Rocket* rocket = new Rocket(this);
@@ -70,5 +72,7 @@
rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
rocket->setDamage(this->getDamage());
+ rocket->setShieldDamage(this->getShieldDamage());
+ rocket->setHealthDamage(this->getHealthDamage());
}
}
Modified: code/branches/presentation/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/presentation/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Oliver Scheuss
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -49,7 +49,7 @@
this->reloadTime_ = 1;
this->bParallelReload_ = false;
- this->damage_ = 100;
+ this->damage_ = 0;
this->speed_ = 500;
this->setMunitionName("RocketMunition");
@@ -61,6 +61,8 @@
{
}
+ /* Creates the Rocket (RocketController) object, sets its properties to the SimpleRocketFire properties, sets target
+ */
void SimpleRocketFire::fire()
{
RocketController* con = new RocketController(this);
@@ -70,7 +72,11 @@
rocket->setPosition(this->getMuzzlePosition());
rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+
rocket->setDamage(this->damage_);
+ rocket->setShieldDamage(this->getShieldDamage());
+ rocket->setHealthDamage(this->getHealthDamage());
+
WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
if (pawnn) con->setTarget(pawnn);
}
Modified: code/branches/presentation/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/presentation/src/orxonox/controllers/Controller.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/controllers/Controller.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -51,6 +51,12 @@
virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {};
+/* Override needed for different visual effects (e.g. in "NewHumanController.cc") depending on
+ the DIFFERENT AMOUNT OF DAMAGE done to the shield and to the health of "victim" (see Projectile.cc, Pawn.cc)
+
+// virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) {};
+*/
+
void setGodMode( bool mode ){ this->bGodMode_ = mode; }
bool getGodMode(){ return this->bGodMode_; }
Modified: code/branches/presentation/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/presentation/src/orxonox/controllers/HumanController.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/controllers/HumanController.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -41,6 +41,7 @@
{
extern const std::string __CC_fire_name = "fire";
extern const std::string __CC_suicide_name = "suicide";
+ const std::string __CC_boost_name = "boost";
SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand();
SetConsoleCommand("HumanController", "moveRightLeft", &HumanController::moveRightLeft ).addShortcut().setAsInputCommand();
@@ -50,7 +51,7 @@
SetConsoleCommand("HumanController", "rotateRoll", &HumanController::rotateRoll ).addShortcut().setAsInputCommand();
SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold);
SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut();
- SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold);
+ SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::keepBoost ).addShortcut().keybindMode(KeybindMode::OnHold);
SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut();
SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut();
SetConsoleCommand("HumanController", "mouseLook", &HumanController::mouseLook ).addShortcut();
@@ -65,14 +66,18 @@
CreateUnloadableFactory(HumanController);
HumanController* HumanController::localController_s = 0;
+ /*static*/ const float HumanController::BOOSTING_TIME = 0.1f;
HumanController::HumanController(BaseObject* creator) : Controller(creator)
{
RegisterObject(HumanController);
- controlPaused_ = false;
+ this->controlPaused_ = false;
+ this->boosting_ = false;
HumanController::localController_s = this;
+ this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));
+ this->boostingTimeout_.stopTimer();
}
HumanController::~HumanController()
@@ -162,12 +167,51 @@
HumanController::localController_s->controllableEntity_->reload();
}
- void HumanController::boost()
+ /**
+ @brief
+ Static method,keeps boosting.
+ */
+ /*static*/ void HumanController::keepBoost()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->boost();
+ HumanController::localController_s->keepBoosting();
}
+
+ /**
+ @brief
+ Starts, or keeps the boosting mode.
+ Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore).
+ */
+ void HumanController::keepBoosting(void)
+ {
+ if(this->boostingTimeout_.isActive())
+ {
+ this->boostingTimeout_.stopTimer();
+ this->boostingTimeout_.startTimer();
+ }
+ else
+ {
+ this->boosting_ = true;
+ this->boostingTimeout_.startTimer();
+
+ this->controllableEntity_->boost(this->boosting_);
+ COUT(4) << "Start boosting" << endl;
+ }
+ }
+ /**
+ @brief
+ Terminates the boosting mode.
+ */
+ void HumanController::terminateBoosting(void)
+ {
+ this->boosting_ = false;
+ this->boostingTimeout_.stopTimer();
+
+ this->controllableEntity_->boost(this->boosting_);
+ COUT(4) << "Stop boosting" << endl;
+ }
+
void HumanController::greet()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
Modified: code/branches/presentation/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/presentation/src/orxonox/controllers/HumanController.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/controllers/HumanController.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -31,6 +31,7 @@
#include "OrxonoxPrereqs.h"
+#include "tools/Timer.h"
#include "tools/interfaces/Tickable.h"
#include "Controller.h"
@@ -63,7 +64,16 @@
virtual void doFire(unsigned int firemode);
static void reload();
- static void boost();
+ static void keepBoost(); // Static method, keeps boosting.
+ /**
+ @brief Check whether the HumanController is in boosting mode.
+ @return Returns true if it is, false if not.
+ */
+ inline bool isBoosting(void)
+ { return this->boosting_; }
+ void keepBoosting(void);
+ void terminateBoosting(void);
+
static void greet();
static void switchCamera();
static void mouseLook();
@@ -91,6 +101,12 @@
protected:
static HumanController* localController_s;
bool controlPaused_;
+
+ private:
+ bool boosting_; // Whether the HumanController is in boosting mode or not.
+ Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.
+ static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.
+
}; // tolua_export
} // tolua_export
Modified: code/branches/presentation/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/presentation/src/orxonox/graphics/Camera.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/graphics/Camera.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -47,7 +47,7 @@
{
CreateFactory(Camera);
- Camera::Camera(BaseObject* creator) : StaticEntity(creator)
+ Camera::Camera(BaseObject* creator) : MovableEntity(creator)
{
RegisterObject(Camera);
Modified: code/branches/presentation/src/orxonox/graphics/Camera.h
===================================================================
--- code/branches/presentation/src/orxonox/graphics/Camera.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/graphics/Camera.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -35,11 +35,12 @@
#include "core/WindowEventListener.h"
#include "tools/interfaces/Tickable.h"
#include "tools/interfaces/TimeFactorListener.h"
-#include "worldentities/StaticEntity.h"
+#include "worldentities/MovableEntity.h"
namespace orxonox
{
- class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener
+
+ class _OrxonoxExport Camera : public MovableEntity, public TimeFactorListener, public WindowEventListener
{
friend class CameraManager;
Modified: code/branches/presentation/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/presentation/src/orxonox/items/Engine.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/items/Engine.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -203,8 +203,6 @@
this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
- if (!this->ship_->getPermanentBoost())
- this->ship_->setBoost(false);
this->ship_->setSteeringDirection(Vector3::ZERO);
if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
Modified: code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -65,6 +65,8 @@
this->reloadTimer_.stopTimer();
this->damage_ = 0;
+ this->healthdamage_ = 0;
+ this->shielddamage_ = 0;
this->muzzleOffset_ = Vector3::ZERO;
this->muzzlePosition_ = Vector3::ZERO;
@@ -105,6 +107,8 @@
XMLPortParam(WeaponMode, "parallelreload", setParallelReload, getParallelReload, xmlelement, mode).description("If true, the weapon reloads in parallel to the magazine reloading");
XMLPortParam(WeaponMode, "damage", setDamage, getDamage, xmlelement, mode);
+ XMLPortParam(WeaponMode, "healthdamage", setHealthDamage, getHealthDamage, xmlelement, mode);
+ XMLPortParam(WeaponMode, "shielddamage", setShieldDamage, getShieldDamage, xmlelement, mode);
XMLPortParam(WeaponMode, "muzzleoffset", setMuzzleOffset, getMuzzleOffset, xmlelement, mode);
}
Modified: code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -103,10 +103,19 @@
// Fire
inline void setDamage(float damage)
- { this->damage_ = damage; }
+ { this->damage_ = damage;}
inline float getDamage() const
{ return this->damage_; }
+ inline void setHealthDamage(float healthdamage)
+ { this->healthdamage_ = healthdamage; }
+ inline float getHealthDamage() const
+ { return this->healthdamage_; }
+ inline void setShieldDamage(float shielddamage)
+ { this->shielddamage_ = shielddamage;}
+ inline float getShieldDamage() const
+ { return this->shielddamage_; }
+
inline void setMuzzleOffset(const Vector3& offset)
{ this->muzzleOffset_ = offset; }
inline const Vector3& getMuzzleOffset() const
@@ -145,6 +154,8 @@
bool bParallelReload_;
float damage_;
+ float healthdamage_;
+ float shielddamage_;
Vector3 muzzleOffset_;
private:
Modified: code/branches/presentation/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/ControllableEntity.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/worldentities/ControllableEntity.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -83,7 +83,6 @@
this->server_angular_velocity_ = Vector3::ZERO;
this->client_angular_velocity_ = Vector3::ZERO;
-
this->setConfigValues();
this->setPriority( Priority::VeryHigh );
this->registerVariables();
Modified: code/branches/presentation/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/ControllableEntity.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/worldentities/ControllableEntity.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -92,7 +92,13 @@
virtual void fired(unsigned int firemode) {}
virtual void reload() {}
- virtual void boost() {}
+ /**
+ @brief Tells the ControllableEntity to either start or stop boosting.
+ This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will.
+ @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop.
+ */
+ virtual void boost(bool bBoost) {}
+
virtual void greet() {}
virtual void switchCamera();
virtual void mouseLook();
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * simonmie
*
*/
@@ -63,9 +63,16 @@
this->health_ = 0;
this->maxHealth_ = 0;
this->initialHealth_ = 0;
+
this->shieldHealth_ = 0;
+ this->initialShieldHealth_ = 0;
+ this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
this->shieldAbsorption_ = 0.5;
+ this->reloadRate_ = 0;
+ this->reloadWaitTime_ = 1.0f;
+ this->reloadWaitCountdown_ = 0;
+
this->lastHitOriginator_ = 0;
this->spawnparticleduration_ = 3.0f;
@@ -108,6 +115,8 @@
XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
+ XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
+ XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
@@ -117,14 +126,18 @@
XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
+
+ XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
+ XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
}
void Pawn::registerVariables()
{
registerVariable(this->bAlive_, VariableDirection::ToClient);
registerVariable(this->health_, VariableDirection::ToClient);
- registerVariable(this->initialHealth_, VariableDirection::ToClient);
+ registerVariable(this->maxHealth_, VariableDirection::ToClient);
registerVariable(this->shieldHealth_, VariableDirection::ToClient);
+ registerVariable(this->maxShieldHealth_, VariableDirection::ToClient);
registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
registerVariable(this->bReload_, VariableDirection::ToServer);
registerVariable(this->aimPosition_, VariableDirection::ToServer); // For the moment this variable gets only transfered to the server
@@ -136,12 +149,25 @@
this->bReload_ = false;
+ // TODO: use the existing timer functions instead
+ if(this->reloadWaitCountdown_ > 0)
+ {
+ this->decreaseReloadCountdownTime(dt);
+ }
+ else
+ {
+ this->addShieldHealth(this->getReloadRate() * dt);
+ this->resetReloadCountdown();
+ }
+
if (GameMode::isMaster())
+ {
if (this->health_ <= 0 && bAlive_)
{
- this->fireEvent(); // Event to notify anyone who want's to know about the death.
+ this->fireEvent(); // Event to notify anyone who wants to know about the death.
this->death();
}
+ }
}
void Pawn::preDestroy()
@@ -167,63 +193,91 @@
ControllableEntity::removePlayer();
}
+
void Pawn::setHealth(float health)
{
- this->health_ = std::min(health, this->maxHealth_);
+ this->health_ = std::min(health, this->maxHealth_); //Health can't be set to a value bigger than maxHealth, otherwise it will be reduced at first hit
}
- void Pawn::damage(float damage, Pawn* originator)
+ void Pawn::setShieldHealth(float shieldHealth)
{
+ this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_);
+ }
+
+ void Pawn::setMaxShieldHealth(float maxshieldhealth)
+ {
+ this->maxShieldHealth_ = maxshieldhealth;
+ }
+
+ void Pawn::setReloadRate(float reloadrate)
+ {
+ this->reloadRate_ = reloadrate;
+ }
+
+ void Pawn::setReloadWaitTime(float reloadwaittime)
+ {
+ this->reloadWaitTime_ = reloadwaittime;
+ }
+
+ void Pawn::decreaseReloadCountdownTime(float dt)
+ {
+ this->reloadWaitCountdown_ -= dt;
+ }
+
+ void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
+ {
if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
{
- //share the dealt damage to the shield and the Pawn.
- float shielddamage = damage*this->shieldAbsorption_;
- float healthdamage = damage*(1-this->shieldAbsorption_);
-
- // In case the shield can not take all the shield damage.
- if (shielddamage > this->getShieldHealth())
+ if (shielddamage >= this->getShieldHealth())
{
- healthdamage += shielddamage-this->getShieldHealth();
this->setShieldHealth(0);
+ this->setHealth(this->health_ - (healthdamage + damage));
}
+ else
+ {
+ this->setShieldHealth(this->shieldHealth_ - shielddamage);
- this->setHealth(this->health_ - healthdamage);
+ // remove remaining shieldAbsorpton-Part of damage from shield
+ shielddamage = damage * this->shieldAbsorption_;
+ shielddamage = std::min(this->getShieldHealth(),shielddamage);
+ this->setShieldHealth(this->shieldHealth_ - shielddamage);
- if (this->getShieldHealth() > 0)
- {
- this->setShieldHealth(this->shieldHealth_ - shielddamage);
+ // set remaining damage to health
+ this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
}
this->lastHitOriginator_ = originator;
-
- // play damage effect
}
}
- void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
+// TODO: Still valid?
+/* HIT-Funktionen
+ Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte)
+
+*/
+
+ void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)
{
if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
{
- this->damage(damage, originator);
+ this->damage(damage, healthdamage, shielddamage, originator);
this->setVelocity(this->getVelocity() + force);
-
- // play hit effect
}
}
- void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
+
+ void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
{
if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
{
- this->damage(damage, originator);
+ this->damage(damage, healthdamage, shielddamage, originator);
if ( this->getController() )
- this->getController()->hit(originator, contactpoint, damage);
-
- // play hit effect
+ this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
}
}
+
void Pawn::kill()
{
this->damage(this->health_);
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -71,21 +71,61 @@
inline float getInitialHealth() const
{ return this->initialHealth_; }
- inline void setShieldHealth(float shieldHealth)
- { this->shieldHealth_ = shieldHealth; }
+ virtual void setShieldHealth(float shieldHealth);
+
inline float getShieldHealth()
{ return this->shieldHealth_; }
+ inline void addShieldHealth(float amount)
+ { this->setShieldHealth(this->shieldHealth_ + amount); }
+
+ inline bool hasShield()
+ { return (this->getShieldHealth() > 0); }
+
+ virtual void setMaxShieldHealth(float maxshieldhealth);
+ inline float getMaxShieldHealth() const
+ { return this->maxShieldHealth_; }
+
+ inline void setInitialShieldHealth(float initialshieldhealth)
+ { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); }
+ inline float getInitialShieldHealth() const
+ { return this->initialShieldHealth_; }
+
+ inline void restoreInitialShieldHealth()
+ { this->setShieldHealth(this->initialShieldHealth_); }
+ inline void restoreMaxShieldHealth()
+ { this->setShieldHealth(this->maxShieldHealth_); }
+
inline void setShieldAbsorption(float shieldAbsorption)
{ this->shieldAbsorption_ = shieldAbsorption; }
inline float getShieldAbsorption()
{ return this->shieldAbsorption_; }
+ // TODO: Rename to shieldRechargeRate
+ virtual void setReloadRate(float reloadrate);
+ inline float getReloadRate() const
+ { return this->reloadRate_; }
+
+ virtual void setReloadWaitTime(float reloadwaittime);
+ inline float getReloadWaitTime() const
+ { return this->reloadWaitTime_; }
+
+ inline void resetReloadCountdown()
+ { this->reloadWaitCountdown_ = 0; }
+
+ inline void startReloadCountdown()
+ { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
+
+ virtual void decreaseReloadCountdownTime(float dt);
+
inline ControllableEntity* getLastHitOriginator() const
{ return this->lastHitOriginator_; }
- virtual void hit(Pawn* originator, const Vector3& force, float damage);
- virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
+ //virtual void hit(Pawn* originator, const Vector3& force, float damage);
+ //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
+ virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
+ virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
+
virtual void kill();
virtual void fired(unsigned int firemode);
@@ -141,7 +181,8 @@
virtual void deatheffect();
virtual void spawneffect();
- virtual void damage(float damage, Pawn* originator = 0);
+ //virtual void damage(float damage, Pawn* originator = 0);
+ virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL);
bool bAlive_;
@@ -153,8 +194,14 @@
float health_;
float maxHealth_;
float initialHealth_;
+
float shieldHealth_;
+ float maxShieldHealth_;
+ float initialShieldHealth_;
float shieldAbsorption_; // Has to be between 0 and 1
+ float reloadRate_;
+ float reloadWaitTime_;
+ float reloadWaitCountdown_;
WeakPtr<Pawn> lastHitOriginator_;
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-25 19:22:53 UTC (rev 8578)
@@ -35,6 +35,9 @@
#include "core/Template.h"
#include "core/XMLPort.h"
#include "items/Engine.h"
+#include "graphics/Camera.h"
+#include "CameraManager.h"
+#include "util/Math.h"
namespace orxonox
{
@@ -52,7 +55,6 @@
this->localLinearAcceleration_.setValue(0, 0, 0);
this->localAngularAcceleration_.setValue(0, 0, 0);
this->bBoost_ = false;
- this->bPermanentBoost_ = false;
this->steering_ = Vector3::ZERO;
this->engine_ = 0;
@@ -75,6 +77,14 @@
this->setConfigValues();
this->registerVariables();
+
+ Camera* camera = CameraManager::getInstance().getActiveCamera();
+ this->cameraOriginalPosition_ = camera->getPosition();
+ this->cameraOriginalOrientation_ = camera->getOrientation();
+
+ this->shakeFrequency_ = 15;
+ this->shakeAmplitude_ = 5;
+ this->shakeDt_ = 0;
}
SpaceShip::~SpaceShip()
@@ -95,6 +105,8 @@
XMLPortParamVariable(SpaceShip, "boostPowerRate", boostPowerRate_, xmlelement, mode);
XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode);
XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
+ XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode);
+ XMLPortParamVariable(SpaceShip, "shakeAmplitude", shakeAmplitude_, xmlelement, mode);
}
void SpaceShip::registerVariables()
@@ -102,6 +114,13 @@
registerVariable(this->primaryThrust_, VariableDirection::ToClient);
registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
registerVariable(this->rotationThrust_, VariableDirection::ToClient);
+ // TODO: Synchronization of boost needed?
+ registerVariable(this->boostPower_, VariableDirection::ToClient);
+ registerVariable(this->boostPowerRate_, VariableDirection::ToClient);
+ registerVariable(this->boostRate_, VariableDirection::ToClient);
+ registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient);
+ registerVariable(this->shakeFrequency_, VariableDirection::ToClient);
+ registerVariable(this->shakeAmplitude_, VariableDirection::ToClient);
}
void SpaceShip::setConfigValues()
@@ -127,6 +146,7 @@
if (this->hasLocalController())
{
+
/*
this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
@@ -149,24 +169,23 @@
{
this->boostPower_ += this->boostPowerRate_*dt;
}
+
if(this->bBoost_)
{
this->boostPower_ -=this->boostRate_*dt;
if(this->boostPower_ <= 0.0f)
{
- this->bBoost_ = false;
+ this->boost(false);
this->bBoostCooldown_ = true;
this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
+
}
+
+ shakeCamera(dt);
}
}
}
- void SpaceShip::boostCooledDown(void)
- {
- this->bBoostCooldown_ = false;
- }
-
void SpaceShip::moveFrontBack(const Vector2& value)
{
this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
@@ -206,28 +225,79 @@
Pawn::rotateRoll(value);
}
- // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
- void SpaceShip::setBoost(bool bBoost)
+ void SpaceShip::fire()
{
- if(bBoost == this->bBoost_)
- return;
+ }
- if(bBoost)
- this->boost();
- else
+ /**
+ @brief
+ Starts or stops boosting.
+ @param bBoost
+ Whether to start or stop boosting.
+ */
+ void SpaceShip::boost(bool bBoost)
+ {
+ if(bBoost && !this->bBoostCooldown_)
{
+ //COUT(0) << "Boost startet!\n";
+ this->bBoost_ = true;
+ }
+ if(!bBoost)
+ {
+ //COUT(0) << "Boost stoppt\n";
+ this->resetCamera();
this->bBoost_ = false;
}
}
-
- void SpaceShip::fire()
+
+ void SpaceShip::boostCooledDown(void)
{
+ this->bBoostCooldown_ = false;
}
+
+ void SpaceShip::shakeCamera(float dt)
+ {
+ //make sure the ship is only shaking if it's moving
+ if (this->getVelocity().squaredLength() > 80)
+ {
+ this->shakeDt_ += dt;
+
+ int frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength());
+
+ if (this->shakeDt_ >= 1 /(frequency))
+ {
+ this->shakeDt_ -= 1/(frequency);
+ }
+
+ Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_);
+
+ //COUT(0) << "Angle: " << angle << std::endl;
+ Camera* c = this->getCamera();
- void SpaceShip::boost()
+ //Shaking Camera effect
+ if (c != 0)
+ {
+ c->setOrientation(Vector3::UNIT_X, angle);
+ }
+ }
+ }
+
+ void SpaceShip::resetCamera()
{
- if(!this->bBoostCooldown_)
- this->bBoost_ = true;
+
+ //COUT(0) << "Resetting camera\n";
+ Camera *c = this->getCamera();
+
+ if (c == 0)
+ {
+ COUT(2) << "Failed to reset camera!";
+ return;
+ }
+
+ shakeDt_ = 0;
+ //
+ c->setPosition(this->cameraOriginalPosition_);
+ c->setOrientation(this->cameraOriginalOrientation_);
}
void SpaceShip::loadEngineTemplate()
@@ -272,4 +342,6 @@
list->push_back(this->engine_);
return list;
}
+
+
}
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2011-05-25 19:07:17 UTC (rev 8577)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2011-05-25 19:22:53 UTC (rev 8578)
@@ -58,7 +58,7 @@
virtual void rotateRoll(const Vector2& value);
virtual void fire();
- virtual void boost();
+ virtual void boost(bool bBoost); // Starts or stops boosting.
void setEngine(Engine* engine);
inline Engine* getEngine() const
@@ -69,7 +69,6 @@
inline const Vector3& getSteeringDirection() const
{ return this->steering_; }
- void setBoost(bool bBoost);
inline bool getBoost() const
{ return this->bBoost_; }
@@ -78,18 +77,12 @@
inline const std::string& getEngineTemplate() const
{ return this->enginetemplate_; }
- inline void setPermanentBoost(bool bPermanent)
- { this->bPermanentBoost_ = bPermanent; }
- inline bool getPermanentBoost() const
- { return this->bPermanentBoost_; }
-
protected:
virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const;
bool bInvertYAxis_;
bool bBoost_;
bool bBoostCooldown_;
- bool bPermanentBoost_;
float boostPower_;
float initialBoostPower_;
float boostRate_;
@@ -102,6 +95,9 @@
btVector3 localLinearAcceleration_;
btVector3 localAngularAcceleration_;
+ float shakeFrequency_;
+ float shakeAmplitude_;
+
private:
void registerVariables();
virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
@@ -109,10 +105,17 @@
void loadEngineTemplate();
void boostCooledDown(void);
+
+ void resetCamera();
+ void shakeCamera(float dt);
std::string enginetemplate_;
Engine* engine_;
Timer timer_;
+ Vector3 cameraOriginalPosition_;
+ Quaternion cameraOriginalOrientation_;
+
+ float shakeDt_;
};
}
More information about the Orxonox-commit
mailing list