Added deity and race checking to AAs, doubled over the sanity check code and found a mistake, added code to make boats move smoother after loading into oot 50 times and seeing it skip every time.

This commit is contained in:
KimLS 2015-06-12 02:56:51 -07:00
parent afaa9ee6c9
commit e5d1e98793
5 changed files with 72 additions and 49 deletions

View File

@ -23,7 +23,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
#include "../common/races.h" #include "../common/races.h"
#include "../common/spdat.h" #include "../common/spdat.h"
#include "../common/string_util.h" #include "../common/string_util.h"
#include "../common/deity.h"
#include "aa.h" #include "aa.h"
#include "client.h" #include "client.h"
#include "corpse.h" #include "corpse.h"
@ -1279,7 +1279,7 @@ void Client::SendAlternateAdvancementTable() {
uint32 charges = 0; uint32 charges = 0;
auto ranks = GetAA(aa.second->first_rank_id, &charges); auto ranks = GetAA(aa.second->first_rank_id, &charges);
if(ranks) { if(ranks) {
if(aa.second->GetMaxLevel() == ranks) { if(aa.second->GetMaxLevel(this) == ranks) {
SendAlternateAdvancementRank(aa.first, ranks); SendAlternateAdvancementRank(aa.first, ranks);
} else { } else {
SendAlternateAdvancementRank(aa.first, ranks); SendAlternateAdvancementRank(aa.first, ranks);
@ -1330,7 +1330,7 @@ void Client::SendAlternateAdvancementRank(int aa_id, int level) {
aai->classes = ability->classes; aai->classes = ability->classes;
aai->level_req = rank->level_req; aai->level_req = rank->level_req;
aai->current_level = level; aai->current_level = level;
aai->max_level = ability->GetMaxLevel(); aai->max_level = ability->GetMaxLevel(this);
aai->prev_id = rank->prev_id; aai->prev_id = rank->prev_id;
if(rank->next && !CanUseAlternateAdvancementRank(rank->next)) { if(rank->next && !CanUseAlternateAdvancementRank(rank->next)) {
@ -1450,9 +1450,11 @@ void Client::PurchaseAlternateAdvancementRank(int rank_id) {
uint32 charges = 0; uint32 charges = 0;
GetAA(rank_id, &charges); GetAA(rank_id, &charges);
if(charges == 0) { if(charges > 0) {
SetAA(rank_id, rank->current_value, rank->base_ability->charges); return;
} }
SetAA(rank_id, rank->current_value, rank->base_ability->charges);
} else { } else {
SetAA(rank_id, rank->current_value, 0); SetAA(rank_id, rank->current_value, 0);
@ -1781,7 +1783,7 @@ bool Mob::SetAA(uint32 rank_id, uint32 new_value, uint32 charges) {
return false; return false;
} }
if(new_value > ability->GetMaxLevel()) { if(new_value > ability->GetMaxLevel(this)) {
return false; return false;
} }
@ -1817,29 +1819,44 @@ bool Mob::CanUseAlternateAdvancementRank(AA::Rank *rank) {
} }
} }
//I might add a races behind the scenes field to take care of this if(!(RuleI(World, ExpansionSettings) & (1 << rank->expansion))) {
// Check for racial/Drakkin blood line AAs return false;
if(ability->category == 8)
{
uint32 client_race = GetBaseRace();
// Drakkin Bloodlines
if(rank->expansion > 522)
{
if(client_race != 522)
return false;
int heritage = this->GetDrakkinHeritage() + 523; // 523 = Drakkin Race(522) + Bloodline
if(heritage != rank->expansion)
return false;
}
else if(client_race != rank->expansion)
{
return false;
}
} }
auto race = GetArrayRace(GetBaseRace());
race = race > 16 ? 1 : race;
if(!(ability->races & (1 << (race - 1)))) {
return false;
}
auto deity = ConvertDeityToBitDeity((DeityTypes)GetDeity());
if(!(ability->deities & deity)) {
return false;
}
// Check for racial/Drakkin blood line AAs
//Commented this out for now, will add a drakkin heritage field later
//if(ability->category == 8)
//{
// uint32 client_race = GetBaseRace();
//
// // Drakkin Bloodlines
// if(rank->expansion > 522)
// {
// if(client_race != 522)
// return false;
//
// int heritage = this->GetDrakkinHeritage() + 523; // 523 = Drakkin Race(522) + Bloodline
//
// if(heritage != rank->expansion)
// return false;
// }
// else if(client_race != rank->expansion)
// {
// return false;
// }
//}
return true; return true;
} }
@ -1858,10 +1875,6 @@ bool Mob::CanPurchaseAlternateAdvancementRank(AA::Rank *rank, bool check_price)
return false; return false;
} }
if(!(RuleI(World, ExpansionSettings) & (1 << rank->expansion))) {
return false;
}
//check level req //check level req
if(rank->level_req > GetLevel()) { if(rank->level_req > GetLevel()) {
return false; return false;
@ -1940,8 +1953,6 @@ void Zone::LoadAlternateAdvancement() {
i++; i++;
current = current->next; current = current->next;
} }
ability.second->GetMaxLevel(true);
} }
Log.Out(Logs::General, Logs::Status, "Loaded Alternate Advancement Data"); Log.Out(Logs::General, Logs::Status, "Loaded Alternate Advancement Data");
@ -1952,7 +1963,7 @@ 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, type, charges, grant_only, first_rank_id FROM aa_ability"; std::string query = "SELECT id, name, category, classes, races, deities, type, charges, grant_only, first_rank_id FROM aa_ability";
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) {
@ -1960,11 +1971,14 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
ability->id = atoi(row[0]); ability->id = atoi(row[0]);
ability->name = row[1]; ability->name = row[1];
ability->category = atoi(row[2]); ability->category = atoi(row[2]);
ability->classes = atoi(row[3]); //EQ client has classes left shifted by one bit for some odd reason
ability->type = atoi(row[4]); ability->classes = atoi(row[3]) << 1;
ability->charges = atoi(row[5]); ability->races = atoi(row[4]);
ability->grant_only = atoi(row[6]) != 0 ? true : false; ability->deities = atoi(row[5]);
ability->first_rank_id = atoi(row[7]); ability->type = atoi(row[6]);
ability->charges = atoi(row[7]);
ability->grant_only = atoi(row[8]) != 0 ? true : false;
ability->first_rank_id = atoi(row[9]);
ability->first = nullptr; ability->first = nullptr;
abilities[ability->id] = std::unique_ptr<AA::Ability>(ability); abilities[ability->id] = std::unique_ptr<AA::Ability>(ability);

View File

@ -18,6 +18,7 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/types.h" #include "../common/types.h"
#include "masterentity.h"
#include "aa_ability.h" #include "aa_ability.h"
AA::Rank *AA::Ability::GetMaxRank() { AA::Rank *AA::Ability::GetMaxRank() {
@ -53,16 +54,17 @@ AA::Rank *AA::Ability::GetRankByPointsSpent(int current_level) {
return current; return current;
} }
int AA::Ability::GetMaxLevel(bool force_calc) { int AA::Ability::GetMaxLevel(Mob *who) {
if(!force_calc) int max_level = 0;
return max_level;
max_level = 0;
Rank *current = first; Rank *current = first;
while(current) { while(current) {
if(!who->CanUseAlternateAdvancementRank(current)) {
return max_level;
}
max_level++; max_level++;
current = current->next; current = current->next;
} }
return max_level; return max_level;
} }

View File

@ -27,6 +27,8 @@
#include "aa_rank_prereqs.h" #include "aa_rank_prereqs.h"
#include "aa_rank.h" #include "aa_rank.h"
class Mob;
namespace AA namespace AA
{ {
@ -39,17 +41,18 @@ public:
Rank *GetMaxRank(); Rank *GetMaxRank();
Rank *GetRankByLevel(int level); Rank *GetRankByLevel(int level);
Rank *GetRankByPointsSpent(int current_level); Rank *GetRankByPointsSpent(int current_level);
int GetMaxLevel(bool force_calc = false); int GetMaxLevel(Mob *who);
int id; int id;
std::string name; std::string name;
int category; int category;
int classes; int classes;
int races;
int deities;
bool grant_only; bool grant_only;
int type; int type;
int charges; int charges;
int first_rank_id; int first_rank_id;
int max_level;
Rank *first; Rank *first;
}; };

View File

@ -1143,6 +1143,10 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
else else
ns->spawn.flymode = flymode; ns->spawn.flymode = flymode;
if(IsBoat()) {
ns->spawn.flymode = 1;
}
ns->spawn.lastName[0] = '\0'; ns->spawn.lastName[0] = '\0';
strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName)); strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName));

View File

@ -212,7 +212,7 @@ void NPC::UpdateWaypoint(int wp_index)
Log.Out(Logs::Detail, Logs::AI, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, m_CurrentWayPoint.w); Log.Out(Logs::Detail, Logs::AI, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, m_CurrentWayPoint.w);
//fix up pathing Z //fix up pathing Z
if(zone->HasMap() && RuleB(Map, FixPathingZAtWaypoints)) if(zone->HasMap() && RuleB(Map, FixPathingZAtWaypoints) && !IsBoat())
{ {
if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() || if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() ||
@ -521,7 +521,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
} }
bool send_update = false; bool send_update = false;
int compare_steps = IsBoat() ? 1 : 20; int compare_steps = 20;
if(tar_ndx < compare_steps && m_TargetLocation.x==x && m_TargetLocation.y==y) { if(tar_ndx < compare_steps && m_TargetLocation.x==x && m_TargetLocation.y==y) {
float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_x = m_Position.x + m_TargetV.x*tar_vector;