Permalink
Browse files

Support all effects for adding visual effects

  • Loading branch information...
1 parent 07e7cb1 commit dc0443044030dfd1465bc57169a47ebd2aa680ec @dorkster dorkster committed Sep 13, 2012
Showing with 66 additions and 63 deletions.
  1. +18 −4 src/Avatar.cpp
  2. +16 −4 src/Enemy.cpp
  3. +2 −3 src/EnemyManager.cpp
  4. +1 −3 src/GameStatePlay.cpp
  5. +11 −36 src/MenuActiveEffects.cpp
  6. +0 −13 src/MenuActiveEffects.h
  7. +4 −0 src/PowerManager.cpp
  8. +13 −0 src/StatBlock.cpp
  9. +1 −0 src/StatBlock.h
View
22 src/Avatar.cpp
@@ -595,6 +595,8 @@ void Avatar::logic(int actionbar_power, bool restrictPowerUse) {
setAnimation("block");
+ stats.addEffect("block");
+
if (powers->powers[actionbar_power].new_state != POWSTATE_BLOCK) {
stats.cur_state = AVATAR_STANCE;
stats.blocking = false;
@@ -760,10 +762,22 @@ bool Avatar::takeHit(Hazard h) {
// after effects
if (stats.hp > 0 && stats.immunity_duration == 0 && dmg > 0) {
- if (h.stun_duration > stats.stun_duration) stats.stun_duration_total = stats.stun_duration = h.stun_duration;
- if (h.slow_duration > stats.slow_duration) stats.slow_duration_total = stats.slow_duration = h.slow_duration;
- if (h.bleed_duration > stats.bleed_duration) stats.bleed_duration_total = stats.bleed_duration = h.bleed_duration;
- if (h.immobilize_duration > stats.immobilize_duration) stats.immobilize_duration_total = stats.immobilize_duration = h.immobilize_duration;
+ if (h.stun_duration > stats.stun_duration) {
+ stats.stun_duration_total = stats.stun_duration = h.stun_duration;
+ stats.addEffect("stun");
+ }
+ if (h.slow_duration > stats.slow_duration) {
+ stats.slow_duration_total = stats.slow_duration = h.slow_duration;
+ stats.addEffect("slow");
+ }
+ if (h.bleed_duration > stats.bleed_duration) {
+ stats.bleed_duration_total = stats.bleed_duration = h.bleed_duration;
+ stats.addEffect("bleed");
+ }
+ if (h.immobilize_duration > stats.immobilize_duration) {
+ stats.immobilize_duration_total = stats.immobilize_duration = h.immobilize_duration;
+ stats.addEffect("immobilize");
+ }
if (h.forced_move_duration > stats.forced_move_duration) stats.forced_move_duration_total = stats.forced_move_duration = h.forced_move_duration;
if (h.forced_move_speed != 0) {
float theta = powers->calcTheta(h.src_stats->pos.x, h.src_stats->pos.y, stats.pos.x, stats.pos.y);
View
20 src/Enemy.cpp
@@ -214,10 +214,22 @@ bool Enemy::takeHit(Hazard h) {
// after effects
if (stats.hp > 0) {
- if (h.stun_duration > stats.stun_duration) stats.stun_duration_total = stats.stun_duration = h.stun_duration;
- if (h.slow_duration > stats.slow_duration) stats.slow_duration_total = stats.slow_duration = h.slow_duration;
- if (h.bleed_duration > stats.bleed_duration) stats.bleed_duration_total = stats.bleed_duration = h.bleed_duration;
- if (h.immobilize_duration > stats.immobilize_duration) stats.immobilize_duration_total = stats.immobilize_duration = h.immobilize_duration;
+ if (h.stun_duration > stats.stun_duration) {
+ stats.stun_duration_total = stats.stun_duration = h.stun_duration;
+ stats.addEffect("stun");
+ }
+ if (h.slow_duration > stats.slow_duration) {
+ stats.slow_duration_total = stats.slow_duration = h.slow_duration;
+ stats.addEffect("slow");
+ }
+ if (h.bleed_duration > stats.bleed_duration) {
+ stats.bleed_duration_total = stats.bleed_duration = h.bleed_duration;
+ stats.addEffect("bleed");
+ }
+ if (h.immobilize_duration > stats.immobilize_duration) {
+ stats.immobilize_duration_total = stats.immobilize_duration = h.immobilize_duration;
+ stats.addEffect("immobilize");
+ }
if (h.forced_move_duration > stats.forced_move_duration) stats.forced_move_duration_total = stats.forced_move_duration = h.forced_move_duration;
if (h.forced_move_speed != 0) {
float theta = powers->calcTheta(stats.hero_pos.x, stats.hero_pos.y, stats.pos.x, stats.pos.y);
View
5 src/EnemyManager.cpp
@@ -298,9 +298,8 @@ void EnemyManager::addRenders(vector<Renderable> &r, vector<Renderable> &r_dead)
// draw corpses below objects so that floor loot is more visible
bool dead = (*it)->stats.corpse;
(dead ? r_dead : r).push_back(re);
- if ((*it)->stats.shield_hp == 0) {
- (*it)->stats.removeEffect("shield");
- }
+
+ (*it)->stats.updateEffects();
re = powers->renderEffects(&(*it)->stats);
(dead ? r_dead : r).push_back(re);
}
View
4 src/GameStatePlay.cpp
@@ -634,9 +634,7 @@ void GameStatePlay::render() {
rens.push_back(pc_hero); // Avatar
// get additional hero overlays
- if (pc->stats.shield_hp == 0) {
- pc->stats.removeEffect("shield");
- }
+ pc->stats.updateEffects();
Renderable re = powers->renderEffects(&pc->stats);
rens.push_back(re);
View
47 src/MenuActiveEffects.cpp
@@ -43,16 +43,6 @@ MenuActiveEffects::MenuActiveEffects(SDL_Surface *_icons) {
icons = _icons;
orientation = 0; // horizontal
- limits.slow = 0;
- limits.bleed = 0;
- limits.stun = 0;
- limits.immobilize = 0;
- limits.immunity = 0;
- limits.transform = 0;
- limits.haste = 0;
- limits.hot = 0;
- limits.shield = 0;
-
// Load config settings
FileParser infile;
if(infile.open(mods->locate("menus/activeeffects.txt"))) {
@@ -115,42 +105,27 @@ void MenuActiveEffects::update(StatBlock *_stats) {
}
void MenuActiveEffects::render() {
- // Make sure the list of effects is empty
- if (effects.size() > 0) effects.clear();
-
- // Append active effects to the effects list
- if (stats->slow_duration > 0) effects.push_back("slow");
- if (stats->bleed_duration > 0) effects.push_back("bleed");
- if (stats->stun_duration > 0) effects.push_back("stun");
- if (stats->immobilize_duration > 0) effects.push_back("immobilize");
- if (stats->immunity_duration > 0) effects.push_back("immunity");
- if (stats->transform_duration > 0) effects.push_back("transform");
- if (stats->haste_duration > 0) effects.push_back("haste");
- if (stats->hot_duration > 0) effects.push_back("hot");
- if (stats->shield_hp > 0) effects.push_back("shield");
- if (stats->blocking) effects.push_back("block");
-
// Step through the list of effects and render those that are active
- for (unsigned int i=0; i<effects.size(); i++) {
- if (effects[i] == "slow")
+ for (unsigned int i=0; i<stats->effects.size(); i++) {
+ if (stats->effects[i].type == "slow")
renderIcon(14,i,stats->slow_duration,stats->slow_duration_total);
- if (effects[i] == "bleed")
+ if (stats->effects[i].type == "bleed")
renderIcon(5,i,stats->bleed_duration,stats->bleed_duration_total);
- if (effects[i] == "stun")
+ if (stats->effects[i].type == "stun")
renderIcon(10,i,stats->stun_duration,stats->stun_duration_total);
- if (effects[i] == "immobilize")
+ if (stats->effects[i].type == "immobilize")
renderIcon(4,i,stats->immobilize_duration,stats->immobilize_duration_total);
- if (effects[i] == "immunity")
+ if (stats->effects[i].type == "immunity")
renderIcon(9,i,stats->immunity_duration,stats->immunity_duration_total);
- if (effects[i] == "transform")
+ if (stats->effects[i].type == "transform")
renderIcon(21,i,stats->transform_duration,stats->transform_duration_total);
- if (effects[i] == "haste")
+ if (stats->effects[i].type == "haste")
renderIcon(12,i,stats->haste_duration,stats->haste_duration_total);
- if (effects[i] == "hot")
+ if (stats->effects[i].type == "hot")
renderIcon(7,i,stats->hot_duration,stats->hot_duration_total);
- if (effects[i] == "shield")
+ if (stats->effects[i].type == "shield")
renderIcon(11,i,stats->shield_hp,stats->shield_hp_total);
- if (effects[i] == "block")
+ if (stats->effects[i].type == "block")
renderIcon(3,i,0,0);
}
}
View
13 src/MenuActiveEffects.h
@@ -37,22 +37,9 @@ class MenuActiveEffects : public Menu {
private:
SDL_Surface *icons;
SDL_Surface *timer;
- std::vector<std::string> effects;
StatBlock *stats;
bool orientation;
- struct limits {
- int slow;
- int bleed;
- int stun;
- int immobilize;
- int immunity;
- int transform;
- int haste;
- int hot;
- int shield;
- }limits;
-
void renderIcon(int icon_id, int index, int current, int max);
public:
View
4 src/PowerManager.cpp
@@ -824,22 +824,26 @@ void PowerManager::buff(int power_index, StatBlock *src_stats, Point target) {
// immunity_duration makes one immune to new debuffs
if (src_stats->immunity_duration < powers[power_index].immunity_duration) {
+ src_stats->addEffect("immunity");
src_stats->immunity_duration = src_stats->immunity_duration_total = powers[power_index].immunity_duration;
}
// transform_duration causes hero to be transformed
if (src_stats->transform_duration < powers[power_index].transform_duration &&
src_stats->transform_duration !=-1) {
+ src_stats->addEffect("transform");
src_stats->transform_duration = src_stats->transform_duration_total = powers[power_index].transform_duration;
}
// haste doubles run speed and removes power cooldowns
if (src_stats->haste_duration < powers[power_index].haste_duration) {
+ src_stats->addEffect("haste");
src_stats->haste_duration = src_stats->haste_duration_total = powers[power_index].haste_duration;
}
// hot is healing over time
if (src_stats->hot_duration < powers[power_index].hot_duration) {
+ src_stats->addEffect("hot");
src_stats->hot_duration = src_stats->hot_duration_total = powers[power_index].hot_duration;
src_stats->hot_value = powers[power_index].hot_value;
}
View
13 src/StatBlock.cpp
@@ -536,6 +536,19 @@ void StatBlock::removeEffect(std::string effect) {
}
}
+void StatBlock::updateEffects() {
+ if (slow_duration == 0) removeEffect("slow");
+ if (bleed_duration == 0) removeEffect("bleed");
+ if (stun_duration == 0) removeEffect("stun");
+ if (immobilize_duration == 0) removeEffect("immobilize");
+ if (immunity_duration == 0) removeEffect("immunity");
+ if (transform_duration == 0) removeEffect("transform");
+ if (haste_duration == 0) removeEffect("haste");
+ if (hot_duration == 0) removeEffect("hot");
+ if (shield_hp == 0) removeEffect("shield");
+ if (!blocking) removeEffect("block");
+}
+
StatBlock::~StatBlock() {
}
View
1 src/StatBlock.h
@@ -88,6 +88,7 @@ class StatBlock {
void clearEffects();
void addEffect(std::string effect);
void removeEffect(std::string effect);
+ void updateEffects();
bool alive;
bool corpse; // creature is dead and done animating

0 comments on commit dc04430

Please sign in to comment.