[Orxonox-commit 6370] r11027 - in code/branches/fabienHS15: data/levels src/libraries/core/input src/modules/notifications/dispatchers src/orxonox/weaponsystem src/orxonox/worldentities/pawns
fvultier at orxonox.net
fvultier at orxonox.net
Sun Jan 3 17:48:18 CET 2016
Author: fvultier
Date: 2016-01-03 17:48:18 +0100 (Sun, 03 Jan 2016)
New Revision: 11027
Modified:
code/branches/fabienHS15/data/levels/notifications.oxw
code/branches/fabienHS15/src/libraries/core/input/KeyBinder.cc
code/branches/fabienHS15/src/libraries/core/input/KeyBinder.h
code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.cc
code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.h
code/branches/fabienHS15/src/orxonox/weaponsystem/WeaponMode.cc
code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h
Log:
Implemented a feature that was requested during PPS: Vulnerability can be switched on/off using the event system. Also: Resolved a TODO in CommandNotification.cc .
Modified: code/branches/fabienHS15/data/levels/notifications.oxw
===================================================================
--- code/branches/fabienHS15/data/levels/notifications.oxw 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/data/levels/notifications.oxw 2016-01-03 16:48:18 UTC (rev 11027)
@@ -18,14 +18,27 @@
</templates>
<?lua include("includes/notifications.oxi") ?>
+ <NotificationQueueCEGUI
+ name="narrative"
+ targets="simpleNotification,commandNotification"
+ size=3
+ displayTime=3.9
+ position="0.2, 0, 0.1, 0"
+ fontSize="23"
+ fontColor="0.3, 1, 0.2, 0.8"
+ alignment="HorzCentred"
+ displaySize="0.6, 0, 0, 0"
+ />
+
<Scene
ambientlight = "0.5, 0.5, 0.5"
skybox = "Orxonox/skyBoxBasic"
>
<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" />
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
- <CommandNotification preMessage="Open the PickupInventory by pressing '" postMessage="'." command="OrxonoxOverlay toggleVisibility PickupInventory">
+ <CommandNotification preMessage="Open the PickupInventory by pressing '" postMessage="'." command="OrxonoxOverlay show PickupInventory">
<events>
<trigger>
<DistanceTrigger name=trigger position="0,0,-100" distance=10 target="Pawn" />
@@ -43,11 +56,5 @@
</SimpleNotification>
<Billboard position="0,0,100" colour="1.0,0,1.0" material="Examples/Flare" />
- <?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=spaceshipassff />
- <?lua end ?>
-
</Scene>
</Level>
Modified: code/branches/fabienHS15/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/fabienHS15/src/libraries/core/input/KeyBinder.cc 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/libraries/core/input/KeyBinder.cc 2016-01-03 16:48:18 UTC (rev 11027)
@@ -358,6 +358,46 @@
/**
@brief
+ Return the first key name for a specific command in a human readable form
+ */
+ const std::string& KeyBinder::getBindingReadable(const std::string& commandName)
+ {
+ const std::string& binding = this->getBinding(commandName);
+
+ SubString substring = SubString(binding, ".");
+ std::string name;
+ std::string group;
+ switch(substring.size())
+ {
+ case 0:
+ return binding;
+ case 1:
+ return binding;
+ case 2:
+ group = substring[0];
+ default:
+ name = substring.subSet(1).join(".");
+ }
+
+ std::stringstream stream;
+ if(group.compare("Keys") == 0)
+ stream << "Key " << name.substr(3);
+ else if(group.compare("MouseButtons") == 0)
+ stream << "Mouse " << name;
+ else if(group.compare("JoyStickButtons") == 0)
+ stream << "Joystick " << name;
+ else if(group.compare("JoyStickAxes") == 0)
+ stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
+ else if(group.compare("MouseAxes") == 0)
+ stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
+ else
+ return binding;
+
+ return *(new std::string(stream.str()));
+ }
+
+ /**
+ @brief
Get the number of different key bindings of a specific command.
@param commandName
The command.
Modified: code/branches/fabienHS15/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/fabienHS15/src/libraries/core/input/KeyBinder.h 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/libraries/core/input/KeyBinder.h 2016-01-03 16:48:18 UTC (rev 11027)
@@ -67,6 +67,7 @@
bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
const std::string& getBinding(const std::string& commandName); //tolua_export
const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export
+ const std::string& getBindingReadable(const std::string& commandName); //tolua_export
unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export
const std::string& getBindingsFilename()
Modified: code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.cc
===================================================================
--- code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.cc 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.cc 2016-01-03 16:48:18 UTC (rev 11027)
@@ -100,52 +100,8 @@
{
std::stringstream stream;
stream << this->getPreMessage();
- stream << this->bindingNiceifyer(KeyBinderManager::getInstance().getCurrent()->getBinding(this->getCommand()));
+ stream << KeyBinderManager::getInstance().getCurrent()->getBindingReadable(this->getCommand());
stream << this->getPostMessage();
return *(new std::string(stream.str()));
}
-
- /**
- @brief
- Transforms the input binding into a human readable form.
- @param binding
- The binding to be transformed
- @return
- Returns a human readable version of the input binding.
- */
- //TODO: Move to KeyBinderManager...
- const std::string& CommandNotification::bindingNiceifyer(const std::string& binding)
- {
- SubString substring = SubString(binding, ".");
- std::string name;
- std::string group;
- switch(substring.size())
- {
- case 0:
- return binding;
- case 1:
- return binding;
- case 2:
- group = substring[0];
- default:
- name = substring.subSet(1).join(".");
- }
-
- std::stringstream stream;
- if(group.compare("Keys") == 0)
- stream << "Key " << name.substr(3);
- else if(group.compare("MouseButtons") == 0)
- stream << "Mouse " << name;
- else if(group.compare("JoyStickButtons") == 0)
- stream << "Joystick " << name;
- else if(group.compare("JoyStickAxes") == 0)
- stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
- else if(group.compare("MouseAxes") == 0)
- stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
- else
- return binding;
-
- return *(new std::string(stream.str()));
- }
-
-}
+}
\ No newline at end of file
Modified: code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.h
===================================================================
--- code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.h 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/modules/notifications/dispatchers/CommandNotification.h 2016-01-03 16:48:18 UTC (rev 11027)
@@ -121,9 +121,6 @@
*/
void setPostMessage(const std::string& message)
{ this->postMessage_ = message; }
-
- const std::string& bindingNiceifyer(const std::string& binding); //!< Transforms the input binding into a human readable form.
-
};
}
Modified: code/branches/fabienHS15/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/fabienHS15/src/orxonox/weaponsystem/WeaponMode.cc 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/orxonox/weaponsystem/WeaponMode.cc 2016-01-03 16:48:18 UTC (rev 11027)
@@ -74,7 +74,7 @@
this->muzzlePosition_ = Vector3::ZERO;
this->muzzleOrientation_ = Quaternion::IDENTITY;
- hudImageString_ = "WSHUD_WM_Unknown";
+ hudImageString_ = "Orxonox/WSHUD_WM_Unknown";
if( GameMode::isMaster() )
{
Modified: code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc 2016-01-03 16:48:18 UTC (rev 11027)
@@ -33,6 +33,7 @@
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
#include "core/XMLPort.h"
+#include "core/EventIncludes.h"
#include "network/NetworkFunction.h"
#include "infos/PlayerInfo.h"
@@ -61,6 +62,7 @@
RegisterObject(Pawn);
this->bAlive_ = true;
+ this->bVulnerable_ = true;
this->health_ = 0;
this->maxHealth_ = 0;
@@ -133,6 +135,8 @@
XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
+ XMLPortParam(Pawn, "vulnerable", setVulnerable, isVulnerable, xmlelement, mode).defaultValues(true);
+
XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
@@ -150,6 +154,13 @@
XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
}
+ void Pawn::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Pawn, XMLEventPort, xmlelement, mode);
+
+ XMLPortEventState(Pawn, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
+ }
+
void Pawn::registerVariables()
{
registerVariable(this->bAlive_, VariableDirection::ToClient);
@@ -241,8 +252,19 @@
this->shieldRechargeWaitCountdown_ -= dt;
}
+ void Pawn::changedVulnerability()
+ {
+
+ }
+
void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
{
+ // A pawn can only get damaged if it is vulnerable
+ if (!isVulnerable())
+ {
+ return;
+ }
+
// Applies multiplier given by the DamageBoost Pickup.
if (originator)
damage *= originator->getDamageMultiplier();
Modified: code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h 2016-01-03 13:57:42 UTC (rev 11026)
+++ code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h 2016-01-03 16:48:18 UTC (rev 11027)
@@ -61,6 +61,7 @@
virtual ~Pawn();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
virtual void tick(float dt);
inline bool isAlive() const
@@ -131,6 +132,20 @@
virtual void decreaseShieldRechargeCountdownTime(float dt);
+ /** @brief Sets the state of the pawns vulnerability. @param bVulnerable */
+ inline void setVulnerable(bool bVulnerable)
+ {
+ if (this->bVulnerable_ != bVulnerable)
+ {
+ this->bVulnerable_ = bVulnerable;
+ this->changedVulnerability();
+ }
+ }
+ /** @brief Returns the state of the pawns vulnerability. @return The state of the vulnerability */
+ inline const bool& isVulnerable() const { return this->bVulnerable_; }
+ /** @brief This function gets called if the vulnerability of the pawn changes. */
+ virtual void changedVulnerability();
+
inline ControllableEntity* getLastHitOriginator() const
{ return this->lastHitOriginator_; }
@@ -211,6 +226,7 @@
virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
bool bAlive_;
+ bool bVulnerable_; ///< If false the pawn may not ged damaged
virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
{ return new std::vector<PickupCarrier*>(); }
More information about the Orxonox-commit
mailing list