mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Quest API] Add EVENT_AA_BUY and EVENT_AA_GAIN to Perl/Lua. (#2504)
# Perl - Add EVENT_AA_BUY to Perl. - Exports `$aa_cost`, `$aa_id`, `$aa_previous_id`, and `$aa_next_id` - Add EVENT_AA_GAIN to Perl. - Exports `$aa_gained` - Add quest::getaaname(aa_id) to Perl. # Lua - Add event_aa_buy to Lua. - Exports `e.aa_cost`, `e.aa_id`, `e.aa_previous_id`, and `e.aa_next_id` - Add event_aa_gain to Lua. - Exports `e.aa_gained` - Add eq.get_aa_name(aa_id) to Lua.
This commit is contained in:
+57
-26
@@ -29,6 +29,7 @@ Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
|
||||
#include "groups.h"
|
||||
#include "mob.h"
|
||||
#include "queryserv.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "raids.h"
|
||||
#include "string_ids.h"
|
||||
#include "titles.h"
|
||||
@@ -1147,65 +1148,95 @@ bool Client::GrantAlternateAdvancementAbility(int aa_id, int points, bool ignore
|
||||
}
|
||||
|
||||
void Client::FinishAlternateAdvancementPurchase(AA::Rank *rank, bool ignore_cost) {
|
||||
int rank_id = rank->base_ability->first_rank_id;
|
||||
auto rank_id = rank->base_ability->first_rank_id;
|
||||
|
||||
if(rank->base_ability->charges > 0) {
|
||||
if (rank->base_ability->charges) {
|
||||
uint32 charges = 0;
|
||||
GetAA(rank_id, &charges);
|
||||
|
||||
if(charges > 0) {
|
||||
if (charges) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetAA(rank_id, rank->current_value, rank->base_ability->charges);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SetAA(rank_id, rank->current_value, 0);
|
||||
|
||||
//if not max then send next aa
|
||||
if(rank->next) {
|
||||
if (rank->next) {
|
||||
SendAlternateAdvancementRank(rank->base_ability->id, rank->next->current_value);
|
||||
}
|
||||
}
|
||||
|
||||
int cost = !ignore_cost ? rank->cost : 0;
|
||||
auto cost = !ignore_cost ? rank->cost : 0;
|
||||
|
||||
m_pp.aapoints -= cost ;
|
||||
m_pp.aapoints -= static_cast<uint32>(cost);
|
||||
SaveAA();
|
||||
|
||||
SendAlternateAdvancementPoints();
|
||||
SendAlternateAdvancementStats();
|
||||
|
||||
if(rank->prev) {
|
||||
MessageString(Chat::Yellow, AA_IMPROVE,
|
||||
std::to_string(rank->title_sid).c_str(),
|
||||
std::to_string(rank->prev->current_value).c_str(),
|
||||
std::to_string(cost).c_str(),
|
||||
cost == 1 ? std::to_string(AA_POINT).c_str() : std::to_string(AA_POINTS).c_str());
|
||||
if (rank->prev) {
|
||||
MessageString(
|
||||
Chat::Yellow,
|
||||
AA_IMPROVE,
|
||||
std::to_string(rank->title_sid).c_str(),
|
||||
std::to_string(rank->prev->current_value).c_str(),
|
||||
std::to_string(cost).c_str(),
|
||||
cost == 1 ? std::to_string(AA_POINT).c_str() : std::to_string(AA_POINTS).c_str()
|
||||
);
|
||||
|
||||
/* QS: Player_Log_AA_Purchases */
|
||||
if(RuleB(QueryServ, PlayerLogAAPurchases)) {
|
||||
std::string event_desc = StringFormat("Ranked AA Purchase :: aa_id:%i at cost:%i in zoneid:%i instid:%i", rank->id, cost, GetZoneID(), GetInstanceID());
|
||||
if (RuleB(QueryServ, PlayerLogAAPurchases)) {
|
||||
const auto event_desc = fmt::format(
|
||||
"Ranked AA Purchase :: aa_id:{} at cost:{} in zoneid:{} instid:{}",
|
||||
rank->id,
|
||||
cost,
|
||||
GetZoneID(),
|
||||
GetInstanceID()
|
||||
);
|
||||
|
||||
QServ->PlayerLogEvent(Player_Log_AA_Purchases, CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MessageString(Chat::Yellow, AA_GAIN_ABILITY,
|
||||
std::to_string(rank->title_sid).c_str(),
|
||||
std::to_string(cost).c_str(),
|
||||
cost == 1 ? std::to_string(AA_POINT).c_str() : std::to_string(AA_POINTS).c_str());
|
||||
} else {
|
||||
MessageString(
|
||||
Chat::Yellow,
|
||||
AA_GAIN_ABILITY,
|
||||
std::to_string(rank->title_sid).c_str(),
|
||||
std::to_string(cost).c_str(),
|
||||
cost == 1 ? std::to_string(AA_POINT).c_str() : std::to_string(AA_POINTS).c_str()
|
||||
);
|
||||
|
||||
/* QS: Player_Log_AA_Purchases */
|
||||
if(RuleB(QueryServ, PlayerLogAAPurchases)) {
|
||||
std::string event_desc = StringFormat("Initial AA Purchase :: aa_id:%i at cost:%i in zoneid:%i instid:%i", rank->id, cost, GetZoneID(), GetInstanceID());
|
||||
if (RuleB(QueryServ, PlayerLogAAPurchases)) {
|
||||
const auto event_desc = fmt::format(
|
||||
"Initial AA Purchase :: aa_id:{} at cost:{} in zoneid:{} instid:{}",
|
||||
rank->id,
|
||||
cost,
|
||||
GetZoneID(),
|
||||
GetInstanceID()
|
||||
);
|
||||
|
||||
QServ->PlayerLogEvent(Player_Log_AA_Purchases, CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
const auto export_string = fmt::format(
|
||||
"{} {} {} {}",
|
||||
cost,
|
||||
rank->id,
|
||||
rank->prev_id,
|
||||
rank->next_id
|
||||
);
|
||||
|
||||
parse->EventPlayer(EVENT_AA_BUY, this, export_string, 0);
|
||||
|
||||
CalcBonuses();
|
||||
|
||||
if(cost > 0) {
|
||||
if(title_manager.IsNewAATitleAvailable(m_pp.aapoints_spent, GetBaseClass()))
|
||||
if (cost) {
|
||||
if (title_manager.IsNewAATitleAvailable(m_pp.aapoints_spent, GetBaseClass())) {
|
||||
NotifyNewTitlesAvailable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user