mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 16:41:29 +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;
|
int refunded = 0;
|
||||||
|
|
||||||
for(auto &rank_value : aa_ranks) {
|
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) {
|
if(!ability) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -809,11 +812,6 @@ void Client::RefundAA() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AA::Rank *rank = ability->GetRankByPointsSpent(rank_value.second.first);
|
|
||||||
if(!rank) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
refunded += rank->total_cost;
|
refunded += rank->total_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -864,20 +862,19 @@ void Client::SendAlternateAdvancementTable() {
|
|||||||
void Client::SendAlternateAdvancementRank(int aa_id, int level) {
|
void Client::SendAlternateAdvancementRank(int aa_id, int level) {
|
||||||
if(!zone)
|
if(!zone)
|
||||||
return;
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!(ability->classes & (1 << GetClass()))) {
|
if(!(ability->classes & (1 << GetClass()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AA::Rank *rank = ability->GetRankByPointsSpent(level);
|
|
||||||
if(!rank)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!CanUseAlternateAdvancementRank(rank)) {
|
if(!CanUseAlternateAdvancementRank(rank)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1224,13 +1221,11 @@ int Mob::GetAlternateAdvancementCooldownReduction(AA::Rank *rank_in) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(auto &aa : aa_ranks) {
|
for(auto &aa : aa_ranks) {
|
||||||
AA::Ability *ability = zone->GetAlternateAdvancementAbility(aa.first);
|
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||||
if(!ability) {
|
auto ability = ability_rank.first;
|
||||||
continue;
|
auto rank = ability_rank.second;
|
||||||
}
|
|
||||||
|
|
||||||
AA::Rank *rank = ability->GetRankByPointsSpent(aa.second.first);
|
if(!ability) {
|
||||||
if(!rank) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,6 +1323,21 @@ AA::Rank *Zone::GetAlternateAdvancementRank(int rank_id) {
|
|||||||
return nullptr;
|
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 {
|
uint32 Mob::GetAA(uint32 rank_id, uint32 *charges) const {
|
||||||
if(zone) {
|
if(zone) {
|
||||||
AA::Ability *ability = zone->GetAlternateAdvancementAbilityByRank(rank_id);
|
AA::Ability *ability = zone->GetAlternateAdvancementAbilityByRank(rank_id);
|
||||||
@ -1345,6 +1355,23 @@ uint32 Mob::GetAA(uint32 rank_id, uint32 *charges) const {
|
|||||||
return 0;
|
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) {
|
bool Mob::SetAA(uint32 rank_id, uint32 new_value, uint32 charges) {
|
||||||
if(zone) {
|
if(zone) {
|
||||||
AA::Ability *ability = zone->GetAlternateAdvancementAbilityByRank(rank_id);
|
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]){
|
if (IsClient() && aabonuses.LimitToSkill[skill]){
|
||||||
|
|
||||||
CanProc = true;
|
CanProc = true;
|
||||||
uint32 effect = 0;
|
uint32 effect_id = 0;
|
||||||
int32 base1 = 0;
|
int32 base1 = 0;
|
||||||
int32 base2 = 0;
|
int32 base2 = 0;
|
||||||
uint32 slot = 0;
|
uint32 slot = 0;
|
||||||
@ -4666,39 +4666,43 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
|
|||||||
proc_spell_id = 0;
|
proc_spell_id = 0;
|
||||||
ProcMod = 0;
|
ProcMod = 0;
|
||||||
|
|
||||||
//old AA
|
for(auto &rank_info : aa_ranks) {
|
||||||
//std::map<uint32, std::map<uint32, AA_Ability> >::const_iterator find_iter = aa_effects.find(aaid);
|
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(rank_info.first, rank_info.second.first);
|
||||||
//if(find_iter == aa_effects.end())
|
auto ability = ability_rank.first;
|
||||||
// break;
|
auto rank = ability_rank.second;
|
||||||
|
|
||||||
//for (std::map<uint32, AA_Ability>::const_iterator iter = aa_effects[aaid].begin(); iter != aa_effects[aaid].end(); ++iter) {
|
if(!ability) {
|
||||||
// effect = iter->second.skill_id;
|
continue;
|
||||||
// base1 = iter->second.base1;
|
}
|
||||||
// base2 = iter->second.base2;
|
|
||||||
// slot = iter->second.slot;
|
for(auto &effect : rank->effects) {
|
||||||
//
|
effect_id = effect.effect_id;
|
||||||
// if (effect == SE_SkillProc || effect == SE_SkillProcSuccess) {
|
base1 = effect.base1;
|
||||||
// proc_spell_id = base1;
|
base2 = effect.base2;
|
||||||
// ProcMod = static_cast<float>(base2);
|
slot = effect.slot;
|
||||||
// }
|
|
||||||
//
|
if(effect_id == SE_SkillProc || effect_id == SE_SkillProcSuccess) {
|
||||||
// else if (effect == SE_LimitToSkill && base1 <= HIGHEST_SKILL) {
|
proc_spell_id = base1;
|
||||||
//
|
ProcMod = static_cast<float>(base2);
|
||||||
// if (CanProc && base1 == skill && IsValidSpell(proc_spell_id)) {
|
}
|
||||||
// float final_chance = chance * (ProcMod / 100.0f);
|
else if(effect_id == SE_LimitToSkill && base1 <= HIGHEST_SKILL) {
|
||||||
//
|
|
||||||
// if (zone->random.Roll(final_chance)) {
|
if (CanProc && base1 == skill && IsValidSpell(proc_spell_id)) {
|
||||||
// ExecWeaponProc(nullptr, proc_spell_id, on);
|
float final_chance = chance * (ProcMod / 100.0f);
|
||||||
// CanProc = false;
|
|
||||||
// break;
|
if (zone->random.Roll(final_chance)) {
|
||||||
// }
|
ExecWeaponProc(nullptr, proc_spell_id, on);
|
||||||
// }
|
CanProc = false;
|
||||||
// }
|
break;
|
||||||
// else {
|
}
|
||||||
// proc_spell_id = 0;
|
}
|
||||||
// ProcMod = 0;
|
}
|
||||||
// }
|
else {
|
||||||
//}
|
proc_spell_id = 0;
|
||||||
|
ProcMod = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -640,14 +640,16 @@ void Client::CalcAABonuses(StatBonuses *newbon)
|
|||||||
memset(newbon, 0, sizeof(StatBonuses)); // start fresh
|
memset(newbon, 0, sizeof(StatBonuses)); // start fresh
|
||||||
|
|
||||||
for (const auto &aa : aa_ranks) {
|
for (const auto &aa : aa_ranks) {
|
||||||
auto ability = zone->GetAlternateAdvancementAbility(aa.first);
|
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||||
// zone doesn't know about this! bad data some where
|
auto ability = ability_rank.first;
|
||||||
if (!ability)
|
auto rank = ability_rank.second;
|
||||||
continue;
|
|
||||||
|
if(!ability) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto rank = ability->GetRankByPointsSpent(aa.second.first);
|
|
||||||
// bad data or no effects
|
// bad data or no effects
|
||||||
if (!rank || rank->effects.empty())
|
if (rank->effects.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ApplyAABonuses(*rank, newbon);
|
ApplyAABonuses(*rank, newbon);
|
||||||
|
|||||||
@ -774,27 +774,23 @@ public:
|
|||||||
void AddAAPoints(uint32 points) { m_pp.aapoints += points; SendAlternateAdvancementStats(); }
|
void AddAAPoints(uint32 points) { m_pp.aapoints += points; SendAlternateAdvancementStats(); }
|
||||||
int GetAAPoints() { return m_pp.aapoints; }
|
int GetAAPoints() { return m_pp.aapoints; }
|
||||||
int GetSpentAA() { return m_pp.aapoints_spent; }
|
int GetSpentAA() { return m_pp.aapoints_spent; }
|
||||||
|
|
||||||
//old AA Methods
|
//old AA methods that we still use
|
||||||
void ResetAA();
|
void ResetAA();
|
||||||
|
void RefundAA();
|
||||||
void SendClearAA();
|
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 GetMaxAAXP(void) const { return max_AAXP; }
|
||||||
inline uint32 GetAAXP() const { return m_pp.expAA; }
|
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 EnableAAEffect(aaEffectType type, uint32 duration = 0);
|
||||||
void DisableAAEffect(aaEffectType type);
|
void DisableAAEffect(aaEffectType type);
|
||||||
bool CheckAAEffect(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();
|
int32 acmod();
|
||||||
|
|
||||||
// Item methods
|
// Item methods
|
||||||
|
|||||||
@ -960,6 +960,7 @@ public:
|
|||||||
|
|
||||||
//aa new
|
//aa new
|
||||||
uint32 GetAA(uint32 rank_id, uint32 *charges = nullptr) const;
|
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);
|
bool SetAA(uint32 rank_id, uint32 new_value, uint32 charges = 0);
|
||||||
void ClearAAs() { aa_ranks.clear(); }
|
void ClearAAs() { aa_ranks.clear(); }
|
||||||
bool CanUseAlternateAdvancementRank(AA::Rank *rank);
|
bool CanUseAlternateAdvancementRank(AA::Rank *rank);
|
||||||
|
|||||||
@ -4077,34 +4077,7 @@ XS(XS_Client_RefundAA) {
|
|||||||
if(THIS == nullptr)
|
if(THIS == nullptr)
|
||||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||||
|
|
||||||
//old aa
|
THIS->RefundAA();
|
||||||
//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
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4149,43 +4149,6 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
|
|||||||
CalcBonuses();
|
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)
|
int16 Client::CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id)
|
||||||
{
|
{
|
||||||
const SPDat_Spell_Struct &spell = spells[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)
|
if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
auto ability = zone->GetAlternateAdvancementAbility(aa.first);
|
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||||
if (!ability)
|
auto ability = ability_rank.first;
|
||||||
continue;
|
auto rank = ability_rank.second;
|
||||||
|
|
||||||
auto rank = ability->GetRankByPointsSpent(aa.second.first);
|
if(!ability) {
|
||||||
if (!rank || rank->effects.empty())
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rank->effects.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
proc_spellid = CalcAAFocus(type, *rank, spell_id);
|
proc_spellid = CalcAAFocus(type, *rank, spell_id);
|
||||||
@ -5474,12 +5440,15 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id) {
|
|||||||
int16 Total3 = 0;
|
int16 Total3 = 0;
|
||||||
|
|
||||||
for (const auto &aa : aa_ranks) {
|
for (const auto &aa : aa_ranks) {
|
||||||
auto ability = zone->GetAlternateAdvancementAbility(aa.first);
|
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
|
||||||
if (!ability)
|
auto ability = ability_rank.first;
|
||||||
continue;
|
auto rank = ability_rank.second;
|
||||||
|
|
||||||
auto rank = ability->GetRankByPointsSpent(aa.second.first);
|
if(!ability) {
|
||||||
if (!rank || rank->effects.empty())
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rank->effects.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Total3 = CalcAAFocus(type, *rank, spell_id);
|
Total3 = CalcAAFocus(type, *rank, spell_id);
|
||||||
|
|||||||
@ -119,6 +119,7 @@ public:
|
|||||||
AA::Ability *GetAlternateAdvancementAbility(int id);
|
AA::Ability *GetAlternateAdvancementAbility(int id);
|
||||||
AA::Ability *GetAlternateAdvancementAbilityByRank(int rank_id);
|
AA::Ability *GetAlternateAdvancementAbilityByRank(int rank_id);
|
||||||
AA::Rank *GetAlternateAdvancementRank(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);
|
void LoadZoneDoors(const char* zone, int16 version);
|
||||||
bool LoadZoneObjects();
|
bool LoadZoneObjects();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user