Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / effect_families.cpp
blob8d00cf2007801df7830a55c7d507661ec8a98c51
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
21 #include "nel/misc/debug.h"
22 #include "nel/misc/string_conversion.h"
24 #include "effect_families.h"
27 namespace EFFECT_FAMILIES
29 NL_BEGIN_STRING_CONVERSION_TABLE (TEffectFamily)
31 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffCharacteristic )
33 NL_STRING_CONVERSION_TABLE_ENTRY( Teleport )
34 NL_STRING_CONVERSION_TABLE_ENTRY( ProcShootAgain )
36 NL_STRING_CONVERSION_TABLE_ENTRY( Hot )
37 NL_STRING_CONVERSION_TABLE_ENTRY( Dot )
38 NL_STRING_CONVERSION_TABLE_ENTRY( DoTStackable )
40 NL_STRING_CONVERSION_TABLE_ENTRY( RedirectAttacks )
41 NL_STRING_CONVERSION_TABLE_ENTRY( Stench )
42 NL_STRING_CONVERSION_TABLE_ENTRY( Bounce )
43 NL_STRING_CONVERSION_TABLE_ENTRY( ReflectDamage )
44 NL_STRING_CONVERSION_TABLE_ENTRY( ReverseDamage )
46 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffSkillMelee )
47 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffSkillMagic )
48 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffSkillRange )
49 NL_STRING_CONVERSION_TABLE_ENTRY( SlowMove )
50 NL_STRING_CONVERSION_TABLE_ENTRY( Snare )
51 NL_STRING_CONVERSION_TABLE_ENTRY( SlowMelee )
52 NL_STRING_CONVERSION_TABLE_ENTRY( SlowMagic )
53 NL_STRING_CONVERSION_TABLE_ENTRY( SlowRange )
54 NL_STRING_CONVERSION_TABLE_ENTRY( SlowAttack )
56 NL_STRING_CONVERSION_TABLE_ENTRY( MadnessMelee )
57 NL_STRING_CONVERSION_TABLE_ENTRY( MadnessMagic )
58 NL_STRING_CONVERSION_TABLE_ENTRY( MadnessRange )
59 NL_STRING_CONVERSION_TABLE_ENTRY( Madness )
61 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistBlunt )
62 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistSlash )
63 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistPierce )
64 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistAcid )
65 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistRot )
66 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistCold )
67 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistFire )
68 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistPoison )
69 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistSchock )
70 NL_STRING_CONVERSION_TABLE_ENTRY( DebuffResistElectricity )
72 NL_STRING_CONVERSION_TABLE_ENTRY( Mezz )
73 NL_STRING_CONVERSION_TABLE_ENTRY( Stun )
74 NL_STRING_CONVERSION_TABLE_ENTRY( Root )
75 NL_STRING_CONVERSION_TABLE_ENTRY( Fear )
76 NL_STRING_CONVERSION_TABLE_ENTRY( Blind )
78 NL_STRING_CONVERSION_TABLE_ENTRY( FaunaHatred )
79 NL_STRING_CONVERSION_TABLE_ENTRY( PlantHatred )
80 NL_STRING_CONVERSION_TABLE_ENTRY( KitinHatred )
81 NL_STRING_CONVERSION_TABLE_ENTRY( HominHatred )
82 NL_STRING_CONVERSION_TABLE_ENTRY( DegeneratedHatred )
83 NL_STRING_CONVERSION_TABLE_ENTRY( PetHatred )
84 NL_STRING_CONVERSION_TABLE_ENTRY( KamiHatred )
85 NL_STRING_CONVERSION_TABLE_ENTRY( AllHatred )
87 NL_STRING_CONVERSION_TABLE_ENTRY( Invincibility )
89 NL_STRING_CONVERSION_TABLE_ENTRY( CombatBleed )
90 NL_STRING_CONVERSION_TABLE_ENTRY( CombatStun )
91 NL_STRING_CONVERSION_TABLE_ENTRY( CombatMvtSlow )
92 NL_STRING_CONVERSION_TABLE_ENTRY( CombatAttackSlow )
93 NL_STRING_CONVERSION_TABLE_ENTRY( CombatCastSlow )
94 NL_STRING_CONVERSION_TABLE_ENTRY( CombatSlow )
95 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDefenseModifier )
96 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDebuffCombatSkills )
97 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDebuffDodge )
99 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDebuffStaminaRegen )
100 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDebuffSapRegen )
101 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDebuffHitPointsRegen )
102 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDebuffFocusRegen )
104 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTRot )
105 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTCold )
106 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTFire )
107 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTElectricity )
108 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTAcid )
109 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTPoison )
110 NL_STRING_CONVERSION_TABLE_ENTRY( CombatDoTShock )
112 NL_STRING_CONVERSION_TABLE_ENTRY( PowerShielding )
113 NL_STRING_CONVERSION_TABLE_ENTRY( PowerLifeAura )
114 NL_STRING_CONVERSION_TABLE_ENTRY( PowerStaminaAura )
115 NL_STRING_CONVERSION_TABLE_ENTRY( PowerSapAura )
116 NL_STRING_CONVERSION_TABLE_ENTRY( PowerUmbrella )
117 NL_STRING_CONVERSION_TABLE_ENTRY( PowerProtection )
118 NL_STRING_CONVERSION_TABLE_ENTRY( PowerAntiMagicShield )
119 NL_STRING_CONVERSION_TABLE_ENTRY( PowerWarCry )
120 NL_STRING_CONVERSION_TABLE_ENTRY( PowerFireWall )
121 NL_STRING_CONVERSION_TABLE_ENTRY( PowerThornWall )
122 NL_STRING_CONVERSION_TABLE_ENTRY( PowerWaterWall )
123 NL_STRING_CONVERSION_TABLE_ENTRY( PowerLightningWall )
125 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootLifeAura )
126 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootStaminaAura )
127 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootSapAura )
128 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootUmbrella )
129 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootProtection )
130 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootAntiMagicShield )
131 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootWarCry )
132 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootFireWall )
133 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootThornWall )
134 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootWaterWall )
135 NL_STRING_CONVERSION_TABLE_ENTRY( PowerRootLightningWall )
136 NL_STRING_CONVERSION_TABLE_ENTRY( PowerInvulnerability )
137 NL_STRING_CONVERSION_TABLE_ENTRY( PowerChgCharac )
139 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModDefenseSkill )
140 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModDodgeSkill )
141 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModParrySkill )
142 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModCraftSkill )
143 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModMeleeSkill )
144 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModRangeSkill )
145 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModMagicSkill )
146 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModForageSkill )
147 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModDesertForageSkill )
148 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModForestForageSkill )
149 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModLacustreForageSkill )
150 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModJungleForageSkill )
151 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModPrimaryRootForageSkill )
153 NL_STRING_CONVERSION_TABLE_ENTRY( PowerModMagicProtection )
154 NL_STRING_CONVERSION_TABLE_ENTRY( PowerSpeedingUp )
155 NL_STRING_CONVERSION_TABLE_ENTRY( PowerBerserker )
156 NL_STRING_CONVERSION_TABLE_ENTRY( PowerEnchantWeapon )
158 NL_STRING_CONVERSION_TABLE_ENTRY( OutpostCombat )
159 NL_STRING_CONVERSION_TABLE_ENTRY( OutpostMagic )
160 NL_STRING_CONVERSION_TABLE_ENTRY( OutpostForage )
161 NL_STRING_CONVERSION_TABLE_ENTRY( OutpostCraft )
163 NL_STRING_CONVERSION_TABLE_ENTRY( ForageLocateDeposit )
165 NL_STRING_CONVERSION_TABLE_ENTRY( TotemStatsHP )
166 NL_STRING_CONVERSION_TABLE_ENTRY( TotemStatsSap )
167 NL_STRING_CONVERSION_TABLE_ENTRY( TotemStatsSta )
168 NL_STRING_CONVERSION_TABLE_ENTRY( TotemStatsFoc )
169 NL_STRING_CONVERSION_TABLE_ENTRY( TotemRegenHP )
170 NL_STRING_CONVERSION_TABLE_ENTRY( TotemRegenSap )
171 NL_STRING_CONVERSION_TABLE_ENTRY( TotemRegenSta )
172 NL_STRING_CONVERSION_TABLE_ENTRY( TotemRegenFoc )
173 NL_STRING_CONVERSION_TABLE_ENTRY( TotemHarvestAgg )
174 NL_STRING_CONVERSION_TABLE_ENTRY( TotemHarvestQty )
175 NL_STRING_CONVERSION_TABLE_ENTRY( TotemHarvestZRs )
176 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCraftSuc )
177 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatRes )
178 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatPar )
179 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatCri )
180 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatMagOff )
181 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatMagDef )
182 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatMROff )
183 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatMRSpd )
184 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatDS )
185 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatArm )
186 NL_STRING_CONVERSION_TABLE_ENTRY( TotemCombatPoZ )
187 NL_STRING_CONVERSION_TABLE_ENTRY( TotemMiscMov )
189 NL_STRING_CONVERSION_TABLE_ENTRY (Unknown)
191 NL_END_STRING_CONVERSION_TABLE(TEffectFamily, EffectFamilyConversion, Unknown)
193 TEffectFamily toEffectFamily(const std::string &str)
195 return EffectFamilyConversion.fromString(str);
198 const std::string &toString(TEffectFamily family)
200 return EffectFamilyConversion.toString(family);
203 TEffectFamily getDebuffResistEffect( DMGTYPE::EDamageType type)
205 switch( type )
207 case DMGTYPE::SLASHING : return DebuffResistSlash;
208 case DMGTYPE::PIERCING : return DebuffResistPierce;
209 case DMGTYPE::BLUNT : return DebuffResistBlunt;
210 case DMGTYPE::ROT : return DebuffResistRot;
211 case DMGTYPE::ACID : return DebuffResistAcid;
212 case DMGTYPE::COLD : return DebuffResistCold;
213 case DMGTYPE::FIRE : return DebuffResistFire;
214 case DMGTYPE::POISON : return DebuffResistPoison;
215 case DMGTYPE::ELECTRICITY : return DebuffResistElectricity;
216 case DMGTYPE::SHOCK : return DebuffResistSchock;
217 default: break;
219 return Unknown;
222 TEffectFamily getCombatDoTEffect( DMGTYPE::EDamageType type)
224 switch( type )
226 case DMGTYPE::ROT : return CombatDoTRot;
227 case DMGTYPE::ACID : return CombatDoTAcid;
228 case DMGTYPE::COLD : return CombatDoTCold;
229 case DMGTYPE::FIRE : return CombatDoTFire;
230 case DMGTYPE::POISON : return CombatDoTPoison;
231 case DMGTYPE::ELECTRICITY : return CombatDoTElectricity;
232 case DMGTYPE::SHOCK : return CombatDoTShock;
233 default: break;
235 return Unknown;
239 bool isEffectABonus(EFFECT_FAMILIES::TEffectFamily family)
241 if (family == EFFECT_FAMILIES::Hot)
242 return true;
244 if (family >= EFFECT_FAMILIES::BeginPowerEffects && family <= EFFECT_FAMILIES::EndPowerEffects)
245 return true;
247 if (family == EFFECT_FAMILIES::ProcShootAgain)
248 return true;
250 return false;
253 // The conversion table
254 const NLMISC::CStringConversion<TEffectFamily>::CPair chatIdTable [] =
256 { "MEZZ", Mezz },
257 { "STUN", Stun },
258 { "STUN", CombatStun },
259 { "ROOT", Root },
260 { "FEAR", Fear },
261 { "BLIND", Blind },
262 { "SLOW_MOVE", CombatMvtSlow },
263 { "SLOW_MOVE", SlowMove },
264 { "SLOW_ATTACKS", CombatAttackSlow },
265 { "DEBUFF_COMBAT", CombatDebuffCombatSkills },
266 { "DEBUFF_DEFENSE", CombatDefenseModifier },
267 { "DEBUFF_DODGE", CombatDebuffDodge },
268 { "INVULNERABILITY", PowerInvulnerability },
269 { "MADNESS", Madness },
270 { "STENCH", Stench },
273 NLMISC::CStringConversion<TEffectFamily> conversion(chatIdTable, sizeof(chatIdTable) / sizeof(chatIdTable[0]), Unknown);
275 const std::string EmptyStr;
276 const std::string UnknownStr = "Unknown";
278 const std::string & getAssociatedChatId(EFFECT_FAMILIES::TEffectFamily family)
280 const std::string &str = conversion.toString(family);
281 if (str == UnknownStr)
282 return EmptyStr;
283 else
284 return str;
287 // conversion effect->sheetid
288 const NLMISC::CStringConversion<TEffectFamily>::CPair sheetIdTable [] =
290 { "mezz.sbrick", Mezz },
291 { "stun.sbrick", Stun },
292 { "stun.sbrick", CombatStun },
293 { "root.sbrick", Root },
294 { "fear.sbrick", Fear },
295 { "blind.sbrick", Blind },
296 { "snare.sbrick", CombatMvtSlow },
297 { "snare.sbrick", SlowMove },
298 { "slow.sbrick", CombatAttackSlow },
299 { "slow.sbrick", CombatSlow },
300 { "stench.sbrick", Stench },
302 { "rot.sbrick", CombatDoTRot },
303 { "cold.sbrick", CombatDoTCold },
304 { "fire.sbrick", CombatDoTFire },
305 { "electric.sbrick", CombatDoTElectricity },
306 { "acid.sbrick", CombatDoTAcid },
307 { "poison.sbrick", CombatDoTPoison },
308 { "shockwave.sbrick", CombatDoTShock },
310 { "debuff_dodge.sbrick", CombatDebuffDodge },
311 { "debuff_combat_skills.sbrick",CombatDebuffCombatSkills },
313 { "shielding.sbrick", PowerShielding },
314 { "life_aura.sbrick", PowerLifeAura },
315 { "stamina_aura.sbrick", PowerStaminaAura },
316 { "sap_aura.sbrick", PowerSapAura },
317 { "umbrella_aura.sbrick", PowerUmbrella },
318 { "melee_protection_aura.sbrick",PowerProtection },
319 { "anti_magic_shield_aura.sbrick",PowerAntiMagicShield },
320 { "invulnerability.sbrick", PowerInvulnerability },
321 { "war_cry_aura.sbrick", PowerWarCry },
322 { "fire_wall_aura.sbrick", PowerFireWall },
323 { "thorn_wall_aura.sbrick", PowerThornWall },
324 { "water_wall_aura.sbrick", PowerWaterWall },
325 { "lightning_wall_aura.sbrick", PowerLightningWall },
326 { "chg_charac.sbrick", PowerChgCharac },
327 { "mod_defense.sbrick", PowerModDefenseSkill },
328 { "mod_dodge.sbrick", PowerModDodgeSkill },
329 { "mod_parry.sbrick", PowerModParrySkill },
330 { "mod_craft_success.sbrick", PowerModCraftSkill },
331 { "mod_melee_success.sbrick", PowerModMeleeSkill },
332 { "mod_range_success.sbrick", PowerModRangeSkill },
333 { "mod_magic_success.sbrick", PowerModMagicSkill },
334 { "mod_forage_success.sbrick", PowerModForageSkill },
335 { "mod_desert_forage_success.sbrick", PowerModDesertForageSkill },
336 { "mod_forest_forage_success.sbrick", PowerModForestForageSkill },
337 { "mod_lacustre_forage_success.sbrick", PowerModLacustreForageSkill },
338 { "mod_jungle_forage_success.sbrick", PowerModJungleForageSkill },
339 { "mod_primary_root_forage_success.sbrick", PowerModPrimaryRootForageSkill },
340 { "mod_protect_magic.sbrick", PowerModMagicProtection },
341 { "speeding_up.sbrick", PowerSpeedingUp },
342 { "berserk.sbrick", PowerBerserker},
343 { "enchant_weapon.sbrick", PowerEnchantWeapon},
345 { "Unknown", Unknown },
347 NLMISC::CStringConversion<TEffectFamily> conversionSheetID(sheetIdTable, sizeof(sheetIdTable) / sizeof(sheetIdTable[0]), Unknown);
349 /// get the sheetId associated to an effect to display on client interface
350 NLMISC::CSheetId getAssociatedSheetId(TEffectFamily family)
352 const std::string &str = conversionSheetID.toString(family);
353 if ( !str.empty() && str != "Unknown")
354 return NLMISC::CSheetId(str);
355 else
356 return NLMISC::CSheetId::Unknown;
359 RESISTANCE_TYPE::TResistanceType getAssociatedResistanceType(TEffectFamily family)
361 switch(family)
363 case Blind:
364 case MadnessMelee:
365 case MadnessMagic:
366 case MadnessRange:
367 case Madness:
368 return RESISTANCE_TYPE::Desert;
369 case Mezz:
370 case SlowMove:
371 return RESISTANCE_TYPE::Forest;
372 case Stun:
373 return RESISTANCE_TYPE::Lacustre;
374 case SlowMelee:
375 case SlowRange:
376 case SlowMagic:
377 case SlowAttack:
378 case Root:
379 return RESISTANCE_TYPE::Jungle;
380 case Fear:
381 return RESISTANCE_TYPE::PrimaryRoot;
382 default:
383 return RESISTANCE_TYPE::None;
387 }; // EFFECT_FAMILIES