1 /* 2 Copyright © 2012-2016 Justin Jacobs 3 4 This file is part of FLARE. 5 6 FLARE is free software: you can redistribute it and/or modify it under the terms 7 of the GNU General Public License as published by the Free Software Foundation, 8 either version 3 of the License, or (at your option) any later version. 9 10 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along with 15 FLARE. If not, see http://www.gnu.org/licenses/ 16 */ 17 18 /** 19 * class EffectManager 20 * 21 * Holds the collection of hazards (active attacks, spells, etc) and handles group operations 22 */ 23 24 #ifndef EFFECT_MANAGER_H 25 #define EFFECT_MANAGER_H 26 27 #include "CommonIncludes.h" 28 #include "Utils.h" 29 30 class Animation; 31 class Hazard; 32 33 class Effect { 34 public: 35 static const int TYPE_COUNT = 26; 36 enum { 37 NONE = 0, 38 DAMAGE = 1, 39 DAMAGE_PERCENT = 2, 40 HPOT = 3, 41 HPOT_PERCENT = 4, 42 MPOT = 5, 43 MPOT_PERCENT = 6, 44 SPEED = 7, 45 ATTACK_SPEED = 8, 46 IMMUNITY = 9, 47 IMMUNITY_DAMAGE = 10, 48 IMMUNITY_SLOW = 11, 49 IMMUNITY_STUN = 12, 50 IMMUNITY_HP_STEAL = 13, 51 IMMUNITY_MP_STEAL = 14, 52 IMMUNITY_KNOCKBACK = 15, 53 IMMUNITY_DAMAGE_REFLECT = 16, 54 IMMUNITY_STAT_DEBUFF = 17, 55 STUN = 18, 56 REVIVE = 19, 57 CONVERT = 20, 58 FEAR = 21, 59 DEATH_SENTENCE = 22, 60 SHIELD = 23, 61 HEAL = 24, 62 KNOCKBACK = 25 63 }; 64 65 Effect(); 66 Effect(const Effect& other); 67 Effect& operator=(const Effect& other); 68 ~Effect(); 69 70 void loadAnimation(const std::string &s); 71 void unloadAnimation(); 72 73 static int getTypeFromString(const std::string& _type); 74 static bool typeIsStat(int t); 75 static bool typeIsDmgMin(int t); 76 static bool typeIsDmgMax(int t); 77 static bool typeIsResist(int t); 78 static bool typeIsPrimary(int t); 79 static int getStatFromType(int t); 80 static size_t getDmgFromType(int t); 81 static size_t getResistFromType(int t); 82 static size_t getPrimaryFromType(int t); 83 84 std::string id; 85 std::string name; 86 int icon; 87 Timer timer; 88 int type; 89 int magnitude; 90 int magnitude_max; 91 std::string animation_name; 92 Animation* animation; 93 bool item; 94 int trigger; 95 bool render_above; 96 size_t passive_id; 97 int source_type; 98 bool group_stack; 99 uint32_t color_mod; 100 uint8_t alpha_mod; 101 std::string attack_speed_anim; 102 }; 103 104 class EffectDef { 105 public: 106 EffectDef(); 107 108 std::string id; 109 int type; 110 std::string name; 111 int icon; 112 std::string animation; 113 bool can_stack; 114 int max_stacks; 115 bool group_stack; 116 bool render_above; 117 Color color_mod; 118 uint8_t alpha_mod; 119 std::string attack_speed_anim; 120 }; 121 122 class EffectManager { 123 private: 124 void removeEffect(size_t id); 125 void clearStatus(); 126 void addEffectInternal(EffectDef &effect, int duration, int magnitude, int source_type, bool item, PowerID power_id); 127 128 public: 129 EffectManager(); 130 ~EffectManager(); 131 void logic(); 132 void addEffect(EffectDef &effect, int duration, int magnitude, int source_type, PowerID power_id); 133 void addItemEffect(EffectDef &effect, int duration, int magnitude); 134 void removeEffectType(const int type); 135 void removeEffectPassive(size_t id); 136 void removeEffectID(const std::vector< std::pair<std::string, int> >& remove_effects); 137 void clearEffects(); 138 void clearNegativeEffects(int type = -1); 139 void clearItemEffects(); 140 void clearTriggerEffects(int trigger); 141 int damageShields(int dmg); 142 bool isDebuffed(); 143 void getCurrentColor(Color& color_mod); 144 void getCurrentAlpha(uint8_t& alpha_mod); 145 bool hasEffect(const std::string& id, int req_count); 146 float getAttackSpeed(const std::string& anim_name); 147 int getDamageSourceType(int dmg_mode); 148 149 std::vector<Effect> effect_list; 150 151 int damage; 152 int damage_percent; 153 int hpot; 154 int hpot_percent; 155 int mpot; 156 int mpot_percent; 157 float speed; 158 bool immunity_damage; 159 bool immunity_slow; 160 bool immunity_stun; 161 bool immunity_hp_steal; 162 bool immunity_mp_steal; 163 bool immunity_knockback; 164 bool immunity_damage_reflect; 165 bool immunity_stat_debuff; 166 bool stun; 167 bool revive; 168 bool convert; 169 bool death_sentence; 170 bool fear; 171 float knockback_speed; 172 173 std::vector<int> bonus; 174 std::vector<int> bonus_resist; 175 std::vector<int> bonus_primary; 176 177 bool triggered_others; 178 bool triggered_block; 179 bool triggered_hit; 180 bool triggered_halfdeath; 181 bool triggered_joincombat; 182 bool triggered_death; 183 184 bool refresh_stats; 185 186 static const int NO_POWER = 0; 187 }; 188 189 #endif 190