Merge fix

This commit is contained in:
KimLS
2017-03-26 17:25:01 -07:00
324 changed files with 13633 additions and 17652 deletions
+4 -4
View File
@@ -550,8 +550,8 @@ faster, but I'm doing it this way to make it readable and easy to modify
bool Mob::IsAttackAllowed(Mob *target, bool isSpellAttack)
{
Mob *mob1, *mob2, *tempmob;
Client *c1, *c2, *becomenpc;
Mob *mob1 = nullptr, *mob2 = nullptr, *tempmob = nullptr;
Client *c1 = nullptr, *c2 = nullptr, *becomenpc = nullptr;
// NPC *npc1, *npc2;
int reverse;
@@ -767,8 +767,8 @@ type', in which case, the answer is yes.
// also goes for their pets
bool Mob::IsBeneficialAllowed(Mob *target)
{
Mob *mob1, *mob2, *tempmob;
Client *c1, *c2;
Mob *mob1 = nullptr, *mob2 = nullptr, *tempmob = nullptr;
Client *c1 = nullptr, *c2 = nullptr;
int reverse;
if(!target)
+17 -12
View File
@@ -867,11 +867,9 @@ void Mob::MeleeMitigation(Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions
auto roll = RollD20(hit.offense, mitigation);
// +0.5 for rounding
hit.damage_done = static_cast<int>(roll * static_cast<double>(hit.base_damage) + 0.5);
// +0.5 for rounding, min to 1 dmg
hit.damage_done = std::max(static_cast<int>(roll * static_cast<double>(hit.base_damage) + 0.5), 1);
if (hit.damage_done < 0)
hit.damage_done = 0;
Log.Out(Logs::Detail, Logs::Attack, "mitigation %d vs offense %d. base %d rolled %f damage %d", mitigation, hit.offense, hit.base_damage, roll, hit.damage_done);
}
@@ -1208,7 +1206,7 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts)
if (strike_through && zone->random.Roll(strike_through)) {
Message_StringID(MT_StrikeThrough,
STRIKETHROUGH_STRING); // You strike through your opponents defenses!
hit.damage_done = 0; // set to zero, we will check this to continue
hit.damage_done = 1; // set to one, we will check this to continue
}
// I'm pretty sure you can riposte a riposte
if (hit.damage_done == DMG_RIPOSTED) {
@@ -1219,7 +1217,7 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts)
Log.Out(Logs::Detail, Logs::Combat, "Avoided/strikethrough damage with code %d", hit.damage_done);
}
if (hit.damage_done == 0) {
if (hit.damage_done >= 0) {
if (other->CheckHitChance(this, hit)) {
other->MeleeMitigation(this, hit, opts);
if (hit.damage_done > 0) {
@@ -1271,7 +1269,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
if (GetFeigned())
return false; // Rogean: How can you attack while feigned? Moved up from Aggro Code.
EQEmu::ItemInstance* weapon;
EQEmu::ItemInstance* weapon = nullptr;
if (Hand == EQEmu::inventory::slotSecondary){ // Kaiyodo - Pick weapon from the attacking hand
weapon = GetInv().GetItem(EQEmu::inventory::slotSecondary);
OffHandAtk(true);
@@ -1298,7 +1296,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
Log.Out(Logs::Detail, Logs::Combat, "Attacking with %s in slot %d using skill %d", weapon?weapon->GetItem()->Name:"Fist", Hand, my_hit.skill);
// Now figure out damage
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.min_damage = 0;
uint8 mylevel = GetLevel() ? GetLevel() : 1;
uint32 hate = 0;
@@ -1438,13 +1436,15 @@ void Client::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::Sk
// cut all PVP spell damage to 2/3
// Blasting ourselfs is considered PvP
//Don't do PvP mitigation if the caster is damaging himself
//should this be applied to all damage? comments sound like some is for spell DMG
//patch notes on PVP reductions only mention archery/throwing ... not normal dmg
if(other && other->IsClient() && (other != this) && damage > 0) {
int PvPMitigation = 100;
if (attack_skill == EQEmu::skills::SkillArchery)
if (attack_skill == EQEmu::skills::SkillArchery || attack_skill == EQEmu::skills::SkillThrowing)
PvPMitigation = 80;
else
PvPMitigation = 67;
damage = (damage * PvPMitigation) / 100;
damage = std::max((damage * PvPMitigation) / 100, 1);
}
if(!ClientFinishedLoading())
@@ -1785,7 +1785,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
DamageHitInfo my_hit;
my_hit.skill = EQEmu::skills::SkillHandtoHand;
my_hit.hand = Hand;
my_hit.damage_done = 0;
my_hit.damage_done = 1;
if (Hand == EQEmu::inventory::slotPrimary) {
my_hit.skill = static_cast<EQEmu::skills::SkillType>(GetPrimSkill());
OffHandAtk(false);
@@ -3196,7 +3196,8 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const
ignore_invul = spell_id == 982 || spells[spell_id].cast_not_standing; // cazic touch
if (!ignore_invul && (GetInvul() || DivineAura())) {
damage = -5;
Log.Out(Logs::Detail, Logs::Combat, "Avoiding %d damage due to invulnerability.", damage);
damage = DMG_INVULNERABLE;
}
if( spell_id != SPELL_UNKNOWN || attacker == nullptr )
@@ -4462,6 +4463,10 @@ void Mob::ApplyDamageTable(DamageHitInfo &hit)
if (hit.offense < 115)
return;
// things that come out to 1 dmg seem to skip this (ex non-bash slam classes)
if (hit.damage_done < 2)
return;
auto &damage_table = GetDamageTable();
if (zone->random.Roll(damage_table.chance))
+30 -30
View File
@@ -462,7 +462,7 @@ void Bot::GenerateBaseStats()
Attack += 17;
break;
case SHADOWKNIGHT:
BotSpellID = 3004;
BotSpellID = 3005;
Strength += 10;
Stamina += 15;
Intelligence += 20;
@@ -1896,12 +1896,12 @@ void Bot::BotRangedAttack(Mob* other) {
}
EQEmu::ItemInstance* rangedItem = GetBotItem(EQEmu::inventory::slotRange);
const EQEmu::ItemData* RangeWeapon = 0;
const EQEmu::ItemData* RangeWeapon = nullptr;
if(rangedItem)
RangeWeapon = rangedItem->GetItem();
EQEmu::ItemInstance* ammoItem = GetBotItem(EQEmu::inventory::slotAmmo);
const EQEmu::ItemData* Ammo = 0;
const EQEmu::ItemData* Ammo = nullptr;
if(ammoItem)
Ammo = ammoItem->GetItem();
@@ -2008,7 +2008,7 @@ void Bot::ApplySpecialAttackMod(EQEmu::skills::SkillType skill, int32 &dmg, int3
if (item_slot >= EQEmu::legacy::EQUIPMENT_BEGIN){
const EQEmu::ItemInstance* inst = GetBotItem(item_slot);
const EQEmu::ItemData* botweapon = 0;
const EQEmu::ItemData* botweapon = nullptr;
if(inst)
botweapon = inst->GetItem();
@@ -2456,7 +2456,7 @@ void Bot::AI_Process() {
//now off hand
if(GetTarget() && attack_dw_timer.Check() && CanThisClassDualWield()) {
const EQEmu::ItemInstance* instweapon = GetBotItem(EQEmu::inventory::slotSecondary);
const EQEmu::ItemData* weapon = 0;
const EQEmu::ItemData* weapon = nullptr;
//can only dual wield without a weapon if you're a monk
if(instweapon || (botClass == MONK)) {
if(instweapon)
@@ -2928,8 +2928,8 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {
ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive];
ns->spawn.helm = helmtexture; //(GetShowHelm() ? helmtexture : 0); //0xFF;
ns->spawn.equip_chest2 = texture; //0xFF;
const EQEmu::ItemData* item = 0;
const EQEmu::ItemInstance* inst = 0;
const EQEmu::ItemData* item = nullptr;
const EQEmu::ItemInstance* inst = nullptr;
uint32 spawnedbotid = 0;
spawnedbotid = this->GetBotID();
for (int i = EQEmu::textures::textureBegin; i < EQEmu::textures::weaponPrimary; i++) {
@@ -3919,9 +3919,9 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b
DamageHitInfo my_hit;
AttackAnimation(my_hit.skill, Hand, weapon);
Log.Out(Logs::Detail, Logs::Combat, "Attacking with %s in slot %d using skill %d", weapon?weapon->GetItem()->Name:"Fist", Hand, my_hit.skill);
// Now figure out damage
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.min_damage = 0;
uint8 mylevel = GetLevel() ? GetLevel() : 1;
uint32 hate = 0;
@@ -4357,9 +4357,9 @@ int32 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) {
//Check if item focus effect exists for the client.
if (itembonuses.FocusEffects[bottype]) {
const EQEmu::ItemData* TempItem = 0;
const EQEmu::ItemData* UsedItem = 0;
const EQEmu::ItemInstance* TempInst = 0;
const EQEmu::ItemData* TempItem = nullptr;
const EQEmu::ItemData* UsedItem = nullptr;
const EQEmu::ItemInstance* TempInst = nullptr;
uint16 UsedFocusID = 0;
int32 Total = 0;
int32 focus_max = 0;
@@ -5031,7 +5031,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, EQEmu::skills::SkillType skill, int32
if (skill == EQEmu::skills::SkillBash) {
const EQEmu::ItemInstance* inst = GetBotItem(EQEmu::inventory::slotSecondary);
const EQEmu::ItemData* botweapon = 0;
const EQEmu::ItemData* botweapon = nullptr;
if(inst)
botweapon = inst->GetItem();
@@ -5046,7 +5046,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, EQEmu::skills::SkillType skill, int32
DamageHitInfo my_hit;
my_hit.base_damage = max_damage;
my_hit.min_damage = min_damage;
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.skill = skill;
my_hit.offense = offense(my_hit.skill);
@@ -5372,7 +5372,7 @@ FACTION_VALUE Bot::GetReverseFactionCon(Mob* iOther) {
}
Mob* Bot::GetOwnerOrSelf() {
Mob* Result = 0;
Mob* Result = nullptr;
if(this->GetBotOwner())
Result = GetBotOwner();
else
@@ -5382,7 +5382,7 @@ Mob* Bot::GetOwnerOrSelf() {
}
Mob* Bot::GetOwner() {
Mob* Result = 0;
Mob* Result = nullptr;
Result = GetBotOwner();
if(!Result)
this->SetBotOwner(0);
@@ -5438,8 +5438,8 @@ bool Bot::IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined) {
void Bot::EquipBot(std::string* errorMessage) {
GetBotItems(m_inv, errorMessage);
const EQEmu::ItemInstance* inst = 0;
const EQEmu::ItemData* item = 0;
const EQEmu::ItemInstance* inst = nullptr;
const EQEmu::ItemData* item = nullptr;
for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::EQUIPMENT_END; ++i) {
inst = GetBotItem(i);
if(inst) {
@@ -7235,7 +7235,7 @@ bool Bot::CanHeal() {
}
Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, std::string botName) {
Bot* Result = 0;
Bot* Result = nullptr;
if(c) {
std::list<Bot*> BotList = entity_list.GetBotsByBotOwnerCharacterID(c->CharacterID());
if(!BotList.empty()) {
@@ -7275,7 +7275,7 @@ void Bot::ProcessBotGroupInvite(Client* c, std::string botName) {
// Processes a group disband request from a Client for a Bot.
void Bot::ProcessBotGroupDisband(Client* c, std::string botName) {
if(c) {
Bot* tempBot = 0;
Bot* tempBot = nullptr;
if(botName.empty())
tempBot = GetFirstBotInGroup(c->GetGroup());
@@ -7318,7 +7318,7 @@ void Bot::ProcessClientZoneChange(Client* botOwner) {
// Finds and returns the first Bot object found in specified group
Bot* Bot::GetFirstBotInGroup(Group* group) {
Bot* Result = 0;
Bot* Result = nullptr;
if(group) {
for(int Counter = 0; Counter < MAX_GROUP_MEMBERS; Counter++) {
@@ -7344,8 +7344,8 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) {
insr->TargetID = inspectedBot->GetNPCTypeID();
insr->playerid = inspectedBot->GetID();
const EQEmu::ItemData* item = 0;
const EQEmu::ItemInstance* inst = 0;
const EQEmu::ItemData* item = nullptr;
const EQEmu::ItemInstance* inst = nullptr;
// Modded to display power source items (will only show up on SoF+ client inspect windows though.)
// I don't think bots are currently coded to use them..but, you'll have to use '#bot inventory list'
@@ -7396,7 +7396,7 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) {
void Bot::CalcItemBonuses(StatBonuses* newbon)
{
const EQEmu::ItemData* itemtmp = 0;
const EQEmu::ItemData* itemtmp = nullptr;
for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= (EQEmu::legacy::EQUIPMENT_END + 1); ++i) {
const EQEmu::ItemInstance* item = GetBotItem((i == 22 ? 9999 : i));
@@ -7989,7 +7989,7 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl
Mob* EntityList::GetMobByBotID(uint32 botID) {
Mob* Result = 0;
Mob* Result = nullptr;
if(botID > 0) {
auto it = mob_list.begin();
for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
@@ -8006,7 +8006,7 @@ Mob* EntityList::GetMobByBotID(uint32 botID) {
}
Bot* EntityList::GetBotByBotID(uint32 botID) {
Bot* Result = 0;
Bot* Result = nullptr;
if(botID > 0) {
for(std::list<Bot*>::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); ++botListItr) {
Bot* tempBot = *botListItr;
@@ -8020,7 +8020,7 @@ Bot* EntityList::GetBotByBotID(uint32 botID) {
}
Bot* EntityList::GetBotByBotName(std::string botName) {
Bot* Result = 0;
Bot* Result = nullptr;
if(!botName.empty()) {
for(std::list<Bot*>::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); ++botListItr) {
Bot* tempBot = *botListItr;
@@ -8197,7 +8197,7 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) {
uint8 Bot::GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets) {
uint8 needHealed = 0;
Group *g;
Group *g = nullptr;
if(this->HasGroup()) {
g = this->GetGroup();
if(g) {
@@ -8237,8 +8237,8 @@ int Bot::GetRawACNoShield(int &shield_ac) {
}
uint32 Bot::CalcCurrentWeight() {
const EQEmu::ItemData* TempItem = 0;
EQEmu::ItemInstance* inst;
const EQEmu::ItemData* TempItem = nullptr;
EQEmu::ItemInstance* inst = nullptr;
uint32 Total = 0;
for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::EQUIPMENT_END; ++i) {
inst = GetBotItem(i);
+15 -14
View File
@@ -133,9 +133,9 @@ Client::Client(EQStreamInterface* ieqs)
fishing_timer(8000),
endupkeep_timer(1000),
forget_timer(0),
autosave_timer(RuleI(Character, AutosaveIntervalS)*1000),
autosave_timer(RuleI(Character, AutosaveIntervalS) * 1000),
#ifdef REVERSE_AGGRO
scanarea_timer(AIClientScanarea_delay),
scanarea_timer(RuleI(Aggro, ClientAggroCheckInterval) * 1000),
#endif
tribute_timer(Tribute_duration),
proximity_timer(ClientProximity_interval),
@@ -159,7 +159,8 @@ Client::Client(EQStreamInterface* ieqs)
m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f),
m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f),
m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f),
last_region_type(RegionTypeUnsupported)
last_region_type(RegionTypeUnsupported),
m_dirtyautohaters(false)
{
for(int cf=0; cf < _FilterCount; cf++)
ClientFilters[cf] = FilterShow;
@@ -624,7 +625,7 @@ bool Client::Save(uint8 iCommitNow) {
GetMercInfo().MercTimerRemaining = GetMercTimer()->GetRemainingTime();
}
if (!(GetMerc() && !dead)) {
if (dead || (!GetMerc() && !GetMercInfo().IsSuspended)) {
memset(&m_mercinfo, 0, sizeof(struct MercInfo));
}
@@ -716,7 +717,7 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) {
c->ack_req = bAckreq;
c->app = *pApp;
*pApp = 0;
*pApp = nullptr;
clientpackets.Append(c);
return true;
@@ -725,7 +726,7 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) {
bool Client::SendAllPackets() {
LinkedListIterator<CLIENTPACKET*> iterator(clientpackets);
CLIENTPACKET* cp = 0;
CLIENTPACKET* cp = nullptr;
iterator.Reset();
while(iterator.MoreElements()) {
cp = iterator.GetData();
@@ -771,7 +772,7 @@ void Client::FastQueuePacket(EQApplicationPacket** app, bool ack_req, CLIENT_CON
eqs->FastQueuePacket((EQApplicationPacket **)app, ack_req);
else if (app && (*app))
delete *app;
*app = 0;
*app = nullptr;
}
return;
}
@@ -2036,7 +2037,7 @@ void Client::ReadBook(BookRequest_Struct *book) {
read_from_slot = book->invslot -1;
}
const EQEmu::ItemInstance *inst = 0;
const EQEmu::ItemInstance *inst = nullptr;
if (read_from_slot <= EQEmu::legacy::SLOT_PERSONAL_BAGS_END)
{
@@ -4044,7 +4045,7 @@ bool Client::KeyRingCheck(uint32 item_id)
void Client::KeyRingList()
{
Message(4,"Keys on Keyring:");
const EQEmu::ItemData *item = 0;
const EQEmu::ItemData *item = nullptr;
for (auto iter = keyring.begin(); iter != keyring.end(); ++iter) {
if ((item = database.GetItem(*iter))!=nullptr) {
Message(4,item->Name);
@@ -4657,7 +4658,7 @@ void Client::SendRespawnBinds()
uint32 PacketLength = 17 + (26 * num_options); //Header size + per-option invariant size
std::list<RespawnOption>::iterator itr;
RespawnOption* opt;
RespawnOption* opt = nullptr;
//Find string size for each option
for (itr = respawn_options.begin(); itr != respawn_options.end(); ++itr)
@@ -8382,7 +8383,7 @@ bool Client::RemoveRespawnOption(std::string option_name)
if (IsHoveringForRespawn() || respawn_options.empty()) { return false; }
bool had = false;
RespawnOption* opt;
RespawnOption* opt = nullptr;
std::list<RespawnOption>::iterator itr;
for (itr = respawn_options.begin(); itr != respawn_options.end(); ++itr)
{
@@ -8429,7 +8430,7 @@ bool Client::RemoveRespawnOption(uint8 position)
void Client::SetHunger(int32 in_hunger)
{
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer;
sta->food = in_hunger;
@@ -8443,7 +8444,7 @@ void Client::SetHunger(int32 in_hunger)
void Client::SetThirst(int32 in_thirst)
{
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer;
sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level;
@@ -8457,7 +8458,7 @@ void Client::SetThirst(int32 in_thirst)
void Client::SetConsumption(int32 in_hunger, int32 in_thirst)
{
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer;
sta->food = in_hunger;
+2 -2
View File
@@ -1211,8 +1211,8 @@ int32 Client::CalcManaRegenCap()
uint32 Client::CalcCurrentWeight()
{
const EQEmu::ItemData* TempItem = 0;
EQEmu::ItemInstance* ins;
const EQEmu::ItemData* TempItem = nullptr;
EQEmu::ItemInstance* ins = nullptr;
uint32 Total = 0;
int x;
for (x = EQEmu::legacy::EQUIPMENT_BEGIN; x <= EQEmu::inventory::slotCursor; x++) { // include cursor or not?
+16 -16
View File
@@ -1074,7 +1074,7 @@ void Client::Handle_Connect_OP_ReqNewZone(const EQApplicationPacket *app)
{
conn_state = NewZoneRequested;
EQApplicationPacket* outapp;
EQApplicationPacket* outapp = nullptr;
/////////////////////////////////////
// New Zone Packet
@@ -1240,12 +1240,12 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
}
uint32 pplen = 0;
EQApplicationPacket* outapp = 0;
MYSQL_RES* result = 0;
EQApplicationPacket* outapp = nullptr;
MYSQL_RES* result = nullptr;
bool loaditems = 0;
uint32 i;
std::string query;
unsigned long* lengths;
unsigned long* lengths = nullptr;
uint32 cid = CharacterID();
character_id = cid; /* Global character_id reference */
@@ -2062,7 +2062,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app)
merchantid = tmp->CastToNPC()->MerchantType;
tmp->CastToNPC()->FaceTarget(this->CastToMob());
const EQEmu::ItemData *item = 0;
const EQEmu::ItemData *item = nullptr;
std::list<MerchantList> merlist = zone->merchanttable[merchantid];
std::list<MerchantList>::const_iterator itr;
for (itr = merlist.begin(); itr != merlist.end() && count<255; ++itr){
@@ -4866,7 +4866,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app)
{
if (m_pp.hunger_level > 6000)
{
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer;
sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level;
@@ -4881,7 +4881,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app)
{
if (m_pp.thirst_level > 6000)
{
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer;
sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level;
@@ -4914,7 +4914,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app)
m_pp.hunger_level = 50000;
if (m_pp.thirst_level > 50000)
m_pp.thirst_level = 50000;
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer;
sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level;
@@ -5902,7 +5902,7 @@ void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app)
return;
}
GMEmoteZone_Struct* gmez = (GMEmoteZone_Struct*)app->pBuffer;
char* newmessage = 0;
char* newmessage = nullptr;
if (strstr(gmez->text, "^") == 0)
entity_list.Message(0, 15, gmez->text);
else{
@@ -8258,7 +8258,7 @@ void Client::Handle_OP_ItemName(const EQApplicationPacket *app)
return;
}
ItemNamePacket_Struct *p = (ItemNamePacket_Struct*)app->pBuffer;
const EQEmu::ItemData *item = 0;
const EQEmu::ItemData *item = nullptr;
if ((item = database.GetItem(p->item_id)) != nullptr) {
auto outapp = new EQApplicationPacket(OP_ItemName, sizeof(ItemNamePacket_Struct));
p = (ItemNamePacket_Struct*)outapp->pBuffer;
@@ -8465,7 +8465,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app)
target_id = request->target;
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_ItemVerifyReply, sizeof(ItemVerifyReply_Struct));
ItemVerifyReply_Struct* reply = (ItemVerifyReply_Struct*)outapp->pBuffer;
reply->slot = slot_id;
@@ -8539,8 +8539,8 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app)
int r;
bool tryaug = false;
EQEmu::ItemInstance* clickaug = 0;
EQEmu::ItemData* augitem = 0;
EQEmu::ItemInstance* clickaug = nullptr;
EQEmu::ItemData* augitem = nullptr;
for (r = EQEmu::inventory::socketBegin; r < EQEmu::inventory::SocketCount; r++) {
const EQEmu::ItemInstance* aug_i = inst->GetAugment(r);
@@ -8669,7 +8669,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app)
if (m_pp.thirst_level > 6000)
m_pp.thirst_level = 6000;
EQApplicationPacket *outapp2;
EQApplicationPacket *outapp2 = nullptr;
outapp2 = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp2->pBuffer;
sta->food = m_pp.hunger_level;
@@ -9193,7 +9193,7 @@ void Client::Handle_OP_LootItem(const EQApplicationPacket *app)
return;
}
EQApplicationPacket* outapp = 0;
EQApplicationPacket* outapp = nullptr;
Entity* entity = entity_list.GetID(*((uint16*)app->pBuffer));
if (entity == 0) {
Message(13, "Error: OP_LootItem: Corpse not found (ent = 0)");
@@ -12020,7 +12020,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app)
else
zoneid = atoi(row[0]);
char* name;
char* name = nullptr;
database.GetZoneLongName(database.GetZoneName(zoneid), &name);
Message(15, "%d - %s", zoneid, name);
}
+3 -3
View File
@@ -210,7 +210,7 @@ bool Client::Process() {
if (bardsong_timer.Check() && bardsong != 0) {
//NOTE: this is kinda a heavy-handed check to make sure the mob still exists before
//doing the next pulse on them...
Mob *song_target;
Mob *song_target = nullptr;
if(bardsong_target_id == GetID()) {
song_target = this;
} else {
@@ -616,7 +616,7 @@ bool Client::Process() {
//At this point, we are still connected, everything important has taken
//place, now check to see if anybody wants to aggro us.
// only if client is not feigned
if(ret && !GetFeigned() && scanarea_timer.Check()) {
if(zone->CanDoCombat() && ret && !GetFeigned() && scanarea_timer.Check()) {
entity_list.CheckClientAggro(this);
}
#endif
@@ -838,7 +838,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
if (m_ClientVersionBit & EQEmu::versions::bit_RoFAndLater) { // RoF+ can send 200 items
numItemSlots = 200;
}
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
std::list<MerchantList> merlist = zone->merchanttable[merchant_id];
std::list<MerchantList>::const_iterator itr;
Mob* merch = entity_list.GetMobByNpcTypeID(npcid);
+1 -1
View File
@@ -10674,7 +10674,7 @@ void command_logs(Client *c, const Seperator *sep){
/* We use a general 'is_category_enabled' now, let's update when we update any output settings
This is used in hot places of code to check if its enabled in any way before triggering logs
*/
if (sep->arg[4] > 0){
if (atoi(sep->arg[4]) > 0){
Log.log_settings[atoi(sep->arg[3])].is_category_enabled = 1;
}
else{
+8 -8
View File
@@ -82,7 +82,7 @@ Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std:
/* Load Items */
ItemList itemlist;
ServerLootItem_Struct* tmp = 0;
ServerLootItem_Struct* tmp = nullptr;
for (unsigned int i = 0; i < pcs->itemcount; i++) {
tmp = new ServerLootItem_Struct;
memcpy(tmp, &pcs->items[i], sizeof(player_lootitem::ServerLootItem_Struct));
@@ -267,7 +267,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
int i;
PlayerProfile_Struct *pp = &client->GetPP();
EQEmu::ItemInstance *item;
EQEmu::ItemInstance *item = nullptr;
/* Check if Zone has Graveyard First */
if(!zone->HasGraveyard()) {
@@ -671,7 +671,7 @@ void Corpse::AddItem(uint32 itemnum, uint16 charges, int16 slot, uint32 aug1, ui
}
ServerLootItem_Struct* Corpse::GetItem(uint16 lootslot, ServerLootItem_Struct** bag_item_data) {
ServerLootItem_Struct *sitem = 0, *sitem2;
ServerLootItem_Struct *sitem = nullptr, *sitem2 = nullptr;
ItemList::iterator cur,end;
cur = itemlist.begin();
@@ -993,7 +993,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
}
int i = 0;
const EQEmu::ItemData* item = 0;
const EQEmu::ItemData* item = nullptr;
ItemList::iterator cur,end;
cur = itemlist.begin();
end = itemlist.end();
@@ -1116,9 +1116,9 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
return;
}
const EQEmu::ItemData *item = 0;
EQEmu::ItemInstance *inst = 0;
ServerLootItem_Struct *item_data = nullptr, *bag_item_data[10];
const EQEmu::ItemData *item = nullptr;
EQEmu::ItemInstance *inst = nullptr;
ServerLootItem_Struct *item_data = nullptr, *bag_item_data[10] = {};
memset(bag_item_data, 0, sizeof(bag_item_data));
if (GetPlayerKillItem() > 1) {
@@ -1437,7 +1437,7 @@ uint32 Corpse::GetEquipment(uint8 material_slot) const {
}
uint32 Corpse::GetEquipmentColor(uint8 material_slot) const {
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
if (material_slot > EQEmu::textures::LastTexture) {
return 0;
+4 -4
View File
@@ -748,7 +748,7 @@ void EntityList::AETaunt(Client* taunter, float range, int32 bonus_hate)
// NPC spells will only affect other NPCs with compatible faction
void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster, int16 resist_adjust)
{
Mob *curmob;
Mob *curmob = nullptr;
float dist = caster->GetAOERange(spell_id);
float dist2 = dist * dist;
@@ -848,7 +848,7 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_
void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster)
{
Mob *curmob;
Mob *curmob = nullptr;
float dist = caster->GetAOERange(spell_id);
float dist2 = dist * dist;
@@ -889,7 +889,7 @@ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool a
// NPC spells will only affect other NPCs with compatible faction
void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster)
{
Mob *curmob;
Mob *curmob = nullptr;
float dist = caster->GetAOERange(spell_id);
float dist2 = dist * dist;
@@ -941,7 +941,7 @@ void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool aff
//NPCs handle it differently in Mob::Rampage
void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool IsFromSpell) {
//Dook- Will need tweaking, currently no pets or players or horses
Mob *curmob;
Mob *curmob = nullptr;
float dist2 = dist * dist;
+13 -1
View File
@@ -2224,7 +2224,8 @@ void EntityList::RemoveAllObjects()
}
}
void EntityList::RemoveAllTraps(){
void EntityList::RemoveAllTraps()
{
auto it = trap_list.begin();
while (it != trap_list.end()) {
safe_delete(it->second);
@@ -2233,6 +2234,16 @@ void EntityList::RemoveAllTraps(){
}
}
void EntityList::RemoveAllEncounters()
{
auto it = encounter_list.begin();
while (it != encounter_list.end()) {
safe_delete(it->second);
free_ids.push(it->first);
it = encounter_list.erase(it);
}
}
bool EntityList::RemoveMob(uint16 delete_id)
{
if (delete_id == 0)
@@ -2439,6 +2450,7 @@ void EntityList::UpdateWho(bool iSendFullUpdate)
memcpy(pack->pBuffer, tmp, pack->size);
pack->size = sizeof(ServerClientListKeepAlive_Struct) + (tmpNumUpdates * 4);
safe_delete_array(tmp);
sclka = (ServerClientListKeepAlive_Struct*) pack->pBuffer;
}
sclka->wid[sclka->numupdates] = it->second->GetWID();
sclka->numupdates++;
+1
View File
@@ -292,6 +292,7 @@ public:
void RemoveAllObjects();
void RemoveAllLocalities();
void RemoveAllRaids();
void RemoveAllEncounters();
void DestroyTempPets(Mob *owner);
int16 CountTempPets(Mob *owner);
void AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy = false);
+4
View File
@@ -47,6 +47,7 @@ Group::Group(uint32 gid)
AssistTargetID = 0;
TankTargetID = 0;
PullerTargetID = 0;
disbandcheck = false;
memset(&LeaderAbilities, 0, sizeof(GroupLeadershipAA_Struct));
uint32 i;
@@ -79,6 +80,7 @@ Group::Group(Mob* leader)
AssistTargetID = 0;
TankTargetID = 0;
PullerTargetID = 0;
disbandcheck = false;
memset(&LeaderAbilities, 0, sizeof(GroupLeadershipAA_Struct));
mentoree = nullptr;
uint32 i;
@@ -398,6 +400,8 @@ void Group::SendHPPacketsTo(Mob *member)
{
members[i]->CreateHPPacket(&hpapp);
member->CastToClient()->QueuePacket(&hpapp, false);
safe_delete_array(hpapp.pBuffer);
hpapp.size = 0;
if (member->CastToClient()->ClientVersion() >= EQEmu::versions::ClientVersion::SoD)
{
outapp.SetOpcode(OP_MobManaUpdate);
+4 -1
View File
@@ -646,7 +646,10 @@ void HealRotation::bias_targets()
// attempt to clear invalid target pool entries
m_target_pool.remove(nullptr);
m_target_pool.remove_if([](Mob* l) { return (!IsHealRotationTargetMobType(l)); });
m_target_pool.remove_if([](Mob* l) {
try { return (!IsHealRotationTargetMobType(l)); }
catch (...) { return true; }
});
uint32 sort_type = 0; // debug
+7
View File
@@ -228,6 +228,10 @@ LuaParser::LuaParser() {
}
LuaParser::~LuaParser() {
// valgrind didn't like when we didn't clean these up :P
lua_encounters.clear();
lua_encounter_events_registered.clear();
lua_encounters_loaded.clear();
if(L) {
lua_close(L);
}
@@ -800,6 +804,9 @@ void LuaParser::ReloadQuests() {
encounter.second->Depop();
}
lua_encounters.clear();
// so the Depop function above depends on the Process being called again so ...
// And there is situations where it wouldn't be :P
entity_list.EncounterProcess();
if(L) {
lua_close(L);
+6 -6
View File
@@ -2183,7 +2183,7 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) {
}
if(castedSpell) {
char* gmsg = 0;
char* gmsg = nullptr;
if(tar != this) {
//we don't need spam of bots healing themselves
@@ -2606,8 +2606,8 @@ int16 Merc::GetFocusEffect(focusType type, uint16 spell_id) {
//Check if item focus effect exists for the client.
if (itembonuses.FocusEffects[type]){
const EQEmu::ItemData* TempItem = 0;
const EQEmu::ItemData* UsedItem = 0;
const EQEmu::ItemData* TempItem = nullptr;
const EQEmu::ItemData* UsedItem = nullptr;
uint16 UsedFocusID = 0;
int16 Total = 0;
int16 focus_max = 0;
@@ -4556,7 +4556,7 @@ void Merc::SetTarget(Mob* mob) {
}
Mob* Merc::GetOwnerOrSelf() {
Mob* Result = 0;
Mob* Result = nullptr;
if(this->GetMercOwner())
Result = GetMercOwner();
@@ -4591,7 +4591,7 @@ bool Merc::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Skil
}
Client* Merc::GetMercOwner() {
Client* mercOwner = 0;
Client* mercOwner = nullptr;
if(GetOwner())
{
@@ -4605,7 +4605,7 @@ Client* Merc::GetMercOwner() {
}
Mob* Merc::GetOwner() {
Mob* Result = 0;
Mob* Result = nullptr;
Result = entity_list.GetMob(GetOwnerID());
+6 -6
View File
@@ -1293,7 +1293,7 @@ void Mob::CreateHPPacket(EQApplicationPacket* app)
void Mob::SendHPUpdate(bool skip_self)
{
EQApplicationPacket hp_app;
Group *group;
Group *group = nullptr;
// destructor will free the pBuffer
CreateHPPacket(&hp_app);
@@ -2788,7 +2788,7 @@ void Mob::SendArmorAppearance(Client *one_client)
{
if (!IsClient())
{
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
for (int i = 0; i < 7; ++i)
{
item = database.GetItem(GetEquipment(i));
@@ -2906,7 +2906,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const
{
uint32 equipmaterial = 0;
int32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
item = database.GetItem(GetEquipment(material_slot));
if (item != 0)
@@ -2959,7 +2959,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const
if (material_slot >= 0 && material_slot < EQEmu::textures::weaponPrimary)
{
uint32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
item = database.GetItem(GetEquipment(material_slot));
int16 invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot);
@@ -3013,7 +3013,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const
uint32 Mob::GetEquipmentColor(uint8 material_slot) const
{
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
if (armor_tint.Slot[material_slot].Color)
{
@@ -3029,7 +3029,7 @@ uint32 Mob::GetEquipmentColor(uint8 material_slot) const
uint32 Mob::IsEliteMaterialItem(uint8 material_slot) const
{
const EQEmu::ItemData *item;
const EQEmu::ItemData *item = nullptr;
item = database.GetItem(GetEquipment(material_slot));
if(item != 0)
+1 -1
View File
@@ -843,7 +843,7 @@ public:
void StartEnrage();
void ProcessEnrage();
bool IsEnraged();
void Taunt(NPC* who, bool always_succeed, float chance_bonus=0, bool FromSpell=false, int32 bonus_hate=0);
void Taunt(NPC *who, bool always_succeed, int chance_bonus = 0, bool FromSpell = false, int32 bonus_hate = 0);
virtual void AI_Init();
virtual void AI_Start(uint32 iMoveDelay = 0);
+58 -49
View File
@@ -704,6 +704,7 @@ void Client::AI_SpellCast()
void Client::AI_Process()
{
if (!IsAIControlled())
return;
@@ -934,6 +935,10 @@ void Mob::AI_Process() {
bool engaged = IsEngaged();
bool doranged = false;
if (!zone->CanDoCombat()) {
engaged = false;
}
// Begin: Additions for Wiz Fear Code
//
if(RuleB(Combat, EnableFearPathing)){
@@ -994,13 +999,14 @@ void Mob::AI_Process() {
SetTarget(hate_list.GetClosestEntOnHateList(this));
else
{
if(AI_target_check_timer->Check())
if (AI_target_check_timer->Check())
{
if (IsFocused()) {
if (!target) {
SetTarget(hate_list.GetEntWithMostHateOnList(this));
}
} else {
}
else {
if (!ImprovedTaunt())
SetTarget(hate_list.GetEntWithMostHateOnList(this));
}
@@ -1020,28 +1026,29 @@ void Mob::AI_Process() {
#ifdef BOTS
if (IsPet() && GetOwner() && GetOwner()->IsBot() && target == GetOwner())
{
// this blocks all pet attacks against owner..bot pet test (copied above check)
RemoveFromHateList(this);
return;
// this blocks all pet attacks against owner..bot pet test (copied above check)
RemoveFromHateList(this);
return;
}
#endif //BOTS
if(DivineAura())
if (DivineAura())
return;
auto npcSpawnPoint = CastToNPC()->GetSpawnPoint();
if(GetSpecialAbility(TETHER)) {
auto npcSpawnPoint = CastToNPC()->GetSpawnPoint();
if (GetSpecialAbility(TETHER)) {
float tether_range = static_cast<float>(GetSpecialAbilityParam(TETHER, 0));
tether_range = tether_range > 0.0f ? tether_range * tether_range : pAggroRange * pAggroRange;
if(DistanceSquaredNoZ(m_Position, npcSpawnPoint) > tether_range) {
if (DistanceSquaredNoZ(m_Position, npcSpawnPoint) > tether_range) {
GMMove(npcSpawnPoint.x, npcSpawnPoint.y, npcSpawnPoint.z, npcSpawnPoint.w);
}
} else if(GetSpecialAbility(LEASH)) {
}
else if (GetSpecialAbility(LEASH)) {
float leash_range = static_cast<float>(GetSpecialAbilityParam(LEASH, 0));
leash_range = leash_range > 0.0f ? leash_range * leash_range : pAggroRange * pAggroRange;
if(DistanceSquaredNoZ(m_Position, npcSpawnPoint) > leash_range) {
if (DistanceSquaredNoZ(m_Position, npcSpawnPoint) > leash_range) {
GMMove(npcSpawnPoint.x, npcSpawnPoint.y, npcSpawnPoint.z, npcSpawnPoint.w);
SetHP(GetMaxHP());
BuffFadeAll();
@@ -1058,16 +1065,16 @@ void Mob::AI_Process() {
{
if (AI_movement_timer->Check())
{
if(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
if (CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
{
SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
SendPosition();
}
SetCurrentSpeed(0);
}
if(IsMoving())
if (IsMoving())
{
if(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
if (CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
{
SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
SendPosition();
@@ -1076,13 +1083,13 @@ void Mob::AI_Process() {
}
//casting checked above...
if(target && !IsStunned() && !IsMezzed() && GetAppearance() != eaDead && !IsMeleeDisabled()) {
if (target && !IsStunned() && !IsMezzed() && GetAppearance() != eaDead && !IsMeleeDisabled()) {
//we should check to see if they die mid-attacks, previous
//crap of checking target for null was not gunna cut it
//try main hand first
if(attack_timer.Check()) {
if (attack_timer.Check()) {
DoMainHandAttackRounds(target);
TriggerDefensiveProcs(target, EQEmu::inventory::slotPrimary, false);
@@ -1128,17 +1135,17 @@ void Mob::AI_Process() {
if (owner) {
int16 flurry_chance = owner->aabonuses.PetFlurry +
owner->spellbonuses.PetFlurry + owner->itembonuses.PetFlurry;
owner->spellbonuses.PetFlurry + owner->itembonuses.PetFlurry;
if (flurry_chance && zone->random.Roll(flurry_chance))
Flurry(nullptr);
}
}
if ((IsPet() || IsTempPet()) && IsPetOwnerClient()){
if (spellbonuses.PC_Pet_Rampage[0] || itembonuses.PC_Pet_Rampage[0] || aabonuses.PC_Pet_Rampage[0]){
if ((IsPet() || IsTempPet()) && IsPetOwnerClient()) {
if (spellbonuses.PC_Pet_Rampage[0] || itembonuses.PC_Pet_Rampage[0] || aabonuses.PC_Pet_Rampage[0]) {
int chance = spellbonuses.PC_Pet_Rampage[0] + itembonuses.PC_Pet_Rampage[0] + aabonuses.PC_Pet_Rampage[0];
if(zone->random.Roll(chance)) {
if (zone->random.Roll(chance)) {
Rampage(nullptr);
}
}
@@ -1148,30 +1155,30 @@ void Mob::AI_Process() {
{
int rampage_chance = GetSpecialAbilityParam(SPECATK_RAMPAGE, 0);
rampage_chance = rampage_chance > 0 ? rampage_chance : 20;
if(zone->random.Roll(rampage_chance)) {
if (zone->random.Roll(rampage_chance)) {
ExtraAttackOptions opts;
int cur = GetSpecialAbilityParam(SPECATK_RAMPAGE, 3);
if(cur > 0) {
if (cur > 0) {
opts.damage_flat = cur;
}
cur = GetSpecialAbilityParam(SPECATK_RAMPAGE, 4);
if(cur > 0) {
if (cur > 0) {
opts.armor_pen_percent = cur / 100.0f;
}
cur = GetSpecialAbilityParam(SPECATK_RAMPAGE, 5);
if(cur > 0) {
if (cur > 0) {
opts.armor_pen_flat = cur;
}
cur = GetSpecialAbilityParam(SPECATK_RAMPAGE, 6);
if(cur > 0) {
if (cur > 0) {
opts.crit_percent = cur / 100.0f;
}
cur = GetSpecialAbilityParam(SPECATK_RAMPAGE, 7);
if(cur > 0) {
if (cur > 0) {
opts.crit_flat = cur;
}
Rampage(&opts);
@@ -1183,30 +1190,30 @@ void Mob::AI_Process() {
{
int rampage_chance = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 0);
rampage_chance = rampage_chance > 0 ? rampage_chance : 20;
if(zone->random.Roll(rampage_chance)) {
if (zone->random.Roll(rampage_chance)) {
ExtraAttackOptions opts;
int cur = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 3);
if(cur > 0) {
if (cur > 0) {
opts.damage_flat = cur;
}
cur = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 4);
if(cur > 0) {
if (cur > 0) {
opts.armor_pen_percent = cur / 100.0f;
}
cur = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 5);
if(cur > 0) {
if (cur > 0) {
opts.armor_pen_flat = cur;
}
cur = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 6);
if(cur > 0) {
if (cur > 0) {
opts.crit_percent = cur / 100.0f;
}
cur = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 7);
if(cur > 0) {
if (cur > 0) {
opts.crit_flat = cur;
}
@@ -1221,7 +1228,7 @@ void Mob::AI_Process() {
DoOffHandAttackRounds(target);
//now special attacks (kick, etc)
if(IsNPC())
if (IsNPC())
CastToNPC()->DoClassAttacks(target);
}
@@ -1230,18 +1237,19 @@ void Mob::AI_Process() {
else {
//we cannot reach our target...
//underwater stuff only works with water maps in the zone!
if(IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) {
auto targetPosition = glm::vec3(target->GetX(), target->GetY(), target->GetZ());
if(!zone->watermap->InLiquid(targetPosition)) {
if (IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) {
auto targetPosition = glm::vec3(target->GetX(), target->GetY(), target->GetZ());
if (!zone->watermap->InLiquid(targetPosition)) {
Mob *tar = hate_list.GetEntWithMostHateOnList(this);
if(tar == target) {
if (tar == target) {
WipeHateList();
Heal();
BuffFadeAll();
AI_walking_timer->Start(100);
pLastFightingDelayMoving = Timer::GetCurrentTime();
return;
} else if(tar != nullptr) {
}
else if (tar != nullptr) {
SetTarget(tar);
return;
}
@@ -1252,35 +1260,35 @@ void Mob::AI_Process() {
if (!HateSummon())
{
//could not summon them, check ranged...
if(GetSpecialAbility(SPECATK_RANGED_ATK))
if (GetSpecialAbility(SPECATK_RANGED_ATK))
doranged = true;
// Now pursue
// TODO: Check here for another person on hate list with close hate value
if(AI_PursueCastCheck()){
if (AI_PursueCastCheck()) {
//we did something, so do not process movement.
}
else if (AI_movement_timer->Check())
{
if(!IsRooted()) {
if (!IsRooted()) {
Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName());
if(!RuleB(Pathing, Aggro) || !zone->pathing)
if (!RuleB(Pathing, Aggro) || !zone->pathing)
CalculateNewPosition2(target->GetX(), target->GetY(), target->GetZ(), GetRunspeed());
else
{
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(target->GetX(), target->GetY(), target->GetZ(),
GetRunspeed(), WaypointChanged, NodeReached);
GetRunspeed(), WaypointChanged, NodeReached);
if(WaypointChanged)
if (WaypointChanged)
tar_ndx = 20;
CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetRunspeed());
}
}
else if(IsMoving()) {
else if (IsMoving()) {
SetHeading(CalculateHeadingToTarget(target->GetX(), target->GetY()));
SetCurrentSpeed(0);
@@ -1289,11 +1297,12 @@ void Mob::AI_Process() {
}
}
}
else
{
else {
if (m_PlayerState & static_cast<uint32>(PlayerState::Aggressive))
SendRemovePlayerState(PlayerState::Aggressive);
if(AI_feign_remember_timer->Check()) {
if(!zone->CanDoCombat() && AI_feign_remember_timer->Check()) {
// 6/14/06
// Improved Feign Death Memory
// check to see if any of our previous feigned targets have gotten up.
@@ -1318,7 +1327,7 @@ void Mob::AI_Process() {
{
//we processed a spell action, so do nothing else.
}
else if (AI_scan_area_timer->Check())
else if (!zone->CanDoCombat() && AI_scan_area_timer->Check())
{
/*
* This is where NPCs look around to see if they want to attack anybody.
+1
View File
@@ -534,6 +534,7 @@ int main(int argc, char** argv) {
}
entity_list.Clear();
entity_list.RemoveAllEncounters(); // gotta do it manually or rewrite lots of shit :P
parse->ClearInterfaces();
+1 -1
View File
@@ -425,7 +425,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
// like the special back items some focused pets may receive.
uint32 petinv[EQEmu::legacy::EQUIPMENT_SIZE];
memset(petinv, 0, sizeof(petinv));
const EQEmu::ItemData *item = 0;
const EQEmu::ItemData *item = nullptr;
if (database.GetBasePetItems(record.equipmentset, petinv)) {
for (int i = 0; i < EQEmu::legacy::EQUIPMENT_SIZE; i++)
+2
View File
@@ -1555,6 +1555,8 @@ void Raid::SendHPPacketsTo(Client *c)
{
members[x].member->CreateHPPacket(&hpapp);
c->QueuePacket(&hpapp, false);
safe_delete_array(hpapp.pBuffer);
hpapp.size = 0;
if (c->ClientVersion() >= EQEmu::versions::ClientVersion::SoD)
{
outapp.SetOpcode(OP_MobManaUpdate);
+61 -57
View File
@@ -96,6 +96,8 @@ int Mob::GetBaseSkillDamage(EQEmu::skills::SkillType skill, Mob *target)
}
if (inst)
ac_bonus = inst->GetItemArmorClass(true) / 25.0f;
else
return 0; // return 0 in cases where we don't have an item
if (ac_bonus > skill_bonus)
ac_bonus = skill_bonus;
return static_cast<int>(ac_bonus + skill_bonus);
@@ -144,7 +146,7 @@ void Mob::DoSpecialAttackDamage(Mob *who, EQEmu::skills::SkillType skill, int32
return;
DamageHitInfo my_hit;
my_hit.damage_done = 0;
my_hit.damage_done = 1; // min 1 dmg
my_hit.base_damage = base_damage;
my_hit.min_damage = min_damage;
my_hit.skill = skill;
@@ -849,7 +851,7 @@ void Mob::DoArcheryAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon,
DamageHitInfo my_hit;
my_hit.base_damage = MaxDmg;
my_hit.min_damage = 0;
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.skill = EQEmu::skills::SkillArchery;
my_hit.offense = offense(my_hit.skill);
@@ -1181,7 +1183,7 @@ void NPC::DoRangedAttackDmg(Mob* other, bool Launch, int16 damage_mod, int16 cha
DamageHitInfo my_hit;
my_hit.base_damage = MaxDmg;
my_hit.min_damage = MinDmg;
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.skill = skill;
my_hit.offense = offense(my_hit.skill);
@@ -1362,7 +1364,7 @@ void Mob::DoThrowingAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon
DamageHitInfo my_hit;
my_hit.base_damage = WDmg;
my_hit.min_damage = 0;
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.skill = EQEmu::skills::SkillThrowing;
my_hit.offense = offense(my_hit.skill);
@@ -1868,18 +1870,18 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte)
}
}
void Mob::Taunt(NPC* who, bool always_succeed, float chance_bonus, bool FromSpell, int32 bonus_hate) {
void Mob::Taunt(NPC *who, bool always_succeed, int chance_bonus, bool FromSpell, int32 bonus_hate)
{
if (who == nullptr)
return;
if(DivineAura())
if (DivineAura())
return;
if(!FromSpell && !CombatRange(who))
if (!FromSpell && !CombatRange(who))
return;
if(!always_succeed && IsClient())
if (!always_succeed && IsClient())
CastToClient()->CheckIncreaseSkill(EQEmu::skills::SkillTaunt, who, 10);
Mob *hate_top = who->GetHateMost();
@@ -1887,69 +1889,72 @@ void Mob::Taunt(NPC* who, bool always_succeed, float chance_bonus, bool FromSpel
int level_difference = GetLevel() - who->GetLevel();
bool Success = false;
//Support for how taunt worked pre 2000 on LIVE - Can not taunt NPC over your level.
if ((RuleB(Combat,TauntOverLevel) == false) && (level_difference < 0) || who->GetSpecialAbility(IMMUNE_TAUNT)){
Message_StringID(MT_SpellFailure,FAILED_TAUNT);
// Support for how taunt worked pre 2000 on LIVE - Can not taunt NPC over your level.
if ((RuleB(Combat, TauntOverLevel) == false) && (level_difference < 0) ||
who->GetSpecialAbility(IMMUNE_TAUNT)) {
Message_StringID(MT_SpellFailure, FAILED_TAUNT);
return;
}
//All values used based on live parses after taunt was updated in 2006.
if ((hate_top && hate_top->GetHPRatio() >= 20) || hate_top == nullptr) {
// All values used based on live parses after taunt was updated in 2006.
if ((hate_top && hate_top->GetHPRatio() >= 20) || hate_top == nullptr || chance_bonus) {
// SE_Taunt this is flat chance
if (chance_bonus) {
Success = zone->random.Roll(chance_bonus);
} else {
float tauntchance = 50.0f;
int32 newhate = 0;
float tauntchance = 50.0f;
if(always_succeed)
tauntchance = 101.0f;
else {
if (level_difference < 0){
tauntchance += static_cast<float>(level_difference)*3.0f;
if (tauntchance < 20)
tauntchance = 20.0f;
}
if (always_succeed)
tauntchance = 101.0f;
else {
tauntchance += static_cast<float>(level_difference)*5.0f;
if (tauntchance > 65)
tauntchance = 65.0f;
if (level_difference < 0) {
tauntchance += static_cast<float>(level_difference) * 3.0f;
if (tauntchance < 20)
tauntchance = 20.0f;
}
else {
tauntchance += static_cast<float>(level_difference) * 5.0f;
if (tauntchance > 65)
tauntchance = 65.0f;
}
}
// TauntSkillFalloff rate is not based on any real data. Default of 33% gives a reasonable
// result.
if (IsClient() && !always_succeed)
tauntchance -= (RuleR(Combat, TauntSkillFalloff) *
(CastToClient()->MaxSkill(EQEmu::skills::SkillTaunt) -
GetSkill(EQEmu::skills::SkillTaunt)));
if (tauntchance < 1)
tauntchance = 1.0f;
tauntchance /= 100.0f;
Success = tauntchance > zone->random.Real(0, 1);
}
//TauntSkillFalloff rate is not based on any real data. Default of 33% gives a reasonable result.
if (IsClient() && !always_succeed)
tauntchance -= (RuleR(Combat, TauntSkillFalloff) * (CastToClient()->MaxSkill(EQEmu::skills::SkillTaunt) - GetSkill(EQEmu::skills::SkillTaunt)));
//From SE_Taunt (Does a taunt with a chance modifier)
if (chance_bonus)
tauntchance += tauntchance*chance_bonus/100.0f;
if (tauntchance < 1)
tauntchance = 1.0f;
tauntchance /= 100.0f;
if (tauntchance > zone->random.Real(0, 1)) {
if (hate_top && hate_top != this){
newhate = (who->GetNPCHate(hate_top) - who->GetNPCHate(this)) + 1 + bonus_hate;
if (Success) {
if (hate_top && hate_top != this) {
int newhate = (who->GetNPCHate(hate_top) - who->GetNPCHate(this)) + 1 + bonus_hate;
who->CastToNPC()->AddToHateList(this, newhate);
Success = true;
} else {
who->CastToNPC()->AddToHateList(this, 12);
}
else
who->CastToNPC()->AddToHateList(this,12);
if (who->CanTalk())
who->Say_StringID(SUCCESSFUL_TAUNT,GetCleanName());
}
else{
Message_StringID(MT_SpellFailure,FAILED_TAUNT);
who->Say_StringID(SUCCESSFUL_TAUNT, GetCleanName());
} else {
Message_StringID(MT_SpellFailure, FAILED_TAUNT);
}
} else {
Message_StringID(MT_SpellFailure, FAILED_TAUNT);
}
else
Message_StringID(MT_SpellFailure,FAILED_TAUNT);
if (HasSkillProcs())
TrySkillProc(who, EQEmu::skills::SkillTaunt, TauntReuseTime * 1000);
@@ -1957,7 +1962,6 @@ void Mob::Taunt(NPC* who, bool always_succeed, float chance_bonus, bool FromSpel
TrySkillProc(who, EQEmu::skills::SkillTaunt, TauntReuseTime * 1000, true);
}
void Mob::InstillDoubt(Mob *who) {
//make sure we can use this skill
/*int skill = GetSkill(INTIMIDATION);*/ //unused
@@ -2119,7 +2123,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob *other, uint16 weapon_damage, EQEmu::skills:
DamageHitInfo my_hit;
my_hit.base_damage = weapon_damage;
my_hit.min_damage = 0;
my_hit.damage_done = 0;
my_hit.damage_done = 1;
my_hit.skill = skillinuse;
my_hit.offense = offense(my_hit.skill);
+9 -9
View File
@@ -439,7 +439,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
{
float x, y, z, heading;
const char *target_zone;
const char *target_zone = nullptr;
x = static_cast<float>(spell.base[1]);
y = static_cast<float>(spell.base[0]);
@@ -511,7 +511,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
case SE_Teleport2:
{
float x, y, z, heading;
const char *target_zone;
const char *target_zone = nullptr;
x = static_cast<float>(spell.base[1]);
y = static_cast<float>(spell.base[0]);
@@ -1724,7 +1724,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
#endif
// can only summon corpses of clients
if(!IsNPC()) {
Client* TargetClient = 0;
Client* TargetClient = nullptr;
if(this->GetTarget())
TargetClient = this->GetTarget()->CastToClient();
else
@@ -2677,7 +2677,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
case SE_Taunt:
{
if (caster && IsNPC()){
caster->Taunt(this->CastToNPC(), false, static_cast<float>(spell.base[i]), true, spell.base2[i]);
caster->Taunt(this->CastToNPC(), false, spell.base[i], true, spell.base2[i]);
}
break;
}
@@ -5178,7 +5178,7 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
//item focus
if (itembonuses.FocusEffects[type]){
const EQEmu::ItemData* TempItem = 0;
const EQEmu::ItemData* TempItem = nullptr;
for (int x = EQEmu::legacy::EQUIPMENT_BEGIN; x <= EQEmu::legacy::EQUIPMENT_END; x++)
{
@@ -5307,8 +5307,8 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id)
//Check if item focus effect exists for the client.
if (itembonuses.FocusEffects[type]){
const EQEmu::ItemData* TempItem = 0;
const EQEmu::ItemData* UsedItem = 0;
const EQEmu::ItemData* TempItem = nullptr;
const EQEmu::ItemData* UsedItem = nullptr;
uint16 UsedFocusID = 0;
int16 Total = 0;
int16 focus_max = 0;
@@ -5579,8 +5579,8 @@ int16 NPC::GetFocusEffect(focusType type, uint16 spell_id) {
if (RuleB(Spells, NPC_UseFocusFromItems) && itembonuses.FocusEffects[type]){
const EQEmu::ItemData* TempItem = 0;
const EQEmu::ItemData* UsedItem = 0;
const EQEmu::ItemData* TempItem = nullptr;
const EQEmu::ItemData* UsedItem = nullptr;
uint16 UsedFocusID = 0;
int16 Total = 0;
int16 focus_max = 0;
+15 -15
View File
@@ -827,7 +827,7 @@ void Mob::InterruptSpell(uint16 spellid)
// color not used right now
void Mob::InterruptSpell(uint16 message, uint16 color, uint16 spellid)
{
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
uint16 message_other;
bool bard_song_mode = false; //has the bard song gone to auto repeat mode
if (spellid == SPELL_UNKNOWN) {
@@ -1268,7 +1268,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
{
bool fromaug = false;
const EQEmu::ItemInstance* inst = CastToClient()->GetInv()[inventory_slot];
EQEmu::ItemData* augitem = 0;
EQEmu::ItemData* augitem = nullptr;
uint32 recastdelay = 0;
uint32 recasttype = 0;
@@ -3429,7 +3429,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
}
}
EQApplicationPacket *action_packet, *message_packet;
EQApplicationPacket *action_packet = nullptr, *message_packet = nullptr;
float spell_effectiveness;
if(!IsValidSpell(spell_id))
@@ -3622,19 +3622,19 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
spelltar != this)
{
Client* pClient = 0;
Raid* pRaid = 0;
Group* pBasicGroup = 0;
Client* pClient = nullptr;
Raid* pRaid = nullptr;
Group* pBasicGroup = nullptr;
uint32 nGroup = 0; //raid group
Client* pClientTarget = 0;
Raid* pRaidTarget = 0;
Group* pBasicGroupTarget = 0;
Client* pClientTarget = nullptr;
Raid* pRaidTarget = nullptr;
Group* pBasicGroupTarget = nullptr;
uint32 nGroupTarget = 0; //raid group
Client* pClientTargetPet = 0;
Raid* pRaidTargetPet = 0;
Group* pBasicGroupTargetPet = 0;
Client* pClientTargetPet = nullptr;
Raid* pRaidTargetPet = nullptr;
Group* pBasicGroupTargetPet = nullptr;
uint32 nGroupTargetPet = 0; //raid group
const uint32 cnWTF = 0xFFFFFFFF + 1; //this should be zero unless on 64bit? forced uint64?
@@ -4937,7 +4937,7 @@ void Mob::Mesmerize()
void Client::MakeBuffFadePacket(uint16 spell_id, int slot_id, bool send_message)
{
EQApplicationPacket* outapp;
EQApplicationPacket* outapp = nullptr;
outapp = new EQApplicationPacket(OP_Buff, sizeof(SpellBuffPacket_Struct));
SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer;
@@ -5417,7 +5417,7 @@ void Mob::_StopSong()
//be used for other things as well
void Client::SendBuffDurationPacket(Buffs_Struct &buff, int slot)
{
EQApplicationPacket* outapp;
EQApplicationPacket* outapp = nullptr;
outapp = new EQApplicationPacket(OP_Buff, sizeof(SpellBuffPacket_Struct));
SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer;
@@ -5453,7 +5453,7 @@ void Client::SendBuffNumHitPacket(Buffs_Struct &buff, int slot)
// UF+ use this packet
if (ClientVersion() < EQEmu::versions::ClientVersion::UF)
return;
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_BuffCreate, sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct));
BuffIcon_Struct *bi = (BuffIcon_Struct *)outapp->pBuffer;
bi->entity_id = GetID();
+3 -3
View File
@@ -290,7 +290,7 @@ bool Zone::LoadGroundSpawns() {
Log.Out(Logs::General, Logs::Status, "Loading Ground Spawns from DB...");
database.LoadGroundSpawns(zoneid, GetInstanceVersion(), &groundspawn);
uint32 ix=0;
char* name=0;
char* name = nullptr;
uint32 gsnumber=0;
for(gsindex=0;gsindex<50;gsindex++){
if(groundspawn.spawn[gsindex].item>0 && groundspawn.spawn[gsindex].item<SAYLINK_ITEM_ID){
@@ -1569,7 +1569,7 @@ void Zone::SetTime(uint8 hour, uint8 minute, bool update_world /*= true*/)
ZonePoint* Zone::GetClosestZonePoint(const glm::vec3& location, uint32 to, Client* client, float max_distance) {
LinkedListIterator<ZonePoint*> iterator(zone_point_list);
ZonePoint* closest_zp = 0;
ZonePoint* closest_zp = nullptr;
float closest_dist = FLT_MAX;
float max_distance2 = max_distance * max_distance;
iterator.Reset();
@@ -1625,7 +1625,7 @@ ZonePoint* Zone::GetClosestZonePoint(const glm::vec3& location, const char* to_n
ZonePoint* Zone::GetClosestZonePointWithoutZone(float x, float y, float z, Client* client, float max_distance) {
LinkedListIterator<ZonePoint*> iterator(zone_point_list);
ZonePoint* closest_zp = 0;
ZonePoint* closest_zp = nullptr;
float closest_dist = FLT_MAX;
float max_distance2 = max_distance*max_distance;
iterator.Reset();
+2 -2
View File
@@ -297,7 +297,7 @@ void Client::SendZoneCancel(ZoneChange_Struct *zc) {
//effectively zone them right back to where they were
//unless we find a better way to stop the zoning process.
SetPortExemption(true);
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct));
ZoneChange_Struct *zc2 = (ZoneChange_Struct*)outapp->pBuffer;
strcpy(zc2->char_name, zc->char_name);
@@ -316,7 +316,7 @@ void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
SetPortExemption(true);
EQApplicationPacket *outapp;
EQApplicationPacket *outapp = nullptr;
outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct));
ZoneChange_Struct *zc2 = (ZoneChange_Struct*)outapp->pBuffer;
strcpy(zc2->char_name, zc->char_name);