diff --git a/changelog.txt b/changelog.txt index b02d48bb8..54cf452d8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 11/01/2014 == Trevius: Fixed potential crash related to Pets/Mercs buffs when targeting themselves. +JJ: (noudess) Revamped faction system. See https://github.com/EQEmu/Server/pull/256 == 10/28/2014 == Uleat: Added Client::InterrogateInventory(). Can be invoked by #interrogateinv and is also called when Handle_OP_MoveItem() calls for SwapItemResync() diff --git a/common/faction.cpp b/common/faction.cpp index 7016f6547..576971ec5 100644 --- a/common/faction.cpp +++ b/common/faction.cpp @@ -47,7 +47,7 @@ const char *FactionValueToString(FACTION_VALUE fv) { //o-------------------------------------------------------------- -//| Name: CalculateFaction; rembrant, Dec. 16, 2001 +//| Name: CalculateFaction; Dec. 16, 2001 //o-------------------------------------------------------------- //| Notes: Returns the faction message value. //| Modify these values to taste. @@ -69,7 +69,7 @@ FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value) return FACTION_INDIFFERENT; } -// neotokyo: this function should check if some races have more than one race define +// this function should check if some races have more than one race define bool IsOfEqualRace(int r1, int r2) { if (r1 == r2) @@ -88,7 +88,7 @@ bool IsOfEqualRace(int r1, int r2) return false; } -// neotokyo: trolls endure ogres, dark elves, ... +// trolls endure ogres, dark elves, ... bool IsOfIndiffRace(int r1, int r2) { if (r1 == r2) diff --git a/common/features.h b/common/features.h index 237a78290..0860788e1 100644 --- a/common/features.h +++ b/common/features.h @@ -163,7 +163,7 @@ enum { //timer settings, all in milliseconds CombatEventTimer_expire = 12000, Tribute_duration = 600000, ZoneTimerResolution = 3, //sleep time between zone main loop runs (milliseconds) - FeignMemoryDuration = 120000, // EverHood - Duration player must feign death to clear zonewide agro. + FeignMemoryDuration = 120000, // Duration player must feign death to clear zonewide agro. EnragedTimer = 360000, EnragedDurationTimer = 10000 }; @@ -208,12 +208,12 @@ enum { //some random constants //chance ratio that a #define THREATENLY_ARRGO_CHANCE 32 // 32/128 (25%) chance that a mob will arrgo on con Threatenly -// max factions per npc faction list +//max factions per npc faction list #define MAX_NPC_FACTIONS 20 -//value caps -#define MAX_FACTION 1500 -#define MIN_FACTION -1500 +//individual faction pool +#define MAX_PERSONAL_FACTION 1200 +#define MIN_PERSONAL_FACTION -3000 //The Level Cap: //#define LEVEL_CAP RuleI(Character, MaxLevel) //hard cap is 127 diff --git a/zone/attack.cpp b/zone/attack.cpp index 5e2baa117..e24b982ab 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1408,7 +1408,7 @@ void Client::Damage(Mob* other, int32 damage, uint16 spell_id, SkillUseTypes att } // cut all PVP spell damage to 2/3 -solar - // EverHood - Blasting ourselfs is considered PvP + // Blasting ourselfs is considered PvP //Don't do PvP mitigation if the caster is damaging himself if(other && other->IsClient() && (other != this) && damage > 0) { int PvPMitigation = 100; @@ -3777,7 +3777,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons safe_delete(outapp); } else { //else, it is a buff tic... - // Everhood - So we can see our dot dmg like live shows it. + // So we can see our dot dmg like live shows it. if(spell_id != SPELL_UNKNOWN && damage > 0 && attacker && attacker != this && attacker->IsClient()) { //might filter on (attack_skill>200 && attack_skill<250), but I dont think we need it attacker->FilteredMessage_StringID(attacker, MT_DoTDamage, FilterDOT, diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 89af2a244..a3e9c5190 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -1484,7 +1484,7 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses* ne case SE_Harmony: { - // neotokyo: Harmony effect as buff - kinda tricky + // Harmony effect as buff - kinda tricky // harmony could stack with a lull spell, which has better aggro range // take the one with less range in any case if(newbon->AssistRange == -1 || effect_value < newbon->AssistRange) diff --git a/zone/client.cpp b/zone/client.cpp index f1fef3b23..13ac70be8 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -7460,7 +7460,7 @@ FACTION_VALUE Client::GetReverseFactionCon(Mob* iOther) { } //o-------------------------------------------------------------- -//| Name: GetFactionLevel; rembrant, Dec. 16, 2001 +//| Name: GetFactionLevel; Dec. 16, 2001 //o-------------------------------------------------------------- //| Notes: Gets the characters faction standing with the specified NPC. //| Will return Indifferent on failure. @@ -7473,7 +7473,7 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra int32 tmpFactionValue; FactionMods fmods; - // neotokyo: few optimizations + // few optimizations if (GetFeigned()) return FACTION_INDIFFERENT; if (invisible_undead && tnpc && !tnpc->SeeInvisibleUndead()) @@ -7496,7 +7496,7 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra { //Get the players current faction with pFaction tmpFactionValue = GetCharacterFactionLevel(pFaction); - // Everhood - tack on any bonuses from Alliance type spell effects + //Tack on any bonuses from Alliance type spell effects tmpFactionValue += GetFactionBonus(pFaction); tmpFactionValue += GetItemFactionBonus(pFaction); //Return the faction to the client @@ -7518,97 +7518,77 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra return fac; } -//o-------------------------------------------------------------- -//| Name: SetFactionLevel; rembrant, Dec. 20, 2001 -//o-------------------------------------------------------------- -//| Notes: Sets the characters faction standing with the specified NPC. -//o-------------------------------------------------------------- +//Sets the characters faction standing with the specified NPC. void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity) { - int32 faction_id[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 }; - int32 npc_value[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 }; - uint8 temp[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 }; + int32 faction_id[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int32 npc_value[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8 temp[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int32 mod; - int32 t; int32 tmpValue; int32 current_value; FactionMods fm; + bool change = false; + bool repair = false; + // Get the npc faction list - if(!database.GetNPCFactionList(npc_id, faction_id, npc_value, temp)) + if (!database.GetNPCFactionList(npc_id, faction_id, npc_value, temp)) return; - for(int i = 0;iitembonuses.HeroicCHA) { + if (this->itembonuses.HeroicCHA) + { int faction_mod = itembonuses.HeroicCHA / 5; // If our result isn't truncated, then just do that - if(npc_value[i] * faction_mod / 100 != 0) + if (npc_value[i] * faction_mod / 100 != 0) npc_value[i] += npc_value[i] * faction_mod / 100; // If our result is truncated, then double a mob's value every once and a while to equal what they would have got - else { - if(MakeRandomInt(0, 100) < faction_mod) + else + { + if (MakeRandomInt(0, 100) < faction_mod) npc_value[i] *= 2; } } - //figure out their modifier - mod = fm.base + fm.class_mod + fm.race_mod + fm.deity_mod; - if(mod > MAX_FACTION) - mod = MAX_FACTION; - else if(mod < MIN_FACTION) - mod = MIN_FACTION; + // Set flag when to update db + if (current_value > MAX_PERSONAL_FACTION) + { + current_value = MAX_PERSONAL_FACTION; + repair = true; + } + else if (current_value < MIN_PERSONAL_FACTION) + { + current_value = MIN_PERSONAL_FACTION; + repair = true; + } + else if ((m_pp.gm != 1) && (npc_value[i] != 0) && ((current_value != MAX_PERSONAL_FACTION) || (current_value != MIN_PERSONAL_FACTION))) + change = true; - // Calculate the faction - if(npc_value[i] != 0) { - tmpValue = current_value + mod + npc_value[i]; + current_value += npc_value[i]; - int16 FactionModPct = spellbonuses.FactionModPct + itembonuses.FactionModPct + aabonuses.FactionModPct; - tmpValue += (tmpValue * FactionModPct) / 100; + if (current_value > MAX_PERSONAL_FACTION) + current_value = MAX_PERSONAL_FACTION; + else if (current_value < MIN_PERSONAL_FACTION) + current_value = MIN_PERSONAL_FACTION; - // Make sure faction hits don't go to GMs... - if (m_pp.gm==1 && (tmpValue < current_value)) { - tmpValue = current_value; - } + if (change || repair) + { + database.SetCharacterFactionLevel(char_id, faction_id[i], current_value, temp[i], factionvalues); - // Make sure we dont go over the min/max faction limits - if(tmpValue >= MAX_FACTION) + if (change) { - t = MAX_FACTION - mod; - if(current_value == t) { - //do nothing, it is already maxed out - } else if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], t, temp[i], factionvalues))) - { - return; - } + mod = fm.base + fm.class_mod + fm.race_mod + fm.deity_mod; + tmpValue = current_value + mod + npc_value[i]; + SendFactionMessage(npc_value[i], faction_id[i], tmpValue, temp[i]); } - else if(tmpValue <= MIN_FACTION) - { - t = MIN_FACTION - mod; - if(current_value == t) { - //do nothing, it is already maxed out - } else if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], t, temp[i], factionvalues))) - { - return; - } - } - else - { - if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], current_value + npc_value[i], temp[i], factionvalues))) - { - return; - } - } - if(tmpValue <= MIN_FACTION) - tmpValue = MIN_FACTION; - - SendFactionMessage(npc_value[i], faction_id[i], tmpValue, temp[i]); } } } @@ -7636,19 +7616,17 @@ int32 Client::GetCharacterFactionLevel(int32 faction_id) return 0; faction_map::iterator res; res = factionvalues.find(faction_id); - if(res == factionvalues.end()) - return(0); - return(res->second); + if (res == factionvalues.end()) + return 0; + return res->second; } // returns the character's faction level, adjusted for racial, class, and deity modifiers int32 Client::GetModCharacterFactionLevel(int32 faction_id) { int32 Modded = GetCharacterFactionLevel(faction_id); FactionMods fm; - if(database.GetFactionData(&fm,GetClass(),GetRace(),GetDeity(),faction_id)) + if (database.GetFactionData(&fm, GetClass(), GetRace(), GetDeity(), faction_id)) Modded += fm.base + fm.class_mod + fm.race_mod + fm.deity_mod; - if (Modded > MAX_FACTION) - Modded = MAX_FACTION; return Modded; } @@ -7727,17 +7705,17 @@ void Client::SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 totalval // default to Faction# if we couldn't get the name from the ID if (database.GetFactionName(faction_id, name, sizeof(name)) == false) - snprintf(name, sizeof(name),"Faction%i",faction_id); + snprintf(name, sizeof(name), "Faction%i", faction_id); if (tmpvalue == 0 || temp == 1 || temp == 2) return; - else if (totalvalue >= MAX_FACTION) + else if (totalvalue >= MAX_PERSONAL_FACTION) Message_StringID(0, FACTION_BEST, name); - else if (tmpvalue > 0 && totalvalue < MAX_FACTION) + else if (tmpvalue > 0 && totalvalue < MAX_PERSONAL_FACTION) Message_StringID(0, FACTION_BETTER, name); - else if (tmpvalue < 0 && totalvalue > MIN_FACTION) + else if (tmpvalue < 0 && totalvalue > MIN_PERSONAL_FACTION) Message_StringID(0, FACTION_WORSE, name); - else if (totalvalue <= MIN_FACTION) + else if (totalvalue <= MIN_PERSONAL_FACTION) Message_StringID(0, FACTION_WORST, name); return; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index db6edf703..207468825 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4732,7 +4732,7 @@ void Client::Handle_OP_Consider(const EQApplicationPacket *app) con->playerid = GetID(); con->targetid = conin->targetid; if (tmob->IsNPC()) - con->faction = GetFactionLevel(character_id, tmob->GetNPCTypeID(), race, class_, deity, (tmob->IsNPC()) ? tmob->CastToNPC()->GetPrimaryFaction() : 0, tmob); // rembrant, Dec. 20, 2001; TODO: Send the players proper deity + con->faction = GetFactionLevel(character_id, tmob->GetNPCTypeID(), race, class_, deity, (tmob->IsNPC()) ? tmob->CastToNPC()->GetPrimaryFaction() : 0, tmob); // Dec. 20, 2001; TODO: Send the players proper deity else con->faction = 1; con->level = GetLevelCon(tmob->GetLevel()); diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index f26615877..e9117db98 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -40,7 +40,7 @@ HateList::~HateList() { } -// neotokyo: added for frenzy support +// added for frenzy support // checks if target still is in frenzy mode void HateList::CheckFrenzyHate() { @@ -170,7 +170,7 @@ Mob* HateList::GetClosest(Mob *hater) { } -// neotokyo: a few comments added, rearranged code for readability +// a few comments added, rearranged code for readability void HateList::Add(Mob *ent, int32 in_hate, int32 in_dam, bool bFrenzy, bool iAddIfNotExist) { if(!ent) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 5f8ea2c11..ff7caceaf 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1438,7 +1438,7 @@ void Mob::AI_Process() { else { if(AIfeignremember_timer->Check()) { - // EverHood - 6/14/06 + // 6/14/06 // Improved Feign Death Memory // check to see if any of our previous feigned targets have gotten up. std::set::iterator RememberedCharID; @@ -1881,7 +1881,7 @@ void Mob::AI_Event_NoLongerEngaged() { pLastFightingDelayMoving += minLastFightingDelayMoving; else pLastFightingDelayMoving += MakeRandomInt(minLastFightingDelayMoving, maxLastFightingDelayMoving); - // EverHood - So mobs don't keep running as a ghost until AIwalking_timer fires + // So mobs don't keep running as a ghost until AIwalking_timer fires // if they were moving prior to losing all hate if(IsMoving()){ SetRunAnimSpeed(0); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 55a0a9c96..d4ae9f642 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -2160,7 +2160,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) case SE_TemporaryPets: //Dook- swarms and wards: { - // EverHood - this makes necro epic 1.5/2.0 proc work properly + // this makes necro epic 1.5/2.0 proc work properly if((spell_id != 6882) && (spell_id != 6884)) // Chaotic Jester/Steadfast Servant { char pet_name[64]; @@ -3065,7 +3065,7 @@ int Mob::CalcSpellEffectValue(uint16 spell_id, int effect_id, int caster_level, int Mob::CalcSpellEffectValue_formula(int formula, int base, int max, int caster_level, uint16 spell_id, int ticsremaining) { /* -neotokyo: i need those formulas checked!!!! +i need those formulas checked!!!! 0 = base 1 - 99 = base + level * formulaID diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 2fb79029b..11d13b992 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3146,7 +3146,7 @@ bool ZoneDatabase::GetFactionData(FactionMods* fm, uint32 class_mod, uint32 race } //o-------------------------------------------------------------- -//| Name: GetFactionName; rembrant, Dec. 16 +//| Name: GetFactionName; Dec. 16 //o-------------------------------------------------------------- //| Notes: Retrieves the name of the specified faction .Returns false on failure. //o-------------------------------------------------------------- @@ -3162,7 +3162,7 @@ bool ZoneDatabase::GetFactionName(int32 faction_id, char* name, uint32 buflen) { } //o-------------------------------------------------------------- -//| Name: GetNPCFactionList; rembrant, Dec. 16, 2001 +//| Name: GetNPCFactionList; Dec. 16, 2001 //o-------------------------------------------------------------- //| Purpose: Gets a list of faction_id's and values bound to the npc_id. Returns false on failure. //o-------------------------------------------------------------- @@ -3186,7 +3186,7 @@ bool ZoneDatabase::GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, in } //o-------------------------------------------------------------- -//| Name: SetCharacterFactionLevel; rembrant, Dec. 20, 2001 +//| Name: SetCharacterFactionLevel; Dec. 20, 2001 //o-------------------------------------------------------------- //| Purpose: Update characters faction level with specified faction_id to specified value. Returns false on failure. //o-------------------------------------------------------------- diff --git a/zone/zonedb.h b/zone/zonedb.h index 30721de9a..db796e481 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -321,10 +321,10 @@ public: /* Faction */ bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0); - bool GetFactionData(FactionMods* fd, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id); //rembrant, needed for factions Dec, 16 2001 - bool GetFactionName(int32 faction_id, char* name, uint32 buflen); // rembrant, needed for factions Dec, 16 2001 - bool GetFactionIdsForNPC(uint32 nfl_id, std::list *faction_list, int32* primary_faction = 0); // neotokyo: improve faction handling - bool SetCharacterFactionLevel(uint32 char_id, int32 faction_id, int32 value, uint8 temp, faction_map &val_list); // rembrant, needed for factions Dec, 16 2001 + bool GetFactionData(FactionMods* fd, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id); //needed for factions Dec, 16 2001 + bool GetFactionName(int32 faction_id, char* name, uint32 buflen); // needed for factions Dec, 16 2001 + bool GetFactionIdsForNPC(uint32 nfl_id, std::list *faction_list, int32* primary_faction = 0); // improve faction handling + bool SetCharacterFactionLevel(uint32 char_id, int32 faction_id, int32 value, uint8 temp, faction_map &val_list); // needed for factions Dec, 16 2001 bool LoadFactionData(); /* AAs */