123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544 |
- /*
- EQ2Emulator: Everquest II Server Emulator
- Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
- This file is part of EQ2Emulator.
- EQ2Emulator is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- EQ2Emulator is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "Entity.h"
- #include <math.h>
- #include "Items/Items.h"
- #include "zoneserver.h"
- #include "World.h"
- #include "../common/Log.h"
- #include "Spells.h"
- #include "SpellProcess.h"
- #include "classes.h"
- #include "LuaInterface.h"
- #include "ClientPacketFunctions.h"
- extern World world;
- extern MasterItemList master_item_list;
- extern MasterSpellList master_spell_list;
- extern Classes classes;
- Entity::Entity(){
- max_speed = 6;
- base_speed = 0.0f;
- last_x = -1;
- last_y = -1;
- last_z = -1;
- last_heading = -1;
- regen_hp_rate = 0;
- regen_power_rate = 0;
- in_combat = false;
- casting = false;
- memset(&melee_combat_data, 0, sizeof(CombatData));
- memset(&ranged_combat_data, 0, sizeof(CombatData));
- memset(&info_struct, 0, sizeof(InfoStruct));
- loot_coins = 0;
- trap_triggered = false;
- memset(&features, 0, sizeof(CharFeatures));
- memset(&equipment, 0, sizeof(EQ2_Equipment));
- pet = 0;
- charmedPet = 0;
- deityPet = 0;
- cosmeticPet = 0;
- speed = 0;
- speed_multiplier = 1.0f;
- m_threatTransfer = 0;
- group_member_info = 0;
- trade = 0;
- deity = 0;
- MProcList.SetName("Entity::m_procList");
- MDetriments.SetName("Entity::MDetriments");
- MMaintainedSpells.SetName("Entity::MMaintainedSpells");
- MSpellEffects.SetName("Entity::MSpellEffects");
- m_procList.clear();
- control_effects.clear();
- for (int i = 0; i < CONTROL_MAX_EFFECTS; i++)
- control_effects[i] = NULL;
- immunities.clear();
- for(int i=0;i<45;i++){
- if(i<NUM_MAINTAINED_EFFECTS){
- info_struct.maintained_effects[i].spell_id = 0xFFFFFFFF;
- if (IsPlayer())
- info_struct.maintained_effects[i].icon = 0xFFFF;
- }
- info_struct.spell_effects[i].spell_id = 0xFFFFFFFF;
- }
- MCommandMutex.SetName("Entity::MCommandMutex");
- }
- Entity::~Entity(){
- vector<Item*>::iterator itr;
- for(itr = loot_items.begin(); itr != loot_items.end(); itr++)
- safe_delete(*itr);
- MutexList<BonusValues*>::iterator itr2 = bonus_list.begin();
- while(itr2.Next())
- safe_delete(itr2.value);
- ClearProcs();
- safe_delete(m_threatTransfer);
- map<int8, MutexList<LuaSpell*>*>::iterator itr3;
- for (itr3 = control_effects.begin(); itr3 != control_effects.end(); itr3++)
- safe_delete(itr3->second);
- control_effects.clear();
- map<int8, MutexList<LuaSpell*>*>::iterator itr4;
- for (itr4 = immunities.begin(); itr4 != immunities.end(); itr4++)
- safe_delete(itr4->second);
- immunities.clear();
- }
- bool Entity::HasMoved(bool include_heading){
- if(GetX() == last_x && GetY() == last_y && GetZ() == last_z && ((!include_heading) || (include_heading && GetHeading() == last_heading)))
- return false;
- bool ret_val = true;
- if(last_x == -1 && last_y == -1 && last_z == -1 && last_heading == -1){
- ret_val = false;
- }
- last_x = GetX();
- last_y = GetY();
- last_z = GetZ();
- last_heading = GetHeading();
- return ret_val;
- }
- int16 Entity::GetStr(){
- return GetInfoStruct()->str;
- }
- int16 Entity::GetSta(){
- return GetInfoStruct()->sta;
- }
- int16 Entity::GetInt(){
- return GetInfoStruct()->intel;
- }
- int16 Entity::GetWis(){
- return GetInfoStruct()->wis;
- }
- int16 Entity::GetAgi(){
- return GetInfoStruct()->agi;
- }
- int16 Entity::GetPrimaryStat(){
- int8 base_class = classes.GetBaseClass(GetAdventureClass());
- if (base_class == FIGHTER)
- return GetInfoStruct()->str;
- else if (base_class == PRIEST)
- return GetInfoStruct()->wis;
- else if (base_class == MAGE)
- return GetInfoStruct()->intel;
- else
- return GetInfoStruct()->agi;
- }
- int16 Entity::GetHeatResistance(){
- return GetInfoStruct()->heat;
- }
- int16 Entity::GetColdResistance(){
- return GetInfoStruct()->cold;
- }
- int16 Entity::GetMagicResistance(){
- return GetInfoStruct()->magic;
- }
- int16 Entity::GetMentalResistance(){
- return GetInfoStruct()->mental;
- }
- int16 Entity::GetDivineResistance(){
- return GetInfoStruct()->divine;
- }
- int16 Entity::GetDiseaseResistance(){
- return GetInfoStruct()->disease;
- }
- int16 Entity::GetPoisonResistance(){
- return GetInfoStruct()->poison;
- }
- int8 Entity::GetConcentrationCurrent() {
- return GetInfoStruct()->cur_concentration;
- }
- int8 Entity::GetConcentrationMax() {
- return GetInfoStruct()->max_concentration;
- }
- int16 Entity::GetStrBase(){
- return GetInfoStruct()->str_base;
- }
- int16 Entity::GetStaBase(){
- return GetInfoStruct()->sta_base;
- }
- int16 Entity::GetIntBase(){
- return GetInfoStruct()->intel_base;
- }
- int16 Entity::GetWisBase(){
- return GetInfoStruct()->wis_base;
- }
- int16 Entity::GetAgiBase(){
- return GetInfoStruct()->agi_base;
- }
- int16 Entity::GetHeatResistanceBase(){
- return GetInfoStruct()->heat_base;
- }
- int16 Entity::GetColdResistanceBase(){
- return GetInfoStruct()->cold_base;
- }
- int16 Entity::GetMagicResistanceBase(){
- return GetInfoStruct()->magic_base;
- }
- int16 Entity::GetMentalResistanceBase(){
- return GetInfoStruct()->mental_base;
- }
- int16 Entity::GetDivineResistanceBase(){
- return GetInfoStruct()->divine_base;
- }
- int16 Entity::GetDiseaseResistanceBase(){
- return GetInfoStruct()->disease_base;
- }
- int16 Entity::GetPoisonResistanceBase(){
- return GetInfoStruct()->poison_base;
- }
- sint8 Entity::GetAlignment(){
- return GetInfoStruct()->alignment;
- }
- bool Entity::IsCasting(){
- return casting;
- }
- void Entity::IsCasting(bool val){
- casting = val;
- }
- int32 Entity::GetRangeLastAttackTime(){
- return ranged_combat_data.range_last_attack_time;
- }
- void Entity::SetRangeLastAttackTime(int32 time){
- ranged_combat_data.range_last_attack_time = time;
- }
- int16 Entity::GetRangeAttackDelay(){
- return ranged_combat_data.ranged_attack_delay;
- // if(IsPlayer()){
- // Item* item = ((Player*)this)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
- // if(item && item->IsRanged())
- // return item->ranged_info->weapon_info.delay*100;
- // }
- // return 3000;
- }
- int32 Entity::GetPrimaryLastAttackTime(){
- return melee_combat_data.primary_last_attack_time;
- }
- int16 Entity::GetPrimaryAttackDelay(){
- return melee_combat_data.primary_attack_delay;
- }
- void Entity::SetPrimaryAttackDelay(int16 new_delay){
- melee_combat_data.primary_attack_delay = new_delay;
- }
- void Entity::SetPrimaryLastAttackTime(int32 new_time){
- melee_combat_data.primary_last_attack_time = new_time;
- }
- int32 Entity::GetSecondaryLastAttackTime(){
- return melee_combat_data.secondary_last_attack_time;
- }
- int16 Entity::GetSecondaryAttackDelay(){
- return melee_combat_data.secondary_attack_delay;
- }
- void Entity::SetSecondaryAttackDelay(int16 new_delay){
- melee_combat_data.secondary_attack_delay = new_delay;
- }
- void Entity::SetSecondaryLastAttackTime(int32 new_time){
- melee_combat_data.secondary_last_attack_time = new_time;
- }
- void Entity::ChangePrimaryWeapon(){
- Item* item = equipment_list.GetItem(EQ2_PRIMARY_SLOT);
- if(item && item->details.item_id > 0 && item->IsWeapon()){
- melee_combat_data.primary_weapon_delay = item->weapon_info->delay * 100;
- melee_combat_data.primary_weapon_damage_low = item->weapon_info->damage_low3;
- melee_combat_data.primary_weapon_damage_high = item->weapon_info->damage_high3;
- melee_combat_data.primary_weapon_type = item->GetWeaponType();
- melee_combat_data.wield_type = item->weapon_info->wield_type;
- }
- else{
- melee_combat_data.primary_weapon_delay = 2000;
- melee_combat_data.primary_weapon_damage_low = (int32)(1 + GetLevel() * .2);
- melee_combat_data.primary_weapon_damage_high = (int32)(5 + GetLevel() * (GetLevel()/5));
- if(IsNPC())
- melee_combat_data.primary_weapon_type = ((NPC*)this)->GetAttackType();
- else
- melee_combat_data.primary_weapon_type = 1;
- melee_combat_data.wield_type = 2;
- }
- if(IsNPC())
- melee_combat_data.primary_weapon_damage_high += (int32)(GetInfoStruct()->str / 10);
- else
- melee_combat_data.primary_weapon_damage_high += (int32)(GetInfoStruct()->str / 25);
- }
- void Entity::ChangeSecondaryWeapon(){
- Item* item = equipment_list.GetItem(EQ2_SECONDARY_SLOT);
- if(item && item->details.item_id > 0 && item->IsWeapon()){
- melee_combat_data.secondary_weapon_delay = item->weapon_info->delay * 100;
- melee_combat_data.secondary_weapon_damage_low = item->weapon_info->damage_low3;
- melee_combat_data.secondary_weapon_damage_high = item->weapon_info->damage_high3;
- melee_combat_data.secondary_weapon_type = item->GetWeaponType();
- }
- else{
- melee_combat_data.secondary_weapon_delay = 2000;
- melee_combat_data.secondary_weapon_damage_low = (int32)(1 + GetLevel() * .2);
- melee_combat_data.secondary_weapon_damage_high = (int32)(5 + GetLevel() * (GetLevel()/6));
- melee_combat_data.secondary_weapon_type = 1;
- }
- if(IsNPC())
- melee_combat_data.secondary_weapon_damage_high += (int32)(GetInfoStruct()->str / 10);
- else
- melee_combat_data.secondary_weapon_damage_high += (int32)(GetInfoStruct()->str / 25);
- }
- void Entity::ChangeRangedWeapon(){
- Item* item = equipment_list.GetItem(EQ2_RANGE_SLOT);
- if(item && item->details.item_id > 0 && item->IsRanged()){
- ranged_combat_data.ranged_weapon_delay = item->ranged_info->weapon_info.delay*100;
- ranged_combat_data.ranged_weapon_damage_low = item->ranged_info->weapon_info.damage_low3;
- ranged_combat_data.ranged_weapon_damage_high = item->ranged_info->weapon_info.damage_high3;
- ranged_combat_data.ranged_weapon_type = item->GetWeaponType();
- }
- }
- int32 Entity::GetPrimaryWeaponMinDamage(){
- return melee_combat_data.primary_weapon_damage_low;
- }
- int32 Entity::GetPrimaryWeaponMaxDamage(){
- return melee_combat_data.primary_weapon_damage_high;
- }
- int32 Entity::GetSecondaryWeaponMinDamage(){
- return melee_combat_data.secondary_weapon_damage_low;
- }
- int32 Entity::GetSecondaryWeaponMaxDamage(){
- return melee_combat_data.secondary_weapon_damage_high;
- }
- int8 Entity::GetPrimaryWeaponType(){
- return melee_combat_data.primary_weapon_type;
- }
- int8 Entity::GetSecondaryWeaponType(){
- return melee_combat_data.secondary_weapon_type;
- }
- int32 Entity::GetRangedWeaponMinDamage(){
- return ranged_combat_data.ranged_weapon_damage_low;
- }
- int32 Entity::GetRangedWeaponMaxDamage(){
- return ranged_combat_data.ranged_weapon_damage_high;
- }
- int8 Entity::GetRangedWeaponType(){
- return ranged_combat_data.ranged_weapon_type;
- }
- bool Entity::IsDualWield(){
- return melee_combat_data.wield_type == 1;
- }
- int8 Entity::GetWieldType(){
- return melee_combat_data.wield_type;
- }
- bool Entity::BehindTarget(Spawn* target){
- float target_angle = 360 - target->GetHeading();
- float angle = 360 - GetHeading();
- if(target_angle > angle)
- angle = target_angle - angle;
- else
- angle -= target_angle;
- return (angle < 90 || angle > 270);
- }
- bool Entity::FlankingTarget(Spawn* target) {
- float angle;
- double diff_x = target->GetX() - GetX();
- double diff_z = target->GetZ() - GetZ();
- if (diff_z == 0) {
- if (diff_x > 0)
- angle = 90;
- else
- angle = 270;
- }
- else
- angle = ((atan(diff_x / diff_z)) * 180) / 3.14159265358979323846;
- if (angle < 0)
- angle = angle + 360;
- else
- angle = angle + 180;
- if (diff_x < 0)
- angle = angle + 180;
-
- if (angle > GetHeading())
- angle = angle - GetHeading();
- else
- angle = GetHeading() - angle;
- if (angle > 360)
- angle -= 360;
- //LogWrite(SPAWN__ERROR, 0, "Angle", "spawn heading = %f", GetHeading());
- //LogWrite(SPAWN__ERROR, 0, "Angle", "angle = %f", angle);
- return (angle >= 45 && angle <= 315);
- }
- float Entity::GetShieldBlockChance(){
- float ret = 0;
- Item* item = equipment_list.GetItem(1);
- if(item && item->details.item_id > 0 && item->IsShield()){
-
- }
- return ret;
- }
- float Entity::GetDodgeChance(){
- float ret = 0;
-
- return ret;
- }
- bool Entity::EngagedInCombat(){
- return in_combat;
- }
- void Entity::InCombat(bool val){
- in_combat = val;
- }
- void Entity::SetHPRegen(int16 new_val){
- regen_hp_rate = new_val;
- }
- void Entity::SetPowerRegen(int16 new_val){
- regen_power_rate = new_val;
- }
- int16 Entity::GetHPRegen(){
- return regen_hp_rate;
- }
- int16 Entity::GetPowerRegen(){
- return regen_power_rate;
- }
- void Entity::DoRegenUpdate(){
- if(GetHP() == 0)//dead
- return;
- sint32 hp = GetHP();
- sint32 power = GetPower();
- int16 level = GetLevel();
- // No regen for NPC's while in combat
- // Temp solution for now
- if (IsNPC() && EngagedInCombat())
- return;
- if(hp < GetTotalHP()){
- if(regen_hp_rate == 0)
- regen_hp_rate = (int)(level*.75)+(int)(level/10) + 1;
- int16 temp = regen_hp_rate + stats[ITEM_STAT_HPREGEN];
- if((hp + temp) > GetTotalHP())
- SetHP(GetTotalHP());
- else
- SetHP(hp + temp);
- LogWrite(MISC__TODO, 1, "TODO", "Fix this later for mobs\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
- }
- if(GetPower() < GetTotalPower()){
- if(regen_power_rate == 0)
- regen_power_rate = level + (int)(level/10) + 1;
- if((power + regen_power_rate) > GetTotalPower())
- SetPower(GetTotalPower());
- else
- SetPower(power + regen_power_rate);
- LogWrite(MISC__TODO, 1, "TODO", "Fix this later for mobs\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
- }
- }
- void Entity::AddMaintainedSpell(LuaSpell* luaspell){
- if (!luaspell)
- return;
- Spell* spell = luaspell->spell;
- MaintainedEffects* effect = GetFreeMaintainedSpellSlot();
- if (effect){
- MMaintainedSpells.writelock(__FUNCTION__, __LINE__);
- effect->spell = luaspell;
- effect->spell_id = spell->GetSpellData()->id;
- LogWrite(NPC__SPELLS, 5, "NPC", "AddMaintainedSpell Spell ID: %u", spell->GetSpellData()->id);
- effect->conc_used = spell->GetSpellData()->req_concentration / 256;
- effect->total_time = spell->GetSpellDuration() / 10;
- effect->tier = spell->GetSpellData()->tier;
- if (spell->GetSpellData()->duration_until_cancel)
- effect->expire_timestamp = 0xFFFFFFFF;
- else
- effect->expire_timestamp = Timer::GetCurrentTime2() + (spell->GetSpellDuration() * 100);
- MMaintainedSpells.releasewritelock(__FUNCTION__, __LINE__);
- }
- }
- void Entity::AddSpellEffect(LuaSpell* luaspell){
- if (!luaspell || !luaspell->caster)
- return;
- Spell* spell = luaspell->spell;
- SpellEffects* old_effect = GetSpellEffect(spell->GetSpellID(), luaspell->caster);
- SpellEffects* effect = 0;
- if (old_effect){
- GetZone()->RemoveTargetFromSpell(old_effect->spell, this);
- RemoveSpellEffect(old_effect->spell);
- }
- effect = GetFreeSpellEffectSlot();
- if(effect){
- MSpellEffects.writelock(__FUNCTION__, __LINE__);
- effect->spell = luaspell;
- effect->spell_id = spell->GetSpellData()->id;
- effect->caster = luaspell->caster;
- effect->total_time = spell->GetSpellDuration()/10;
- if (spell->GetSpellData()->duration_until_cancel)
- effect->expire_timestamp = 0xFFFFFFFF;
- else
- effect->expire_timestamp = Timer::GetCurrentTime2() + (spell->GetSpellDuration()*100);
- effect->icon = spell->GetSpellData()->icon;
- effect->icon_backdrop = spell->GetSpellData()->icon_backdrop;
- effect->tier = spell->GetSpellTier();
- MSpellEffects.releasewritelock(__FUNCTION__, __LINE__);
- changed = true;
- info_changed = true;
- AddChangedZoneSpawn();
- }
- }
- void Entity::RemoveMaintainedSpell(LuaSpell* luaspell){
- if (!luaspell)
- return;
- bool found = false;
- MMaintainedSpells.writelock(__FUNCTION__, __LINE__);
- for (int i = 0; i<30; i++){
- // If we already found the spell then we are bumping all other up one so there are no gaps
- // This check needs to be first so found can never be true on the first iteration (i = 0)
- if (found) {
- GetInfoStruct()->maintained_effects[i].slot_pos = i - 1;
- GetInfoStruct()->maintained_effects[i - 1] = GetInfoStruct()->maintained_effects[i];
- }
- // Compare spells, if we found a match set the found flag
- if (GetInfoStruct()->maintained_effects[i].spell == luaspell)
- found = true;
- }
- // if we found the spell in the array then we need to set the last element to empty
- if (found) {
- memset(&GetInfoStruct()->maintained_effects[29], 0, sizeof(MaintainedEffects));
- GetInfoStruct()->maintained_effects[29].spell_id = 0xFFFFFFFF;
- GetInfoStruct()->maintained_effects[29].icon = 0xFFFF;
- }
- MMaintainedSpells.releasewritelock(__FUNCTION__, __LINE__);
- }
- void Entity::RemoveSpellEffect(LuaSpell* spell) {
- bool found = false;
- MSpellEffects.writelock(__FUNCTION__, __LINE__);
- for(int i=0;i<45;i++) {
- if (found) {
- GetInfoStruct()->spell_effects[i-1] = GetInfoStruct()->spell_effects[i];
- }
- if (GetInfoStruct()->spell_effects[i].spell == spell)
- found = true;
- }
- if (found) {
- memset(&GetInfoStruct()->spell_effects[44], 0, sizeof(SpellEffects));
- GetInfoStruct()->spell_effects[44].spell_id = 0xFFFFFFFF;
- changed = true;
- info_changed = true;
- AddChangedZoneSpawn();
- }
- MSpellEffects.releasewritelock(__FUNCTION__, __LINE__);
- }
- bool Entity::HasActiveMaintainedSpell(Spell* spell, Spawn* target){
- LogWrite(MISC__TODO, 1, "TODO", "This does nothing... yet...\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
- return false;
- }
- bool Entity::HasActiveSpellEffect(Spell* spell, Spawn* target){
- LogWrite(MISC__TODO, 1, "TODO", "This does nothing... yet...\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
- return false;
- }
- MaintainedEffects* Entity::GetFreeMaintainedSpellSlot(){
- MaintainedEffects* ret = 0;
- InfoStruct* info = GetInfoStruct();
- MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
- for (int i = 0; i<NUM_MAINTAINED_EFFECTS; i++){
- if (info->maintained_effects[i].spell_id == 0xFFFFFFFF){
- ret = &info->maintained_effects[i];
- ret->spell_id = 0;
- ret->slot_pos = i;
- break;
- }
- }
- MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
- return ret;
- }
- MaintainedEffects* Entity::GetMaintainedSpell(int32 spell_id){
- MaintainedEffects* ret = 0;
- InfoStruct* info = GetInfoStruct();
- MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
- for (int i = 0; i<NUM_MAINTAINED_EFFECTS; i++){
- if (info->maintained_effects[i].spell_id == spell_id){
- ret = &info->maintained_effects[i];
- break;
- }
- }
- MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
- return ret;
- }
- SpellEffects* Entity::GetFreeSpellEffectSlot(){
- SpellEffects* ret = 0;
- InfoStruct* info = GetInfoStruct();
- MSpellEffects.readlock(__FUNCTION__, __LINE__);
- for(int i=0;i<45;i++){
- if(info->spell_effects[i].spell_id == 0xFFFFFFFF){
- ret = &info->spell_effects[i];
- ret->spell_id = 0;
- break;
- }
- }
- MSpellEffects.releasereadlock(__FUNCTION__, __LINE__);
- return ret;
- }
- SpellEffects* Entity::GetSpellEffect(int32 id, Entity* caster) {
- SpellEffects* ret = 0;
- InfoStruct* info = GetInfoStruct();
- MSpellEffects.readlock(__FUNCTION__, __LINE__);
- for(int i = 0; i < 45; i++) {
- if(info->spell_effects[i].spell_id == id) {
- if (!caster || info->spell_effects[i].caster == caster){
- ret = &info->spell_effects[i];
- break;
- }
- }
- }
- MSpellEffects.releasereadlock(__FUNCTION__, __LINE__);
- return ret;
- }
- InfoStruct* Entity::GetInfoStruct(){
- return &info_struct;
- }
- Item* Entity::LootItem(int32 id){
- Item* ret = 0;
- vector<Item*>::iterator itr;
- MLootItems.lock();
- for(itr = loot_items.begin(); itr != loot_items.end(); itr++){
- if((*itr)->details.item_id == id){
- ret = *itr;
- loot_items.erase(itr);
- break;
- }
- }
- MLootItems.unlock();
- return ret;
- }
- int32 Entity::GetLootItemID(){
- int32 ret = 0;
- vector<Item*>::iterator itr;
- MLootItems.lock();
- for(itr = loot_items.begin(); itr != loot_items.end(); itr++){
- ret = (*itr)->details.item_id;
- break;
- }
- MLootItems.unlock();
- return ret;
- }
- bool Entity::HasLootItemID(int32 id) {
- bool ret = false;
- vector<Item*>::iterator itr;
- MLootItems.readlock(__FUNCTION__, __LINE__);
- for (itr = loot_items.begin(); itr != loot_items.end(); itr++) {
- if ((*itr)->details.item_id == id) {
- ret = true;
- break;
- }
- }
- MLootItems.releasereadlock(__FUNCTION__, __LINE__);
- return ret;
- }
- Skill* Entity::GetSkillByName(const char* name, bool check_update){
- LogWrite(MISC__TODO, 1, "TODO", "This does nothing... yet...\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
- return 0;
- }
- float Entity::GetMaxSpeed(){
- return max_speed;
- }
- void Entity::SetMaxSpeed(float val){
- max_speed = val;
- }
- void Entity::CalculateBonuses(){
- InfoStruct* info = &info_struct;
- info->block = info->block_base;
-
- info->cur_attack = info->attack_base;
- info->cur_mitigation = info->mitigation_base;
- info->base_avoidance_pct = info->avoidance_base;
- LogWrite(MISC__TODO, 1, "TODO", "Calculate via current spells\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
- //info->cur_concentration = 0;
- info->parry = info->parry_base;
- info->deflection = info->deflection_base;
- info->disease = info->disease_base;
- info->divine = info->divine_base;
- info->heat = info->heat_base;
- info->magic = info->magic_base;
- info->mental = info->mental_base;
- info->cold = info->cold_base;
- info->poison = info->poison_base;
- info->elemental_base = info->heat;
- info->noxious_base = info->poison;
- info->arcane_base = info->magic;
- info->sta = info->sta_base;
- info->agi = info->agi_base;
- info->str = info->str_base;
- info->wis = info->wis_base;
- info->intel = info->intel_base;
- info->ability_modifier = 0;
- info->critical_mitigation = 0;
- info->block_chance = 0;
- info->crit_chance = 0;
- info->crit_bonus = 0;
- info->potency = 0;
- info->hate_mod = 0;
- info->reuse_speed = 0;
- info->casting_speed = 0;
- info->recovery_speed = 0;
- info->spell_reuse_speed = 0;
- info->spell_multi_attack = 0;
- info->dps = 0;
- info->dps_multiplier = 0;
- info->haste = 0;
- info->attackspeed = 0;
- info->multi_attack = 0;
- info->flurry = 0;
- info->melee_ae = 0;
- info->strikethrough = 0;
- info->accuracy = 0;
- info->offensivespeed = 0;
- stats.clear();
- ItemStatsValues* values = equipment_list.CalculateEquipmentBonuses(this);
- CalculateSpellBonuses(values);
- info->sta += values->sta;
- info->str += values->str;
- info->agi += values->agi;
- info->wis += values->wis;
- info->intel += values->int_;
- info->disease += values->vs_disease;
- info->divine += values->vs_divine;
- info->heat += values->vs_heat;
- info->magic += values->vs_magic;
- int32 sta_hp_bonus = 0.0;
- int32 prim_power_bonus = 0.0;
- float bonus_mod = 0.0;
- if (IsPlayer()) {
- bonus_mod = CalculateBonusMod();
- sta_hp_bonus = info->sta * bonus_mod;
- prim_power_bonus = GetPrimaryStat() * bonus_mod;
- }
- prim_power_bonus = floor(float(prim_power_bonus));
- sta_hp_bonus = floor(float(sta_hp_bonus));
- SetTotalHP(GetTotalHPBase() + values->health + sta_hp_bonus);
- SetTotalPower(GetTotalPowerBase() + values->power + prim_power_bonus);
- if(GetHP() > GetTotalHP())
- SetHP(GetTotalHP());
- if(GetPower() > GetTotalPower())
- SetPower(GetTotalPower());
- info->mental += values->vs_mental;
- info->poison += values->vs_poison;
- info->max_concentration += values->concentration;
- info->cold += values->vs_cold;
- info->mitigation_skill1 += values->vs_slash;
- info->mitigation_skill2 += values->vs_pierce;
- info->mitigation_skill3 += values->vs_crush;
- info->ability_modifier += values->ability_modifier;
- info->critical_mitigation += values->criticalmitigation;
- info->block_chance += values->extrashieldblockchance;
- info->crit_chance += values->beneficialcritchance;
- info->crit_bonus += values->critbonus;
- info->potency += values->potency;
- info->hate_mod += values->hategainmod;
- info->reuse_speed += values->abilityreusespeed;
- info->casting_speed += values->abilitycastingspeed;
- info->recovery_speed += values->abilityrecoveryspeed;
- info->spell_reuse_speed += values->spellreusespeed;
- info->spell_multi_attack += values->spellmultiattackchance;
- info->dps += values->dps;
- info->dps_multiplier = CalculateDPSMultiplier();
- info->haste += values->attackspeed;
- info->multi_attack += values->multiattackchance;
- info->flurry += values->flurry;
- info->melee_ae += values->aeautoattackchance;
- info->strikethrough += values->strikethrough;
- info->accuracy += values->accuracy;
- info->offensivespeed += values->offensivespeed;
- info->uncontested_block += values->uncontested_block;
- info->uncontested_parry += values->uncontested_parry;
- info->uncontested_dodge += values->uncontested_dodge;
- info->uncontested_riposte += values->uncontested_riposte;
- safe_delete(values);
- }
- EquipmentItemList* Entity::GetEquipmentList(){
- return &equipment_list;
- }
- void Entity::SetEquipment(Item* item, int8 slot){
- if(!item && slot < NUM_SLOTS){
- SetInfo(&equipment.equip_id[slot], 0);
- SetInfo(&equipment.color[slot].red, 0);
- SetInfo(&equipment.color[slot].green, 0);
- SetInfo(&equipment.color[slot].blue, 0);
- SetInfo(&equipment.highlight[slot].red, 0);
- SetInfo(&equipment.highlight[slot].green, 0);
- SetInfo(&equipment.highlight[slot].blue, 0);
- }
- else{
- SetInfo(&equipment.equip_id[item->details.slot_id], item->generic_info.appearance_id);
- SetInfo(&equipment.color[item->details.slot_id].red, item->generic_info.appearance_red);
- SetInfo(&equipment.color[item->details.slot_id].green, item->generic_info.appearance_green);
- SetInfo(&equipment.color[item->details.slot_id].blue, item->generic_info.appearance_blue);
- SetInfo(&equipment.highlight[item->details.slot_id].red, item->generic_info.appearance_highlight_red);
- SetInfo(&equipment.highlight[item->details.slot_id].green, item->generic_info.appearance_highlight_green);
- SetInfo(&equipment.highlight[item->details.slot_id].blue, item->generic_info.appearance_highlight_blue);
- }
- }
- bool Entity::CheckSpellBonusRemoval(LuaSpell* spell, int16 type){
- MutexList<BonusValues*>::iterator itr = bonus_list.begin();
- while(itr.Next()){
- if(itr.value->luaspell == spell && itr.value->type == type){
- bonus_list.Remove(itr.value, true);
- return true;
- }
- }
- return false;
- }
- void Entity::AddSpellBonus(LuaSpell* spell, int16 type, float value, int64 class_req, vector<int16> race_req, vector<int16> faction_req){
- CheckSpellBonusRemoval(spell, type);
- BonusValues* bonus = new BonusValues;
- bonus->spell_id = spell->spell->GetSpellID();
- bonus->luaspell = spell;
- bonus->type = type;
- bonus->value = value;
- bonus->class_req = class_req;
- bonus->race_req = race_req;
- bonus->faction_req = faction_req;
- bonus->tier = spell ? spell->spell->GetSpellTier() : 0;
- bonus_list.Add(bonus);
- }
- BonusValues* Entity::GetSpellBonus(int32 spell_id) {
- BonusValues *ret = 0;
- MutexList<BonusValues*>::iterator itr = bonus_list.begin();
- while (itr.Next()) {
- if (itr.value->spell_id == spell_id) {
- ret = itr.value;
- break;
- }
- }
- return ret;
- }
- vector<BonusValues*>* Entity::GetAllSpellBonuses(LuaSpell* spell) {
- vector<BonusValues*>* list = new vector<BonusValues*>;
- MutexList<BonusValues*>::iterator itr = bonus_list.begin();
- while (itr.Next()) {
- if (itr.value->luaspell == spell)
- list->push_back(itr.value);
- }
- return list;
- }
- void Entity::RemoveSpellBonus(const LuaSpell* spell){
- MutexList<BonusValues*>::iterator itr = bonus_list.begin();
- while(itr.Next()){
- if(itr.value->luaspell == spell)
- bonus_list.Remove(itr.value, true);
- }
- }
- void Entity::CalculateSpellBonuses(ItemStatsValues* stats){
- if(stats){
- MutexList<BonusValues*>::iterator itr = bonus_list.begin();
- vector<BonusValues*> bv;
- //First check if we meet the requirement for each bonus
- bool race_match = false;
- while(itr.Next()) {
- if (itr.value->race_req.size() > 0) {
- for (int8 i = 0; i < itr.value->race_req.size(); i++) {
- if (GetRace() == itr.value->race_req[i]) {
- race_match = true;
- }
- }
- }
- else
- race_match = true; // if the race_req.size = 0 then there is no race requirement and the race_match will be true
- int64 const class1 = pow(2.0, (GetAdventureClass() - 1));
- int64 const class2 = pow(2.0, (classes.GetSecondaryBaseClass(GetAdventureClass()) - 1));
- int64 const class3 = pow(2.0, (classes.GetBaseClass(GetAdventureClass()) - 1));
- if (itr.value->class_req == 0 || (itr.value->class_req & class1) == class1 || (itr.value->class_req & class2) == class2 || (itr.value->class_req & class3) == class3 && race_match )
- bv.push_back(itr.value);
- }
- //Sort the bonuses by spell id and luaspell
- BonusValues* bonus = nullptr;
- map <int32, map<LuaSpell*, vector<BonusValues*> > > sort;
- for (int8 i = 0; i < bv.size(); i++){
- bonus = bv.at(i);
- sort[bonus->spell_id][bonus->luaspell].push_back(bonus);
- }
- //Now check for the highest tier of each spell id and apply those bonuses
- map<LuaSpell*, vector<BonusValues*> >::iterator tier_itr;
- map <int32, map<LuaSpell*, vector<BonusValues*> > >::iterator sort_itr;
- for (sort_itr = sort.begin(); sort_itr != sort.end(); sort_itr++){
- LuaSpell* key = nullptr;
- sint8 highest_tier = -1;
- //Find the highest tier for this spell id
- for (tier_itr = sort_itr->second.begin(); tier_itr != sort_itr->second.end(); tier_itr++){
- LuaSpell* current_spell = tier_itr->first;
- sint8 current_tier = 0;
- if (current_spell && ((current_tier = current_spell->spell->GetSpellTier()) > highest_tier)) {
- highest_tier = current_tier;
- key = current_spell;
- }
- }
- //We've found the highest tier for this spell id, so add the bonuses
- vector<BonusValues*>* final_bonuses = &sort_itr->second[key];
- for (int8 i = 0; i < final_bonuses->size(); i++)
- world.AddBonuses(stats, final_bonuses->at(i)->type, final_bonuses->at(i)->value, this);
- }
- }
- }
- void Entity::AddMezSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_MEZ])
- control_effects[CONTROL_EFFECT_TYPE_MEZ] = new MutexList<LuaSpell*>;
- MutexList<LuaSpell*>* mez_spells = control_effects[CONTROL_EFFECT_TYPE_MEZ];
- if (IsPlayer() && !IsStunned() && !IsMezImmune() && mez_spells->size(true) == 0){
- ((Player*)this)->SetPlayerControlFlag(1, 16, true);
- if (!IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, true);
- if (!IsStifled() && !IsFeared())
- GetZone()->LockAllSpells((Player*)this);
- }
- if (IsNPC() && !IsMezImmune())
- {
- HaltMovement();
- }
- mez_spells->Add(spell);
- }
- void Entity::RemoveMezSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* mez_spells = control_effects[CONTROL_EFFECT_TYPE_MEZ];
- if (!mez_spells || mez_spells->size(true) == 0)
- return;
- mez_spells->Remove(spell);
- if (mez_spells->size(true) == 0){
- if (IsPlayer() && !IsMezImmune() && !IsStunned()){
- if (!IsStifled() && !IsFeared())
- GetZone()->UnlockAllSpells((Player*)this);
- ((Player*)this)->SetPlayerControlFlag(1, 16, false);
- if (!IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, false);
- }
- }
- }
- void Entity::RemoveAllMezSpells() {
- MutexList<LuaSpell*>* mez_spells = control_effects[CONTROL_EFFECT_TYPE_MEZ];
- if (!mez_spells)
- return;
- MutexList<LuaSpell*>::iterator itr = mez_spells->begin();
- while (itr.Next()){
- LuaSpell* spell = itr.value;
- if (!spell)
- continue;
- GetZone()->RemoveTargetFromSpell(spell, this);
- RemoveDetrimentalSpell(spell);
- RemoveSpellEffect(spell);
- if (IsPlayer())
- ((Player*)this)->RemoveSkillBonus(spell->spell->GetSpellID());
- }
- mez_spells->clear();
- if (IsPlayer() && !IsMezImmune() && !IsStunned()){
- if (!IsStifled() && !IsFeared())
- GetZone()->UnlockAllSpells((Player*)this);
- ((Player*)this)->SetPlayerControlFlag(1, 16, false);
- if (!IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, false);
- }
- }
- void Entity::AddStifleSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_STIFLE])
- control_effects[CONTROL_EFFECT_TYPE_STIFLE] = new MutexList<LuaSpell*>;
- if (IsPlayer() && control_effects[CONTROL_EFFECT_TYPE_STIFLE]->size(true) == 0 && !IsStifleImmune() && !IsMezzedOrStunned())
- GetZone()->LockAllSpells((Player*)this);
- control_effects[CONTROL_EFFECT_TYPE_STIFLE]->Add(spell);
- }
- void Entity::RemoveStifleSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* stifle_list = control_effects[CONTROL_EFFECT_TYPE_STIFLE];
- if (!stifle_list || stifle_list->size(true) == 0)
- return;
- stifle_list->Remove(spell);
- if (IsPlayer() && stifle_list->size(true) == 0 && !IsStifleImmune() && !IsMezzedOrStunned())
- GetZone()->UnlockAllSpells((Player*)this);
- }
- void Entity::AddDazeSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_DAZE])
- control_effects[CONTROL_EFFECT_TYPE_DAZE] = new MutexList<LuaSpell*>;
- control_effects[CONTROL_EFFECT_TYPE_DAZE]->Add(spell);
- }
- void Entity::RemoveDazeSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* daze_list = control_effects[CONTROL_EFFECT_TYPE_DAZE];
- if (!daze_list || daze_list->size(true) == 0)
- return;
- daze_list->Remove(spell);
- }
- void Entity::AddStunSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_STUN])
- control_effects[CONTROL_EFFECT_TYPE_STUN] = new MutexList<LuaSpell*>;
- if (IsPlayer() && control_effects[CONTROL_EFFECT_TYPE_STUN]->size(true) == 0 && !IsStunImmune()){
- if (!IsMezzed()){
- ((Player*)this)->SetPlayerControlFlag(1, 16, true);
- if (!IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, true);
- if (!IsStifled() && !IsFeared())
- GetZone()->LockAllSpells((Player*)this);
- }
- }
- control_effects[CONTROL_EFFECT_TYPE_STUN]->Add(spell);
- }
- void Entity::RemoveStunSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* stun_list = control_effects[CONTROL_EFFECT_TYPE_STUN];
- if (!stun_list || stun_list->size(true) == 0)
- return;
- stun_list->Remove(spell);
- if (stun_list->size(true) == 0){
- if (IsPlayer() && !IsMezzed() && !IsStunImmune()){
- ((Player*)this)->SetPlayerControlFlag(1, 16, false);
- if (!IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, false);
- if (!IsStifled() && !IsFeared())
- GetZone()->UnlockAllSpells((Player*)this);
- }
- }
- }
- void Entity::HideDeityPet(bool val) {
- if (!deityPet)
- return;
- if (val) {
- deityPet->AddAllowAccessSpawn(deityPet);
- GetZone()->HidePrivateSpawn(deityPet);
- }
- else
- deityPet->MakeSpawnPublic();
- }
- void Entity::HideCosmeticPet(bool val) {
- if (!cosmeticPet)
- return;
- if (val) {
- cosmeticPet->AddAllowAccessSpawn(cosmeticPet);
- GetZone()->HidePrivateSpawn(cosmeticPet);
- }
- else
- cosmeticPet->MakeSpawnPublic();
- }
- void Entity::DismissPet(NPC* pet, bool from_death) {
- if (!pet)
- return;
- Entity* PetOwner = pet->GetOwner();
- pet->SetDismissing(true);
- // Remove the spell maintained spell
- Spell* spell = master_spell_list.GetSpell(pet->GetPetSpellID(), pet->GetPetSpellTier());
- if (spell)
- GetZone()->GetSpellProcess()->DeleteCasterSpell(this, spell);
- if (pet->GetPetType() == PET_TYPE_CHARMED) {
- PetOwner->SetCharmedPet(0);
- if (!from_death) {
- // set the pet flag to false, owner to 0, and give the mob its old brain back
- pet->SetPet(false);
- pet->SetOwner(0);
- pet->SetBrain(new Brain(pet));
- pet->SetDismissing(false);
- }
- }
- else if (pet->GetPetType() == PET_TYPE_COMBAT)
- PetOwner->SetCombatPet(0);
- else if (pet->GetPetType() == PET_TYPE_DEITY)
- PetOwner->SetDeityPet(0);
- else if (pet->GetPetType() == PET_TYPE_COSMETIC)
- PetOwner->SetCosmeticPet(0);
- // if owner is player and no combat pets left reset the pet info
- if (PetOwner->IsPlayer()) {
- if (!PetOwner->GetPet() && !PetOwner->GetCharmedPet())
- ((Player*)PetOwner)->ResetPetInfo();
- }
- // remove the spawn from the world
- if (!from_death && pet->GetPetType() != PET_TYPE_CHARMED)
- GetZone()->RemoveSpawn(false, pet);
- }
- float Entity::CalculateBonusMod() {
- int8 level = GetLevel();
- if (level <= 20)
- return 3.0;
- else if (level >= 90)
- return 10.0;
- else
- return (level - 20) * .1 + 3.0;
- }
- float Entity::CalculateDPSMultiplier(){
- float dps = GetInfoStruct()->dps;
- if (dps > 0){
- if (dps <= 100)
- return (dps / 100 + 1);
- else if (dps <= 200)
- return (((dps - 100) * .25 + 100) / 100 + 1);
- else if (dps <= 300)
- return (((dps - 200) * .1 + 125) / 100 + 1);
- else if (dps <= 900)
- return (((dps - 300) * .05 + 135) / 100 + 1);
- else
- return (((dps - 900) * .01 + 165) / 100 + 1);
- }
- return 1;
- }
- void Entity::AddWard(int32 spellID, WardInfo* ward) {
- if (m_wardList.count(spellID) == 0) {
- m_wardList[spellID] = ward;
- }
- }
- WardInfo* Entity::GetWard(int32 spellID) {
- WardInfo* ret = 0;
- if (m_wardList.count(spellID) > 0)
- ret = m_wardList[spellID];
- return ret;
- }
- void Entity::RemoveWard(int32 spellID) {
- if (m_wardList.count(spellID) > 0) {
- // Delete the ward info
- safe_delete(m_wardList[spellID]);
- // Remove from the ward list
- m_wardList.erase(spellID);
- }
- }
- int32 Entity::CheckWards(Entity* attacker, int32 damage, int8 damage_type) {
- map<int32, WardInfo*>::iterator itr;
- WardInfo* ward = 0;
- LuaSpell* spell = 0;
- while (m_wardList.size() > 0 && damage > 0) {
- // Get the ward with the lowest base damage
- for (itr = m_wardList.begin(); itr != m_wardList.end(); itr++) {
- if (!ward || itr->second->BaseDamage < ward->BaseDamage) {
- if ((itr->second->AbsorbAllDamage || itr->second->DamageLeft > 0) &&
- (itr->second->WardType == WARD_TYPE_ALL ||
- (itr->second->WardType == WARD_TYPE_PHYSICAL && damage_type >= DAMAGE_PACKET_DAMAGE_TYPE_SLASH && damage_type <= DAMAGE_PACKET_DAMAGE_TYPE_PIERCE) ||
- (itr->second->WardType == WARD_TYPE_MAGICAL && ((itr->second->DamageType == 0 && damage_type >= DAMAGE_PACKET_DAMAGE_TYPE_PIERCE) || (damage_type >= DAMAGE_PACKET_DAMAGE_TYPE_PIERCE && itr->second->DamageType == damage_type)))))
- ward = itr->second;
- }
- }
- if (!ward)
- break;
- spell = ward->Spell;
- // damage to redirect at the source (like intercept)
- int32 redirectDamage = 0;
- if (ward->RedirectDamagePercent)
- redirectDamage = (int32)(double)damage * ((double)ward->RedirectDamagePercent / 100.0);
- // percentage the spell absorbs of all possible damage
- int32 damageToAbsorb = 0;
- if (ward->DamageAbsorptionPercentage > 0)
- damageToAbsorb = (int32)(double)damage * ((double)ward->DamageAbsorptionPercentage/100.0);
- else
- damageToAbsorb = damage;
- int32 maxDamageAbsorptionAllowed = 0;
- // spells like Divine Aura have caps on health, eg. anything more than 50% damage is not absorbed
- if (ward->DamageAbsorptionMaxHealthPercent > 0)
- maxDamageAbsorptionAllowed = (int32)(double)GetTotalHP() * ((double)ward->DamageAbsorptionMaxHealthPercent / 100.0);
- if (maxDamageAbsorptionAllowed > 0 && damageToAbsorb >= maxDamageAbsorptionAllowed)
- damageToAbsorb = 0; // its over or equal to 50% of the total hp allowed, thus this damage is not absorbed
- int32 baseDamageRemaining = damage - damageToAbsorb;
- bool hasSpellBeenRemoved = false;
- if (ward->AbsorbAllDamage)
- {
- ward->LastAbsorbedDamage = ward->DamageLeft;
- GetZone()->SendHealPacket(ward->Spell->caster, this, HEAL_PACKET_TYPE_ABSORB, damage, spell->spell->GetName());
- damage = 0;
- }
- else if (damageToAbsorb >= ward->DamageLeft) {
- // Damage is greater than or equal to the amount left on the ward
- ward->LastAbsorbedDamage = ward->DamageLeft;
- // remove what damage we can absorb
- damageToAbsorb -= ward->DamageLeft;
- // move back what couldn't be absorbed to the base dmg and apply to the overall damage
- baseDamageRemaining += damageToAbsorb;
- damage = baseDamageRemaining;
- ward->DamageLeft = 0;
- spell->damage_remaining = 0;
- GetZone()->SendHealPacket(spell->caster, this, HEAL_PACKET_TYPE_ABSORB, ward->DamageLeft, spell->spell->GetName());
- if (!ward->keepWard) {
- hasSpellBeenRemoved = true;
- RemoveWard(spell->spell->GetSpellID());
- GetZone()->GetSpellProcess()->DeleteCasterSpell(spell);
- }
- }
- else {
- ward->LastAbsorbedDamage = damageToAbsorb;
- // Damage is less then the amount left on the ward
- ward->DamageLeft -= damageToAbsorb;
- spell->damage_remaining = ward->DamageLeft;
- if (spell->caster->IsPlayer())
- ClientPacketFunctions::SendMaintainedExamineUpdate(GetZone()->GetClientBySpawn(spell->caster), spell->slot_pos, ward->DamageLeft, 1);
- GetZone()->SendHealPacket(ward->Spell->caster, this, HEAL_PACKET_TYPE_ABSORB, damage, spell->spell->GetName());
- // remaining damage not absorbed by percentage must be set
- damage = baseDamageRemaining;
- }
- if (redirectDamage)
- {
- ward->LastRedirectDamage = redirectDamage;
- if (attacker && spell->caster)
- attacker->DamageSpawn(spell->caster, DAMAGE_PACKET_TYPE_SPELL_DAMAGE, damage_type, redirectDamage, redirectDamage, 0);
- }
- bool shouldRemoveSpell = false;
- ward->HitCount++; // increment hit count
- if (ward->MaxHitCount && spell->num_triggers)
- {
- spell->num_triggers--;
- ClientPacketFunctions::SendMaintainedExamineUpdate(spell->caster->GetZone()->GetClientBySpawn(spell->caster), spell->slot_pos, spell->num_triggers, 0);
- }
-
- if (ward->HitCount >= ward->MaxHitCount) // there isn't a max hit requirement with the hit count, so just go based on hit count
- shouldRemoveSpell = true;
- if (shouldRemoveSpell && !hasSpellBeenRemoved)
- {
- RemoveWard(spell->spell->GetSpellID());
- GetZone()->GetSpellProcess()->DeleteCasterSpell(spell);
- }
- // Reset ward pointer
- ward = 0;
- }
- return damage;
- }
- float Entity::CalculateCastingSpeedMod() {
- float cast_speed = info_struct.casting_speed;
-
- if(cast_speed > 0)
- return 100 * max((float) 0.5, (float) (1 + (1 - (1 / (1 + (cast_speed * .01))))));
- else if (cast_speed < 0)
- return 100 * min((float) 1.5, (float) (1 + (1 - (1 / (1 + (cast_speed * -.01))))));
- return 0;
- }
- float Entity::GetSpeed() {
- float ret = speed > GetBaseSpeed() ? speed : GetBaseSpeed();
- if (EngagedInCombat() && GetMaxSpeed() > 0.0f)
- ret = GetMaxSpeed();
- if (IsStealthed() || IsInvis())
- ret += stats[ITEM_STAT_STEALTHINVISSPEEDMOD];
- else if (EngagedInCombat())
- ret += stats[ITEM_STAT_OFFENSIVESPEED];
- else
- ret += max(stats[ITEM_STAT_SPEED], stats[ITEM_STAT_MOUNTSPEED]);
- ret *= speed_multiplier;
- return ret;
- }
- float Entity::GetAirSpeed() {
- float ret = speed;
- if (!EngagedInCombat())
- ret += stats[ITEM_STAT_MOUNTAIRSPEED];
- ret *= speed_multiplier;
- return ret;
- }
- int8 Entity::GetTraumaCount() {
- return det_count_list[DET_TYPE_TRAUMA];
- }
- int8 Entity::GetArcaneCount() {
- return det_count_list[DET_TYPE_ARCANE];
- }
- int8 Entity::GetNoxiousCount() {
- return det_count_list[DET_TYPE_NOXIOUS];
- }
- int8 Entity::GetElementalCount() {
- return det_count_list[DET_TYPE_ELEMENTAL];
- }
- int8 Entity::GetCurseCount() {
- return det_count_list[DET_TYPE_CURSE];
- }
- Mutex* Entity::GetDetrimentMutex() {
- return &MDetriments;
- }
- Mutex* Entity::GetMaintainedMutex() {
- return &MMaintainedSpells;
- }
- Mutex* Entity::GetSpellEffectMutex() {
- return &MSpellEffects;
- }
- bool Entity::HasCurableDetrimentType(int8 det_type) {
- DetrimentalEffects* det;
- bool ret = false;
- MDetriments.readlock(__FUNCTION__, __LINE__);
- for (int32 i = 0; i < detrimental_spell_effects.size(); i++){
- det = &detrimental_spell_effects.at(i);
- if(det && det->det_type == det_type && !det->incurable){
- ret = true;
- break;
- }
- }
- MDetriments.releasereadlock(__FUNCTION__, __LINE__);
- return ret;
- }
- void Entity::ClearAllDetriments() {
- MDetriments.writelock(__FUNCTION__, __LINE__);
- detrimental_spell_effects.clear();
- det_count_list.clear();
- MDetriments.releasewritelock(__FUNCTION__, __LINE__);
- }
- void Entity::CureDetrimentByType(int8 cure_count, int8 det_type, string cure_name, Entity* caster, int8 cure_level) {
- if (cure_count <= 0 || GetDetTypeCount(det_type) <= 0)
- return;
- vector<DetrimentalEffects>* det_list = &detrimental_spell_effects;
- DetrimentalEffects* det;
- vector<LuaSpell*> remove_list;
- LuaSpell* spell = 0;
- vector<LevelArray*>* levels;
- int8 caster_class1 = 0;
- int8 caster_class2 = 0;
- int8 caster_class3 = 0;
- int8 level_class = 0;
- InfoStruct* info_struct = 0;
- bool pass_level_check = false;
- MDetriments.readlock(__FUNCTION__, __LINE__);
- for (int32 i = 0; i<det_list->size(); i++){
- det = &det_list->at(i);
- if (det && det->det_type == det_type && !det->incurable){
- levels = det->spell->spell->GetSpellLevels();
- info_struct = det->caster->GetInfoStruct();
- caster_class1 = info_struct->class1;
- caster_class2 = info_struct->class2;
- caster_class3 = info_struct->class3;
- pass_level_check = false;
- for (int32 x = 0; x < levels->size(); x++){
- level_class = levels->at(x)->adventure_class;
- if (!cure_level || ((caster_class1 == level_class || caster_class2 == level_class || caster_class3 == level_class)
- && cure_level >= (levels->at(x)->spell_level / 10))){
- pass_level_check = true;
- break;
- }
- }
- if (pass_level_check){
- remove_list.push_back(det->spell);
- cure_count--;
- if (cure_count == 0)
- break;
- }
- }
- }
- MDetriments.releasereadlock(__FUNCTION__, __LINE__);
- for (int32 i = 0; i<remove_list.size(); i++){
- spell = remove_list.at(i);
- GetZone()->SendDispellPacket(caster, this, cure_name, (string)remove_list.at(i)->spell->GetName(), DISPELL_TYPE_CURE);
- if (GetZone())
- GetZone()->RemoveTargetFromSpell(spell, this);
- RemoveSpellEffect(spell);
- RemoveDetrimentalSpell(spell);
- }
- remove_list.clear();
- }
- void Entity::CureDetrimentByControlEffect(int8 cure_count, int8 control_type, string cure_name, Entity* caster, int8 cure_level) {
- if (cure_count <= 0 || GetDetCount() <= 0)
- return;
- vector<DetrimentalEffects>* det_list = &detrimental_spell_effects;
- DetrimentalEffects* det;
- vector<LuaSpell*> remove_list;
- LuaSpell* spell = 0;
- vector<LevelArray*>* levels;
- int8 caster_class1 = 0;
- int8 caster_class2 = 0;
- int8 caster_class3 = 0;
- int8 level_class = 0;
- InfoStruct* info_struct = 0;
- bool pass_level_check = false;
- MDetriments.readlock(__FUNCTION__, __LINE__);
- for (int32 i = 0; i<det_list->size(); i++){
- det = &det_list->at(i);
- if (det && det->control_effect == control_type && !det->incurable){
- levels = det->spell->spell->GetSpellLevels();
- info_struct = det->caster->GetInfoStruct();
- caster_class1 = info_struct->class1;
- caster_class2 = info_struct->class2;
- caster_class3 = info_struct->class3;
- pass_level_check = false;
- for (int32 x = 0; x < levels->size(); x++){
- level_class = levels->at(x)->adventure_class;
- if (!cure_level || ((caster_class1 == level_class || caster_class2 == level_class || caster_class3 == level_class)
- && cure_level >= (levels->at(x)->spell_level / 10))){
- pass_level_check = true;
- break;
- }
- }
- if (pass_level_check){
- remove_list.push_back(det->spell);
- cure_count--;
- if (cure_count == 0)
- break;
- }
- }
- }
- MDetriments.releasereadlock(__FUNCTION__, __LINE__);
- for (int32 i = 0; i<remove_list.size(); i++){
- spell = remove_list.at(i);
- GetZone()->SendDispellPacket(caster, this, cure_name, (string)remove_list.at(i)->spell->GetName(), DISPELL_TYPE_CURE);
- if (GetZone())
- GetZone()->RemoveTargetFromSpell(spell, this);
- RemoveSpellEffect(spell);
- RemoveDetrimentalSpell(spell);
- }
- remove_list.clear();
- }
- void Entity::RemoveDetrimentalSpell(LuaSpell* spell) {
- if(!spell || spell->spell->GetSpellData()->det_type == 0)
- return;
- MDetriments.writelock(__FUNCTION__, __LINE__);
- vector<DetrimentalEffects>* det_list = &detrimental_spell_effects;
- vector<DetrimentalEffects>::iterator itr;
- for(itr = det_list->begin(); itr != det_list->end(); itr++){
- if((*itr).spell == spell){
- det_count_list[(*itr).det_type]--;
- det_list->erase(itr);
- if(IsPlayer())
- ((Player*)this)->SetCharSheetChanged(true);
- break;
- }
- }
- MDetriments.releasewritelock(__FUNCTION__, __LINE__);
- }
- int8 Entity::GetDetTypeCount(int8 det_type){
- return det_count_list[det_type];
- }
- int8 Entity::GetDetCount() {
- int8 det_count = 0;
- map<int8, int8>::iterator itr;
- for(itr=det_count_list.begin(); itr != det_count_list.end(); itr++)
- det_count += (*itr).second;
-
- return det_count;
- }
- vector<DetrimentalEffects>* Entity::GetDetrimentalSpellEffects() {
- return &detrimental_spell_effects;
- }
- void Entity::AddDetrimentalSpell(LuaSpell* luaspell){
- if(!luaspell || !luaspell->caster)
- return;
-
- Spell* spell = luaspell->spell;
- DetrimentalEffects* det = GetDetrimentalEffect(spell->GetSpellID(), luaspell->caster);
- DetrimentalEffects new_det;
- if(det)
- RemoveDetrimentalSpell(det->spell);
- SpellData* data = spell->GetSpellData();
- if(!data)
- return;
- new_det.caster = luaspell->caster;
- new_det.spell = luaspell;
- if (spell->GetSpellData()->duration_until_cancel)
- new_det.expire_timestamp = 0xFFFFFFFF;
- else
- new_det.expire_timestamp = Timer::GetCurrentTime2() + (spell->GetSpellDuration()*100);
- new_det.icon = data->icon;
- new_det.icon_backdrop = data->icon_backdrop;
- new_det.tier = data->tier;
- new_det.det_type = data->det_type;
- new_det.incurable = data->incurable;
- new_det.spell_id = spell->GetSpellID();
- new_det.control_effect = data->control_effect_type;
- new_det.total_time = spell->GetSpellDuration()/10;
- MDetriments.writelock(__FUNCTION__, __LINE__);
- detrimental_spell_effects.push_back(new_det);
- det_count_list[new_det.det_type]++;
- MDetriments.releasewritelock(__FUNCTION__, __LINE__);
- }
- DetrimentalEffects* Entity::GetDetrimentalEffect(int32 spell_id, Entity* caster){
- vector<DetrimentalEffects>* det_list = &detrimental_spell_effects;
- DetrimentalEffects* ret = 0;
- MDetriments.readlock(__FUNCTION__, __LINE__);
- for(int32 i=0; i<det_list->size(); i++){
- if (det_list->at(i).spell_id == spell_id && det_list->at(i).caster == caster)
- ret = &det_list->at(i);
- }
- MDetriments.releasereadlock(__FUNCTION__, __LINE__);
-
- return ret;
- }
- void Entity::CancelAllStealth() {
- bool did_change = false;
- MutexList<LuaSpell*>* stealth_list = control_effects[CONTROL_EFFECT_TYPE_STEALTH];
- if (stealth_list){
- MutexList<LuaSpell*>::iterator itr = stealth_list->begin();
- while (itr.Next()){
- if (itr.value->caster == this)
- GetZone()->GetSpellProcess()->AddSpellCancel(itr.value);
- else{
- GetZone()->RemoveTargetFromSpell(itr.value, this);
- RemoveSpellEffect(itr.value);
- }
- did_change = true;
- }
- }
- MutexList<LuaSpell*>* invis_list = control_effects[CONTROL_EFFECT_TYPE_INVIS];
- if (invis_list){
- MutexList<LuaSpell*>::iterator invis_itr = invis_list->begin();
- while (invis_itr.Next()){
- if (invis_itr.value->caster == this)
- GetZone()->GetSpellProcess()->AddSpellCancel(invis_itr.value);
- else{
- GetZone()->RemoveTargetFromSpell(invis_itr.value, this);
- RemoveSpellEffect(invis_itr.value);
- }
- did_change = true;
- }
- }
- if (did_change){
- info_changed = true;
- changed = true;
- AddChangedZoneSpawn();
- if (IsPlayer())
- ((Player*)this)->SetCharSheetChanged(true);
- }
- }
- bool Entity::IsStealthed(){
- MutexList<LuaSpell*>* stealth_list = control_effects[CONTROL_EFFECT_TYPE_STEALTH];
- return (!stealth_list || stealth_list->size(true) == 0) == false;
- }
- bool Entity::CanSeeInvis(Entity* target) {
- return true;
- }
- bool Entity::IsInvis(){
- MutexList<LuaSpell*>* invis_list = control_effects[CONTROL_EFFECT_TYPE_INVIS];
- return (!invis_list || invis_list->size(true) == 0) == false;
- }
- void Entity::AddStealthSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_STEALTH])
- control_effects[CONTROL_EFFECT_TYPE_STEALTH] = new MutexList<LuaSpell*>;
- control_effects[CONTROL_EFFECT_TYPE_STEALTH]->Add(spell);
- if (control_effects[CONTROL_EFFECT_TYPE_STEALTH]->size(true) == 1){
- info_changed = true;
- changed = true;
- AddChangedZoneSpawn();
- if (IsPlayer())
- ((Player*)this)->SetCharSheetChanged(true);
- }
- }
- void Entity::AddInvisSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_INVIS])
- control_effects[CONTROL_EFFECT_TYPE_INVIS] = new MutexList<LuaSpell*>;
- control_effects[CONTROL_EFFECT_TYPE_INVIS]->Add(spell);
- if (control_effects[CONTROL_EFFECT_TYPE_INVIS]->size(true) == 1){
- info_changed = true;
- changed = true;
- AddChangedZoneSpawn();
- if (IsPlayer())
- ((Player*)this)->SetCharSheetChanged(true);
- }
- }
- void Entity::RemoveInvisSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* invis_list = control_effects[CONTROL_EFFECT_TYPE_INVIS];
- if (!invis_list || invis_list->size(true) == 0)
- return;
- invis_list->Remove(spell);
- RemoveSpellEffect(spell);
- if (invis_list->size(true) == 0){
- info_changed = true;
- changed = true;
- AddChangedZoneSpawn();
- if (IsPlayer())
- ((Player*)this)->SetCharSheetChanged(true);
- }
- }
- void Entity::RemoveStealthSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* stealth_list = control_effects[CONTROL_EFFECT_TYPE_STEALTH];
- if (!stealth_list || stealth_list->size(true) == 0)
- return;
- stealth_list->Remove(spell);
- RemoveSpellEffect(spell);
- if (stealth_list->size() == 0){
- info_changed = true;
- changed = true;
- AddChangedZoneSpawn();
- if (IsPlayer())
- ((Player*)this)->SetCharSheetChanged(true);
- }
- }
- void Entity::AddRootSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_ROOT])
- control_effects[CONTROL_EFFECT_TYPE_ROOT] = new MutexList<LuaSpell*>;
- if (control_effects[CONTROL_EFFECT_TYPE_ROOT]->size(true) == 0 && !IsRootImmune()) {
- if (IsPlayer()){
- if (!IsMezzedOrStunned())
- ((Player*)this)->SetPlayerControlFlag(1, 8, true); // heading movement only
- }
- else
- SetSpeedMultiplier(0.0f);
- }
- control_effects[CONTROL_EFFECT_TYPE_ROOT]->Add(spell);
- }
- void Entity::RemoveRootSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* root_list = control_effects[CONTROL_EFFECT_TYPE_ROOT];
- if (!root_list || root_list->size(true) == 0)
- return;
- root_list->Remove(spell);
- if (root_list->size(true) == 0 && !IsRootImmune()) {
- if (IsPlayer()){
- if (!IsMezzedOrStunned())
- ((Player*)this)->SetPlayerControlFlag(1, 8, false); // heading movement only
- }
- else {
- // GetHighestSnare() will return 1.0f if no snares returning the spawn to full speed
- SetSpeedMultiplier(GetHighestSnare());
- }
- }
- }
- void Entity::AddFearSpell(LuaSpell* spell){
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_FEAR])
- control_effects[CONTROL_EFFECT_TYPE_FEAR] = new MutexList<LuaSpell*>;
- if (IsPlayer() && control_effects[CONTROL_EFFECT_TYPE_FEAR]->size(true) == 0 && !IsFearImmune()){
- ((Player*)this)->SetPlayerControlFlag(4, 4, true); // feared
- if (!IsMezzedOrStunned() && !IsStifled())
- GetZone()->LockAllSpells((Player*)this);
- }
- if (!IsFearImmune() && IsNPC())
- {
- HaltMovement();
- }
- control_effects[CONTROL_EFFECT_TYPE_FEAR]->Add(spell);
- }
- void Entity::RemoveFearSpell(LuaSpell* spell){
- MutexList<LuaSpell*>* fear_list = control_effects[CONTROL_EFFECT_TYPE_FEAR];
- if (!fear_list || fear_list->size(true) == 0)
- return;
- fear_list->Remove(spell);
- if (IsPlayer() && fear_list->size(true) == 0 && !IsFearImmune()){
- ((Player*)this)->SetPlayerControlFlag(4, 4, false); // feared disabled
- if (!IsMezzedOrStunned() && !IsStifled())
- GetZone()->LockAllSpells((Player*)this);
- }
- if (IsNPC())
- {
- HaltMovement();
- }
- }
- void Entity::AddSnareSpell(LuaSpell* spell) {
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_SNARE])
- control_effects[CONTROL_EFFECT_TYPE_SNARE] = new MutexList<LuaSpell*>;
- control_effects[CONTROL_EFFECT_TYPE_SNARE]->Add(spell);
- // Don't set speed multiplier if there is a root or no snare values
- MutexList<LuaSpell*>* roots = control_effects[CONTROL_EFFECT_TYPE_ROOT];
- if ((!roots || roots->size(true) == 0) && snare_values.size() > 0)
- SetSpeedMultiplier(GetHighestSnare());
- }
- void Entity::RemoveSnareSpell(LuaSpell* spell) {
- MutexList<LuaSpell*>* snare_list = control_effects[CONTROL_EFFECT_TYPE_SNARE];
- if (!snare_list || snare_list->size(true) == 0)
- return;
- snare_list->Remove(spell);
- snare_values.erase(spell);
- //LogWrite(PLAYER__ERROR, 0, "Debug", "snare_values.size() = %u", snare_values.size());
- // only change speeds if there are no roots
- MutexList<LuaSpell*>* roots = control_effects[CONTROL_EFFECT_TYPE_ROOT];
- if (!roots || roots->size(true) == 0) {
- float multiplier = GetHighestSnare();
- //LogWrite(PLAYER__ERROR, 0, "Debug", "GetHighestSnare() = %f", multiplier);
- SetSpeedMultiplier(multiplier);
- }
- }
- void Entity::SetSnareValue(LuaSpell* spell, float snare_val) {
- if (!spell)
- return;
- snare_values[spell] = snare_val;
- }
- float Entity::GetHighestSnare() {
- // For simplicity this will return the highest snare value, which is actually the lowest value
- float ret = 1.0f;
- if (snare_values.size() == 0)
- return ret;
- map<LuaSpell*, float>::iterator itr;
- for (itr = snare_values.begin(); itr != snare_values.end(); itr++) {
- if (itr->second < ret)
- ret = itr->second;
- }
- return ret;
- }
- bool Entity::IsSnared() {
- if (control_effects.size() < 1 || !control_effects[CONTROL_EFFECT_TYPE_SNARE])
- return false;
- MutexList<LuaSpell*>* snare_list = control_effects[CONTROL_EFFECT_TYPE_SNARE];
- return (!snare_list || snare_list->size(true) == 0) == false;
- }
- bool Entity::IsMezzed(){
- if (control_effects.size() < 1 || !control_effects[CONTROL_EFFECT_TYPE_MEZ])
- return false;
- MutexList<LuaSpell*>* mez_spells = control_effects[CONTROL_EFFECT_TYPE_MEZ];
- return (!mez_spells || mez_spells->size(true) == 0 || IsMezImmune()) == false;
- }
- bool Entity::IsStifled(){
- if (!control_effects[CONTROL_EFFECT_TYPE_STIFLE])
- return false;
- MutexList<LuaSpell*>* stifle_list = control_effects[CONTROL_EFFECT_TYPE_STIFLE];
- return (!stifle_list || stifle_list->size(true) == 0 || IsStifleImmune()) == false;
- }
- bool Entity::IsDazed(){
- if (control_effects.size() < 1 || !control_effects[CONTROL_EFFECT_TYPE_DAZE])
- return false;
- MutexList<LuaSpell*>* daze_list = control_effects[CONTROL_EFFECT_TYPE_DAZE];
- return (!daze_list || daze_list->size(true) == 0 || IsDazeImmune()) == false;
- }
- bool Entity::IsStunned(){
- if (!control_effects[CONTROL_EFFECT_TYPE_STUN])
- return false;
- MutexList<LuaSpell*>* stun_list = control_effects[CONTROL_EFFECT_TYPE_STUN];
- return (!stun_list || stun_list->size(true) == 0 || IsStunImmune()) == false;
- }
- bool Entity::IsRooted(){
- if (control_effects.size() < 1 || !control_effects[CONTROL_EFFECT_TYPE_ROOT])
- return false;
- MutexList<LuaSpell*>* root_list = control_effects[CONTROL_EFFECT_TYPE_ROOT];
- return (!root_list || root_list->size(true) == 0 || IsRootImmune()) == false;
- }
- bool Entity::IsFeared(){
- if (control_effects.size() < 1 || !control_effects[CONTROL_EFFECT_TYPE_FEAR])
- return false;
- MutexList<LuaSpell*>* fear_list = control_effects[CONTROL_EFFECT_TYPE_FEAR];
- return (!fear_list || fear_list->size(true) == 0 || IsFearImmune()) == false;
- }
- void Entity::AddWaterwalkSpell(LuaSpell* spell){
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_WALKUNDERWATER])
- control_effects[CONTROL_EFFECT_TYPE_WALKUNDERWATER] = new MutexList<LuaSpell*>;
- control_effects[CONTROL_EFFECT_TYPE_WALKUNDERWATER]->Add(spell);
- if (control_effects[CONTROL_EFFECT_TYPE_WALKUNDERWATER]->size(true) == 1 && IsPlayer())
- ((Player*)this)->SetPlayerControlFlag(3, 128, true); // enable walking underwater
- }
- void Entity::RemoveWaterwalkSpell(LuaSpell* spell){
- MutexList<LuaSpell*>* waterwalk_list = control_effects[CONTROL_EFFECT_TYPE_WALKUNDERWATER];
- if (!waterwalk_list || waterwalk_list->size(true) == 0)
- return;
- waterwalk_list->Remove(spell);
- if (waterwalk_list->size(true) == 0 && IsPlayer())
- ((Player*)this)->SetPlayerControlFlag(3, 128, false); // disable walking underwater
- }
- void Entity::AddWaterjumpSpell(LuaSpell* spell){
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_JUMPUNDERWATER])
- control_effects[CONTROL_EFFECT_TYPE_JUMPUNDERWATER] = new MutexList<LuaSpell*>;
- control_effects[CONTROL_EFFECT_TYPE_JUMPUNDERWATER]->Add(spell);
- if (control_effects[CONTROL_EFFECT_TYPE_JUMPUNDERWATER]->size(true) == 1 && IsPlayer())
- ((Player*)this)->SetPlayerControlFlag(4, 1, true); // enable moonjumps underwater
- }
- void Entity::RemoveWaterjumpSpell(LuaSpell* spell){
- MutexList<LuaSpell*>* waterjump_list = control_effects[CONTROL_EFFECT_TYPE_JUMPUNDERWATER];
- if (!waterjump_list || waterjump_list->size(true) == 0)
- return;
- waterjump_list->Remove(spell);
- if (waterjump_list->size(true) == 0 && IsPlayer())
- ((Player*)this)->SetPlayerControlFlag(4, 1, false); // disable moonjumps underwater
- }
- void Entity::AddAOEImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_AOE])
- immunities[IMMUNITY_TYPE_AOE] = new MutexList<LuaSpell*>;
- immunities[IMMUNITY_TYPE_AOE]->Add(spell);
- }
- void Entity::RemoveAOEImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* aoe_list = immunities[IMMUNITY_TYPE_AOE];
- if (!aoe_list || aoe_list->size(true) == 0)
- return;
- aoe_list->Remove(spell);
- }
- bool Entity::IsAOEImmune(){
- return (immunities[IMMUNITY_TYPE_AOE] && immunities[IMMUNITY_TYPE_AOE]->size(true));
- }
- void Entity::AddStunImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_STUN])
- immunities[IMMUNITY_TYPE_STUN] = new MutexList<LuaSpell*>;
- if (IsPlayer() && IsStunned() && !IsMezzed()){
- ((Player*)this)->SetPlayerControlFlag(4, 64, false);
- if (!IsFeared() && !IsStifled())
- ((Player*)this)->UnlockAllSpells();
- }
- immunities[IMMUNITY_TYPE_STUN]->Add(spell);
- }
- void Entity::RemoveStunImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* stun_list = immunities[IMMUNITY_TYPE_STUN];
- if (!stun_list || stun_list->size(true) == 0)
- return;
- stun_list->Remove(spell);
- if (IsPlayer() && IsStunned() && !IsMezzed()){
- ((Player*)this)->SetPlayerControlFlag(4, 64, true);
- if (!IsFeared() && !IsStifled())
- ((Player*)this)->UnlockAllSpells();
- }
- }
- bool Entity::IsStunImmune(){
- return (immunities[IMMUNITY_TYPE_STUN] && immunities[IMMUNITY_TYPE_STUN]->size(true) > 0);
- }
- void Entity::AddStifleImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_STIFLE])
- immunities[IMMUNITY_TYPE_STIFLE] = new MutexList<LuaSpell*>;
- if (IsPlayer() && immunities[IMMUNITY_TYPE_STIFLE]->size(true) == 0){
- if (IsStifled() && !IsMezzedOrStunned() && !IsFeared())
- ((Player*)this)->UnlockAllSpells();
- }
- immunities[IMMUNITY_TYPE_STIFLE]->Add(spell);
- }
- void Entity::RemoveStifleImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* stifle_list = immunities[IMMUNITY_TYPE_STIFLE];
- if (!stifle_list || stifle_list->size(true) == 0)
- return;
- stifle_list->Remove(spell);
- if (IsPlayer() && IsStifled() && !IsMezzedOrStunned() && !IsFeared())
- ((Player*)this)->UnlockAllSpells();
- }
- bool Entity::IsStifleImmune(){
- return (immunities[IMMUNITY_TYPE_STIFLE] && immunities[IMMUNITY_TYPE_STIFLE]->size(true) > 0);
- }
- void Entity::AddMezImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_MEZ])
- immunities[IMMUNITY_TYPE_MEZ] = new MutexList<LuaSpell*>;
- if (IsPlayer() && IsMezzed() && !IsStunned()){
- ((Player*)this)->SetPlayerControlFlag(4, 64, false);
- if (!IsFeared() && !IsStifled())
- ((Player*)this)->UnlockAllSpells();
- }
- immunities[IMMUNITY_TYPE_MEZ]->Add(spell);
- }
- void Entity::RemoveMezImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* mez_list = immunities[IMMUNITY_TYPE_MEZ];
- if (!mez_list || mez_list->size(true) == 0)
- return;
- mez_list->Remove(spell);
- if (IsPlayer() && IsMezzed() && !IsStunned()){
- ((Player*)this)->SetPlayerControlFlag(4, 64, true);
- if (!IsFeared() && !IsStifled())
- ((Player*)this)->LockAllSpells();
- }
- }
- bool Entity::IsMezImmune(){
- return (immunities[IMMUNITY_TYPE_MEZ] && immunities[IMMUNITY_TYPE_MEZ]->size(true) > 0);
- }
- void Entity::AddRootImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_ROOT])
- immunities[IMMUNITY_TYPE_ROOT] = new MutexList<LuaSpell*>;
- if (IsPlayer() && IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, false);
- immunities[IMMUNITY_TYPE_ROOT]->Add(spell);
- }
- void Entity::RemoveRootImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* root_list = immunities[IMMUNITY_TYPE_ROOT];
- if (!root_list || root_list->size(true) == 0)
- return;
- root_list->Remove(spell);
- if (IsPlayer() && IsRooted())
- ((Player*)this)->SetPlayerControlFlag(1, 8, true);
- }
- bool Entity::IsRootImmune(){
- return (immunities[IMMUNITY_TYPE_ROOT] && immunities[IMMUNITY_TYPE_ROOT]->size(true) > 0);
- }
- void Entity::AddFearImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_FEAR])
- immunities[IMMUNITY_TYPE_FEAR] = new MutexList<LuaSpell*>;
- if (IsPlayer() && IsFeared()){
- if (!IsMezzedOrStunned() && !IsStifled())
- ((Player*)this)->UnlockAllSpells();
- ((Player*)this)->SetPlayerControlFlag(4, 4, false);
- }
- immunities[IMMUNITY_TYPE_FEAR]->Add(spell);
- }
- void Entity::RemoveFearImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* fear_list = immunities[IMMUNITY_TYPE_FEAR];
- if (!fear_list || fear_list->size(true) == 0)
- return;
- fear_list->Remove(spell);
- if (IsPlayer() && IsFeared()){
- if (!IsMezzedOrStunned() && !IsStifled())
- ((Player*)this)->LockAllSpells();
- ((Player*)this)->SetPlayerControlFlag(4, 4, true);
- }
- }
- bool Entity::IsFearImmune(){
- return (immunities[IMMUNITY_TYPE_FEAR] && immunities[IMMUNITY_TYPE_FEAR]->size(true) > 0);
- }
- void Entity::AddDazeImmunity(LuaSpell* spell){
- if (!spell)
- return;
- if (!immunities[IMMUNITY_TYPE_DAZE])
- immunities[IMMUNITY_TYPE_DAZE] = new MutexList<LuaSpell*>;
- immunities[IMMUNITY_TYPE_DAZE]->Add(spell);
- }
- void Entity::RemoveDazeImmunity(LuaSpell* spell){
- MutexList<LuaSpell*>* daze_list = immunities[IMMUNITY_TYPE_DAZE];
- if (!daze_list || daze_list->size(true) == 0)
- return;
- daze_list->Remove(spell);
- }
- bool Entity::IsDazeImmune(){
- return (immunities[IMMUNITY_TYPE_DAZE] && immunities[IMMUNITY_TYPE_DAZE]->size(true) > 0);
- }
- void Entity::RemoveEffectsFromLuaSpell(LuaSpell* spell){
- if (!spell)
- return;
- //Attempt to remove all applied effects from this spell when spell has been removed from just this target. Should improve performance/easier maitenance
- int32 effect_bitmask = spell->effect_bitmask;
- if (effect_bitmask == 0)
- return;
- if (effect_bitmask & EFFECT_FLAG_STUN)
- RemoveStunSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_ROOT)
- RemoveRootSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_MEZ)
- RemoveMezSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_STIFLE)
- RemoveStifleSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_DAZE)
- RemoveDazeSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_FEAR)
- RemoveFearSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_SPELLBONUS)
- RemoveSpellBonus(spell);
- if (effect_bitmask & EFFECT_FLAG_SKILLBONUS)
- RemoveSkillBonus(spell->spell->GetSpellID());
- if (effect_bitmask & EFFECT_FLAG_STEALTH)
- RemoveStealthSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_INVIS)
- RemoveInvisSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_SNARE)
- RemoveSnareSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_WATERWALK)
- RemoveWaterwalkSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_WATERJUMP)
- RemoveWaterjumpSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_FLIGHT)
- RemoveFlightSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_GLIDE)
- RemoveGlideSpell(spell);
- if (effect_bitmask & EFFECT_FLAG_AOE_IMMUNE)
- RemoveAOEImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_STUN_IMMUNE)
- RemoveStunImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_MEZ_IMMUNE)
- RemoveMezImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_DAZE_IMMUNE)
- RemoveDazeImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_ROOT_IMMUNE)
- RemoveRootImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_STIFLE_IMMUNE)
- RemoveStifleImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_FEAR_IMMUNE)
- RemoveFearImmunity(spell);
- if (effect_bitmask & EFFECT_FLAG_SAFEFALL)
- RemoveSafefallSpell(spell);
- }
- void Entity::RemoveSkillBonus(int32 spell_id){
- //This is a virtual, just making it so we don't have to do extra checks for player/npcs
- return;
- }
- void Entity::AddFlightSpell(LuaSpell* spell){
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_FLIGHT])
- control_effects[CONTROL_EFFECT_TYPE_FLIGHT] = new MutexList<LuaSpell*>;
- if (IsPlayer() && control_effects[CONTROL_EFFECT_TYPE_FLIGHT]->size(true) == 0)
- ((Player*)this)->SetPlayerControlFlag(5, 32, true);
- control_effects[CONTROL_EFFECT_TYPE_FLIGHT]->Add(spell);
- }
- void Entity::RemoveFlightSpell(LuaSpell* spell){
- MutexList<LuaSpell*>* flight_list = control_effects[CONTROL_EFFECT_TYPE_FLIGHT];
- if (!flight_list || flight_list->size(true) == 0)
- return;
- flight_list->Remove(spell);
- if (IsPlayer() && flight_list->size(true) == 0)
- ((Player*)this)->SetPlayerControlFlag(5, 32, false);
- }
- void Entity::AddGlideSpell(LuaSpell* spell){
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_GLIDE])
- control_effects[CONTROL_EFFECT_TYPE_GLIDE] = new MutexList<LuaSpell*>;
- if (IsPlayer() && control_effects[CONTROL_EFFECT_TYPE_GLIDE]->size(true) == 0)
- ((Player*)this)->SetPlayerControlFlag(4, 16, true);
- control_effects[CONTROL_EFFECT_TYPE_GLIDE]->Add(spell);
- }
- void Entity::RemoveGlideSpell(LuaSpell* spell){
- MutexList<LuaSpell*>* glide_list = control_effects[CONTROL_EFFECT_TYPE_GLIDE];
- if (!glide_list || glide_list->size(true) == 0)
- return;
- glide_list->Remove(spell);
- if (IsPlayer() && glide_list->size(true) == 0)
- ((Player*)this)->SetPlayerControlFlag(4, 16, false);
- }
- void Entity::AddSafefallSpell(LuaSpell* spell){
- if (!spell)
- return;
- if (!control_effects[CONTROL_EFFECT_TYPE_SAFEFALL])
- control_effects[CONTROL_EFFECT_TYPE_SAFEFALL] = new MutexList<LuaSpell*>;
- if (IsPlayer() && control_effects[CONTROL_EFFECT_TYPE_SAFEFALL]->size(true) == 0)
- ((Player*)this)->SetPlayerControlFlag(4, 32, true);
- control_effects[CONTROL_EFFECT_TYPE_SAFEFALL]->Add(spell);
- }
- void Entity::RemoveSafefallSpell(LuaSpell* spell){
- MutexList<LuaSpell*>* safe_list = control_effects[CONTROL_EFFECT_TYPE_SAFEFALL];
- if (!safe_list || safe_list->size(true) == 0)
- return;
- safe_list->Remove(spell);
- if (IsPlayer() && safe_list->size(true) == 0)
- ((Player*)this)->SetPlayerControlFlag(4, 32, false);
- }
- void Entity::UpdateGroupMemberInfo() {
- if (!group_member_info)
- return;
- group_member_info->class_id = GetAdventureClass();
- group_member_info->hp_max = GetTotalHP();
- group_member_info->hp_current = GetHP();
- group_member_info->level_max = GetLevel();
- group_member_info->level_current = GetLevel();
- group_member_info->name = string(GetName());
- group_member_info->power_current = GetPower();
- group_member_info->power_max = GetTotalPower();
- group_member_info->race_id = GetRace();
- if (GetZone())
- group_member_info->zone = GetZone()->GetZoneDescription();
- else
- group_member_info->zone = "Unknown";
- }
- #include "WorldDatabase.h"
- extern WorldDatabase database;
- void Entity::CustomizeAppearance(PacketStruct* packet) {
- bool is_soga = packet->getType_int8_ByName("is_soga") == 1 ? true : false;
- int16 model_id = database.GetAppearanceID(packet->getType_EQ2_16BitString_ByName("race_file").data);
- EQ2_Color skin_color = packet->getType_EQ2_Color_ByName("skin_color");
- EQ2_Color skin_color2 = packet->getType_EQ2_Color_ByName("skin_color2");
- EQ2_Color eye_color = packet->getType_EQ2_Color_ByName("eye_color");
- EQ2_Color hair_color1 = packet->getType_EQ2_Color_ByName("hair_color1");
- EQ2_Color hair_color2 = packet->getType_EQ2_Color_ByName("hair_color2");
- EQ2_Color hair_highlight = packet->getType_EQ2_Color_ByName("hair_highlight");
- int16 hair_id = database.GetAppearanceID(packet->getType_EQ2_16BitString_ByName("hair_file").data);
- EQ2_Color hair_type_color = packet->getType_EQ2_Color_ByName("hair_type_color");
- EQ2_Color hair_type_highlight_color = packet->getType_EQ2_Color_ByName("hair_type_highlight_color");
- int16 face_id = database.GetAppearanceID(packet->getType_EQ2_16BitString_ByName("face_file").data);
- EQ2_Color hair_face_color = packet->getType_EQ2_Color_ByName("hair_face_color");
- EQ2_Color hair_face_highlight_color = packet->getType_EQ2_Color_ByName("hair_face_highlight_color");
- int16 wing_id = database.GetAppearanceID(packet->getType_EQ2_16BitString_ByName("wing_file").data);
- EQ2_Color wing_color1 = packet->getType_EQ2_Color_ByName("wing_color1");
- EQ2_Color wing_color2 = packet->getType_EQ2_Color_ByName("wing_color2");
- int16 chest_id = database.GetAppearanceID(packet->getType_EQ2_16BitString_ByName("chest_file").data);
- EQ2_Color shirt_color = packet->getType_EQ2_Color_ByName("shirt_color");
- EQ2_Color unknown_chest_color = packet->getType_EQ2_Color_ByName("unknown_chest_color");
- int16 legs_id = database.GetAppearanceID(packet->getType_EQ2_16BitString_ByName("legs_file").data);
- EQ2_Color pants_color = packet->getType_EQ2_Color_ByName("pants_color");
- EQ2_Color unknown_legs_color = packet->getType_EQ2_Color_ByName("unknown_legs_color");
- EQ2_Color unknown2 = packet->getType_EQ2_Color_ByName("unknown2");
- float eyes2[3];
- eyes2[0] = packet->getType_float_ByName("eyes2", 0) * 100;
- eyes2[1] = packet->getType_float_ByName("eyes2", 1) * 100;
- eyes2[2] = packet->getType_float_ByName("eyes2", 2) * 100;
- float ears[3];
- ears[0] = packet->getType_float_ByName("ears", 0) * 100;
- ears[1] = packet->getType_float_ByName("ears", 1) * 100;
- ears[2] = packet->getType_float_ByName("ears", 2) * 100;
- float eye_brows[3];
- eye_brows[0] = packet->getType_float_ByName("eye_brows", 0) * 100;
- eye_brows[1] = packet->getType_float_ByName("eye_brows", 1) * 100;
- eye_brows[2] = packet->getType_float_ByName("eye_brows", 2) * 100;
- float cheeks[3];
- cheeks[0] = packet->getType_float_ByName("cheeks", 0) * 100;
- cheeks[1] = packet->getType_float_ByName("cheeks", 1) * 100;
- cheeks[2] = packet->getType_float_ByName("cheeks", 2) * 100;
- float lips[3];
- lips[0] = packet->getType_float_ByName("lips", 0) * 100;
- lips[1] = packet->getType_float_ByName("lips", 1) * 100;
- lips[2] = packet->getType_float_ByName("lips", 2) * 100;
- float chin[3];
- chin[0] = packet->getType_float_ByName("chin", 0) * 100;
- chin[1] = packet->getType_float_ByName("chin", 1) * 100;
- chin[2] = packet->getType_float_ByName("chin", 2) * 100;
- float nose[3];
- nose[0] = packet->getType_float_ByName("nose", 0) * 100;
- nose[1] = packet->getType_float_ByName("nose", 1) * 100;
- nose[2] = packet->getType_float_ByName("nose", 2) * 100;
- sint8 body_size = (sint8)(packet->getType_float_ByName("body_size") * 100);
- sint8 body_age = (sint8)(packet->getType_float_ByName("body_age") * 100);
- if (is_soga) {
- appearance.soga_model_type = model_id;
- features.soga_skin_color = skin_color;
- features.soga_eye_color = eye_color;
- features.soga_hair_color1 = hair_color1;
- features.soga_hair_color2 = hair_color2;
- features.soga_hair_highlight_color = hair_highlight;
- features.soga_hair_type = hair_id;
- features.soga_hair_type_color = hair_type_color;
- features.soga_hair_type_highlight_color = hair_type_highlight_color;
- features.soga_hair_face_type = face_id;
- features.soga_hair_face_color = hair_face_color;
- features.soga_hair_face_highlight_color = hair_face_highlight_color;
- features.wing_type = wing_id;
- features.wing_color1 = wing_color1;
- features.wing_color2 = wing_color2;
- features.soga_chest_type = chest_id;
- features.shirt_color = shirt_color;
- features.soga_legs_type = legs_id;
- features.pants_color = pants_color;
- features.soga_eye_type[0] = eyes2[0];
- features.soga_eye_type[1] = eyes2[1];
- features.soga_eye_type[2] = eyes2[2];
- features.soga_ear_type[0] = ears[0];
- features.soga_ear_type[0] = ears[1];
- features.soga_ear_type[0] = ears[2];
- features.soga_eye_brow_type[0] = eye_brows[0];
- features.soga_eye_brow_type[1] = eye_brows[1];
- features.soga_eye_brow_type[2] = eye_brows[2];
- features.soga_cheek_type[0] = cheeks[0];
- features.soga_cheek_type[1] = cheeks[1];
- features.soga_cheek_type[2] = cheeks[2];
- features.soga_lip_type[0] = lips[0];
- features.soga_lip_type[1] = lips[1];
- features.soga_lip_type[2] = lips[2];
- features.soga_chin_type[0] = chin[0];
- features.soga_chin_type[1] = chin[1];
- features.soga_chin_type[2] = chin[2];
- features.soga_nose_type[0] = nose[0];
- features.soga_nose_type[1] = nose[1];
- features.soga_nose_type[2] = nose[2];
- }
- else {
- appearance.model_type = model_id;
- features.skin_color = skin_color;
- features.eye_color = eye_color;
- features.hair_color1 = hair_color1;
- features.hair_color2 = hair_color2;
- features.hair_highlight_color = hair_highlight;
- features.hair_type = hair_id;
- features.hair_type_color = hair_type_color;
- features.hair_type_highlight_color = hair_type_highlight_color;
- features.hair_face_type = face_id;
- features.hair_face_color = hair_face_color;
- features.hair_face_highlight_color = hair_face_highlight_color;
- features.wing_type = wing_id;
- features.wing_color1 = wing_color1;
- features.wing_color2 = wing_color2;
- features.chest_type = chest_id;
- features.shirt_color = shirt_color;
- features.legs_type = legs_id;
- features.pants_color = pants_color;
- features.eye_type[0] = eyes2[0];
- features.eye_type[1] = eyes2[1];
- features.eye_type[2] = eyes2[2];
- features.ear_type[0] = ears[0];
- features.ear_type[0] = ears[1];
- features.ear_type[0] = ears[2];
- features.eye_brow_type[0] = eye_brows[0];
- features.eye_brow_type[1] = eye_brows[1];
- features.eye_brow_type[2] = eye_brows[2];
- features.cheek_type[0] = cheeks[0];
- features.cheek_type[1] = cheeks[1];
- features.cheek_type[2] = cheeks[2];
- features.lip_type[0] = lips[0];
- features.lip_type[1] = lips[1];
- features.lip_type[2] = lips[2];
- features.chin_type[0] = chin[0];
- features.chin_type[1] = chin[1];
- features.chin_type[2] = chin[2];
- features.nose_type[0] = nose[0];
- features.nose_type[1] = nose[1];
- features.nose_type[2] = nose[2];
- }
- features.body_size = body_size;
- features.body_age = body_age;
- info_changed = true;
- changed = true;
- }
- void Entity::AddSkillBonus(int32 spell_id, int32 skill_id, float value) {
- // handled in npc or player
- return;
- }
- void Entity::HaltMovement()
- {
- this->ClearRunningLocations();
- if (GetZone())
- GetZone()->movementMgr->StopNavigation(this);
- RunToLocation(GetX(), GetY(), GetZ());
- }
|