commit 563becae
Added different damage types. No resistance yet.
Changed files
| M | src/saland/Game.cpp before |
| M | src/saland/GameUpdates.cpp before |
| M | src/saland/model/placeables.hpp before |
diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp
index 10e9016..5739fa1 100644
--- a/src/saland/Game.cpp
+++ b/src/saland/Game.cpp
@@ -719,6 +719,7 @@ void Game::Update() {
projectile->Radius = 8.0f;
projectile->directionX = projectile->X - data->world_mouse_x;
projectile->directionY = projectile->Y - data->world_mouse_y;
+ projectile->damage.fire = 10.0f;
SetLengthToOne(projectile->directionX, projectile->directionY);
projectile->fired_by = data->human;
data->gameRegion.placeables.push_back(projectile);
@@ -745,6 +746,8 @@ void Game::Update() {
projectile->Radius = 8.0f;
projectile->velocity = 0.0f;
projectile->sprite = "";
+ projectile->damage.slash = 15.0f;
+ projectile->damage.piercing = 5.0f;
projectile->directionX = projectile->X - data->world_mouse_x;
projectile->directionY = projectile->Y - data->world_mouse_y;
SetLengthToOne(projectile->directionX, projectile->directionY);
diff --git a/src/saland/GameUpdates.cpp b/src/saland/GameUpdates.cpp
index ddea0ee..c1cb974 100644
--- a/src/saland/GameUpdates.cpp
+++ b/src/saland/GameUpdates.cpp
@@ -128,7 +128,7 @@ void UpdateProjectile(Projectile* entity, float fDeltaTime) {
void ProjectileHit(Projectile* p, Placeable* target) {
//Monster* monster = dynamic_cast<Monster*> (target);
if (target->destructible) {
- target->health -= 10.0f;
+ target->health -= p->damage.getDamage();
p->removeMe = true;
}
}
\ No newline at end of file
diff --git a/src/saland/model/placeables.hpp b/src/saland/model/placeables.hpp
index 85bd4d7..7e37ec9 100644
--- a/src/saland/model/placeables.hpp
+++ b/src/saland/model/placeables.hpp
@@ -30,6 +30,19 @@ https://github.com/sago007/saland
const float pixel2unit = 32.0f;
+
+class Damage {
+public:
+ float slash = 0.0f;
+ float piercing = 0.0f;
+ float fire = 0.0f;
+ float water = 0.0f;
+ float lightning = 0.0f;
+ float getDamage() {
+ return slash + piercing + fire + water + lightning;
+ }
+};
+
class Placeable {
public:
std::string id = "noid";
@@ -89,6 +102,7 @@ public:
float aiNextThink = 0.0;
};
+
class Projectile : public Placeable {
public:
bool active = true;
@@ -96,6 +110,7 @@ public:
float directionY = 1;
float velocity = 1.0f;
float timeToLive = 2000.0;
+ Damage damage;
std::shared_ptr<Placeable> fired_by;
std::string sprite = "effect_fireball";
};