Added AA grant to quest system, fixed a bug here or there noticed incrementaa needs to be fixed or removed

This commit is contained in:
KimLS 2015-06-17 12:05:09 -07:00
parent c445f63186
commit 065363480f
9 changed files with 171 additions and 11 deletions

View File

@ -1015,6 +1015,7 @@ void Client::PurchaseAlternateAdvancementRank(int rank_id) {
NotifyNewTitlesAvailable(); NotifyNewTitlesAvailable();
} }
//need to rewrite this
void Client::IncrementAlternateAdvancementRank(int rank_id) { void Client::IncrementAlternateAdvancementRank(int rank_id) {
AA::Rank *rank = zone->GetAlternateAdvancementRank(rank_id); AA::Rank *rank = zone->GetAlternateAdvancementRank(rank_id);
if(!rank) { if(!rank) {
@ -1139,8 +1140,6 @@ void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) {
if(!SpellFinished(rank->spell, entity_list.GetMob(target_id), 10, -1, -1, spells[rank->spell].ResistDiff, false)) { if(!SpellFinished(rank->spell, entity_list.GetMob(target_id), 10, -1, -1, spells[rank->spell].ResistDiff, false)) {
return; return;
} }
CastToClient()->GetPTimers().Start(rank->spell_type, cooldown);
SendAlternateAdvancementTimer(rank->spell_type, 0, 0);
ExpendAlternateAdvancementCharge(ability->id); ExpendAlternateAdvancementCharge(ability->id);
} else { } else {
if(!CastSpell(rank->spell, target_id, USE_ITEM_SPELL_SLOT, -1, -1, 0, -1, rank->spell_type + pTimerAAStart, cooldown, nullptr, rank->id)) { if(!CastSpell(rank->spell, target_id, USE_ITEM_SPELL_SLOT, -1, -1, 0, -1, rank->spell_type + pTimerAAStart, cooldown, nullptr, rank->id)) {
@ -1312,6 +1311,8 @@ uint32 Mob::GetAAByAAID(uint32 aa_id, uint32 *charges) const {
return iter->second.first; return iter->second.first;
} }
} }
return 0;
} }
bool Mob::SetAA(uint32 rank_id, uint32 new_value, uint32 charges) { bool Mob::SetAA(uint32 rank_id, uint32 new_value, uint32 charges) {
@ -1474,9 +1475,14 @@ void Zone::LoadAlternateAdvancement() {
current->total_cost = current->cost + current->prev->total_cost; current->total_cost = current->cost + current->prev->total_cost;
} }
else { else {
current->prev_id = -1;
current->total_cost = current->cost; current->total_cost = current->cost;
} }
if(!current->next) {
current->next_id = -1;
}
i++; i++;
current = current->next; current = current->next;
} }
@ -1490,7 +1496,8 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
{ {
Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Abilities..."); Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Abilities...");
abilities.clear(); abilities.clear();
std::string query = "SELECT id, name, category, classes, races, deities, drakkin_heritage, status, type, charges, grant_only, first_rank_id FROM aa_ability"; std::string query = "SELECT id, name, category, classes, races, deities, drakkin_heritage, status, type, charges, "
"grant_only, first_rank_id FROM aa_ability WHERE enabled = 1";
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if(results.Success()) { if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) { for(auto row = results.begin(); row != results.end(); ++row) {
@ -1522,7 +1529,7 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Ranks..."); Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Ranks...");
ranks.clear(); ranks.clear();
query = "SELECT id, upper_hotkey_sid, lower_hotkey_sid, title_sid, desc_sid, cost, level_req, spell, spell_type, recast_time, " query = "SELECT id, upper_hotkey_sid, lower_hotkey_sid, title_sid, desc_sid, cost, level_req, spell, spell_type, recast_time, "
"prev_id, next_id, expansion, account_time_required FROM aa_ranks"; "prev_id, next_id, expansion FROM aa_ranks";
results = QueryDatabase(query); results = QueryDatabase(query);
if(results.Success()) { if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) { for(auto row = results.begin(); row != results.end(); ++row) {
@ -1540,7 +1547,6 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
rank->prev_id = atoi(row[10]); rank->prev_id = atoi(row[10]);
rank->next_id = atoi(row[11]); rank->next_id = atoi(row[11]);
rank->expansion = atoi(row[12]); rank->expansion = atoi(row[12]);
rank->account_time_required = atoul(row[13]);
rank->base_ability = nullptr; rank->base_ability = nullptr;
rank->total_cost = 0; rank->total_cost = 0;
rank->next = nullptr; rank->next = nullptr;
@ -1606,3 +1612,42 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
return true; return true;
} }
void Mob::GrantAlternateAdvancementAbility(int aa_id, int points) {
if(!zone)
return;
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa_id, points);
auto ability = ability_rank.first;
auto rank = ability_rank.second;
if(!ability) {
return;
}
if(ability->charges > 0) {
return;
}
if(!ability->grant_only) {
return;
}
if(!CanUseAlternateAdvancementRank(rank)) {
return;
}
SetAA(ability->first_rank_id, rank->current_value, 0);
if(IsClient()) {
Client *c = CastToClient();
if(rank->next) {
c->SendAlternateAdvancementRank(rank->base_ability->id, rank->next->current_value);
}
c->SendAlternateAdvancementPoints();
c->SendAlternateAdvancementStats();
c->CalcBonuses();
}
}

View File

@ -39,7 +39,6 @@ public:
~Ability() { } ~Ability() { }
Rank *GetMaxRank(); Rank *GetMaxRank();
Rank *GetRankByLevel(int level);
Rank *GetRankByPointsSpent(int current_level); Rank *GetRankByPointsSpent(int current_level);
int GetMaxLevel(Mob *who); int GetMaxLevel(Mob *who);

View File

@ -45,7 +45,6 @@ public:
Rank *next; Rank *next;
int current_value; int current_value;
int expansion; int expansion;
uint32 account_time_required;
int total_cost; int total_cost;
Ability *base_ability; Ability *base_ability;
std::vector<RankEffect> effects; std::vector<RankEffect> effects;

View File

@ -533,6 +533,10 @@ bool Client::SaveAA() {
if(!ability) if(!ability)
continue; continue;
if(ability->grant_only) {
continue;
}
if(rank.second.first > 0) { if(rank.second.first > 0) {
AA::Rank *r = ability->GetRankByPointsSpent(rank.second.first); AA::Rank *r = ability->GetRankByPointsSpent(rank.second.first);

View File

@ -1195,6 +1195,26 @@ int Lua_Mob::GetAA(int id) {
return self->GetAA(id); return self->GetAA(id);
} }
int Lua_Mob::GetAAByAAID(int id) {
Lua_Safe_Call_Int();
return self->GetAAByAAID(id);
}
bool Lua_Mob::SetAA(int rank_id, int new_value) {
Lua_Safe_Call_Bool();
return self->SetAA(rank_id, new_value);
}
bool Lua_Mob::SetAA(int rank_id, int new_value, int charges) {
Lua_Safe_Call_Bool();
return self->SetAA(rank_id, new_value, charges);
}
void Lua_Mob::GrantAlternateAdvancementAbility(int aa_id, int points) {
Lua_Safe_Call_Void();
self->GrantAlternateAdvancementAbility(aa_id, points);
}
bool Lua_Mob::DivineAura() { bool Lua_Mob::DivineAura() {
Lua_Safe_Call_Bool(); Lua_Safe_Call_Bool();
return self->DivineAura(); return self->DivineAura();
@ -2074,6 +2094,10 @@ luabind::scope lua_register_mob() {
.def("CheckHealAggroAmount", (int(Lua_Mob::*)(int))&Lua_Mob::CheckHealAggroAmount) .def("CheckHealAggroAmount", (int(Lua_Mob::*)(int))&Lua_Mob::CheckHealAggroAmount)
.def("CheckHealAggroAmount", (int(Lua_Mob::*)(int,uint32))&Lua_Mob::CheckHealAggroAmount) .def("CheckHealAggroAmount", (int(Lua_Mob::*)(int,uint32))&Lua_Mob::CheckHealAggroAmount)
.def("GetAA", (int(Lua_Mob::*)(int))&Lua_Mob::GetAA) .def("GetAA", (int(Lua_Mob::*)(int))&Lua_Mob::GetAA)
.def("GetAAByAAID", (int(Lua_Mob::*)(int))&Lua_Mob::GetAAByAAID)
.def("SetAA", (bool(Lua_Mob::*)(int,int))&Lua_Mob::SetAA)
.def("SetAA", (bool(Lua_Mob::*)(int,int,int))&Lua_Mob::SetAA)
.def("GrantAlternateAdvancementAbility", (void(Lua_Mob::*)(int, int))&Lua_Mob::GrantAlternateAdvancementAbility)
.def("DivineAura", (bool(Lua_Mob::*)(void))&Lua_Mob::DivineAura) .def("DivineAura", (bool(Lua_Mob::*)(void))&Lua_Mob::DivineAura)
.def("SetOOCRegen", (void(Lua_Mob::*)(int))&Lua_Mob::SetOOCRegen) .def("SetOOCRegen", (void(Lua_Mob::*)(int))&Lua_Mob::SetOOCRegen)
.def("GetEntityVariable", (const char*(Lua_Mob::*)(const char*))&Lua_Mob::GetEntityVariable) .def("GetEntityVariable", (const char*(Lua_Mob::*)(const char*))&Lua_Mob::GetEntityVariable)

View File

@ -249,6 +249,10 @@ public:
int CheckHealAggroAmount(int spell_id); int CheckHealAggroAmount(int spell_id);
int CheckHealAggroAmount(int spell_id, uint32 heal_possible); int CheckHealAggroAmount(int spell_id, uint32 heal_possible);
int GetAA(int id); int GetAA(int id);
int GetAAByAAID(int id);
bool SetAA(int rank_id, int new_value);
bool SetAA(int rank_id, int new_value, int charges);
void GrantAlternateAdvancementAbility(int aa_id, int points);
bool DivineAura(); bool DivineAura();
void SetOOCRegen(int regen); void SetOOCRegen(int regen);
const char* GetEntityVariable(const char *name); const char* GetEntityVariable(const char *name);

View File

@ -969,6 +969,7 @@ public:
void ExpendAlternateAdvancementCharge(uint32 aa_id); void ExpendAlternateAdvancementCharge(uint32 aa_id);
void CalcAABonuses(StatBonuses* newbon); void CalcAABonuses(StatBonuses* newbon);
void ApplyAABonuses(const AA::Rank &rank, StatBonuses* newbon); void ApplyAABonuses(const AA::Rank &rank, StatBonuses* newbon);
void GrantAlternateAdvancementAbility(int aa_id, int points);
protected: protected:
void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillUseTypes attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic); void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillUseTypes attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic);

View File

@ -6360,12 +6360,12 @@ XS(XS_Mob_GetAA)
{ {
dXSARGS; dXSARGS;
if (items != 2) if (items != 2)
Perl_croak(aTHX_ "Usage: Mob::GetAA(THIS, aa_id)"); Perl_croak(aTHX_ "Usage: Mob::GetAA(THIS, rank_id)");
{ {
Mob * THIS; Mob * THIS;
uint32 RETVAL; uint32 RETVAL;
dXSTARG; dXSTARG;
uint32 aa_id = (uint32)SvUV(ST(1)); uint32 rank_id = (uint32)SvUV(ST(1));
if (sv_derived_from(ST(0), "Mob")) { if (sv_derived_from(ST(0), "Mob")) {
IV tmp = SvIV((SV*)SvRV(ST(0))); IV tmp = SvIV((SV*)SvRV(ST(0)));
@ -6376,12 +6376,93 @@ XS(XS_Mob_GetAA)
if(THIS == nullptr) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetAA(aa_id); RETVAL = THIS->GetAA(rank_id);
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
} }
XSRETURN(1); XSRETURN(1);
} }
XS(XS_Mob_GetAAByAAID); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mob_GetAAByAAID)
{
dXSARGS;
if(items != 2)
Perl_croak(aTHX_ "Usage: Mob::GetAAByAAID(THIS, aa_id)");
{
Mob * THIS;
uint32 RETVAL;
dXSTARG;
uint32 aa_id = (uint32)SvUV(ST(1));
if(sv_derived_from(ST(0), "Mob")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Mob *, tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Mob");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetAAByAAID(aa_id);
XSprePUSH; PUSHu((UV)RETVAL);
}
XSRETURN(1);
}
XS(XS_Mob_SetAA); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mob_SetAA)
{
dXSARGS;
if(items < 3 || items > 4)
Perl_croak(aTHX_ "Usage: Mob::SetAA(THIS, aa_id, points, [charges])");
{
Mob * THIS;
bool RETVAL;
int aa_id = (int)SvIV(ST(1));
int points = (int)SvIV(ST(2));
int charges = (items == 4) ? (int)SvIV(ST(3)) : 0;
if(sv_derived_from(ST(0), "Mob")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Mob *, tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Mob");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->SetAA(aa_id, points, charges);
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_Mob_GrantAlternateAdvancementAbility); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mob_GrantAlternateAdvancementAbility)
{
dXSARGS;
if(items != 3)
Perl_croak(aTHX_ "Usage: Mob::GrantAlternateAdvancementAbility(THIS, aa_id, points)");
{
Mob * THIS;
int aa_id = (int)SvIV(ST(1));
int points = (int)SvIV(ST(2));
if(sv_derived_from(ST(0), "Mob")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Mob *, tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Mob");
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
THIS->GrantAlternateAdvancementAbility(aa_id, points);
}
XSRETURN_EMPTY;
}
XS(XS_Mob_DivineAura); /* prototype to pass -Wmissing-prototypes */ XS(XS_Mob_DivineAura); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mob_DivineAura) XS(XS_Mob_DivineAura)
{ {
@ -8625,6 +8706,9 @@ XS(boot_Mob)
newXSproto(strcpy(buf, "CheckAggroAmount"), XS_Mob_CheckAggroAmount, file, "$$"); newXSproto(strcpy(buf, "CheckAggroAmount"), XS_Mob_CheckAggroAmount, file, "$$");
newXSproto(strcpy(buf, "CheckHealAggroAmount"), XS_Mob_CheckHealAggroAmount, file, "$$"); newXSproto(strcpy(buf, "CheckHealAggroAmount"), XS_Mob_CheckHealAggroAmount, file, "$$");
newXSproto(strcpy(buf, "GetAA"), XS_Mob_GetAA, file, "$$"); newXSproto(strcpy(buf, "GetAA"), XS_Mob_GetAA, file, "$$");
newXSproto(strcpy(buf, "GetAAByAAID"), XS_Mob_GetAAByAAID, file, "$$");
newXSproto(strcpy(buf, "SetAA"), XS_Mob_SetAA, file, "$$$;$");
newXSproto(strcpy(buf, "GrantAlternateAdvancementAbility"), XS_Mob_GrantAlternateAdvancementAbility, file, "$$$");
newXSproto(strcpy(buf, "DivineAura"), XS_Mob_DivineAura, file, "$"); newXSproto(strcpy(buf, "DivineAura"), XS_Mob_DivineAura, file, "$");
newXSproto(strcpy(buf, "AddFeignMemory"), XS_Mob_AddFeignMemory, file, "$$"); newXSproto(strcpy(buf, "AddFeignMemory"), XS_Mob_AddFeignMemory, file, "$$");
newXSproto(strcpy(buf, "RemoveFromFeignMemory"), XS_Mob_RemoveFromFeignMemory, file, "$$"); newXSproto(strcpy(buf, "RemoveFromFeignMemory"), XS_Mob_RemoveFromFeignMemory, file, "$$");

View File

@ -820,8 +820,8 @@ void Mob::InterruptSpell(uint16 message, uint16 color, uint16 spellid)
if(casting_spell_aa_id && IsClient()) { //Rest AA Timer on failed cast if(casting_spell_aa_id && IsClient()) { //Rest AA Timer on failed cast
AA::Rank *rank = zone->GetAlternateAdvancementRank(casting_spell_aa_id); AA::Rank *rank = zone->GetAlternateAdvancementRank(casting_spell_aa_id);
if(rank) { if(rank) {
CastToClient()->Message_StringID(MT_SpellFailure, ABILITY_FAILED);
CastToClient()->SendAlternateAdvancementTimer(rank->spell_type, 0, 0x7fffffff); CastToClient()->SendAlternateAdvancementTimer(rank->spell_type, 0, 0x7fffffff);
CastToClient()->Message_StringID(15, ABILITY_FAILED);
CastToClient()->GetPTimers().Clear(&database, rank->spell_type + pTimerAAStart); CastToClient()->GetPTimers().Clear(&database, rank->spell_type + pTimerAAStart);
} }
} }