mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 15:41:30 +00:00
Some cleanup as well as fix for a certain type of aa proc
This commit is contained in:
parent
34f0106437
commit
a984e9bd7c
65
zone/aa.cpp
65
zone/aa.cpp
@ -800,7 +800,10 @@ void Client::RefundAA() {
|
||||
int refunded = 0;
|
||||
|
||||
for(auto &rank_value : aa_ranks) {
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbility(rank_value.first);
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(rank_value.first, rank_value.second.first);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
@ -809,11 +812,6 @@ void Client::RefundAA() {
|
||||
continue;
|
||||
}
|
||||
|
||||
AA::Rank *rank = ability->GetRankByPointsSpent(rank_value.second.first);
|
||||
if(!rank) {
|
||||
continue;
|
||||
}
|
||||
|
||||
refunded += rank->total_cost;
|
||||
}
|
||||
|
||||
@ -864,20 +862,19 @@ void Client::SendAlternateAdvancementTable() {
|
||||
void Client::SendAlternateAdvancementRank(int aa_id, int level) {
|
||||
if(!zone)
|
||||
return;
|
||||
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbility(aa_id);
|
||||
|
||||
if(!ability)
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa_id, level);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
if(!ability) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(ability->classes & (1 << GetClass()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
AA::Rank *rank = ability->GetRankByPointsSpent(level);
|
||||
if(!rank)
|
||||
return;
|
||||
|
||||
if(!CanUseAlternateAdvancementRank(rank)) {
|
||||
return;
|
||||
}
|
||||
@ -1224,13 +1221,11 @@ int Mob::GetAlternateAdvancementCooldownReduction(AA::Rank *rank_in) {
|
||||
}
|
||||
|
||||
for(auto &aa : aa_ranks) {
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbility(aa.first);
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
AA::Rank *rank = ability->GetRankByPointsSpent(aa.second.first);
|
||||
if(!rank) {
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1328,6 +1323,21 @@ AA::Rank *Zone::GetAlternateAdvancementRank(int rank_id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::pair<AA::Ability*, AA::Rank*> Zone::GetAlternateAdvancementAbilityAndRank(int id, int points_spent) {
|
||||
AA::Ability *ability = GetAlternateAdvancementAbility(id);
|
||||
|
||||
if(!ability) {
|
||||
return std::make_pair(nullptr, nullptr);
|
||||
}
|
||||
|
||||
AA::Rank *rank = ability->GetRankByPointsSpent(points_spent);
|
||||
if(!rank) {
|
||||
return std::make_pair(nullptr, nullptr);
|
||||
}
|
||||
|
||||
return std::make_pair(ability, rank);
|
||||
}
|
||||
|
||||
uint32 Mob::GetAA(uint32 rank_id, uint32 *charges) const {
|
||||
if(zone) {
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbilityByRank(rank_id);
|
||||
@ -1345,6 +1355,23 @@ uint32 Mob::GetAA(uint32 rank_id, uint32 *charges) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Mob::GetAAByAAID(uint32 aa_id, uint32 *charges) const {
|
||||
if(zone) {
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbility(aa_id);
|
||||
|
||||
if(!ability)
|
||||
return 0;
|
||||
|
||||
auto iter = aa_ranks.find(ability->id);
|
||||
if(iter != aa_ranks.end()) {
|
||||
if(charges) {
|
||||
*charges = iter->second.second;
|
||||
}
|
||||
return iter->second.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Mob::SetAA(uint32 rank_id, uint32 new_value, uint32 charges) {
|
||||
if(zone) {
|
||||
AA::Ability *ability = zone->GetAlternateAdvancementAbilityByRank(rank_id);
|
||||
|
||||
@ -4647,7 +4647,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
|
||||
if (IsClient() && aabonuses.LimitToSkill[skill]){
|
||||
|
||||
CanProc = true;
|
||||
uint32 effect = 0;
|
||||
uint32 effect_id = 0;
|
||||
int32 base1 = 0;
|
||||
int32 base2 = 0;
|
||||
uint32 slot = 0;
|
||||
@ -4666,39 +4666,43 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
|
||||
proc_spell_id = 0;
|
||||
ProcMod = 0;
|
||||
|
||||
//old AA
|
||||
//std::map<uint32, std::map<uint32, AA_Ability> >::const_iterator find_iter = aa_effects.find(aaid);
|
||||
//if(find_iter == aa_effects.end())
|
||||
// break;
|
||||
for(auto &rank_info : aa_ranks) {
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(rank_info.first, rank_info.second.first);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
//for (std::map<uint32, AA_Ability>::const_iterator iter = aa_effects[aaid].begin(); iter != aa_effects[aaid].end(); ++iter) {
|
||||
// effect = iter->second.skill_id;
|
||||
// base1 = iter->second.base1;
|
||||
// base2 = iter->second.base2;
|
||||
// slot = iter->second.slot;
|
||||
//
|
||||
// if (effect == SE_SkillProc || effect == SE_SkillProcSuccess) {
|
||||
// proc_spell_id = base1;
|
||||
// ProcMod = static_cast<float>(base2);
|
||||
// }
|
||||
//
|
||||
// else if (effect == SE_LimitToSkill && base1 <= HIGHEST_SKILL) {
|
||||
//
|
||||
// if (CanProc && base1 == skill && IsValidSpell(proc_spell_id)) {
|
||||
// float final_chance = chance * (ProcMod / 100.0f);
|
||||
//
|
||||
// if (zone->random.Roll(final_chance)) {
|
||||
// ExecWeaponProc(nullptr, proc_spell_id, on);
|
||||
// CanProc = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// proc_spell_id = 0;
|
||||
// ProcMod = 0;
|
||||
// }
|
||||
//}
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(auto &effect : rank->effects) {
|
||||
effect_id = effect.effect_id;
|
||||
base1 = effect.base1;
|
||||
base2 = effect.base2;
|
||||
slot = effect.slot;
|
||||
|
||||
if(effect_id == SE_SkillProc || effect_id == SE_SkillProcSuccess) {
|
||||
proc_spell_id = base1;
|
||||
ProcMod = static_cast<float>(base2);
|
||||
}
|
||||
else if(effect_id == SE_LimitToSkill && base1 <= HIGHEST_SKILL) {
|
||||
|
||||
if (CanProc && base1 == skill && IsValidSpell(proc_spell_id)) {
|
||||
float final_chance = chance * (ProcMod / 100.0f);
|
||||
|
||||
if (zone->random.Roll(final_chance)) {
|
||||
ExecWeaponProc(nullptr, proc_spell_id, on);
|
||||
CanProc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
proc_spell_id = 0;
|
||||
ProcMod = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,14 +640,16 @@ void Client::CalcAABonuses(StatBonuses *newbon)
|
||||
memset(newbon, 0, sizeof(StatBonuses)); // start fresh
|
||||
|
||||
for (const auto &aa : aa_ranks) {
|
||||
auto ability = zone->GetAlternateAdvancementAbility(aa.first);
|
||||
// zone doesn't know about this! bad data some where
|
||||
if (!ability)
|
||||
continue;
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto rank = ability->GetRankByPointsSpent(aa.second.first);
|
||||
// bad data or no effects
|
||||
if (!rank || rank->effects.empty())
|
||||
if (rank->effects.empty())
|
||||
continue;
|
||||
|
||||
ApplyAABonuses(*rank, newbon);
|
||||
|
||||
@ -774,27 +774,23 @@ public:
|
||||
void AddAAPoints(uint32 points) { m_pp.aapoints += points; SendAlternateAdvancementStats(); }
|
||||
int GetAAPoints() { return m_pp.aapoints; }
|
||||
int GetSpentAA() { return m_pp.aapoints_spent; }
|
||||
|
||||
//old AA Methods
|
||||
|
||||
//old AA methods that we still use
|
||||
void ResetAA();
|
||||
void RefundAA();
|
||||
void SendClearAA();
|
||||
//this function is used by some AA stuff
|
||||
void MemorizeSpell(uint32 slot,uint32 spellid,uint32 scribing);
|
||||
void SetAATitle(const char *Title);
|
||||
void SetTitleSuffix(const char *txt);
|
||||
inline uint32 GetMaxAAXP(void) const { return max_AAXP; }
|
||||
inline uint32 GetAAXP() const { return m_pp.expAA; }
|
||||
int16 CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id);
|
||||
void SetAATitle(const char *Title);
|
||||
void SetTitleSuffix(const char *txt);
|
||||
|
||||
//old AA Methods that are slated for removal
|
||||
void MemorizeSpell(uint32 slot,uint32 spellid,uint32 scribing);
|
||||
void EnableAAEffect(aaEffectType type, uint32 duration = 0);
|
||||
void DisableAAEffect(aaEffectType type);
|
||||
bool CheckAAEffect(aaEffectType type);
|
||||
void HandleAAAction(aaID activate);
|
||||
int16 CalcAAFocusEffect(focusType type, uint16 focus_spell, uint16 spell_id);
|
||||
int16 CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id);
|
||||
void RefundAA();
|
||||
int32 GetAAEffectDataBySlot(uint32 aa_ID, uint32 slot_id, bool GetEffect, bool GetBase1, bool GetBase2);
|
||||
int32 GetAAEffectid(uint32 aa_ID, uint32 slot_id) { return GetAAEffectDataBySlot(aa_ID, slot_id, true, false,false); }
|
||||
int32 GetAABase1(uint32 aa_ID, uint32 slot_id) { return GetAAEffectDataBySlot(aa_ID, slot_id, false, true,false); }
|
||||
int32 GetAABase2(uint32 aa_ID, uint32 slot_id) { return GetAAEffectDataBySlot(aa_ID, slot_id, false, false,true); }
|
||||
|
||||
int32 acmod();
|
||||
|
||||
// Item methods
|
||||
|
||||
@ -960,6 +960,7 @@ public:
|
||||
|
||||
//aa new
|
||||
uint32 GetAA(uint32 rank_id, uint32 *charges = nullptr) const;
|
||||
uint32 GetAAByAAID(uint32 aa_id, uint32 *charges = nullptr) const;
|
||||
bool SetAA(uint32 rank_id, uint32 new_value, uint32 charges = 0);
|
||||
void ClearAAs() { aa_ranks.clear(); }
|
||||
bool CanUseAlternateAdvancementRank(AA::Rank *rank);
|
||||
|
||||
@ -4077,34 +4077,7 @@ XS(XS_Client_RefundAA) {
|
||||
if(THIS == nullptr)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
//old aa
|
||||
//int curpt = 0;
|
||||
//bool refunded = false;
|
||||
//
|
||||
//for(int x1=0;x1<aaHighestID;x1++){
|
||||
// curpt = THIS->GetAA(x1);
|
||||
// if(curpt > 0){
|
||||
// SendAA_Struct* curaa = zone->FindAA(x1);
|
||||
// if(curaa){
|
||||
// THIS->SetAA(x1, 0);
|
||||
// for(int x2=0;x2<curpt;x2++){ //add up all the AA points pt by pt to get the correct cost
|
||||
// THIS->GetPP().aapoints += curaa->cost + (curaa->cost_inc * x2);
|
||||
// refunded = true;
|
||||
// }
|
||||
// }
|
||||
// else //aa doesn't exist.. but if they bought it then it had at least a cost of 1 point each
|
||||
// { //so give back what we can
|
||||
// THIS->GetPP().aapoints += curpt;
|
||||
// THIS->SetAA(x1, 0);
|
||||
// refunded = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//if(refunded){
|
||||
// THIS->Save(); //save of course
|
||||
// THIS->Kick(); //client gets all buggy if we don't immediatly relog so just force it on them
|
||||
//}
|
||||
THIS->RefundAA();
|
||||
}
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
@ -4149,43 +4149,6 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
|
||||
CalcBonuses();
|
||||
}
|
||||
|
||||
int32 Client::GetAAEffectDataBySlot(uint32 aa_ID, uint32 slot_id, bool GetEffect, bool GetBase1, bool GetBase2)
|
||||
{
|
||||
int32 aa_effects_data[3] = { 0 };
|
||||
uint32 effect = 0;
|
||||
int32 base1 = 0;
|
||||
int32 base2 = 0;
|
||||
uint32 slot = 0;
|
||||
|
||||
//old aa
|
||||
//std::map<uint32, std::map<uint32, AA_Ability> >::const_iterator find_iter = aa_effects.find(aa_ID);
|
||||
//if(find_iter == aa_effects.end())
|
||||
// return 0;
|
||||
//
|
||||
//for (std::map<uint32, AA_Ability>::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter)
|
||||
//{
|
||||
// effect = iter->second.skill_id;
|
||||
// base1 = iter->second.base1;
|
||||
// base2 = iter->second.base2;
|
||||
// slot = iter->second.slot;
|
||||
//
|
||||
// if (slot && slot == slot_id) {
|
||||
//
|
||||
// if (GetEffect)
|
||||
// return effect;
|
||||
//
|
||||
// if (GetBase1)
|
||||
// return base1;
|
||||
//
|
||||
// if (GetBase2)
|
||||
// return base2;
|
||||
// }
|
||||
//}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int16 Client::CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id)
|
||||
{
|
||||
const SPDat_Spell_Struct &spell = spells[spell_id];
|
||||
@ -5207,12 +5170,15 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
|
||||
if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS)
|
||||
break;
|
||||
|
||||
auto ability = zone->GetAlternateAdvancementAbility(aa.first);
|
||||
if (!ability)
|
||||
continue;
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
auto rank = ability->GetRankByPointsSpent(aa.second.first);
|
||||
if (!rank || rank->effects.empty())
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rank->effects.empty())
|
||||
continue;
|
||||
|
||||
proc_spellid = CalcAAFocus(type, *rank, spell_id);
|
||||
@ -5474,12 +5440,15 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id) {
|
||||
int16 Total3 = 0;
|
||||
|
||||
for (const auto &aa : aa_ranks) {
|
||||
auto ability = zone->GetAlternateAdvancementAbility(aa.first);
|
||||
if (!ability)
|
||||
continue;
|
||||
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||
auto ability = ability_rank.first;
|
||||
auto rank = ability_rank.second;
|
||||
|
||||
auto rank = ability->GetRankByPointsSpent(aa.second.first);
|
||||
if (!rank || rank->effects.empty())
|
||||
if(!ability) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rank->effects.empty())
|
||||
continue;
|
||||
|
||||
Total3 = CalcAAFocus(type, *rank, spell_id);
|
||||
|
||||
@ -119,6 +119,7 @@ public:
|
||||
AA::Ability *GetAlternateAdvancementAbility(int id);
|
||||
AA::Ability *GetAlternateAdvancementAbilityByRank(int rank_id);
|
||||
AA::Rank *GetAlternateAdvancementRank(int rank_id);
|
||||
std::pair<AA::Ability*, AA::Rank*> GetAlternateAdvancementAbilityAndRank(int id, int points_spent);
|
||||
|
||||
void LoadZoneDoors(const char* zone, int16 version);
|
||||
bool LoadZoneObjects();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user