Spells.cpp 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator 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 General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "Spells.h"
  17. #include "../common/ConfigReader.h"
  18. #include "WorldDatabase.h"
  19. #include "../common/Log.h"
  20. #include "Traits/Traits.h"
  21. #include "AltAdvancement/AltAdvancement.h"
  22. #include <cmath>
  23. extern ConfigReader configReader;
  24. extern WorldDatabase database;
  25. extern MasterTraitList master_trait_list;
  26. extern MasterAAList master_aa_list;
  27. extern MasterSpellList master_spell_list;
  28. Spell::Spell(){
  29. spell = new SpellData;
  30. heal_spell = false;
  31. buff_spell = false;
  32. damage_spell = false;
  33. control_spell = false;
  34. offense_spell = false;
  35. MSpellInfo.SetName("Spell::MSpellInfo");
  36. }
  37. Spell::Spell(SpellData* in_spell){
  38. spell = in_spell;
  39. heal_spell = false;
  40. buff_spell = false;
  41. damage_spell = false;
  42. control_spell = false;
  43. offense_spell = false;
  44. MSpellInfo.SetName("Spell::MSpellInfo");
  45. }
  46. Spell::~Spell(){
  47. vector<LevelArray*>::iterator itr1;
  48. for(itr1=levels.begin();itr1!=levels.end();itr1++) {
  49. safe_delete(*itr1);
  50. }
  51. vector<SpellDisplayEffect*>::iterator itr2;
  52. for(itr2=effects.begin();itr2!=effects.end();itr2++) {
  53. safe_delete(*itr2);
  54. }
  55. vector<LUAData*>::iterator itr3;
  56. for(itr3=lua_data.begin();itr3!=lua_data.end();itr3++) {
  57. safe_delete(*itr3);
  58. }
  59. safe_delete(spell);
  60. }
  61. void Spell::AddSpellLuaData(int8 type, int int_value, int int_value2, float float_value, float float_value2, bool bool_value, string string_value, string string_value2, string helper){
  62. LUAData* data = new LUAData;
  63. data->type = type;
  64. data->int_value = int_value;
  65. data->int_value2 = int_value2;
  66. data->float_value = float_value;
  67. data->float_value2 = float_value2;
  68. data->bool_value = bool_value;
  69. data->string_value = string_value;
  70. data->string_value2 = string_value2;
  71. data->string_helper = helper;
  72. MSpellInfo.lock();
  73. lua_data.push_back(data);
  74. MSpellInfo.unlock();
  75. }
  76. void Spell::AddSpellLuaDataInt(int value, int value2, string helper) {
  77. LUAData *data = new LUAData;
  78. data->type = 0;
  79. data->int_value = value;
  80. data->int_value2 = value2;
  81. data->float_value = 0;
  82. data->float_value2 = 0;
  83. data->bool_value = false;
  84. data->string_helper = helper;
  85. MSpellInfo.lock();
  86. lua_data.push_back(data);
  87. MSpellInfo.unlock();
  88. }
  89. void Spell::AddSpellLuaDataFloat(float value, float value2, string helper) {
  90. LUAData *data = new LUAData;
  91. data->type = 1;
  92. data->int_value = 0;
  93. data->int_value2 = 0;
  94. data->float_value = value;
  95. data->float_value2 = value2;
  96. data->bool_value = false;
  97. data->string_helper = helper;
  98. MSpellInfo.lock();
  99. lua_data.push_back(data);
  100. MSpellInfo.unlock();
  101. }
  102. void Spell::AddSpellLuaDataBool(bool value, string helper) {
  103. LUAData *data = new LUAData;
  104. data->type = 2;
  105. data->int_value = 0;
  106. data->float_value = 0;
  107. data->bool_value = value;
  108. data->string_helper = helper;
  109. MSpellInfo.lock();
  110. lua_data.push_back(data);
  111. MSpellInfo.unlock();
  112. }
  113. void Spell::AddSpellLuaDataString(string value, string value2,string helper) {
  114. LUAData *data = new LUAData;
  115. data->type = 3;
  116. data->int_value = 0;
  117. data->int_value2 = 0;
  118. data->float_value = 0;
  119. data->float_value2 = 0;
  120. data->bool_value = false;
  121. data->string_value = value;
  122. data->string_value2 = value2;
  123. data->string_helper = helper;
  124. MSpellInfo.lock();
  125. lua_data.push_back(data);
  126. MSpellInfo.unlock();
  127. }
  128. int16 Spell::GetLevelRequired(Player* player){
  129. int16 ret = 0xFFFF;
  130. if(!player)
  131. return ret;
  132. LevelArray* level = 0;
  133. vector<LevelArray*>::iterator itr;
  134. for(itr = levels.begin(); itr != levels.end(); itr++){
  135. level = *itr;
  136. if(level && level->adventure_class == player->GetAdventureClass()){
  137. ret = level->spell_level/10;
  138. break;
  139. }
  140. }
  141. return ret;
  142. }
  143. void Spell::SetAAPacketInformation(PacketStruct* packet, AltAdvanceData* data, Client* client, bool display_tier) {
  144. int8 current_tier = client->GetPlayer()->GetSpellTier(spell->id);
  145. Spell* next_spell;
  146. SpellData* spell2;
  147. if (data->maxRank > current_tier) {
  148. next_spell = master_spell_list.GetSpell(spell->id, current_tier + 1);
  149. spell2 = next_spell->GetSpellData();
  150. }
  151. SpellDisplayEffect* effect2;
  152. //next_spell->effects[1]->description;
  153. int xxx = 0;
  154. int16 hp_req = 0;
  155. int16 power_req = 0;
  156. if (current_tier > 0) {
  157. packet->setSubstructDataByName("spell_info", "current_id", spell->id);
  158. packet->setSubstructDataByName("spell_info", "current_icon", spell->icon);
  159. packet->setSubstructDataByName("spell_info", "current_icon2", spell->icon_heroic_op); // fix struct element name eventually
  160. packet->setSubstructDataByName("spell_info", "current_icontype", spell->icon_backdrop); // fix struct element name eventually
  161. if (packet->GetVersion() >= 63119) {
  162. packet->setSubstructDataByName("spell_info", "current_version", 0x04);
  163. packet->setSubstructDataByName("spell_info", "current_sub_version", 0x24);
  164. }
  165. else if (packet->GetVersion() >= 58617) {
  166. packet->setSubstructDataByName("spell_info", "current_version", 0x03);
  167. packet->setSubstructDataByName("spell_info", "current_sub_version", 0x131A);
  168. }
  169. else {
  170. packet->setSubstructDataByName("spell_info", "current_version", 0x00);
  171. packet->setSubstructDataByName("spell_info", "current_sub_version", 0xD9);
  172. }
  173. packet->setSubstructDataByName("spell_info", "current_type", spell->type);
  174. packet->setSubstructDataByName("spell_info", "unknown_MJ1d", 1); //63119 test
  175. packet->setSubstructDataByName("spell_info", "current_class_skill", spell->class_skill);
  176. packet->setSubstructDataByName("spell_info", "current_mastery_skill", spell->mastery_skill);
  177. packet->setSubstructDataByName("spell_info", "duration_flag", spell->duration_until_cancel);
  178. if (client && spell->type != 2) {
  179. sint8 spell_text_color = client->GetPlayer()->GetArrowColor(GetLevelRequired(client->GetPlayer()));
  180. if (spell_text_color != ARROW_COLOR_WHITE && spell_text_color != ARROW_COLOR_RED && spell_text_color != ARROW_COLOR_GRAY)
  181. spell_text_color = ARROW_COLOR_WHITE;
  182. spell_text_color -= 6;
  183. if (spell_text_color < 0)
  184. spell_text_color *= -1;
  185. packet->setSubstructDataByName("spell_info", "current_spell_text_color", (xxx == 1 ? 0xFFFFFFFF : spell_text_color));
  186. }
  187. else {
  188. packet->setSubstructDataByName("spell_info", "current_spell_text_color", (xxx == 1 ? 0xFFFFFFFF : 3));
  189. }
  190. packet->setSubstructDataByName("spell_info", "current_spell_text_color", (xxx == 1 ? 0xFFFFFFFF : 3));
  191. packet->setSubstructDataByName("spell_info", "current_tier", (spell->tier));
  192. if (spell->type != 2) {
  193. packet->setArrayLengthByName("current_num_levels", 0);
  194. for (int32 i = 0; i < levels.size(); i++) {
  195. packet->setArrayDataByName("spell_info_aa_adventure_class", levels[i]->adventure_class, i);
  196. packet->setArrayDataByName("spell_info_aa_tradeskill_class", levels[i]->tradeskill_class, i);
  197. packet->setArrayDataByName("spell_info_aa_spell_level", levels[i]->spell_level, i);
  198. }
  199. }
  200. //packet->setSubstructDataByName("spell_info","unknown9", 20);
  201. if (client) {
  202. hp_req = GetHPRequired(client->GetPlayer());
  203. power_req = GetPowerRequired(client->GetPlayer());
  204. // might need version checks around these?
  205. if (client->GetVersion() >= 1193)
  206. {
  207. int16 savagery_req = GetSavageryRequired(client->GetPlayer()); // dunno why we need to do this
  208. packet->setSubstructDataByName("spell_info", "current_savagery_req", savagery_req);
  209. packet->setSubstructDataByName("spell_info", "current_savagery_upkeep", spell->savagery_upkeep);
  210. }
  211. if (client->GetVersion() >= 57048)
  212. {
  213. int16 dissonance_req = GetDissonanceRequired(client->GetPlayer()); // dunno why we need to do this
  214. packet->setSubstructDataByName("spell_info", "dissonance_req", dissonance_req);
  215. packet->setSubstructDataByName("spell_info", "dissonance_upkeep", spell->dissonance_upkeep);
  216. }
  217. }
  218. packet->setSubstructDataByName("spell_info", "current_health_req", hp_req);
  219. packet->setSubstructDataByName("spell_info", "current_health_upkeep", spell->hp_upkeep);
  220. packet->setSubstructDataByName("spell_info", "current_power_req", power_req);
  221. packet->setSubstructDataByName("spell_info", "current_power_upkeep", spell->power_upkeep);
  222. packet->setSubstructDataByName("spell_info", "current_req_concentration", spell->req_concentration);
  223. //unknown1 savagery???
  224. packet->setSubstructDataByName("spell_info", "current_cast_time", spell->cast_time);
  225. packet->setSubstructDataByName("spell_info", "current_recovery", spell->recovery);
  226. packet->setSubstructDataByName("spell_info", "current_recast", spell->recast);
  227. packet->setSubstructDataByName("spell_info", "current_radius", spell->radius);
  228. packet->setSubstructDataByName("spell_info", "current_max_aoe_targets", spell->max_aoe_targets);
  229. packet->setSubstructDataByName("spell_info", "current_friendly_spell", spell->friendly_spell);
  230. // rumber of reagents with array
  231. packet->setSubstructArrayLengthByName("spell_info", "current_num_effects", (xxx == 1 ? 0 : effects.size()));
  232. for (int32 i = 0; i < effects.size(); i++) {
  233. packet->setArrayDataByName("current_subbulletflag", effects[i]->subbullet, i);
  234. string effect_message;
  235. if (effects[i]->description.length() > 0) {
  236. effect_message = effects[i]->description;
  237. if (effect_message.find("%LM") < 0xFFFFFFFF) {
  238. int string_index = effect_message.find("%LM");
  239. int data_index = stoi(effect_message.substr(string_index + 3, 2));
  240. float value;
  241. if (lua_data[data_index]->type == 1)
  242. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  243. else
  244. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  245. string strValue = to_string(value);
  246. strValue.erase(strValue.find_last_not_of('0') + 1, std::string::npos);
  247. effect_message.replace(effect_message.find("%LM"), 5, strValue);
  248. }
  249. // Magic damage min
  250. if (effect_message.find("%DML") < 0xFFFFFFFF) {
  251. int string_index = effect_message.find("%DML");
  252. int data_index = stoi(effect_message.substr(string_index + 4, 2));
  253. float value;
  254. if (lua_data[data_index]->type == 1)
  255. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  256. else
  257. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  258. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  259. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  260. value += mod;
  261. string damage = to_string((int)round(value));
  262. effect_message.replace(effect_message.find("%DML"), 6, damage);
  263. }
  264. // Magic damage max
  265. if (effect_message.find("%DMH") < 0xFFFFFFFF) {
  266. int string_index = effect_message.find("%DMH");
  267. int data_index = stoi(effect_message.substr(string_index + 4, 2));
  268. float value;
  269. if (lua_data[data_index]->type == 1)
  270. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  271. else
  272. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  273. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  274. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  275. value += mod;
  276. string damage = to_string((int)round(value));
  277. effect_message.replace(effect_message.find("%DMH"), 6, damage);
  278. }
  279. // level based Magic damage min
  280. if (effect_message.find("%LDML") < 0xFFFFFFFF) {
  281. int string_index = effect_message.find("%LDML");
  282. int data_index = stoi(effect_message.substr(string_index + 5, 2));
  283. float value;
  284. if (lua_data[data_index]->type == 1)
  285. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  286. else
  287. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  288. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  289. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  290. value += mod;
  291. string damage = to_string((int)round(value));
  292. effect_message.replace(effect_message.find("%LDML"), 7, damage);
  293. }
  294. // level based Magic damage max
  295. if (effect_message.find("%LDMH") < 0xFFFFFFFF) {
  296. int string_index = effect_message.find("%LDMH");
  297. int data_index = stoi(effect_message.substr(string_index + 5, 2));
  298. float value;
  299. if (lua_data[data_index]->type == 1)
  300. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  301. else
  302. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  303. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  304. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  305. value += mod;
  306. string damage = to_string((int)round(value));
  307. effect_message.replace(effect_message.find("%LDMH"), 7, damage);
  308. }
  309. //GetZone()->SimpleMessage(CHANNEL_COLOR_SPELL_EFFECT, effect_message.c_str(), victim, 50);
  310. packet->setArrayDataByName("current_effect", effect_message.c_str(), i);
  311. }
  312. packet->setArrayDataByName("current_percentage", effects[i]->percentage, i);
  313. }
  314. if (display_tier == true)
  315. packet->setSubstructDataByName("spell_info", "current_display_spell_tier", 1);// spell2->display_spell_tier);
  316. else
  317. packet->setSubstructDataByName("spell_info", "current_display_spell_tier", 1);// 0);
  318. packet->setSubstructDataByName("spell_info", "current_unknown_1", 1);// 0);
  319. //unkown1_1
  320. packet->setSubstructDataByName("spell_info", "current_minimum_range", spell->min_range);
  321. packet->setSubstructDataByName("spell_info", "current_range", spell->range);
  322. packet->setSubstructDataByName("spell_info", "current_duration_1", spell->duration1);
  323. packet->setSubstructDataByName("spell_info", "current_duration_2", spell->duration2);
  324. packet->setSubstructDataByName("spell_info", "current_duration_flag", spell->duration_until_cancel);
  325. packet->setSubstructDataByName("spell_info", "current_target", spell->target_type);
  326. packet->setSubstructDataByName("spell_info", "current_can_effect_raid", spell->can_effect_raid);
  327. packet->setSubstructDataByName("spell_info", "current_affect_only_group_members", spell->affect_only_group_members);
  328. packet->setSubstructDataByName("spell_info", "current_group_spell", spell->group_spell);
  329. packet->setSubstructDataByName("spell_info", "current_resistibility", spell->resistibility);
  330. packet->setSubstructDataByName("spell_info", "current_name", &(spell->name));
  331. packet->setSubstructDataByName("spell_info", "current_description", &(spell->description));
  332. }
  333. if (current_tier + 1 <= data->maxRank) {
  334. packet->setSubstructDataByName("spell_info", "next_id", spell2->id);
  335. packet->setSubstructDataByName("spell_info", "next_icon", spell2->icon);
  336. packet->setSubstructDataByName("spell_info", "next_icon2", spell2->icon_heroic_op); // fix struct element name eventually
  337. packet->setSubstructDataByName("spell_info", "next_icontype", spell2->icon_backdrop); // fix struct element name eventually
  338. if (packet->GetVersion() >= 63119) {
  339. packet->setSubstructDataByName("spell_info", "next_aa_spell_info2", "version", 0x04);
  340. packet->setSubstructDataByName("spell_info", "next_aa_spell_info2", "sub_version", 0x24);
  341. }
  342. else if (packet->GetVersion() >= 58617) {
  343. packet->setSubstructDataByName("spell_info", "next_version", 0x03);
  344. packet->setSubstructDataByName("spell_info", "next_sub_version", 0x131A);
  345. }
  346. else {
  347. packet->setSubstructDataByName("spell_info", "next_version", 0x00);
  348. packet->setSubstructDataByName("spell_info", "next_sub_version", 0xD9);
  349. }
  350. packet->setSubstructDataByName("spell_info", "next_type", spell2->type);
  351. packet->setSubstructDataByName("spell_info", "next_unknown_MJ1d", 1); //63119 test
  352. packet->setSubstructDataByName("spell_info", "next_class_skill", spell2->class_skill);
  353. packet->setSubstructDataByName("spell_info", "next_mastery_skill", spell2->mastery_skill);
  354. packet->setSubstructDataByName("spell_info", "next_duration_flag", spell2->duration_until_cancel);
  355. if (client && spell->type != 2) {
  356. sint8 spell_text_color = client->GetPlayer()->GetArrowColor(GetLevelRequired(client->GetPlayer()));
  357. if (spell_text_color != ARROW_COLOR_WHITE && spell_text_color != ARROW_COLOR_RED && spell_text_color != ARROW_COLOR_GRAY)
  358. spell_text_color = ARROW_COLOR_WHITE;
  359. spell_text_color -= 6;
  360. if (spell_text_color < 0)
  361. spell_text_color *= -1;
  362. packet->setSubstructDataByName("spell_info", "next_spell_text_color", spell_text_color);
  363. }
  364. else
  365. packet->setSubstructDataByName("spell_info", "next_spell_text_color", 3);
  366. if (spell->type != 2) {
  367. packet->setArrayLengthByName("num_levels", levels.size());
  368. for (int32 i = 0; i < levels.size(); i++) {
  369. packet->setArrayDataByName("spell_info_aa_adventure_class2", levels[i]->adventure_class, i);
  370. packet->setArrayDataByName("spell_info_aa_tradeskill_class2", levels[i]->tradeskill_class, i);
  371. packet->setArrayDataByName("spell_info_aa_spell_level2", levels[i]->spell_level, i);
  372. }
  373. }
  374. //packet->setSubstructDataByName("spell_info","unknown9", 20);
  375. hp_req = 0;
  376. power_req = 0;
  377. if (client) {
  378. hp_req = GetHPRequired(client->GetPlayer());
  379. power_req = GetPowerRequired(client->GetPlayer());
  380. // might need version checks around these?
  381. if (client->GetVersion() >= 1193)
  382. {
  383. int16 savagery_req = GetSavageryRequired(client->GetPlayer()); // dunno why we need to do this
  384. packet->setSubstructDataByName("spell_info", "next_savagery_req", savagery_req);
  385. packet->setSubstructDataByName("spell_info", "next_savagery_upkeep", spell->savagery_upkeep);
  386. }
  387. if (client->GetVersion() >= 57048)
  388. {
  389. int16 dissonance_req = GetDissonanceRequired(client->GetPlayer()); // dunno why we need to do this
  390. packet->setSubstructDataByName("spell_info", "next_dissonance_req", dissonance_req);
  391. packet->setSubstructDataByName("spell_info", "next_dissonance_upkeep", spell->dissonance_upkeep);
  392. }
  393. }
  394. packet->setSubstructDataByName("spell_info", "next_target", spell->target_type);
  395. packet->setSubstructDataByName("spell_info", "next_recovery", spell->recovery);
  396. packet->setSubstructDataByName("spell_info", "next_health_upkeep", spell->hp_upkeep);
  397. packet->setSubstructDataByName("spell_info", "next_health_req", hp_req);
  398. packet->setSubstructDataByName("spell_info", "next_tier", spell->tier);
  399. packet->setSubstructDataByName("spell_info", "next_power_req", power_req);
  400. packet->setSubstructDataByName("spell_info", "next_power_upkeep", spell->power_upkeep);
  401. packet->setSubstructDataByName("spell_info", "next_cast_time", spell->cast_time);
  402. packet->setSubstructDataByName("spell_info", "next_recast", spell->recast);
  403. packet->setSubstructDataByName("spell_info", "next_radius", spell->radius);
  404. packet->setSubstructDataByName("spell_info", "next_req_concentration", spell->req_concentration);
  405. //packet->setSubstructDataByName("spell_info","req_concentration2", 2);
  406. packet->setSubstructDataByName("spell_info", "next_max_aoe_targets", spell->max_aoe_targets);
  407. packet->setSubstructDataByName("spell_info", "next_friendly_spell", spell->friendly_spell);
  408. packet->setSubstructArrayLengthByName("spell_info", "next_num_effects", next_spell->effects.size());
  409. for (int32 i = 0; i < next_spell->effects.size(); i++) {
  410. packet->setArrayDataByName("next_subbulletflag", next_spell->effects[i]->subbullet, i);
  411. string effect_message;
  412. if (next_spell->effects[i]->description.length() > 0) {
  413. effect_message = next_spell->effects[i]->description;
  414. if (effect_message.find("%LM") < 0xFFFFFFFF) {
  415. int string_index = effect_message.find("%LM");
  416. int data_index = stoi(effect_message.substr(string_index + 3, 2));
  417. float value;
  418. if (next_spell->lua_data[data_index]->type == 1)
  419. value = next_spell->lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  420. else
  421. value = next_spell->lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  422. string strValue = to_string(value);
  423. strValue.erase(strValue.find_last_not_of('0') + 1, std::string::npos);
  424. effect_message.replace(effect_message.find("%LM"), 5, strValue);
  425. }
  426. // Magic damage min
  427. if (effect_message.find("%DML") < 0xFFFFFFFF) {
  428. int string_index = effect_message.find("%DML");
  429. int data_index = stoi(effect_message.substr(string_index + 4, 2));
  430. float value;
  431. if (next_spell->lua_data[data_index]->type == 1)
  432. value = next_spell->lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  433. else
  434. value = next_spell->lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  435. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  436. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  437. value += mod;
  438. string damage = to_string((int)round(value));
  439. damage.erase(damage.find_last_not_of('0') + 1, std::string::npos);
  440. effect_message.replace(effect_message.find("%DML"), 6, damage);
  441. }
  442. // Magic damage max
  443. if (effect_message.find("%DMH") < 0xFFFFFFFF) {
  444. int string_index = effect_message.find("%DMH");
  445. int data_index = stoi(effect_message.substr(string_index + 4, 2));
  446. float value;
  447. if (next_spell->lua_data[data_index]->type == 1)
  448. value = next_spell->lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  449. else
  450. value = next_spell->lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  451. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  452. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  453. value += mod;
  454. string damage = to_string((int)round(value));
  455. damage.erase(damage.find_last_not_of('0') + 1, std::string::npos);
  456. effect_message.replace(effect_message.find("%DMH"), 6, damage);
  457. }
  458. // level based Magic damage min
  459. if (effect_message.find("%LDML") < 0xFFFFFFFF) {
  460. int string_index = effect_message.find("%LDML");
  461. int data_index = stoi(effect_message.substr(string_index + 5, 2));
  462. float value;
  463. if (next_spell->lua_data[data_index]->type == 1)
  464. value = next_spell->lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  465. else
  466. value = next_spell->lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  467. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  468. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  469. value += mod;
  470. string damage = to_string((int)round(value));
  471. effect_message.replace(effect_message.find("%LDML"), 7, damage);
  472. }
  473. // level based Magic damage max
  474. if (effect_message.find("%LDMH") < 0xFFFFFFFF) {
  475. int string_index = effect_message.find("%LDMH");
  476. int data_index = stoi(effect_message.substr(string_index + 5, 2));
  477. float value;
  478. if (next_spell->lua_data[data_index]->type == 1)
  479. value = next_spell->lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  480. else
  481. value = next_spell->lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  482. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  483. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  484. value += mod;
  485. string damage = to_string((int)round(value));
  486. effect_message.replace(effect_message.find("%LDMH"), 7, damage);
  487. }
  488. //GetZone()->SimpleMessage(CHANNEL_COLOR_SPELL_EFFECT, effect_message.c_str(), victim, 50);
  489. packet->setArrayDataByName("next_effect", effect_message.c_str(), i);
  490. }
  491. packet->setArrayDataByName("next_percentage", next_spell->effects[i]->percentage, i);
  492. }
  493. if (display_tier == true)
  494. packet->setSubstructDataByName("spell_info", "next_display_spell_tier", 1);// spell->display_spell_tier);
  495. else
  496. packet->setSubstructDataByName("spell_info", "next_display_spell_tier", 1);//0
  497. packet->setSubstructDataByName("spell_info", "next_unknown_1", 1);//0
  498. packet->setSubstructDataByName("spell_info", "next_range", spell2->range);
  499. packet->setSubstructDataByName("spell_info", "next_duration_1", spell2->duration1);
  500. packet->setSubstructDataByName("spell_info", "next_duration_2", spell2->duration2);
  501. packet->setSubstructDataByName("spell_info", "next_can_effect_raid", spell2->can_effect_raid);
  502. packet->setSubstructDataByName("spell_info", "next_affect_only_group_members", spell2->affect_only_group_members);
  503. packet->setSubstructDataByName("spell_info", "next_group_spell", spell2->group_spell);
  504. packet->setSubstructDataByName("spell_info", "next_resistibility", spell2->resistibility);
  505. packet->setSubstructDataByName("spell_info", "next_name", &(spell2->name));
  506. packet->setSubstructDataByName("spell_info", "next_description", &(spell2->description));
  507. }
  508. }
  509. void Spell::SetPacketInformation(PacketStruct* packet, Client* client, bool display_tier) {
  510. packet->setSubstructDataByName("spell_info", "id", spell->id);
  511. packet->setSubstructDataByName("spell_info", "icon", spell->icon);
  512. packet->setSubstructDataByName("spell_info", "icon2", spell->icon_heroic_op); // fix struct element name eventually
  513. packet->setSubstructDataByName("spell_info", "icontype", spell->icon_backdrop); // fix struct element name eventually
  514. if (packet->GetVersion() >= 63119) {
  515. packet->setSubstructDataByName("spell_info", "version", 0x04);
  516. packet->setSubstructDataByName("spell_info", "sub_version", 0x24);
  517. }
  518. else if (packet->GetVersion() >= 60114) {
  519. packet->setSubstructDataByName("spell_info", "version", 0x03);
  520. packet->setSubstructDataByName("spell_info", "sub_version", 4890);
  521. }
  522. else if (packet->GetVersion() <= 546) {
  523. packet->setSubstructDataByName("spell_info", "version", 0x10);
  524. packet->setSubstructDataByName("spell_info", "sub_version", 0x0f);
  525. }
  526. else {
  527. packet->setSubstructDataByName("spell_info", "version", 0x11);
  528. packet->setSubstructDataByName("spell_info", "sub_version", 0x14);
  529. }
  530. packet->setSubstructDataByName("spell_info", "type", spell->type);
  531. packet->setSubstructDataByName("spell_info", "unknown_MJ1d", 1); //63119 test
  532. packet->setSubstructDataByName("spell_info", "class_skill", spell->class_skill);
  533. packet->setSubstructDataByName("spell_info", "mastery_skill", spell->mastery_skill);
  534. packet->setSubstructDataByName("spell_info", "duration_flag", spell->duration_until_cancel);
  535. if (client && spell->type != 2) {
  536. sint8 spell_text_color = client->GetPlayer()->GetArrowColor(GetLevelRequired(client->GetPlayer()));
  537. if (spell_text_color != ARROW_COLOR_WHITE && spell_text_color != ARROW_COLOR_RED && spell_text_color != ARROW_COLOR_GRAY)
  538. spell_text_color = ARROW_COLOR_WHITE;
  539. spell_text_color -= 6;
  540. if (spell_text_color < 0)
  541. spell_text_color *= -1;
  542. packet->setSubstructDataByName("spell_info", "spell_text_color", spell_text_color);
  543. }
  544. else
  545. packet->setSubstructDataByName("spell_info", "spell_text_color", 3);
  546. if (spell->type != 2) {
  547. packet->setSubstructArrayLengthByName("spell_info", "num_levels", levels.size());
  548. for (int32 i = 0; i < levels.size(); i++) {
  549. packet->setArrayDataByName("adventure_class", levels[i]->adventure_class, i);
  550. packet->setArrayDataByName("tradeskill_class", levels[i]->tradeskill_class, i);
  551. packet->setArrayDataByName("spell_level", levels[i]->spell_level, i);
  552. }
  553. }
  554. packet->setSubstructDataByName("spell_info", "unknown9", 20);
  555. int16 hp_req = 0;
  556. int16 power_req = 0;
  557. if (client) {
  558. hp_req = GetHPRequired(client->GetPlayer());
  559. power_req = GetPowerRequired(client->GetPlayer());
  560. // might need version checks around these?
  561. if (client->GetVersion() >= 1193)
  562. {
  563. int16 savagery_req = GetSavageryRequired(client->GetPlayer()); // dunno why we need to do this
  564. packet->setSubstructDataByName("spell_info", "savagery_req", savagery_req);
  565. packet->setSubstructDataByName("spell_info", "savagery_upkeep", spell->savagery_upkeep);
  566. }
  567. if (client->GetVersion() >= 57048)
  568. {
  569. int16 dissonance_req = GetDissonanceRequired(client->GetPlayer()); // dunno why we need to do this
  570. packet->setSubstructDataByName("spell_info", "dissonance_req", dissonance_req);
  571. packet->setSubstructDataByName("spell_info", "dissonance_upkeep", spell->dissonance_upkeep);
  572. }
  573. }
  574. packet->setSubstructDataByName("spell_info", "target", spell->target_type);
  575. packet->setSubstructDataByName("spell_info", "recovery", spell->recovery);
  576. packet->setSubstructDataByName("spell_info", "health_upkeep", spell->hp_upkeep);
  577. packet->setSubstructDataByName("spell_info", "health_req", hp_req);
  578. packet->setSubstructDataByName("spell_info", "tier", spell->tier);
  579. packet->setSubstructDataByName("spell_info", "power_req", power_req);
  580. packet->setSubstructDataByName("spell_info", "power_upkeep", spell->power_upkeep);
  581. packet->setSubstructDataByName("spell_info", "cast_time", spell->cast_time);
  582. packet->setSubstructDataByName("spell_info", "recast", spell->recast);
  583. packet->setSubstructDataByName("spell_info", "radius", spell->radius);
  584. packet->setSubstructDataByName("spell_info", "req_concentration", spell->req_concentration);
  585. //packet->setSubstructDataByName("spell_info","req_concentration2", 2);
  586. packet->setSubstructDataByName("spell_info", "max_aoe_targets", spell->max_aoe_targets);
  587. packet->setSubstructDataByName("spell_info", "friendly_spell", spell->friendly_spell);
  588. packet->setSubstructArrayLengthByName("spell_info", "num_effects", effects.size());
  589. for (int32 i = 0; i < effects.size(); i++) {
  590. packet->setArrayDataByName("subbulletflag", effects[i]->subbullet, i);
  591. string effect_message;
  592. if (effects[i]->description.length() > 0) {
  593. effect_message = effects[i]->description;
  594. if (effect_message.find("%LM") < 0xFFFFFFFF) {
  595. int string_index = effect_message.find("%LM");
  596. int data_index = stoi(effect_message.substr(string_index + 3, 2));
  597. float value;
  598. if (lua_data[data_index]->type == 1)
  599. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  600. else
  601. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  602. string strValue = to_string(value);
  603. strValue.erase(strValue.find_last_not_of('0') + 1, std::string::npos);
  604. effect_message.replace(effect_message.find("%LM"), 5, strValue);
  605. }
  606. // Magic damage min
  607. if (effect_message.find("%DML") < 0xFFFFFFFF) {
  608. int string_index = effect_message.find("%DML");
  609. int data_index = stoi(effect_message.substr(string_index + 4, 2));
  610. float value;
  611. if (lua_data[data_index]->type == 1)
  612. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  613. else
  614. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  615. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  616. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  617. value += mod;
  618. string damage = to_string((int)round(value));
  619. effect_message.replace(effect_message.find("%DML"), 6, damage);
  620. }
  621. // Magic damage max
  622. if (effect_message.find("%DMH") < 0xFFFFFFFF) {
  623. int string_index = effect_message.find("%DMH");
  624. int data_index = stoi(effect_message.substr(string_index + 4, 2));
  625. float value;
  626. if (lua_data[data_index]->type == 1)
  627. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  628. else
  629. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  630. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  631. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  632. value += mod;
  633. string damage = to_string((int)round(value));
  634. effect_message.replace(effect_message.find("%DMH"), 6, damage);
  635. }
  636. // level based Magic damage min
  637. if (effect_message.find("%LDML") < 0xFFFFFFFF) {
  638. int string_index = effect_message.find("%LDML");
  639. int data_index = stoi(effect_message.substr(string_index + 5, 2));
  640. float value;
  641. if (lua_data[data_index]->type == 1)
  642. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  643. else
  644. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  645. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  646. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  647. value += mod;
  648. string damage = to_string((int)round(value));
  649. effect_message.replace(effect_message.find("%LDML"), 7, damage);
  650. }
  651. // level based Magic damage max
  652. if (effect_message.find("%LDMH") < 0xFFFFFFFF) {
  653. int string_index = effect_message.find("%LDMH");
  654. int data_index = stoi(effect_message.substr(string_index + 5, 2));
  655. float value;
  656. if (lua_data[data_index]->type == 1)
  657. value = lua_data[data_index]->float_value * client->GetPlayer()->GetLevel();
  658. else
  659. value = lua_data[data_index]->int_value * client->GetPlayer()->GetLevel();
  660. value *= ((client->GetPlayer()->GetInfoStruct()->potency / 100) + 1);
  661. int32 mod = (int32)min(client->GetPlayer()->GetInfoStruct()->ability_modifier, (float)(value / 2));
  662. value += mod;
  663. string damage = to_string((int)round(value));
  664. effect_message.replace(effect_message.find("%LDMH"), 7, damage);
  665. }
  666. //GetZone()->SimpleMessage(CHANNEL_COLOR_SPELL_EFFECT, effect_message.c_str(), victim, 50);
  667. }
  668. packet->setArrayDataByName("effect", effect_message.c_str(), i);
  669. packet->setArrayDataByName("percentage", effects[i]->percentage, i);
  670. }
  671. if (display_tier == true)
  672. packet->setSubstructDataByName("spell_info", "display_spell_tier", spell->display_spell_tier);
  673. else
  674. packet->setSubstructDataByName("spell_info", "display_spell_tier", 0);
  675. packet->setSubstructDataByName("spell_info", "range", spell->range);
  676. packet->setSubstructDataByName("spell_info", "duration1", spell->duration1);
  677. packet->setSubstructDataByName("spell_info", "duration2", spell->duration2);
  678. packet->setSubstructDataByName("spell_info", "can_effect_raid", spell->can_effect_raid);
  679. packet->setSubstructDataByName("spell_info", "affect_only_group_members", spell->affect_only_group_members);
  680. packet->setSubstructDataByName("spell_info", "group_spell", spell->group_spell);
  681. packet->setSubstructDataByName("spell_info", "resistibility", spell->resistibility);
  682. packet->setSubstructDataByName("spell_info", "name", &(spell->name));
  683. packet->setSubstructDataByName("spell_info", "description", &(spell->description));
  684. //packet->PrintPacket();
  685. }
  686. EQ2Packet* Spell::SerializeSpecialSpell(Client* client, bool display, int8 packet_type, int8 sub_packet_type) {
  687. if (client->GetVersion() <= 283)
  688. return SerializeSpell(client, display, false, packet_type, 0, "WS_ExaminePartialSpellInfo");
  689. return SerializeSpell(client, display, false, packet_type, sub_packet_type, "WS_ExamineSpecialSpellInfo");
  690. }
  691. EQ2Packet* Spell::SerializeAASpell(Client* client, int8 tier, AltAdvanceData* data, bool display, bool trait_display, int8 packet_type, int8 sub_packet_type, const char* struct_name) {
  692. if (!client)
  693. return 0;
  694. int16 version = 1;
  695. if (client)
  696. version = client->GetVersion();
  697. if (!struct_name)
  698. struct_name = "WS_ExamineAASpellInfo";
  699. PacketStruct* packet = configReader.getStruct(struct_name, version);
  700. if (display)
  701. packet->setSubstructDataByName("info_header", "show_name", 1);//1
  702. else
  703. if (!trait_display)
  704. packet->setSubstructDataByName("info_header", "show_popup", 1);//1
  705. else
  706. packet->setSubstructDataByName("info_header", "show_popup", 0);
  707. if (packet_type > 0)
  708. packet->setSubstructDataByName("info_header", "packettype", packet_type * 256 + 0xFE);
  709. else
  710. packet->setSubstructDataByName("info_header", "packettype", 0x4FFE);// 0x45FE GetItemPacketType(version));
  711. //packet->setDataByName("unknown2",5);
  712. //packet->setDataByName("unknown7", 1);
  713. //packet->setDataByName("unknown9", 20);
  714. //packet->setDataByName("unknown10", 1, 2);
  715. if (sub_packet_type == 0)
  716. sub_packet_type = 0x83;
  717. packet->setSubstructDataByName("info_header", "packetsubtype", 4);// sub_packet_type);
  718. packet->setSubstructDataByName("spell_info", "aa_id", data->spellID);
  719. packet->setSubstructDataByName("spell_info", "aa_tab_id", data->group);
  720. packet->setSubstructDataByName("spell_info", "aa_icon", data->icon);
  721. packet->setSubstructDataByName("spell_info", "aa_icon2", data->icon2);
  722. packet->setSubstructDataByName("spell_info", "aa_current_rank", tier); // how to get this info to here?
  723. packet->setSubstructDataByName("spell_info", "aa_max_rank", data->maxRank);
  724. packet->setSubstructDataByName("spell_info", "aa_rank_cost", data->rankCost);
  725. packet->setSubstructDataByName("spell_info", "aa_unknown_2", 20);
  726. packet->setSubstructDataByName("spell_info", "aa_name", &(spell->name));
  727. packet->setSubstructDataByName("spell_info", "aa_description", &(spell->description));
  728. //packet->setDataByName("unknown3",2);
  729. //packet->setDataByName("unknown7", 50);
  730. if (sub_packet_type == 0x81)
  731. SetAAPacketInformation(packet, data, client);
  732. else
  733. SetAAPacketInformation(packet, data, client, true);
  734. packet->setSubstructDataByName("spell_info", "uses_remaining", 0xFFFF);
  735. packet->setSubstructDataByName("spell_info", "damage_remaining", 0xFFFF);
  736. //packet->PrintPacket();
  737. // This adds the second portion to the spell packet. Could be used for bonuses etc.?
  738. string* data1 = packet->serializeString();
  739. uchar* data2 = (uchar*)data1->c_str();
  740. uchar* ptr2 = data2;
  741. int32 size = data1->length();// *2;
  742. ////uchar* data3 = new uchar[size];
  743. ////memcpy(data3, data2, data1->length());
  744. ////uchar* ptr = data3;
  745. ////size -= 17;
  746. ////memcpy(ptr, &size, sizeof(int32));
  747. ////size += 3;
  748. ////ptr += data1->length();
  749. ////ptr2 += 14;
  750. ////memcpy(ptr, ptr2, data1->length() - 14);
  751. EQ2Packet* outapp = new EQ2Packet(OP_ClientCmdMsg, data2, size);
  752. //DumpPacket(outapp);
  753. //safe_delete_array(data3);
  754. safe_delete(packet);
  755. return outapp;
  756. /*PacketStruct* packet = configReader.getStruct("WS_ExamineAASpellInfo", client->GetVersion());
  757. packet->setSubstructDataByName("info_header", "show_name", 0);
  758. packet->setSubstructDataByName("info_header", "show_popup", 0);
  759. packet->setSubstructDataByName("info_header", "packettype", packet_type);
  760. packet->setSubstructDataByName("info_header", "packetsubtype", sub_packet_type);
  761. packet->setSubstructDataByName("Spell_info", "aa_id", data->spellID);
  762. packet->setSubstructDataByName("Spell_info", "aa_tab_id", data->group);
  763. packet->setSubstructDataByName("Spell_info", "aa_icon", data->icon);
  764. packet->setSubstructDataByName("Spell_info", "aa_icon2", data->icon2);
  765. packet->setSubstructDataByName("Spell_info", "current_rank", 0); // how to get this info to here?
  766. packet->setSubstructDataByName("Spell_info", "max_rank", data->maxRank);
  767. packet->setSubstructDataByName("Spell_info", "rank_cost", data->rankCost);
  768. packet->setSubstructDataByName("spell_info", "unknown2", 20);
  769. // Spell info
  770. packet->setSubstructDataByName("spell_info", "id", spell->id);
  771. packet->setSubstructDataByName("spell_info", "icon", spell->icon);
  772. packet->setSubstructDataByName("spell_info", "icon2", spell->icon_heroic_op); // fix struct element name eventually
  773. packet->setSubstructDataByName("spell_info", "icontype", spell->icon_backdrop); // fix struct element name eventually
  774. if (packet->GetVersion() >= 63119) {
  775. packet->setSubstructDataByName("spell_info", "version", 0x04);
  776. packet->setSubstructDataByName("spell_info", "sub_version", 0x24);
  777. }
  778. else if (packet->GetVersion() >= 1193) {
  779. packet->setSubstructDataByName("spell_info", "version", 0x00);
  780. packet->setSubstructDataByName("spell_info", "sub_version", 0xD9);
  781. }
  782. else {
  783. packet->setSubstructDataByName("spell_info", "version", 0x11);
  784. packet->setSubstructDataByName("spell_info", "sub_version", 0x14);
  785. }
  786. packet->setSubstructDataByName("spell_info", "type", spell->type);
  787. packet->setSubstructDataByName("spell_info", "unknown_MJ1d", 1); //63119 test
  788. packet->setSubstructDataByName("spell_info", "class_skill", spell->class_skill);
  789. packet->setSubstructDataByName("spell_info", "mastery_skill", spell->mastery_skill);
  790. packet->setSubstructDataByName("spell_info", "duration_flag", spell->duration_until_cancel);
  791. if (client && spell->type != 2) {
  792. sint8 spell_text_color = client->GetPlayer()->GetArrowColor(GetLevelRequired(client));
  793. if (spell_text_color != ARROW_COLOR_WHITE && spell_text_color != ARROW_COLOR_RED && spell_text_color != ARROW_COLOR_GRAY)
  794. spell_text_color = ARROW_COLOR_WHITE;
  795. spell_text_color -= 6;
  796. if (spell_text_color < 0)
  797. spell_text_color *= -1;
  798. packet->setSubstructDataByName("spell_info", "spell_text_color", spell_text_color);
  799. }
  800. else
  801. packet->setSubstructDataByName("spell_info", "spell_text_color", 3);
  802. if (spell->type != 2) {
  803. packet->setSubstructArrayLengthByName("spell_info", "num_levels", levels.size());
  804. for (int32 i = 0; i < levels.size(); i++) {
  805. packet->setArrayDataByName("adventure_class", levels[i]->adventure_class, i);
  806. packet->setArrayDataByName("tradeskill_class", levels[i]->tradeskill_class, i);
  807. packet->setArrayDataByName("spell_level", levels[i]->spell_level, i);
  808. }
  809. }
  810. //packet->setSubstructDataByName("spell_info", "unknown9", 20);
  811. int16 hp_req = 0;
  812. int16 power_req = 0;
  813. if (client) {
  814. hp_req = GetHPRequired(client->GetPlayer());
  815. power_req = GetPowerRequired(client->GetPlayer());
  816. // might need version checks around these?
  817. if (client->GetVersion() >= 1193)
  818. {
  819. int16 savagery_req = GetSavageryRequired(client->GetPlayer()); // dunno why we need to do this
  820. packet->setSubstructDataByName("spell_info", "savagery_req", savagery_req);
  821. packet->setSubstructDataByName("spell_info", "savagery_upkeep", spell->savagery_upkeep);
  822. }
  823. if (client->GetVersion() >= 57048)
  824. {
  825. int16 dissonance_req = GetDissonanceRequired(client->GetPlayer()); // dunno why we need to do this
  826. packet->setSubstructDataByName("spell_info", "dissonance_req", dissonance_req);
  827. packet->setSubstructDataByName("spell_info", "dissonance_upkeep", spell->dissonance_upkeep);
  828. }
  829. }
  830. packet->setSubstructDataByName("spell_info", "tier", spell->tier);
  831. packet->setSubstructDataByName("spell_info", "health_req", hp_req);
  832. packet->setSubstructDataByName("spell_info", "health_upkeep", spell->hp_upkeep);
  833. packet->setSubstructDataByName("spell_info", "power_req", power_req);
  834. packet->setSubstructDataByName("spell_info", "power_upkeep", spell->power_upkeep);
  835. packet->setSubstructDataByName("spell_info", "req_concentration", spell->req_concentration);
  836. //packet->setDataByName("req_concentration2", 2);
  837. packet->setSubstructDataByName("spell_info", "cast_time", spell->cast_time);
  838. packet->setSubstructDataByName("spell_info", "recovery", spell->recovery);
  839. packet->setSubstructDataByName("spell_info", "recast", spell->recast);
  840. packet->setSubstructDataByName("spell_info", "radius", spell->radius);
  841. packet->setSubstructDataByName("spell_info", "max_aoe_targets", spell->max_aoe_targets);
  842. packet->setSubstructDataByName("spell_info", "friendly_spell", spell->friendly_spell);
  843. //reageants??
  844. packet->setSubstructArrayLengthByName("spell_info", "num_effects", effects.size());
  845. for (int32 i = 0; i < effects.size(); i++) {
  846. packet->setArrayDataByName("subbulletflag", effects[i]->subbullet, i);
  847. packet->setArrayDataByName("effect", effects[i]->description.c_str(), i);
  848. packet->setArrayDataByName("percentage", effects[i]->percentage, i);
  849. }
  850. //if (display_tier == true)
  851. packet->setSubstructDataByName("spell_info", "display_spell_tier", spell->display_spell_tier);
  852. //else
  853. // packet->setSubstructDataByName("spell_info", "display_spell_tier", 0);
  854. // minimum range??
  855. packet->setSubstructDataByName("spell_info", "range", spell->range);
  856. packet->setSubstructDataByName("spell_info", "duration1", spell->duration1);
  857. packet->setSubstructDataByName("spell_info", "duration2", spell->duration2);
  858. //unknown9 ??
  859. //duration flag??
  860. packet->setSubstructDataByName("spell_info", "target", spell->target_type);
  861. packet->setSubstructDataByName("spell_info", "can_effect_raid", spell->can_effect_raid);
  862. packet->setSubstructDataByName("spell_info", "affect_only_group_members", spell->affect_only_group_members);
  863. packet->setSubstructDataByName("spell_info", "group_spell", spell->group_spell);
  864. packet->setSubstructDataByName("spell_info", "resistibility", spell->resistibility);
  865. //unknown11 ??
  866. //hit_bonus ??
  867. //unknown12 ??
  868. packet->setSubstructDataByName("spell_info", "name", &(spell->name));
  869. packet->setSubstructDataByName("spell_info", "description", &(spell->description));
  870. EQ2Packet* packetdata = packet->serialize();
  871. //EQ2Packet* app = new EQ2Packet(OP_AdventureList, packetdata->pBuffer, packetdata->size);
  872. EQ2Packet* app = new EQ2Packet(OP_ClientCmdMsg, packetdata->pBuffer, packetdata->size);
  873. packet->PrintPacket();
  874. //DumpPacket(app);
  875. safe_delete(packet);
  876. safe_delete(data);
  877. return app;
  878. */
  879. }
  880. EQ2Packet* Spell::SerializeSpell(Client* client, bool display, bool trait_display, int8 packet_type, int8 sub_packet_type, const char* struct_name) {
  881. int16 version = 1;
  882. if (client)
  883. version = client->GetVersion();
  884. if (!struct_name)
  885. struct_name = "WS_ExamineSpellInfo";
  886. if (version <= 283) {
  887. if (packet_type == 1)
  888. struct_name = "WS_ExamineEffectInfo";
  889. else if (!display)
  890. struct_name = "WS_ExaminePartialSpellInfo";
  891. else
  892. struct_name = "WS_ExamineSpellInfo";
  893. }
  894. PacketStruct* packet = configReader.getStruct(struct_name, version);
  895. if (display)
  896. packet->setSubstructDataByName("info_header", "show_name", 1);
  897. else {
  898. if (!trait_display)
  899. packet->setSubstructDataByName("info_header", "show_popup", 1);
  900. else
  901. packet->setSubstructDataByName("info_header", "show_popup", 0);
  902. }
  903. if (version > 546) {
  904. if (packet_type > 0)
  905. packet->setSubstructDataByName("info_header", "packettype", packet_type * 256 + 0xFE);
  906. else
  907. packet->setSubstructDataByName("info_header", "packettype", GetItemPacketType(version));
  908. }
  909. else {
  910. if (packet_type == 3 || packet_type == 0)
  911. packet->setSubstructDataByName("info_header", "packettype", 3); // 0: item, 1: effect, 2: recipe, 3: spell/ability
  912. else
  913. packet->setSubstructDataByName("info_header", "packettype", 1);
  914. }
  915. //packet->setDataByName("unknown2",5);
  916. //packet->setDataByName("unknown7", 1);
  917. //packet->setDataByName("unknown9", 20);
  918. //packet->setDataByName("unknown10", 1, 2);
  919. if (sub_packet_type == 0)
  920. sub_packet_type = 0x83;
  921. packet->setSubstructDataByName("info_header", "packetsubtype", sub_packet_type);
  922. //packet->setDataByName("unknown3",2);
  923. //packet->setDataByName("unknown7", 50);
  924. if (sub_packet_type == 0x81)
  925. SetPacketInformation(packet, client);
  926. else
  927. SetPacketInformation(packet, client, true);
  928. packet->setSubstructDataByName("spell_info", "uses_remaining", 0xFFFF);
  929. packet->setSubstructDataByName("spell_info", "damage_remaining", 0xFFFF);
  930. //packet->PrintPacket();
  931. // This adds the second portion to the spell packet. Could be used for bonuses etc.?
  932. int8 offset = 0;
  933. if (packet->GetVersion() == 60114) {
  934. offset = 28;
  935. }
  936. else {
  937. offset = 14;
  938. }
  939. EQ2Packet* outapp = 0;
  940. if (version > 546) {
  941. string* data1 = packet->serializeString();
  942. uchar* data2 = (uchar*)data1->c_str();
  943. uchar* ptr2 = data2;
  944. int32 size = data1->length() * 2;
  945. uchar* data3 = new uchar[size];
  946. memcpy(data3, data2, data1->length());
  947. uchar* ptr = data3;
  948. size -= offset + 3;
  949. memcpy(ptr, &size, sizeof(int32));
  950. size += 3;
  951. ptr += data1->length();
  952. ptr2 += offset;
  953. memcpy(ptr, ptr2, data1->length() - offset);
  954. outapp = new EQ2Packet(OP_ClientCmdMsg, data3, size);
  955. safe_delete_array(data3);
  956. safe_delete(packet);
  957. }
  958. else
  959. outapp = packet->serialize();
  960. //DumpPacket(outapp);
  961. return outapp;
  962. }
  963. void Spell::AddSpellEffect(int8 percentage, int8 subbullet, string description){
  964. SpellDisplayEffect* effect = new SpellDisplayEffect;
  965. effect->description = description;
  966. effect->subbullet = subbullet;
  967. effect->percentage = percentage;
  968. MSpellInfo.lock();
  969. effects.push_back(effect);
  970. MSpellInfo.unlock();
  971. }
  972. int16 Spell::GetHPRequired(Spawn* spawn){
  973. int16 hp_req = spell->hp_req;
  974. if(spawn && spell->hp_req_percent > 0){
  975. double result = ((double)spell->hp_req_percent/100)*spawn->GetTotalHP();
  976. if(result >= (((int16)result) + .5))
  977. result++;
  978. hp_req = (int16)result;
  979. }
  980. return hp_req;
  981. }
  982. int16 Spell::GetPowerRequired(Spawn* spawn){
  983. int16 power_req;
  984. if (spell->power_by_level == true) {
  985. power_req =round( (spell->power_req) * spawn->GetLevel());
  986. }
  987. else {
  988. power_req = round(spell->power_req);
  989. }
  990. if(spawn && spell->power_req_percent > 0){
  991. double result = ((double)spell->power_req_percent/100)*spawn->GetTotalPower();
  992. if(result >= (((int16)result) + .5))
  993. result++;
  994. power_req = (int16)result;
  995. }
  996. return power_req;
  997. }
  998. int16 Spell::GetSavageryRequired(Spawn* spawn){
  999. int16 savagery_req = spell->savagery_req;
  1000. if(spawn && spell->savagery_req_percent > 0){
  1001. double result = ((double)spell->savagery_req_percent/100)*spawn->GetTotalSavagery();
  1002. if(result >= (((int16)result) + .5))
  1003. result++;
  1004. savagery_req = (int16)result;
  1005. }
  1006. return savagery_req;
  1007. }
  1008. int16 Spell::GetDissonanceRequired(Spawn* spawn){
  1009. int16 dissonance_req = spell->dissonance_req;
  1010. if(spawn && spell->dissonance_req_percent > 0){
  1011. double result = ((double)spell->dissonance_req_percent/100)*spawn->GetTotalDissonance();
  1012. if(result >= (((int16)result) + .5))
  1013. result++;
  1014. dissonance_req = (int16)result;
  1015. }
  1016. return dissonance_req;
  1017. }
  1018. int32 Spell::GetSpellDuration(){
  1019. if(spell->duration1 == spell->duration2)
  1020. return spell->duration1;
  1021. int32 difference = 0;
  1022. int32 lower = 0;
  1023. if(spell->duration2 > spell->duration1){
  1024. difference = spell->duration2 - spell->duration1;
  1025. lower = spell->duration1;
  1026. }
  1027. else{
  1028. difference = spell->duration1 - spell->duration2;
  1029. lower = spell->duration2;
  1030. }
  1031. int32 duration = (rand()%difference) + lower;
  1032. return duration;
  1033. }
  1034. const char* Spell::GetName(){
  1035. return spell->name.data.c_str();
  1036. }
  1037. const char* Spell::GetDescription(){
  1038. return spell->description.data.c_str();
  1039. }
  1040. void Spell::AddSpellLevel(int8 adventure_class, int8 tradeskill_class, int16 level){
  1041. LevelArray* lvl = new LevelArray;
  1042. lvl->adventure_class = adventure_class;
  1043. lvl->tradeskill_class = tradeskill_class;
  1044. lvl->spell_level = level;
  1045. MSpellInfo.lock();
  1046. levels.push_back(lvl);
  1047. MSpellInfo.unlock();
  1048. }
  1049. int32 Spell::GetSpellID(){
  1050. if (spell)
  1051. return spell->id;
  1052. return 0;
  1053. }
  1054. int8 Spell::GetSpellTier(){
  1055. if (spell)
  1056. return spell->tier;
  1057. return 0;
  1058. }
  1059. vector<LUAData*>* Spell::GetLUAData(){
  1060. return &lua_data;
  1061. }
  1062. SpellData* Spell::GetSpellData(){
  1063. return spell;
  1064. }
  1065. int16 Spell::GetSpellIcon(){
  1066. if (spell)
  1067. return spell->icon;
  1068. return 0;
  1069. }
  1070. int16 Spell::GetSpellIconBackdrop(){
  1071. if (spell)
  1072. return spell->icon_backdrop;
  1073. return 0;
  1074. }
  1075. int16 Spell::GetSpellIconHeroicOp(){
  1076. if (spell)
  1077. return spell->icon_heroic_op;
  1078. return 0;
  1079. }
  1080. bool Spell::IsHealSpell(){
  1081. return heal_spell;
  1082. }
  1083. bool Spell::IsBuffSpell(){
  1084. return buff_spell;
  1085. }
  1086. bool Spell::IsDamageSpell(){
  1087. return damage_spell;
  1088. }
  1089. bool Spell::IsControlSpell(){
  1090. return control_spell;
  1091. }
  1092. bool Spell::IsOffenseSpell(){
  1093. return offense_spell;
  1094. }
  1095. void Spell::ModifyCastTime(Entity* caster){
  1096. int16 cast_time = spell->cast_time;
  1097. float cast_speed = caster->GetInfoStruct()->casting_speed;
  1098. if (cast_time > 0){
  1099. if (cast_speed > 0) // casting speed can only reduce up to half a cast time
  1100. spell->cast_time *= max((float) 0.5, (float) (1 / (1 + (cast_speed * .01))));
  1101. else if (cast_speed < 0) // not sure if casting speed debuff is capped on live or not, capping at 1.5 * the normal rate for now
  1102. spell->cast_time *= min((float) 1.5, (float) (1 + (1 - (1 / (1 + (cast_speed * -.01))))));
  1103. }
  1104. }
  1105. vector <SpellDisplayEffect*>* Spell::GetSpellEffects(){
  1106. MSpellInfo.lock();
  1107. vector <SpellDisplayEffect*>* ret = &effects;
  1108. MSpellInfo.unlock();
  1109. return ret;
  1110. }
  1111. vector <LevelArray*>* Spell::GetSpellLevels(){
  1112. MSpellInfo.lock();
  1113. vector <LevelArray*>* ret = &levels;
  1114. MSpellInfo.unlock();
  1115. return ret;
  1116. }
  1117. bool Spell::ScribeAllowed(Player* player){
  1118. bool ret = false;
  1119. if(player){
  1120. MSpellInfo.lock();
  1121. for(int32 i=0;!ret && i<levels.size();i++){
  1122. int16 mylevel = player->GetLevel();
  1123. int16 spelllevels = levels[i]->spell_level;
  1124. bool advlev = player->GetAdventureClass() == levels[i]->adventure_class;
  1125. bool tslev = player->GetTradeskillClass() == levels[i]->tradeskill_class;
  1126. bool levelmatch = player->GetLevel() >= levels[i]->spell_level;
  1127. if((player->GetAdventureClass() == levels[i]->adventure_class || player->GetTradeskillClass() == levels[i]->tradeskill_class) && player->GetLevel() >= levels[i]->spell_level/10)
  1128. ret = true;
  1129. }
  1130. MSpellInfo.unlock();
  1131. }
  1132. return ret;
  1133. }
  1134. MasterSpellList::MasterSpellList(){
  1135. MMasterSpellList.SetName("MasterSpellList::MMasterSpellList");
  1136. }
  1137. MasterSpellList::~MasterSpellList(){
  1138. DestroySpells();
  1139. }
  1140. void MasterSpellList::DestroySpells(){
  1141. spell_errors.clear();
  1142. MMasterSpellList.lock();
  1143. map<int32, map<int32, Spell*> >::iterator iter;
  1144. map<int32, Spell*>::iterator iter2;
  1145. for(iter = spell_list.begin();iter != spell_list.end(); iter++){
  1146. for(iter2 = iter->second.begin();iter2 != iter->second.end(); iter2++){
  1147. safe_delete(iter2->second);
  1148. }
  1149. }
  1150. spell_list.clear();
  1151. MMasterSpellList.unlock();
  1152. }
  1153. void MasterSpellList::AddSpell(int32 id, int8 tier, Spell* spell){
  1154. MMasterSpellList.lock();
  1155. spell_list[id][tier] = spell;
  1156. spell_name_map[spell->GetName()] = spell;
  1157. spell_soecrc_map[spell->GetSpellData()->soe_spell_crc] = spell;
  1158. MMasterSpellList.unlock();
  1159. }
  1160. Spell* MasterSpellList::GetSpell(int32 id, int8 tier){
  1161. if (spell_list.count(id) > 0 && spell_list[id].count(tier) > 0)
  1162. return spell_list[id][tier];
  1163. return 0;
  1164. }
  1165. Spell* MasterSpellList::GetSpellByName(const char* name){
  1166. if(spell_name_map.count(name) > 0)
  1167. return spell_name_map[name];
  1168. return 0;
  1169. }
  1170. Spell* MasterSpellList::GetSpellByCRC(int32 spell_crc){
  1171. if(spell_soecrc_map.count(spell_crc) > 0)
  1172. return spell_soecrc_map[spell_crc];
  1173. return 0;
  1174. }
  1175. EQ2Packet* MasterSpellList::GetSpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type){
  1176. Spell* spell = GetSpell(id, tier);
  1177. if(spell)
  1178. return spell->SerializeSpell(client, display, packet_type);
  1179. return 0;
  1180. }
  1181. EQ2Packet* MasterSpellList::GetAASpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type) {
  1182. Spell* spell = GetSpell(id, (tier == 0 ? 1 : tier));
  1183. //Spell* spell2= GetSpell(id, (tier +1));
  1184. AltAdvanceData* data = master_aa_list.GetAltAdvancement(id);
  1185. if (spell)
  1186. return spell->SerializeAASpell(client,tier, data, display,false, packet_type);
  1187. return 0;
  1188. }
  1189. EQ2Packet* MasterSpellList::GetSpecialSpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type){
  1190. Spell* spell = GetSpell(id, tier);
  1191. if(spell)
  1192. return spell->SerializeSpecialSpell(client, display, packet_type, 0x81);
  1193. return 0;
  1194. }
  1195. vector<Spell*>* MasterSpellList::GetSpellListByAdventureClass(int8 class_id, int16 max_level, int8 max_tier){
  1196. vector<Spell*>* ret = new vector<Spell*>;
  1197. Spell* spell = 0;
  1198. vector<LevelArray*>* levels = 0;
  1199. LevelArray* level = 0;
  1200. vector<LevelArray*>::iterator level_itr;
  1201. MMasterSpellList.lock();
  1202. map<int32, map<int32, Spell*> >::iterator iter;
  1203. map<int32, Spell*>::iterator iter2;
  1204. max_level *= 10; //convert to client level format, which is 10 times higher
  1205. for(iter = spell_list.begin();iter != spell_list.end(); iter++){
  1206. for(iter2 = iter->second.begin();iter2 != iter->second.end(); iter2++){
  1207. spell = iter2->second;
  1208. if(iter2->first <= max_tier && spell){
  1209. levels = spell->GetSpellLevels();
  1210. for(level_itr = levels->begin(); level_itr != levels->end(); level_itr++){
  1211. level = *level_itr;
  1212. if(level->spell_level <= max_level && level->adventure_class == class_id){
  1213. ret->push_back(spell);
  1214. break;
  1215. }
  1216. }
  1217. }
  1218. }
  1219. }
  1220. MMasterSpellList.unlock();
  1221. return ret;
  1222. }
  1223. vector<Spell*>* MasterSpellList::GetSpellListByTradeskillClass(int8 class_id, int16 max_level, int8 max_tier){
  1224. vector<Spell*>* ret = new vector<Spell*>;
  1225. Spell* spell = 0;
  1226. vector<LevelArray*>* levels = 0;
  1227. LevelArray* level = 0;
  1228. vector<LevelArray*>::iterator level_itr;
  1229. MMasterSpellList.lock();
  1230. map<int32, map<int32, Spell*> >::iterator iter;
  1231. map<int32, Spell*>::iterator iter2;
  1232. for(iter = spell_list.begin();iter != spell_list.end(); iter++){
  1233. for(iter2 = iter->second.begin();iter2 != iter->second.end(); iter2++){
  1234. spell = iter2->second;
  1235. if(iter2->first <= max_tier && spell){
  1236. levels = spell->GetSpellLevels();
  1237. for(level_itr = levels->begin(); level_itr != levels->end(); level_itr++){
  1238. level = *level_itr;
  1239. if(level->spell_level <= max_level && level->tradeskill_class == class_id){
  1240. ret->push_back(spell);
  1241. break;
  1242. }
  1243. }
  1244. }
  1245. }
  1246. }
  1247. MMasterSpellList.unlock();
  1248. return ret;
  1249. }
  1250. void MasterSpellList::Reload(){
  1251. master_trait_list.DestroyTraits();
  1252. DestroySpells();
  1253. database.LoadSpells();
  1254. database.LoadSpellErrors();
  1255. database.LoadTraits();
  1256. }
  1257. int16 MasterSpellList::GetSpellErrorValue(int16 version, int8 error_index) {
  1258. version = GetClosestVersion(version);
  1259. if (spell_errors[version].count(error_index) == 0) {
  1260. LogWrite(SPELL__ERROR, 0, "Spells", "No spell error entry. (version = %i, error_index = %i)", version, error_index);
  1261. // 1 will give the client a pop up message of "Cannot cast" and a chat message of "[BUG] Cannot cast. Unknown failure casting spell."
  1262. return 1;
  1263. }
  1264. return spell_errors[version][error_index];
  1265. }
  1266. void MasterSpellList::AddSpellError(int16 version, int8 error_index, int16 error_value) {
  1267. if (spell_errors[version].count(error_index) == 0)
  1268. spell_errors[version][error_index] = error_value;
  1269. }
  1270. int16 MasterSpellList::GetClosestVersion(int16 version) {
  1271. int16 ret = 0;
  1272. map<int16, map<int8, int16> >::iterator itr;
  1273. // Get the closest version in the list that is less then or equal to the given version
  1274. for (itr = spell_errors.begin(); itr != spell_errors.end(); itr++) {
  1275. if (itr->first <= version) {
  1276. if (itr->first > ret)
  1277. ret = itr->first;
  1278. }
  1279. }
  1280. return ret;
  1281. }
  1282. bool Spell::CastWhileStunned(){
  1283. return (spell->casting_flags & CASTING_FLAG_STUNNED) == CASTING_FLAG_STUNNED;
  1284. }
  1285. bool Spell::CastWhileMezzed(){
  1286. return (spell->casting_flags & CASTING_FLAG_MEZZED) == CASTING_FLAG_MEZZED;
  1287. }
  1288. bool Spell::CastWhileStifled(){
  1289. return (spell->casting_flags & CASTING_FLAG_STIFLED) == CASTING_FLAG_STIFLED;
  1290. }
  1291. bool Spell::CastWhileFeared(){
  1292. return (spell->casting_flags & CASTING_FLAG_FEARED) == CASTING_FLAG_FEARED;
  1293. }