Switched out our kinda juryrigged vector types for glm::vec types since we use that as a 3d math library already but never switched out the types

This commit is contained in:
KimLS 2015-01-23 00:01:10 -08:00
parent 03286f540a
commit 269d56e1d0
68 changed files with 1524 additions and 1692 deletions

View File

@ -546,11 +546,11 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u
if(summon_count > MAX_SWARM_PETS)
summon_count = MAX_SWARM_PETS;
static const xy_location swarmPetLocations[MAX_SWARM_PETS] = {
xy_location(5, 5), xy_location(-5, 5), xy_location(5, -5), xy_location(-5, -5),
xy_location(10, 10), xy_location(-10, 10), xy_location(10, -10), xy_location(-10, -10),
xy_location(8, 8), xy_location(-8, 8), xy_location(8, -8), xy_location(-8, -8)
};
static const glm::vec2 swarmPetLocations[MAX_SWARM_PETS] = {
glm::vec2(5, 5), glm::vec2(-5, 5), glm::vec2(5, -5), glm::vec2(-5, -5),
glm::vec2(10, 10), glm::vec2(-10, 10), glm::vec2(10, -10), glm::vec2(-10, -10),
glm::vec2(8, 8), glm::vec2(-8, 8), glm::vec2(8, -8), glm::vec2(-8, -8)
};
while(summon_count > 0) {
int pet_duration = pet.duration;
@ -568,7 +568,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u
NPC* npca = new NPC(
(npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer
0,
GetPosition() + swarmPetLocations[summon_count],
GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f),
FlyMode3);
if (followme)
@ -643,11 +643,11 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid
if(summon_count > MAX_SWARM_PETS)
summon_count = MAX_SWARM_PETS;
static const xy_location swarmPetLocations[MAX_SWARM_PETS] = {
xy_location(5, 5), xy_location(-5, 5), xy_location(5, -5), xy_location(-5, -5),
xy_location(10, 10), xy_location(-10, 10), xy_location(10, -10), xy_location(-10, -10),
xy_location(8, 8), xy_location(-8, 8), xy_location(8, -8), xy_location(-8, -8)
};;
static const glm::vec2 swarmPetLocations[MAX_SWARM_PETS] = {
glm::vec2(5, 5), glm::vec2(-5, 5), glm::vec2(5, -5), glm::vec2(-5, -5),
glm::vec2(10, 10), glm::vec2(-10, 10), glm::vec2(10, -10), glm::vec2(-10, -10),
glm::vec2(8, 8), glm::vec2(-8, 8), glm::vec2(8, -8), glm::vec2(-8, -8)
};;
while(summon_count > 0) {
int pet_duration = pet.duration;
@ -665,7 +665,7 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid
NPC* npca = new NPC(
(npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer
0,
GetPosition()+swarmPetLocations[summon_count],
GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f),
FlyMode3);
if (followme)
@ -1458,26 +1458,26 @@ bool ZoneDatabase::LoadAAEffects2() {
const std::string query = "SELECT aaid, slot, effectid, base1, base2 FROM aa_effects ORDER BY aaid ASC, slot ASC";
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::LoadAAEffects2 query: '%s': %s", query.c_str(), results.ErrorMessage().c_str());
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::LoadAAEffects2 query: '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
if (!results.RowCount()) { //no results
LogFile->write(EQEmuLog::Error, "Error loading AA Effects, none found in the database.");
return false;
LogFile->write(EQEmuLog::Error, "Error loading AA Effects, none found in the database.");
return false;
}
for(auto row = results.begin(); row != results.end(); ++row) {
int aaid = atoi(row[0]);
int slot = atoi(row[1]);
int effectid = atoi(row[2]);
int base1 = atoi(row[3]);
int base2 = atoi(row[4]);
aa_effects[aaid][slot].skill_id = effectid;
aa_effects[aaid][slot].base1 = base1;
aa_effects[aaid][slot].base2 = base2;
aa_effects[aaid][slot].slot = slot; //not really needed, but we'll populate it just in case
}
for(auto row = results.begin(); row != results.end(); ++row) {
int aaid = atoi(row[0]);
int slot = atoi(row[1]);
int effectid = atoi(row[2]);
int base1 = atoi(row[3]);
int base2 = atoi(row[4]);
aa_effects[aaid][slot].skill_id = effectid;
aa_effects[aaid][slot].base1 = base1;
aa_effects[aaid][slot].base2 = base2;
aa_effects[aaid][slot].slot = slot; //not really needed, but we'll populate it just in case
}
return true;
}
@ -1796,34 +1796,34 @@ bool ZoneDatabase::LoadAAEffects() {
memset(AA_Actions, 0, sizeof(AA_Actions)); //I hope the compiler is smart about this size...
const std::string query = "SELECT aaid, rank, reuse_time, spell_id, target, "
"nonspell_action, nonspell_mana, nonspell_duration, "
"redux_aa, redux_rate, redux_aa2, redux_rate2 FROM aa_actions";
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in LoadAAEffects query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
"nonspell_action, nonspell_mana, nonspell_duration, "
"redux_aa, redux_rate, redux_aa2, redux_rate2 FROM aa_actions";
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in LoadAAEffects query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
}
for (auto row = results.begin(); row != results.end(); ++row) {
for (auto row = results.begin(); row != results.end(); ++row) {
int aaid = atoi(row[0]);
int rank = atoi(row[1]);
if(aaid < 0 || aaid >= aaHighestID || rank < 0 || rank >= MAX_AA_ACTION_RANKS)
continue;
AA_DBAction *caction = &AA_Actions[aaid][rank];
int aaid = atoi(row[0]);
int rank = atoi(row[1]);
if(aaid < 0 || aaid >= aaHighestID || rank < 0 || rank >= MAX_AA_ACTION_RANKS)
continue;
AA_DBAction *caction = &AA_Actions[aaid][rank];
caction->reuse_time = atoi(row[2]);
caction->spell_id = atoi(row[3]);
caction->target = (aaTargetType) atoi(row[4]);
caction->action = (aaNonspellAction) atoi(row[5]);
caction->mana_cost = atoi(row[6]);
caction->duration = atoi(row[7]);
caction->redux_aa = (aaID) atoi(row[8]);
caction->redux_rate = atoi(row[9]);
caction->redux_aa2 = (aaID) atoi(row[10]);
caction->redux_rate2 = atoi(row[11]);
caction->reuse_time = atoi(row[2]);
caction->spell_id = atoi(row[3]);
caction->target = (aaTargetType) atoi(row[4]);
caction->action = (aaNonspellAction) atoi(row[5]);
caction->mana_cost = atoi(row[6]);
caction->duration = atoi(row[7]);
caction->redux_aa = (aaID) atoi(row[8]);
caction->redux_rate = atoi(row[9]);
caction->redux_aa2 = (aaID) atoi(row[10]);
caction->redux_rate2 = atoi(row[11]);
}
}
return true;
}
@ -1837,16 +1837,16 @@ bool ZoneDatabase::LoadAAEffects() {
uint8 ZoneDatabase::GetTotalAALevels(uint32 skill_id) {
std::string query = StringFormat("SELECT count(slot) FROM aa_effects WHERE aaid = %i", skill_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetTotalAALevels '%s: %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
}
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetTotalAALevels '%s: %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
}
if (results.RowCount() != 1)
return 0;
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
auto row = results.begin();
return atoi(row[0]);
}
@ -1893,14 +1893,14 @@ uint32 ZoneDatabase::CountAAs(){
const std::string query = "SELECT count(title_sid) FROM altadv_vars";
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::CountAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::CountAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
}
if (results.RowCount() != 1)
return 0;
return 0;
auto row = results.begin();
auto row = results.begin();
return atoi(row[0]);;
}
@ -1910,14 +1910,14 @@ uint32 ZoneDatabase::CountAAEffects() {
const std::string query = "SELECT count(id) FROM aa_effects";
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::CountAALevels query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::CountAALevels query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return 0;
}
if (results.RowCount() != 1)
return 0;
return 0;
auto row = results.begin();
auto row = results.begin();
return atoi(row[0]);
}
@ -1947,59 +1947,59 @@ void ZoneDatabase::LoadAAs(SendAA_Struct **load){
}
AARequiredLevelAndCost.clear();
query = "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id";
results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return;
}
query = "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id";
results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return;
}
AALevelCost_Struct aalcs;
for (auto row = results.begin(); row != results.end(); ++row) {
aalcs.Level = atoi(row[1]);
aalcs.Cost = atoi(row[2]);
AARequiredLevelAndCost[atoi(row[0])] = aalcs;
}
AALevelCost_Struct aalcs;
for (auto row = results.begin(); row != results.end(); ++row) {
aalcs.Level = atoi(row[1]);
aalcs.Cost = atoi(row[2]);
AARequiredLevelAndCost[atoi(row[0])] = aalcs;
}
}
SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
{
std::string query = "SET @row = 0"; //initialize "row" variable in database for next query
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return nullptr;
}
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return nullptr;
}
query = StringFormat("SELECT a.cost, a.max_level, a.hotkey_sid, a.hotkey_sid2, a.title_sid, a.desc_sid, a.type, "
"COALESCE(" //So we can return 0 if it's null.
"(" // this is our derived table that has the row #
// that we can SELECT from, because the client is stupid.
"SELECT p.prereq_index_num "
"FROM (SELECT a2.skill_id, @row := @row + 1 AS prereq_index_num "
query = StringFormat("SELECT a.cost, a.max_level, a.hotkey_sid, a.hotkey_sid2, a.title_sid, a.desc_sid, a.type, "
"COALESCE(" //So we can return 0 if it's null.
"(" // this is our derived table that has the row #
// that we can SELECT from, because the client is stupid.
"SELECT p.prereq_index_num "
"FROM (SELECT a2.skill_id, @row := @row + 1 AS prereq_index_num "
"FROM altadv_vars a2) AS p "
"WHERE p.skill_id = a.prereq_skill), 0) "
"AS prereq_skill_index, a.prereq_minpoints, a.spell_type, a.spell_refresh, a.classes, "
"a.berserker, a.spellid, a.class_type, a.name, a.cost_inc, a.aa_expansion, a.special_category, "
"a.sof_type, a.sof_cost_inc, a.sof_max_level, a.sof_next_skill, "
"a.clientver, " // Client Version 0 = None, 1 = All, 2 = Titanium/6.2, 4 = SoF 5 = SOD 6 = UF
"a.account_time_required, a.sof_current_level, a.sof_next_id, a.level_inc "
"FROM altadv_vars a WHERE skill_id=%i", skill_id);
results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return nullptr;
}
"WHERE p.skill_id = a.prereq_skill), 0) "
"AS prereq_skill_index, a.prereq_minpoints, a.spell_type, a.spell_refresh, a.classes, "
"a.berserker, a.spellid, a.class_type, a.name, a.cost_inc, a.aa_expansion, a.special_category, "
"a.sof_type, a.sof_cost_inc, a.sof_max_level, a.sof_next_skill, "
"a.clientver, " // Client Version 0 = None, 1 = All, 2 = Titanium/6.2, 4 = SoF 5 = SOD 6 = UF
"a.account_time_required, a.sof_current_level, a.sof_next_id, a.level_inc "
"FROM altadv_vars a WHERE skill_id=%i", skill_id);
results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return nullptr;
}
if (results.RowCount() != 1)
return nullptr;
if (results.RowCount() != 1)
return nullptr;
int total_abilities = GetTotalAALevels(skill_id); //eventually we'll want to use zone->GetTotalAALevels(skill_id) since it should save queries to the DB
int total_abilities = GetTotalAALevels(skill_id); //eventually we'll want to use zone->GetTotalAALevels(skill_id) since it should save queries to the DB
int totalsize = total_abilities * sizeof(AA_Ability) + sizeof(SendAA_Struct);
SendAA_Struct* sendaa = nullptr;
uchar* buffer;
SendAA_Struct* sendaa = nullptr;
uchar* buffer;
buffer = new uchar[totalsize];
memset(buffer,0,totalsize);
@ -2010,7 +2010,7 @@ SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
//ATOI IS NOT UNSIGNED LONG-SAFE!!!
sendaa->cost = atoul(row[0]);
sendaa->cost2 = sendaa->cost;
sendaa->cost2 = sendaa->cost;
sendaa->max_level = atoul(row[1]);
sendaa->hotkey_sid = atoul(row[2]);
sendaa->id = skill_id;

View File

@ -88,7 +88,7 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo
if (mob->IsClient()) //also ensures that mob != around
continue;
if (ComparativeDistance(mob->GetPosition(), from_who->GetPosition()) > d2)
if (DistanceSquared(mob->GetPosition(), from_who->GetPosition()) > d2)
continue;
if (engaged) {
@ -150,7 +150,7 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) {
return;
}
float dist2 = ComparativeDistance(mob->GetPosition(), m_Position);
float dist2 = DistanceSquared(mob->GetPosition(), m_Position);
float iAggroRange2 = iAggroRange*iAggroRange;
if( dist2 > iAggroRange2 ) {
@ -296,7 +296,7 @@ bool Mob::CheckWillAggro(Mob *mob) {
return(false);
}
float dist2 = ComparativeDistance(mob->GetPosition(), m_Position);
float dist2 = DistanceSquared(mob->GetPosition(), m_Position);
float iAggroRange2 = iAggroRange*iAggroRange;
if( dist2 > iAggroRange2 ) {
@ -414,7 +414,7 @@ int EntityList::GetHatedCount(Mob *attacker, Mob *exclude)
AggroRange *= AggroRange;
if (ComparativeDistance(mob->GetPosition(), attacker->GetPosition()) > AggroRange)
if (DistanceSquared(mob->GetPosition(), attacker->GetPosition()) > AggroRange)
continue;
Count++;
@ -444,7 +444,7 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) {
// && !mob->IsCorpse()
// && mob->IsAIControlled()
&& mob->GetPrimaryFaction() != 0
&& ComparativeDistance(mob->GetPosition(), sender->GetPosition()) <= r
&& DistanceSquared(mob->GetPosition(), sender->GetPosition()) <= r
&& !mob->IsEngaged()
&& ((!mob->IsPet()) || (mob->IsPet() && mob->GetOwner() && !mob->GetOwner()->IsClient()))
// If we're a pet we don't react to any calls for help if our owner is a client
@ -471,7 +471,7 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) {
if(mob->CheckLosFN(sender)) {
#if (EQDEBUG>=5)
LogFile->write(EQEmuLog::Debug, "AIYellForHelp(\"%s\",\"%s\") %s attacking %s Dist %f Z %f",
sender->GetName(), attacker->GetName(), mob->GetName(), attacker->GetName(), ComparativeDistance(mob->GetPosition(), sender->GetPosition()), fabs(sender->GetZ()+mob->GetZ()));
sender->GetName(), attacker->GetName(), mob->GetName(), attacker->GetName(), DistanceSquared(mob->GetPosition(), sender->GetPosition()), fabs(sender->GetZ()+mob->GetZ()));
#endif
mob->AddToHateList(attacker, 1, 0, false);
}
@ -878,7 +878,7 @@ bool Mob::CombatRange(Mob* other)
if (size_mod > 10000)
size_mod = size_mod / 7;
float _DistNoRoot = ComparativeDistance(m_Position, other->GetPosition());
float _DistNoRoot = DistanceSquared(m_Position, other->GetPosition());
if (GetSpecialAbility(NPC_CHASE_DISTANCE)){
@ -935,8 +935,8 @@ bool Mob::CheckLosFN(float posX, float posY, float posZ, float mobSize) {
#endif
}
Map::Vertex myloc;
Map::Vertex oloc;
glm::vec3 myloc;
glm::vec3 oloc;
#define LOS_DEFAULT_HEIGHT 6.0f

View File

@ -2471,7 +2471,7 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b
}
if(IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) {
if(!zone->watermap->InLiquid(other->GetPosition())) {
if(!zone->watermap->InLiquid(glm::vec3(other->GetPosition()))) {
return;
}
}
@ -3917,8 +3917,8 @@ void Mob::TryDefensiveProc(const ItemInst* weapon, Mob *on, uint16 hand) {
float chance = ProcChance * (static_cast<float>(DefensiveProcs[i].chance)/100.0f);
if (zone->random.Roll(chance)) {
ExecWeaponProc(nullptr, DefensiveProcs[i].spellID, on);
CheckNumHitsRemaining(NumHit::DefensiveSpellProcs, 0,
DefensiveProcs[i].base_spellID);
CheckNumHitsRemaining(NumHit::DefensiveSpellProcs, 0,
DefensiveProcs[i].base_spellID);
}
}
}
@ -4095,7 +4095,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on,
i, SpellProcs[i].spellID, chance);
ExecWeaponProc(nullptr, SpellProcs[i].spellID, on);
CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0,
SpellProcs[i].base_spellID);
SpellProcs[i].base_spellID);
} else {
mlog(COMBAT__PROCS,
"Spell proc %d failed to proc %d (%.2f percent chance)",
@ -4112,7 +4112,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on,
i, RangedProcs[i].spellID, chance);
ExecWeaponProc(nullptr, RangedProcs[i].spellID, on);
CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0,
RangedProcs[i].base_spellID);
RangedProcs[i].base_spellID);
} else {
mlog(COMBAT__PROCS,
"Ranged proc %d failed to proc %d (%.2f percent chance)",
@ -4530,7 +4530,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
if (zone->random.Roll(final_chance)) {
ExecWeaponProc(nullptr, proc_spell_id, on);
CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0,
base_spell_id);
base_spell_id);
CanProc = false;
break;
}
@ -4824,20 +4824,20 @@ void Mob::CommonBreakInvisible()
/* Dev quotes:
* Old formula
* Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 100) * Original Delay)
* Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 100) * Original Delay)
* New formula
* Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 1000) * (Original Delay / (haste mod *.01f))
* Base Delay 20 25 30 37
* Haste 2.25 2.25 2.25 2.25
* HHE (old) -17 -17 -17 -17
* Final Delay 5.488888889 6.861111111 8.233333333 10.15444444
* Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 1000) * (Original Delay / (haste mod *.01f))
* Base Delay 20 25 30 37
* Haste 2.25 2.25 2.25 2.25
* HHE (old) -17 -17 -17 -17
* Final Delay 5.488888889 6.861111111 8.233333333 10.15444444
*
* Base Delay 20 25 30 37
* Haste 2.25 2.25 2.25 2.25
* HHE (new) -383 -383 -383 -383
* Final Delay 5.484444444 6.855555556 8.226666667 10.14622222
* Base Delay 20 25 30 37
* Haste 2.25 2.25 2.25 2.25
* HHE (new) -383 -383 -383 -383
* Final Delay 5.484444444 6.855555556 8.226666667 10.14622222
*
* Difference -0.004444444 -0.005555556 -0.006666667 -0.008222222
* Difference -0.004444444 -0.005555556 -0.006666667 -0.008222222
*
* These times are in 10th of a second
*/

View File

@ -9,7 +9,7 @@
extern volatile bool ZoneLoaded;
// This constructor is used during the bot create command
Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, xyz_heading::Origin(), 0, false), rest_timer(1) {
Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, glm::vec4(), 0, false), rest_timer(1) {
if(botOwner) {
this->SetBotOwner(botOwner);
this->_botOwnerCharacterID = botOwner->CharacterID();
@ -99,7 +99,7 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, xyz
}
// This constructor is used when the bot is loaded out of the database
Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType npcTypeData) : NPC(&npcTypeData, nullptr, xyz_heading::Origin(), 0, false), rest_timer(1) {
Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType npcTypeData) : NPC(&npcTypeData, nullptr, glm::vec4(), 0, false), rest_timer(1) {
this->_botOwnerCharacterID = botOwnerCharacterID;
if(this->_botOwnerCharacterID > 0) {
@ -3354,7 +3354,7 @@ void Bot::AI_Process() {
if(GetHasBeenSummoned()) {
if(IsBotCaster() || IsBotArcher()) {
if (AImovement_timer->Check()) {
if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (ComparativeDistanceNoZ(static_cast<xyz_location>(m_Position), m_PreSummonLocation) < 10)) {
if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistanceSquaredNoZ(static_cast<glm::vec3>(m_Position), m_PreSummonLocation) < 10)) {
if(GetTarget())
FaceTarget(GetTarget());
SetHasBeenSummoned(false);
@ -3363,8 +3363,8 @@ void Bot::AI_Process() {
if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this)
{
mlog(AI__WAYPOINTS, "Returning to location prior to being summoned.");
CalculateNewPosition2(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y, m_PreSummonLocation.m_Z, GetRunspeed());
SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y));
CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetRunspeed());
SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.x, m_PreSummonLocation.y));
return;
}
}
@ -3505,7 +3505,7 @@ void Bot::AI_Process() {
if(IsBotCasterCombatRange(GetTarget()))
atCombatRange = true;
}
else if(ComparativeDistance(m_Position, GetTarget()->GetPosition()) <= meleeDistance) {
else if(DistanceSquared(m_Position, GetTarget()->GetPosition()) <= meleeDistance) {
atCombatRange = true;
}
@ -3533,7 +3533,7 @@ void Bot::AI_Process() {
return;
}
}
else if(!IsMoving() && GetClass() != ROGUE && (ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) < GetTarget()->GetSize())) {
else if(!IsMoving() && GetClass() != ROGUE && (DistanceSquaredNoZ(m_Position, GetTarget()->GetPosition()) < GetTarget()->GetSize())) {
// If we are not a rogue trying to backstab, let's try to adjust our melee range so we don't appear to be bunched up
float newX = 0;
float newY = 0;
@ -3732,7 +3732,7 @@ void Bot::AI_Process() {
Mob* follow = entity_list.GetMob(GetFollowID());
if(follow) {
float dist = ComparativeDistance(m_Position, follow->GetPosition());
float dist = DistanceSquared(m_Position, follow->GetPosition());
float speed = follow->GetRunspeed();
if(dist < GetFollowDistance() + 1000)
@ -3865,7 +3865,7 @@ void Bot::PetAIProcess() {
return;
}
}
else if(ComparativeDistanceNoZ(botPet->GetPosition(), botPet->GetTarget()->GetPosition()) < botPet->GetTarget()->GetSize()) {
else if(DistanceSquaredNoZ(botPet->GetPosition(), botPet->GetTarget()->GetPosition()) < botPet->GetTarget()->GetSize()) {
// Let's try to adjust our melee range so we don't appear to be bunched up
bool isBehindMob = false;
bool moveBehindMob = false;
@ -4003,7 +4003,7 @@ void Bot::PetAIProcess() {
switch(pStandingPetOrder) {
case SPO_Follow:
{
float dist = ComparativeDistance(botPet->GetPosition(), botPet->GetTarget()->GetPosition());
float dist = DistanceSquared(botPet->GetPosition(), botPet->GetTarget()->GetPosition());
botPet->SetRunAnimSpeed(0);
if(dist > 184) {
botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetTarget()->GetRunspeed());
@ -4105,9 +4105,9 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName());
// Spawn the bot at the bow owner's loc
this->m_Position.m_X = botCharacterOwner->GetX();
this->m_Position.m_Y = botCharacterOwner->GetY();
this->m_Position.m_Z = botCharacterOwner->GetZ();
this->m_Position.x = botCharacterOwner->GetX();
this->m_Position.y = botCharacterOwner->GetY();
this->m_Position.z = botCharacterOwner->GetZ();
// Make the bot look at the bot owner
FaceTarget(botCharacterOwner);
@ -10387,7 +10387,7 @@ bool Bot::IsArcheryRange(Mob *target) {
range *= range;
float targetDistance = ComparativeDistanceNoZ(m_Position, target->GetPosition());
float targetDistance = DistanceSquaredNoZ(m_Position, target->GetPosition());
float minRuleDistance = RuleI(Combat, MinRangedAttackDist) * RuleI(Combat, MinRangedAttackDist);
@ -10411,7 +10411,7 @@ bool Bot::IsBotCasterCombatRange(Mob *target) {
// half the max so the bot doesn't always stop at max range to allow combat movement
range *= .5;
float targetDistance = ComparativeDistanceNoZ(m_Position, target->GetPosition());
float targetDistance = DistanceSquaredNoZ(m_Position, target->GetPosition());
if(targetDistance > range)
result = false;
@ -15749,9 +15749,9 @@ void EntityList::BotPickLock(Bot* rogue)
auto diff = rogue->GetPosition() - cdoor->GetPosition();
diff.ABS_XYZ();
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y;
float curdist = diff.x * diff.x + diff.y * diff.y;
if((diff.m_Z * diff.m_Z >= 10) || (curdist > 130))
if((diff.z * diff.z >= 10) || (curdist > 130))
continue;
// All rogue items with lock pick bonuses are hands or primary
@ -16161,7 +16161,7 @@ bool Bot::HasOrMayGetAggro() {
void Bot::SetHasBeenSummoned(bool wasSummoned) {
_hasBeenSummoned = wasSummoned;
if(!wasSummoned)
m_PreSummonLocation = xyz_location::Origin();
m_PreSummonLocation = glm::vec3();
}

View File

@ -448,7 +448,7 @@ public:
uint32 GetAA(uint32 aa_id);
void ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon);
bool GetHasBeenSummoned() { return _hasBeenSummoned; }
const xyz_location GetPreSummonLocation() const { return m_PreSummonLocation; }
const glm::vec3 GetPreSummonLocation() const { return m_PreSummonLocation; }
bool GetGroupMessagesOn() { return _groupMessagesOn; }
bool GetInHealRotation() { return _isInHealRotation; }
bool GetHealRotationActive() { return (GetInHealRotation() && _isHealRotationActive); }
@ -533,7 +533,7 @@ public:
void SetSpellRecastTimer(int timer_index, int32 recast_delay);
void SetDisciplineRecastTimer(int timer_index, int32 recast_delay);
void SetHasBeenSummoned(bool s);
void SetPreSummonLocation(const xyz_location& location) { m_PreSummonLocation = location; }
void SetPreSummonLocation(const glm::vec3& location) { m_PreSummonLocation = location; }
void SetGroupMessagesOn(bool groupMessagesOn) { _groupMessagesOn = groupMessagesOn; }
void SetInHealRotation( bool inRotation ) { _isInHealRotation = inRotation; }
void SetHealRotationActive( bool isActive ) { _isHealRotationActive = isActive; }
@ -600,7 +600,7 @@ private:
int32 end_regen;
uint32 timers[MaxTimer];
bool _hasBeenSummoned;
xyz_location m_PreSummonLocation;
glm::vec3 m_PreSummonLocation;
uint8 _spellCastingChances[MaxStances][MaxSpellTypes];
bool _groupMessagesOn;
bool _isInHealRotation;

View File

@ -898,7 +898,7 @@ bool Bot::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgain
if (AIspells[i].type & SpellType_Escape) {
dist2 = 0;
} else
dist2 = ComparativeDistance(m_Position, tar->GetPosition());
dist2 = DistanceSquared(m_Position, tar->GetPosition());
if (((((spells[AIspells[i].spellid].targettype==ST_GroupTeleport && AIspells[i].type==2)
|| spells[AIspells[i].spellid].targettype==ST_AECaster
@ -1755,7 +1755,7 @@ Mob* Bot::GetFirstIncomingMobToMez(Bot* botCaster, BotSpell botSpell) {
for(std::list<NPC*>::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) {
NPC* npc = *itr;
if(ComparativeDistanceNoZ(npc->GetPosition(), botCaster->GetPosition()) <= botCaster->GetActSpellRange(botSpell.SpellId, spells[botSpell.SpellId].range)) {
if(DistanceSquaredNoZ(npc->GetPosition(), botCaster->GetPosition()) <= botCaster->GetActSpellRange(botSpell.SpellId, spells[botSpell.SpellId].range)) {
if(!npc->IsMezzed()) {
if(botCaster->HasGroup()) {
Group* g = botCaster->GetGroup();

View File

@ -76,7 +76,7 @@ Client::Client(EQStreamInterface* ieqs)
0, // npctypeid
0, // size
0.7, // runspeed
xyz_heading::Origin(),
glm::vec4(),
0, // light
0xFF, // texture
0xFF, // helmtexture
@ -374,9 +374,9 @@ Client::~Client() {
{
m_pp.zone_id = m_pp.binds[0].zoneId;
m_pp.zoneInstance = m_pp.binds[0].instance_id;
m_Position.m_X = m_pp.binds[0].x;
m_Position.m_Y = m_pp.binds[0].y;
m_Position.m_Z = m_pp.binds[0].z;
m_Position.x = m_pp.binds[0].x;
m_Position.y = m_pp.binds[0].y;
m_Position.z = m_pp.binds[0].z;
}
// we save right now, because the client might be zoning and the world
@ -500,11 +500,11 @@ bool Client::Save(uint8 iCommitNow) {
return false;
/* Wrote current basics to PP for saves */
m_pp.x = m_Position.m_X;
m_pp.y = m_Position.m_Y;
m_pp.z = m_Position.m_Z;
m_pp.x = m_Position.x;
m_pp.y = m_Position.y;
m_pp.z = m_Position.z;
m_pp.guildrank = guildrank;
m_pp.heading = m_Position.m_Heading;
m_pp.heading = m_Position.w;
/* Mana and HP */
if (GetHP() <= 0) {
@ -521,8 +521,8 @@ bool Client::Save(uint8 iCommitNow) {
database.SaveCharacterCurrency(CharacterID(), &m_pp);
/* Save Current Bind Points */
auto regularBindPosition = xyz_heading(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f);
auto homeBindPosition = xyz_heading(m_pp.binds[4].x, m_pp.binds[4].y, m_pp.binds[4].z, 0.0f);
auto regularBindPosition = glm::vec4(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f);
auto homeBindPosition = glm::vec4(m_pp.binds[4].x, m_pp.binds[4].y, m_pp.binds[4].z, 0.0f);
database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, regularBindPosition, 0); /* Regular bind */
database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[4].zoneId, m_pp.binds[4].instance_id, homeBindPosition, 1); /* Home Bind */
@ -994,7 +994,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
CheckEmoteHail(GetTarget(), message);
if(ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) <= 200) {
if(DistanceSquaredNoZ(m_Position, GetTarget()->GetPosition()) <= 200) {
NPC *tar = GetTarget()->CastToNPC();
parse->EventNPC(EVENT_SAY, tar->CastToNPC(), this, message, language);
@ -1006,7 +1006,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
}
}
else {
if (ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) <= 200) {
if (DistanceSquaredNoZ(m_Position, GetTarget()->GetPosition()) <= 200) {
parse->EventNPC(EVENT_AGGRO_SAY, GetTarget()->CastToNPC(), this, message, language);
}
}
@ -2540,7 +2540,7 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
}
else {
if (!GetFeigned() && (ComparativeDistance(bindmob->GetPosition(), m_Position) <= 400)) {
if (!GetFeigned() && (DistanceSquared(bindmob->GetPosition(), m_Position) <= 400)) {
// send bindmob bind done
if(!bindmob->IsAIControlled() && bindmob != this ) {
@ -3179,7 +3179,7 @@ void Client::Insight(uint32 t_id)
Message(0,"This ability can only be used on NPCs.");
return;
}
if (Distance(static_cast<xyz_location>(m_Position), static_cast<xyz_location>(who->GetPosition())) > 200)
if (Distance(static_cast<glm::vec3>(m_Position), static_cast<glm::vec3>(who->GetPosition())) > 200)
{
Message(0,"You must get closer to your target!");
return;
@ -3839,37 +3839,37 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
void Client::KeyRingLoad()
{
std::string query = StringFormat("SELECT item_id FROM keyring "
"WHERE char_id = '%i' ORDER BY item_id", character_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in Client::KeyRingLoad query '" << query << "' " << results.ErrorMessage() << std::endl;
"WHERE char_id = '%i' ORDER BY item_id", character_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in Client::KeyRingLoad query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
}
}
for (auto row = results.begin(); row != results.end(); ++row)
keyring.push_back(atoi(row[0]));
for (auto row = results.begin(); row != results.end(); ++row)
keyring.push_back(atoi(row[0]));
}
void Client::KeyRingAdd(uint32 item_id)
{
if(0==item_id)
return;
return;
bool found = KeyRingCheck(item_id);
if (found)
return;
return;
std::string query = StringFormat("INSERT INTO keyring(char_id, item_id) VALUES(%i, %i)", character_id, item_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in Doors::HandleClick query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
}
std::string query = StringFormat("INSERT INTO keyring(char_id, item_id) VALUES(%i, %i)", character_id, item_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in Doors::HandleClick query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
}
Message(4,"Added to keyring.");
Message(4,"Added to keyring.");
keyring.push_back(item_id);
keyring.push_back(item_id);
}
bool Client::KeyRingCheck(uint32 item_id)
@ -3901,15 +3901,15 @@ void Client::KeyRingList()
bool Client::IsDiscovered(uint32 itemid) {
std::string query = StringFormat("SELECT count(*) FROM discovered_items WHERE item_id = '%lu'", itemid);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in IsDiscovered query '" << query << "' " << results.ErrorMessage() << std::endl;
return false;
}
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in IsDiscovered query '" << query << "' " << results.ErrorMessage() << std::endl;
return false;
}
auto row = results.begin();
if (!atoi(row[0]))
return false;
if (!atoi(row[0]))
return false;
return true;
}
@ -3917,9 +3917,9 @@ bool Client::IsDiscovered(uint32 itemid) {
void Client::DiscoverItem(uint32 itemid) {
std::string query = StringFormat("INSERT INTO discovered_items "
"SET item_id = %lu, char_name = '%s', "
"discovered_date = UNIX_TIMESTAMP(), account_status = %i",
itemid, GetName(), Admin());
"SET item_id = %lu, char_name = '%s', "
"discovered_date = UNIX_TIMESTAMP(), account_status = %i",
itemid, GetName(), Admin());
auto results = database.QueryDatabase(query);
parse->EventPlayer(EVENT_DISCOVER_ITEM, this, "", itemid);
@ -4553,7 +4553,7 @@ void Client::HandleLDoNOpen(NPC *target)
return;
}
if(ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if(DistanceSquaredNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
LogFile->write(EQEmuLog::Debug, "%s tried to open %s but %s was out of range",
GetName(), target->GetName(), target->GetName());
@ -4806,11 +4806,11 @@ void Client::SummonAndRezzAllCorpses()
Message(clientMessageYellow, "All your corpses have been summoned to your feet and have received a 100% resurrection.");
}
void Client::SummonAllCorpses(const xyz_heading& position)
void Client::SummonAllCorpses(const glm::vec4& position)
{
auto summonLocation = position;
if(position.isOrigin() && position.m_Heading == 0.0f)
summonLocation = GetPosition();
auto summonLocation = position;
if(IsOrigin(position) && position.w == 0.0f)
summonLocation = GetPosition();
ServerPacket *Pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct));
@ -5285,50 +5285,50 @@ void Client::SendRewards()
{
std::vector<ClientReward> rewards;
std::string query = StringFormat("SELECT reward_id, amount "
"FROM account_rewards "
"WHERE account_id = %i "
"ORDER BY reward_id", AccountID());
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in Client::SendRewards(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
"FROM account_rewards "
"WHERE account_id = %i "
"ORDER BY reward_id", AccountID());
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in Client::SendRewards(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
return;
}
}
for (auto row = results.begin(); row != results.end(); ++row) {
ClientReward cr;
cr.id = atoi(row[0]);
cr.amount = atoi(row[1]);
rewards.push_back(cr);
}
for (auto row = results.begin(); row != results.end(); ++row) {
ClientReward cr;
cr.id = atoi(row[0]);
cr.amount = atoi(row[1]);
rewards.push_back(cr);
}
if(rewards.size() == 0)
return;
return;
EQApplicationPacket *vetapp = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(InternalVeteranReward) * rewards.size()));
uchar *data = vetapp->pBuffer;
for(int i = 0; i < rewards.size(); ++i) {
InternalVeteranReward *ivr = (InternalVeteranReward*)data;
ivr->claim_id = rewards[i].id;
ivr->number_available = rewards[i].amount;
auto iter = zone->VeteranRewards.begin();
for (;iter != zone->VeteranRewards.end(); ++iter)
if((*iter).claim_id == rewards[i].id)
break;
uchar *data = vetapp->pBuffer;
for(int i = 0; i < rewards.size(); ++i) {
InternalVeteranReward *ivr = (InternalVeteranReward*)data;
ivr->claim_id = rewards[i].id;
ivr->number_available = rewards[i].amount;
auto iter = zone->VeteranRewards.begin();
for (;iter != zone->VeteranRewards.end(); ++iter)
if((*iter).claim_id == rewards[i].id)
break;
if(iter != zone->VeteranRewards.end()) {
InternalVeteranReward ivro = (*iter);
ivr->claim_count = ivro.claim_count;
for(int x = 0; x < ivro.claim_count; ++x) {
ivr->items[x].item_id = ivro.items[x].item_id;
ivr->items[x].charges = ivro.items[x].charges;
strcpy(ivr->items[x].item_name, ivro.items[x].item_name);
}
}
if(iter != zone->VeteranRewards.end()) {
InternalVeteranReward ivro = (*iter);
ivr->claim_count = ivro.claim_count;
for(int x = 0; x < ivro.claim_count; ++x) {
ivr->items[x].item_id = ivro.items[x].item_id;
ivr->items[x].charges = ivro.items[x].charges;
strcpy(ivr->items[x].item_name, ivro.items[x].item_name);
}
}
data += sizeof(InternalVeteranReward);
}
data += sizeof(InternalVeteranReward);
}
FastQueuePacket(&vetapp);
FastQueuePacket(&vetapp);
}
bool Client::TryReward(uint32 claim_id) {
@ -5354,20 +5354,20 @@ bool Client::TryReward(uint32 claim_id) {
char errbuf[MYSQL_ERRMSG_SIZE];
std::string query = StringFormat("SELECT amount FROM account_rewards "
"WHERE account_id = %i AND reward_id = %i",
AccountID(), claim_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
"WHERE account_id = %i AND reward_id = %i",
AccountID(), claim_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
return false;
}
}
if (results.RowCount() == 0)
return false;
if (results.RowCount() == 0)
return false;
auto row = results.begin();
auto row = results.begin();
uint32 amt = atoi(row[0]);
uint32 amt = atoi(row[0]);
if(amt == 0)
return false;
@ -5380,18 +5380,18 @@ bool Client::TryReward(uint32 claim_id) {
return false;
if(amt == 1) {
query = StringFormat("DELETE FROM account_rewards "
"WHERE account_id = %i AND reward_id = %i",
AccountID(), claim_id);
auto results = database.QueryDatabase(query);
query = StringFormat("DELETE FROM account_rewards "
"WHERE account_id = %i AND reward_id = %i",
AccountID(), claim_id);
auto results = database.QueryDatabase(query);
if(!results.Success())
LogFile->write(EQEmuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
}
else {
query = StringFormat("UPDATE account_rewards SET amount = (amount-1) "
"WHERE account_id = %i AND reward_id = %i",
AccountID(), claim_id);
auto results = database.QueryDatabase(query);
query = StringFormat("UPDATE account_rewards SET amount = (amount-1) "
"WHERE account_id = %i AND reward_id = %i",
AccountID(), claim_id);
auto results = database.QueryDatabase(query);
if(!results.Success())
LogFile->write(EQEmuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
}
@ -5399,31 +5399,31 @@ bool Client::TryReward(uint32 claim_id) {
InternalVeteranReward ivr = (*iter);
ItemInst *claim = database.CreateItem(ivr.items[0].item_id, ivr.items[0].charges);
if(!claim) {
Save();
return true;
Save();
return true;
}
bool lore_conflict = CheckLoreConflict(claim->GetItem());
bool lore_conflict = CheckLoreConflict(claim->GetItem());
for(int y = 1; y < 8; y++)
if(ivr.items[y].item_id && claim->GetItem()->ItemClass == 1) {
ItemInst *item_temp = database.CreateItem(ivr.items[y].item_id, ivr.items[y].charges);
if(item_temp) {
if(CheckLoreConflict(item_temp->GetItem())) {
lore_conflict = true;
DuplicateLoreMessage(ivr.items[y].item_id);
}
claim->PutItem(y-1, *item_temp);
}
}
for(int y = 1; y < 8; y++)
if(ivr.items[y].item_id && claim->GetItem()->ItemClass == 1) {
ItemInst *item_temp = database.CreateItem(ivr.items[y].item_id, ivr.items[y].charges);
if(item_temp) {
if(CheckLoreConflict(item_temp->GetItem())) {
lore_conflict = true;
DuplicateLoreMessage(ivr.items[y].item_id);
}
claim->PutItem(y-1, *item_temp);
}
}
if(lore_conflict) {
safe_delete(claim);
return true;
}
if(lore_conflict) {
safe_delete(claim);
return true;
}
PutItemInInventory(free_slot, *claim);
SendItemPacket(free_slot, claim, ItemPacketTrade);
PutItemInInventory(free_slot, *claim);
SendItemPacket(free_slot, claim, ItemPacketTrade);
Save();
return true;
@ -6187,7 +6187,7 @@ void Client::DragCorpses()
Mob *corpse = entity_list.GetMob(It->second);
if (corpse && corpse->IsPlayerCorpse() &&
(ComparativeDistanceNoZ(m_Position, corpse->GetPosition()) <= RuleR(Character, DragCorpseDistance)))
(DistanceSquaredNoZ(m_Position, corpse->GetPosition()) <= RuleR(Character, DragCorpseDistance)))
continue;
if (!corpse || !corpse->IsPlayerCorpse() ||
@ -6274,11 +6274,11 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid
if(summon_count > MAX_SWARM_PETS)
summon_count = MAX_SWARM_PETS;
static const xy_location swarmPetLocations[MAX_SWARM_PETS] = {
xy_location(5, 5), xy_location(-5, 5), xy_location(5, -5), xy_location(-5, -5),
xy_location(10, 10), xy_location(-10, 10), xy_location(10, -10), xy_location(-10, -10),
xy_location(8, 8), xy_location(-8, 8), xy_location(8, -8), xy_location(-8, -8)
};
static const glm::vec2 swarmPetLocations[MAX_SWARM_PETS] = {
glm::vec2(5, 5), glm::vec2(-5, 5), glm::vec2(5, -5), glm::vec2(-5, -5),
glm::vec2(10, 10), glm::vec2(-10, 10), glm::vec2(10, -10), glm::vec2(-10, -10),
glm::vec2(8, 8), glm::vec2(-8, 8), glm::vec2(8, -8), glm::vec2(-8, -8)
};
while(summon_count > 0) {
NPCType *npc_dup = nullptr;
@ -6290,7 +6290,7 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid
NPC* npca = new NPC(
(npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer
0,
GetPosition()+swarmPetLocations[summon_count],
GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f),
FlyMode3);
if(!npca->GetSwarmInfo()){
@ -7768,24 +7768,24 @@ void Client::LoadAccountFlags()
accountflags.clear();
std::string query = StringFormat("SELECT p_flag, p_value "
"FROM account_flags WHERE p_accid = '%d'",
account_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in LoadAccountFlags query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
}
"FROM account_flags WHERE p_accid = '%d'",
account_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
std::cerr << "Error in LoadAccountFlags query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
}
for (auto row = results.begin(); row != results.end(); ++row)
accountflags[row[0]] = row[1];
for (auto row = results.begin(); row != results.end(); ++row)
accountflags[row[0]] = row[1];
}
void Client::SetAccountFlag(std::string flag, std::string val) {
std::string query = StringFormat("REPLACE INTO account_flags (p_accid, p_flag, p_value) "
"VALUES( '%d', '%s', '%s')",
account_id, flag.c_str(), val.c_str());
auto results = database.QueryDatabase(query);
std::string query = StringFormat("REPLACE INTO account_flags (p_accid, p_flag, p_value) "
"VALUES( '%d', '%s', '%s')",
account_id, flag.c_str(), val.c_str());
auto results = database.QueryDatabase(query);
if(!results.Success()) {
std::cerr << "Error in SetAccountFlags query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
@ -8125,7 +8125,7 @@ void Client::Consume(const Item_Struct *item, uint8 type, int16 slot, bool auto_
{
if(!item) { return; }
uint32 cons_mod = 180;
uint32 cons_mod = 180;
int32 metabolism_bonus = spellbonuses.Metabolism + itembonuses.Metabolism + aabonuses.Metabolism;
@ -8136,36 +8136,36 @@ void Client::Consume(const Item_Struct *item, uint8 type, int16 slot, bool auto_
if(type == ItemTypeFood)
{
int hchange = item->CastTime * cons_mod;
hchange = mod_food_value(item, hchange);
int hchange = item->CastTime * cons_mod;
hchange = mod_food_value(item, hchange);
if(hchange < 0) { return; }
if(hchange < 0) { return; }
m_pp.hunger_level += hchange;
DeleteItemInInventory(slot, 1, false);
m_pp.hunger_level += hchange;
DeleteItemInInventory(slot, 1, false);
if(!auto_consume) //no message if the client consumed for us
entity_list.MessageClose_StringID(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name);
if(!auto_consume) //no message if the client consumed for us
entity_list.MessageClose_StringID(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name);
#if EQDEBUG >= 5
LogFile->write(EQEmuLog::Debug, "Eating from slot:%i", (int)slot);
LogFile->write(EQEmuLog::Debug, "Eating from slot:%i", (int)slot);
#endif
}
else
{
int tchange = item->CastTime * cons_mod;
tchange = mod_drink_value(item, tchange);
int tchange = item->CastTime * cons_mod;
tchange = mod_drink_value(item, tchange);
if(tchange < 0) { return; }
if(tchange < 0) { return; }
m_pp.thirst_level += tchange;
DeleteItemInInventory(slot, 1, false);
m_pp.thirst_level += tchange;
DeleteItemInInventory(slot, 1, false);
if(!auto_consume) //no message if the client consumed for us
entity_list.MessageClose_StringID(this, true, 50, 0, DRINKING_MESSAGE, GetName(), item->Name);
if(!auto_consume) //no message if the client consumed for us
entity_list.MessageClose_StringID(this, true, 50, 0, DRINKING_MESSAGE, GetName(), item->Name);
#if EQDEBUG >= 5
LogFile->write(EQEmuLog::Debug, "Drinking from slot:%i", (int)slot);
LogFile->write(EQEmuLog::Debug, "Drinking from slot:%i", (int)slot);
#endif
}
}
@ -8203,15 +8203,15 @@ void Client::PlayMP3(const char* fname)
void Client::ExpeditionSay(const char *str, int ExpID) {
std::string query = StringFormat("SELECT `player_name` FROM `cust_inst_players` "
"WHERE `inst_id` = %i", ExpID);
auto results = database.QueryDatabase(query);
"WHERE `inst_id` = %i", ExpID);
auto results = database.QueryDatabase(query);
if (!results.Success())
return;
if(results.RowCount() == 0) {
this->Message(14, "You say to the expedition, '%s'", str);
return;
}
this->Message(14, "You say to the expedition, '%s'", str);
return;
}
for(auto row = results.begin(); row != results.end(); ++row) {
const char* charName = row[0];
@ -8321,8 +8321,8 @@ void Client::TextLink::generate_body()
RoF2: "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%02X" "%05X" "%08X" (56)
RoF: "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X" (55)
SoF: "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X" (50)
6.2: "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%08X" (45)
SoF: "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X" (50)
6.2: "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%08X" (45)
*/
memset(&m_LinkBodyStruct, 0, sizeof(TextLinkBody_Struct));

View File

@ -398,10 +398,10 @@ public:
inline const char* GetLastName() const { return lastname; }
inline float ProximityX() const { return m_Proximity.m_X; }
inline float ProximityY() const { return m_Proximity.m_Y; }
inline float ProximityZ() const { return m_Proximity.m_Z; }
inline void ClearAllProximities() { entity_list.ProcessMove(this, xyz_location(FLT_MAX, FLT_MAX, FLT_MAX)); m_Proximity = xyz_location(FLT_MAX,FLT_MAX,FLT_MAX); }
inline float ProximityX() const { return m_Proximity.x; }
inline float ProximityY() const { return m_Proximity.y; }
inline float ProximityZ() const { return m_Proximity.z; }
inline void ClearAllProximities() { entity_list.ProcessMove(this, glm::vec3(FLT_MAX, FLT_MAX, FLT_MAX)); m_Proximity = glm::vec3(FLT_MAX,FLT_MAX,FLT_MAX); }
/*
Begin client modifiers
@ -580,7 +580,7 @@ public:
void GoToBind(uint8 bindnum = 0);
void GoToSafeCoords(uint16 zone_id, uint16 instance_id);
void Gate();
void SetBindPoint(int to_zone = -1, int to_instance = 0, const xyz_location& location = xyz_location::Origin());
void SetBindPoint(int to_zone = -1, int to_instance = 0, const glm::vec3& location = glm::vec3());
void SetStartZone(uint32 zoneid, float x = 0.0f, float y =0.0f, float z = 0.0f);
uint32 GetStartZone(void);
void MovePC(const char* zonename, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited);
@ -1079,7 +1079,7 @@ public:
void DoItemEnterZone();
bool DoItemEnterZone(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
void SummonAndRezzAllCorpses();
void SummonAllCorpses(const xyz_heading& position);
void SummonAllCorpses(const glm::vec4& position);
void DepopAllCorpses();
void DepopPlayerCorpse(uint32 dbid);
void BuryPlayerCorpses();
@ -1268,8 +1268,8 @@ protected:
Mob* bind_sight_target;
xyz_heading m_AutoAttackPosition;
xyz_location m_AutoAttackTargetLocation;
glm::vec4 m_AutoAttackPosition;
glm::vec3 m_AutoAttackTargetLocation;
Mob *aa_los_them_mob;
bool los_status;
bool los_status_facing;
@ -1425,7 +1425,7 @@ private:
void ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm);
void ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited);
xyz_location m_ZoneSummonLocation;
glm::vec3 m_ZoneSummonLocation;
uint16 zonesummon_id;
uint8 zonesummon_ignorerestrictions;
ZoneMode zone_mode;
@ -1464,7 +1464,7 @@ private:
Timer RespawnFromHoverTimer;
Timer merc_timer;
xyz_location m_Proximity;
glm::vec3 m_Proximity;
void BulkSendInventoryItems();

View File

@ -1454,9 +1454,9 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
/* If PP is set to weird coordinates */
if ((m_pp.x == -1 && m_pp.y == -1 && m_pp.z == -1) || (m_pp.x == -2 && m_pp.y == -2 && m_pp.z == -2)) {
auto safePoint = zone->GetSafePoint();
m_pp.x = safePoint.m_X;
m_pp.y = safePoint.m_Y;
m_pp.z = safePoint.m_Z;
m_pp.x = safePoint.x;
m_pp.y = safePoint.y;
m_pp.z = safePoint.z;
}
/* If too far below ground, then fix */
// float ground_z = GetGroundZ(m_pp.x, m_pp.y, m_pp.z);
@ -1466,10 +1466,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
/* Set Mob variables for spawn */
class_ = m_pp.class_;
level = m_pp.level;
m_Position.m_X = m_pp.x;
m_Position.m_Y = m_pp.y;
m_Position.m_Z = m_pp.z;
m_Position.m_Heading = m_pp.heading;
m_Position.x = m_pp.x;
m_Position.y = m_pp.y;
m_Position.z = m_pp.z;
m_Position.w = m_pp.heading;
race = m_pp.race;
base_race = m_pp.race;
gender = m_pp.gender;
@ -2028,7 +2028,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app)
return;
//you have to be somewhat close to them to be properly using them
if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
return;
merchantid = tmp->CastToNPC()->MerchantType;
@ -2203,7 +2203,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app)
return;
//you have to be somewhat close to them to be properly using them
if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
return;
merchantid = tmp->CastToNPC()->MerchantType;
@ -2294,7 +2294,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app)
return;
}
if (ComparativeDistance(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2)
{
Message(13, "Vendor is out of range.");
return;
@ -2552,7 +2552,7 @@ void Client::Handle_OP_AltCurrencyMerchantRequest(const EQApplicationPacket *app
NPC* tar = entity_list.GetNPCByID(*((uint32*)app->pBuffer));
if (tar) {
if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
return;
if (tar->GetClass() != ALT_CURRENCY_MERCHANT) {
@ -2631,7 +2631,7 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app)
AltCurrencyPurchaseItem_Struct *purchase = (AltCurrencyPurchaseItem_Struct*)app->pBuffer;
NPC* tar = entity_list.GetNPCByID(purchase->merchant_entity_id);
if (tar) {
if (ComparativeDistance(m_Position, tar->GetPosition())> USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tar->GetPosition())> USE_NPC_RANGE2)
return;
if (tar->GetClass() != ALT_CURRENCY_MERCHANT) {
@ -2768,7 +2768,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app)
NPC* tar = entity_list.GetNPCByID(sell->merchant_entity_id);
if (tar) {
if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
return;
if (tar->GetClass() != ALT_CURRENCY_MERCHANT) {
@ -2865,7 +2865,7 @@ void Client::Handle_OP_AltCurrencySellSelection(const EQApplicationPacket *app)
AltCurrencySelectItem_Struct *select = (AltCurrencySelectItem_Struct*)app->pBuffer;
NPC* tar = entity_list.GetNPCByID(select->merchant_entity_id);
if (tar) {
if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
return;
if (tar->GetClass() != ALT_CURRENCY_MERCHANT) {
@ -3239,8 +3239,8 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app)
ranged_timer.Disable();
attack_dw_timer.Disable();
m_AutoAttackPosition = xyz_heading::Origin();
m_AutoAttackTargetLocation = xyz_location::Origin();
m_AutoAttackPosition = glm::vec4();
m_AutoAttackTargetLocation = glm::vec3();
aa_los_them_mob = nullptr;
}
else if (app->pBuffer[0] == 1)
@ -3255,14 +3255,14 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app)
{
aa_los_them_mob = GetTarget();
m_AutoAttackPosition = GetPosition();
m_AutoAttackTargetLocation = aa_los_them_mob->GetPosition();
m_AutoAttackTargetLocation = glm::vec3(aa_los_them_mob->GetPosition());
los_status = CheckLosFN(aa_los_them_mob);
los_status_facing = IsFacingMob(aa_los_them_mob);
}
else
{
m_AutoAttackPosition = GetPosition();
m_AutoAttackTargetLocation = xyz_location::Origin();
m_AutoAttackTargetLocation = glm::vec3();
aa_los_them_mob = nullptr;
los_status = false;
los_status_facing = false;
@ -3984,7 +3984,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app)
CastSpell_Struct* castspell = (CastSpell_Struct*)app->pBuffer;
m_TargetRing = xyz_location(castspell->x_pos, castspell->y_pos, castspell->z_pos);
m_TargetRing = glm::vec3(castspell->x_pos, castspell->y_pos, castspell->z_pos);
#ifdef _EQDEBUG
LogFile->write(EQEmuLog::Debug, "cs_unknown2: %u %i", (uint8)castspell->cs_unknown[0], castspell->cs_unknown[0]);
@ -4016,7 +4016,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app)
return;
}
m_TargetRing = xyz_location(castspell->x_pos, castspell->y_pos, castspell->z_pos);
m_TargetRing = glm::vec3(castspell->x_pos, castspell->y_pos, castspell->z_pos);
CastSpell(spell_to_cast, castspell->target_id, castspell->slot);
}
@ -4360,7 +4360,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
}
// set the boat's position deltas
auto boatDelta = xyz_heading(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading);
auto boatDelta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading);
boat->SetDelta(boatDelta);
// send an update to everyone nearby except the client controlling the boat
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
@ -4377,9 +4377,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
float dist = 0;
float tmp;
tmp = m_Position.m_X - ppu->x_pos;
tmp = m_Position.x - ppu->x_pos;
dist += tmp*tmp;
tmp = m_Position.m_Y - ppu->y_pos;
tmp = m_Position.y - ppu->y_pos;
dist += tmp*tmp;
dist = sqrt(dist);
@ -4522,41 +4522,41 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
float rewind_x_diff = 0;
float rewind_y_diff = 0;
rewind_x_diff = ppu->x_pos - m_RewindLocation.m_X;
rewind_x_diff = ppu->x_pos - m_RewindLocation.x;
rewind_x_diff *= rewind_x_diff;
rewind_y_diff = ppu->y_pos - m_RewindLocation.m_Y;
rewind_y_diff = ppu->y_pos - m_RewindLocation.y;
rewind_y_diff *= rewind_y_diff;
//We only need to store updated values if the player has moved.
//If the player has moved more than units for x or y, then we'll store
//his pre-PPU x and y for /rewind, in case he gets stuck.
if ((rewind_x_diff > 750) || (rewind_y_diff > 750))
m_RewindLocation = m_Position;
m_RewindLocation = glm::vec3(m_Position);
//If the PPU was a large jump, such as a cross zone gate or Call of Hero,
//just update rewind coords to the new ppu coords. This will prevent exploitation.
if ((rewind_x_diff > 5000) || (rewind_y_diff > 5000))
m_RewindLocation = xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos);
m_RewindLocation = glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos);
if(proximity_timer.Check()) {
entity_list.ProcessMove(this, xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos));
entity_list.ProcessMove(this, glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos));
if(RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem,EnableTaskProximity))
ProcessTaskProximities(ppu->x_pos, ppu->y_pos, ppu->z_pos);
m_Proximity = xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos);
m_Proximity = glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos);
}
// Update internal state
m_Delta = xyz_heading(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading);
m_Delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading);
if(IsTracking() && ((m_Position.m_X!=ppu->x_pos) || (m_Position.m_Y!=ppu->y_pos))){
if(IsTracking() && ((m_Position.x!=ppu->x_pos) || (m_Position.y!=ppu->y_pos))){
if(zone->random.Real(0, 100) < 70)//should be good
CheckIncreaseSkill(SkillTracking, nullptr, -20);
}
// Break Hide if moving without sneaking and set rewind timer if moved
if(ppu->y_pos != m_Position.m_Y || ppu->x_pos != m_Position.m_X){
if(ppu->y_pos != m_Position.y || ppu->x_pos != m_Position.x){
if((hidden || improved_hidden) && !sneaking){
hidden = false;
improved_hidden = false;
@ -4576,12 +4576,12 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
// Outgoing client packet
float tmpheading = EQ19toFloat(ppu->heading);
if (!FCMP(ppu->y_pos, m_Position.m_Y) || !FCMP(ppu->x_pos, m_Position.m_X) || !FCMP(tmpheading, m_Position.m_Heading) || ppu->animation != animation)
if (!FCMP(ppu->y_pos, m_Position.y) || !FCMP(ppu->x_pos, m_Position.x) || !FCMP(tmpheading, m_Position.w) || ppu->animation != animation)
{
m_Position.m_X = ppu->x_pos;
m_Position.m_Y = ppu->y_pos;
m_Position.m_Z = ppu->z_pos;
m_Position.m_Heading = tmpheading;
m_Position.x = ppu->x_pos;
m_Position.y = ppu->y_pos;
m_Position.z = ppu->z_pos;
m_Position.w = tmpheading;
animation = ppu->animation;
@ -4595,7 +4595,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
safe_delete(outapp);
}
if(zone->watermap && zone->watermap->InLiquid(m_Position))
if(zone->watermap && zone->watermap->InLiquid(glm::vec3(m_Position)))
CheckIncreaseSkill(SkillSwimming, nullptr, -17);
return;
@ -5668,8 +5668,8 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
}
else
{
Map::Vertex Start(GetX(), GetY(), GetZ() + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION);
Map::Vertex End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION);
glm::vec3 Start(GetX(), GetY(), GetZ() + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION);
glm::vec3 End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION);
if (!zone->zonemap->LineIntersectsZone(Start, End, 1.0f, nullptr) && zone->pathing->NoHazards(Start, End))
{
@ -5712,7 +5712,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
bool LeadsToTeleporter = false;
Map::Vertex v = zone->pathing->GetPathNodeCoordinates(pathlist.back());
glm::vec3 v = zone->pathing->GetPathNodeCoordinates(pathlist.back());
p.x = v.x;
p.y = v.y;
@ -5732,7 +5732,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
break;
}
Map::Vertex v = zone->pathing->GetPathNodeCoordinates((*Iterator), false);
glm::vec3 v = zone->pathing->GetPathNodeCoordinates((*Iterator), false);
p.x = v.x;
p.y = v.y;
p.z = v.z;
@ -8720,7 +8720,7 @@ void Client::Handle_OP_LDoNDisarmTraps(const EQApplicationPacket *app)
{
if (HasSkill(SkillDisarmTraps))
{
if (ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if (DistanceSquaredNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
Message(13, "%s is too far away.", target->GetCleanName());
return;
@ -8753,7 +8753,7 @@ void Client::Handle_OP_LDoNPickLock(const EQApplicationPacket *app)
{
if (HasSkill(SkillPickLock))
{
if (ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if (DistanceSquaredNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
Message(13, "%s is too far away.", target->GetCleanName());
return;
@ -8772,7 +8772,7 @@ void Client::Handle_OP_LDoNSenseTraps(const EQApplicationPacket *app)
{
if (HasSkill(SkillSenseTraps))
{
if (ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if (DistanceSquaredNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
Message(13, "%s is too far away.", target->GetCleanName());
return;
@ -9195,7 +9195,7 @@ void Client::Handle_OP_LootRequest(const EQApplicationPacket *app)
{
SetLooting(ent->GetID()); //store the entity we are looting
Corpse *ent_corpse = ent->CastToCorpse();
if (ComparativeDistanceNoZ(m_Position, ent_corpse->GetPosition()) > 625)
if (DistanceSquaredNoZ(m_Position, ent_corpse->GetPosition()) > 625)
{
Message(13, "Corpse too far away.");
Corpse::SendLootReqErrorPacket(this);
@ -9427,7 +9427,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app)
int mercTypeCount = 0;
int mercCount = 0;
if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tar->GetPosition()) > USE_NPC_RANGE2)
return;
if (tar->GetClass() != MERCERNARY_MASTER) {
@ -9809,7 +9809,7 @@ void Client::Handle_OP_OpenGuildTributeMaster(const EQApplicationPacket *app)
StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer;
Mob* tribmast = entity_list.GetMob(st->tribute_master_id);
if (tribmast && tribmast->IsNPC() && tribmast->GetClass() == GUILD_TRIBUTE_MASTER
&& ComparativeDistance(m_Position, tribmast->GetPosition()) <= USE_NPC_RANGE2) {
&& DistanceSquared(m_Position, tribmast->GetPosition()) <= USE_NPC_RANGE2) {
st->response = 1;
QueuePacket(app);
tribute_master_id = st->tribute_master_id;
@ -9841,7 +9841,7 @@ void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app)
StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer;
Mob* tribmast = entity_list.GetMob(st->tribute_master_id);
if (tribmast && tribmast->IsNPC() && tribmast->GetClass() == TRIBUTE_MASTER
&& ComparativeDistance(m_Position, tribmast->GetPosition()) <= USE_NPC_RANGE2) {
&& DistanceSquared(m_Position, tribmast->GetPosition()) <= USE_NPC_RANGE2) {
st->response = 1;
QueuePacket(app);
tribute_master_id = st->tribute_master_id;
@ -9936,7 +9936,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
}
if ((mypet->GetPetType() == petAnimation && GetAA(aaAnimationEmpathy) >= 2) || mypet->GetPetType() != petAnimation) {
if (GetTarget() != this && ComparativeDistanceNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) {
if (GetTarget() != this && DistanceSquaredNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) {
if (mypet->IsHeld()) {
if (!mypet->IsFocused()) {
mypet->SetHeld(false); //break the hold and guard if we explicitly tell the pet to attack.
@ -9971,7 +9971,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
}
if ((mypet->GetPetType() == petAnimation && GetAA(aaAnimationEmpathy) >= 2) || mypet->GetPetType() != petAnimation) {
if (GetTarget() != this && ComparativeDistanceNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) {
if (GetTarget() != this && DistanceSquaredNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) {
zone->AddAggroMob();
mypet->AddToHateList(GetTarget(), 1);
Message_StringID(MT_PetResponse, PET_ATTACKING, mypet->GetCleanName(), GetTarget()->GetCleanName());
@ -11688,7 +11688,7 @@ void Client::Handle_OP_Rewind(const EQApplicationPacket *app)
Message_StringID(MT_System, REWIND_WAIT);
}
else {
CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_RewindLocation.m_X, m_RewindLocation.m_Y, m_RewindLocation.m_Z, 0, 2, Rewind);
CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_RewindLocation.x, m_RewindLocation.y, m_RewindLocation.z, 0, 2, Rewind);
rewind_timer.Start(30000, true);
}
}
@ -11812,29 +11812,29 @@ void Client::Handle_OP_SenseTraps(const EQApplicationPacket *app)
int uskill = GetSkill(SkillSenseTraps);
if ((zone->random.Int(0, 99) + uskill) >= (zone->random.Int(0, 99) + trap->skill*0.75))
{
auto diff = trap->m_Position - GetPosition();
auto diff = trap->m_Position - glm::vec3(GetPosition());
if (diff.m_X == 0 && diff.m_Y == 0)
if (diff.x == 0 && diff.y == 0)
Message(MT_Skills, "You sense a trap right under your feet!");
else if (diff.m_X > 10 && diff.m_Y > 10)
else if (diff.x > 10 && diff.y > 10)
Message(MT_Skills, "You sense a trap to the NorthWest.");
else if (diff.m_X < -10 && diff.m_Y > 10)
else if (diff.x < -10 && diff.y > 10)
Message(MT_Skills, "You sense a trap to the NorthEast.");
else if (diff.m_Y > 10)
else if (diff.y > 10)
Message(MT_Skills, "You sense a trap to the North.");
else if (diff.m_X > 10 && diff.m_Y < -10)
else if (diff.x > 10 && diff.y < -10)
Message(MT_Skills, "You sense a trap to the SouthWest.");
else if (diff.m_X < -10 && diff.m_Y < -10)
else if (diff.x < -10 && diff.y < -10)
Message(MT_Skills, "You sense a trap to the SouthEast.");
else if (diff.m_Y < -10)
else if (diff.y < -10)
Message(MT_Skills, "You sense a trap to the South.");
else if (diff.m_X > 10)
else if (diff.x > 10)
Message(MT_Skills, "You sense a trap to the West.");
else
Message(MT_Skills, "You sense a trap to the East.");
trap->detected = true;
float angle = CalculateHeadingToTarget(trap->m_Position.m_X, trap->m_Position.m_Y);
float angle = CalculateHeadingToTarget(trap->m_Position.x, trap->m_Position.y);
if (angle < 0)
angle = (256 + angle);
@ -12115,7 +12115,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
if (mp->quantity < 1) return;
//you have to be somewhat close to them to be properly using them
if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
return;
merchantid = tmp->CastToNPC()->MerchantType;
@ -12364,7 +12364,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
return;
//you have to be somewhat close to them to be properly using them
if (ComparativeDistance(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2)
return;
uint32 price = 0;
@ -12523,7 +12523,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app)
return;
//you have to be somewhat close to them to be properly using them
if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
return;
merchantid = tmp->CastToNPC()->MerchantType;
@ -13019,7 +13019,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
// For /target, send reject or success packet
if (app->GetOpcode() == OP_TargetCommand) {
if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (ComparativeDistance(m_Position, GetTarget()->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) {
if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (DistanceSquared(m_Position, GetTarget()->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) {
if (GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special
|| GetTarget()->GetBodyType() == BT_NoTarget)
{
@ -13108,9 +13108,9 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
}
else if (GetBindSightTarget())
{
if (ComparativeDistance(GetBindSightTarget()->GetPosition(), GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
if (DistanceSquared(GetBindSightTarget()->GetPosition(), GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
{
if (ComparativeDistance(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
if (DistanceSquared(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
{
char *hacker_str = nullptr;
MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units,"
@ -13124,7 +13124,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
}
}
}
else if (ComparativeDistance(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
else if (DistanceSquared(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
{
char *hacker_str = nullptr;
MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units,"
@ -13756,7 +13756,7 @@ void Client::Handle_OP_TributeItem(const EQApplicationPacket *app)
Mob* tribmast = entity_list.GetMob(t->tribute_master_id);
if (!tribmast || !tribmast->IsNPC() || tribmast->GetClass() != TRIBUTE_MASTER)
return;
if (ComparativeDistance(m_Position, tribmast->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tribmast->GetPosition()) > USE_NPC_RANGE2)
return;
t->tribute_points = TributeItem(t->slot, t->quantity);
@ -13785,7 +13785,7 @@ void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app)
Mob* tribmast = entity_list.GetMob(t->tribute_master_id);
if (!tribmast || !tribmast->IsNPC() || tribmast->GetClass() != TRIBUTE_MASTER)
return;
if (ComparativeDistance(m_Position, tribmast->GetPosition()) > USE_NPC_RANGE2)
if (DistanceSquared(m_Position, tribmast->GetPosition()) > USE_NPC_RANGE2)
return;
t->tribute_points = TributeMoney(t->platinum);

View File

@ -340,23 +340,23 @@ bool Client::Process() {
if(aa_los_them_mob)
{
if(auto_attack_target != aa_los_them_mob ||
m_AutoAttackPosition.m_X != GetX() ||
m_AutoAttackPosition.m_Y != GetY() ||
m_AutoAttackPosition.m_Z != GetZ() ||
m_AutoAttackTargetLocation.m_X != aa_los_them_mob->GetX() ||
m_AutoAttackTargetLocation.m_Y != aa_los_them_mob->GetY() ||
m_AutoAttackTargetLocation.m_Z != aa_los_them_mob->GetZ())
m_AutoAttackPosition.x != GetX() ||
m_AutoAttackPosition.y != GetY() ||
m_AutoAttackPosition.z != GetZ() ||
m_AutoAttackTargetLocation.x != aa_los_them_mob->GetX() ||
m_AutoAttackTargetLocation.y != aa_los_them_mob->GetY() ||
m_AutoAttackTargetLocation.z != aa_los_them_mob->GetZ())
{
aa_los_them_mob = auto_attack_target;
m_AutoAttackPosition = GetPosition();
m_AutoAttackTargetLocation = aa_los_them_mob->GetPosition();
m_AutoAttackTargetLocation = glm::vec3(aa_los_them_mob->GetPosition());
los_status = CheckLosFN(auto_attack_target);
los_status_facing = IsFacingMob(aa_los_them_mob);
}
// If only our heading changes, we can skip the CheckLosFN call
// but above we still need to update los_status_facing
if (m_AutoAttackPosition.m_Heading != GetHeading()) {
m_AutoAttackPosition.m_Heading = GetHeading();
if (m_AutoAttackPosition.w != GetHeading()) {
m_AutoAttackPosition.w = GetHeading();
los_status_facing = IsFacingMob(aa_los_them_mob);
}
}
@ -364,7 +364,7 @@ bool Client::Process() {
{
aa_los_them_mob = auto_attack_target;
m_AutoAttackPosition = GetPosition();
m_AutoAttackTargetLocation = aa_los_them_mob->GetPosition();
m_AutoAttackTargetLocation = glm::vec3(aa_los_them_mob->GetPosition());
los_status = CheckLosFN(auto_attack_target);
los_status_facing = IsFacingMob(aa_los_them_mob);
}
@ -519,7 +519,7 @@ bool Client::Process() {
else
{
animation = 0;
m_Delta = xyz_heading(0.0f, 0.0f, 0.0f, m_Delta.m_Heading);
m_Delta = glm::vec4(0.0f, 0.0f, 0.0f, m_Delta.w);
SendPosUpdate(2);
}
}
@ -1601,7 +1601,7 @@ void Client::OPGMTraining(const EQApplicationPacket *app)
return;
//you have to be somewhat close to a trainer to be properly using them
if(ComparativeDistance(m_Position,pTrainer->GetPosition()) > USE_NPC_RANGE2)
if(DistanceSquared(m_Position,pTrainer->GetPosition()) > USE_NPC_RANGE2)
return;
// if this for-loop acts up again (crashes linux), try enabling the before and after #pragmas
@ -1649,7 +1649,7 @@ void Client::OPGMEndTraining(const EQApplicationPacket *app)
return;
//you have to be somewhat close to a trainer to be properly using them
if(ComparativeDistance(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2)
if(DistanceSquared(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2)
return;
// goodbye message
@ -1678,7 +1678,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app)
return;
//you have to be somewhat close to a trainer to be properly using them
if(ComparativeDistance(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2)
if(DistanceSquared(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2)
return;
if (gmskill->skillbank == 0x01)
@ -2117,9 +2117,9 @@ void Client::HandleRespawnFromHover(uint32 Option)
if (corpse)
{
m_Position.m_X = corpse->GetX();
m_Position.m_Y = corpse->GetY();
m_Position.m_Z = corpse->GetZ();
m_Position.x = corpse->GetX();
m_Position.y = corpse->GetY();
m_Position.z = corpse->GetZ();
}
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ZonePlayerToBind, sizeof(ZonePlayerToBind_Struct) + 10);
@ -2172,10 +2172,10 @@ void Client::HandleRespawnFromHover(uint32 Option)
SetMana(GetMaxMana());
SetEndurance(GetMaxEndurance());
m_Position.m_X = chosen->x;
m_Position.m_Y = chosen->y;
m_Position.m_Z = chosen->z;
m_Position.m_Heading = chosen->heading;
m_Position.x = chosen->x;
m_Position.y = chosen->y;
m_Position.z = chosen->z;
m_Position.w = chosen->heading;
ClearHover();
entity_list.RefreshClientXTargets(this);

View File

@ -1839,7 +1839,7 @@ void command_itemtest(Client *c, const Seperator *sep)
void command_gassign(Client *c, const Seperator *sep)
{
if (sep->IsNumber(1) && c->GetTarget() && c->GetTarget()->IsNPC())
database.AssignGrid(c, c->GetTarget()->CastToNPC()->m_SpawnPoint, atoi(sep->arg[1]));
database.AssignGrid(c, glm::vec2(c->GetTarget()->CastToNPC()->m_SpawnPoint), atoi(sep->arg[1]));
else
c->Message(0,"Usage: #gassign [num] - must have an npc target!");
}
@ -2095,7 +2095,7 @@ void command_wp(Client *c, const Seperator *sep)
}
else {
auto position = c->GetPosition();
position.m_Heading = -1;
position.w = -1;
database.AddWP(c, atoi(sep->arg[2]),wp, position, atoi(sep->arg[3]),zone->GetZoneID());
}
}
@ -4908,7 +4908,7 @@ void command_manaburn(Client *c, const Seperator *sep)
c->Message(0, "#Manaburn needs a target.");
else {
int cur_level=c->GetAA(MANA_BURN);//ManaBurn ID
if (ComparativeDistance(c->GetPosition(), target->GetPosition()) > 200)
if (DistanceSquared(c->GetPosition(), target->GetPosition()) > 200)
c->Message(0,"You are too far away from your target.");
else {
if(cur_level == 1) {
@ -5440,7 +5440,7 @@ void command_wpadd(Client *c, const Seperator *sep)
}
auto position = c->GetPosition();
if (strcmp("-h",sep->arg[2]) != 0)
position.m_Heading = -1;
position.w = -1;
uint32 tmp_grid = database.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone->GetZoneID());
if (tmp_grid)
@ -6973,7 +6973,7 @@ void command_path(Client *c, const Seperator *sep)
if(zone->zonemap)
{
Map::Vertex loc(px, py, pz);
glm::vec3 loc(px, py, pz);
best_z = zone->zonemap->FindBestZ(loc, nullptr);
}
else
@ -7000,7 +7000,7 @@ void command_path(Client *c, const Seperator *sep)
if(zone->zonemap)
{
Map::Vertex loc(px, py, pz);
glm::vec3 loc(px, py, pz);
best_z = zone->zonemap->FindBestZ(loc, nullptr);
}
else
@ -7133,8 +7133,8 @@ void command_path(Client *c, const Seperator *sep)
{
if(c && c->GetTarget())
{
if (zone->pathing->NoHazardsAccurate(Map::Vertex(c->GetX(), c->GetY(), c->GetZ()),
Map::Vertex(c->GetTarget()->GetX(), c->GetTarget()->GetY(), c->GetTarget()->GetZ())))
if (zone->pathing->NoHazardsAccurate(glm::vec3(c->GetX(), c->GetY(), c->GetZ()),
glm::vec3(c->GetTarget()->GetX(), c->GetTarget()->GetY(), c->GetTarget()->GetZ())))
{
c->Message(0, "No hazards.");
}
@ -7210,7 +7210,7 @@ void command_path(Client *c, const Seperator *sep)
{
Mob *m = c->GetTarget();
Map::Vertex Position(m->GetX(), m->GetY(), m->GetZ());
glm::vec3 Position(m->GetX(), m->GetY(), m->GetZ());
int Node = zone->pathing->FindNearestPathNode(Position);
@ -7344,12 +7344,12 @@ void command_bestz(Client *c, const Seperator *sep) {
if (zone->zonemap == nullptr) {
c->Message(0,"Map not loaded for this zone");
} else {
Map::Vertex me;
glm::vec3 me;
me.x = c->GetX();
me.y = c->GetY();
me.z = c->GetZ() + (c->GetSize() == 0.0 ? 6 : c->GetSize()) * HEAD_POSITION;
Map::Vertex hit;
Map::Vertex bme(me);
glm::vec3 hit;
glm::vec3 bme(me);
bme.z -= 500;
float best_z = zone->zonemap->FindBestZ(me, &hit);
@ -7372,7 +7372,7 @@ void command_bestz(Client *c, const Seperator *sep) {
if(c->GetTarget()) {
z=c->GetTarget()->GetZ();
auto position = xyz_location(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z);
auto position = glm::vec3(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z);
RegionType = zone->watermap->ReturnRegionType(position);
c->Message(0,"InWater returns %d", zone->watermap->InWater(position));
c->Message(0,"InLava returns %d", zone->watermap->InLava(position));
@ -7380,7 +7380,7 @@ void command_bestz(Client *c, const Seperator *sep) {
}
else {
z=c->GetZ();
auto position = xyz_location(c->GetX(), c->GetY(), z);
auto position = glm::vec3(c->GetX(), c->GetY(), z);
RegionType = zone->watermap->ReturnRegionType(position);
c->Message(0,"InWater returns %d", zone->watermap->InWater(position));
c->Message(0,"InLava returns %d", zone->watermap->InLava(position));
@ -10305,7 +10305,7 @@ void command_disarmtrap(Client *c, const Seperator *sep)
{
if(c->HasSkill(SkillDisarmTraps))
{
if(ComparativeDistanceNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if(DistanceSquaredNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
c->Message(13, "%s is too far away.", target->GetCleanName());
return;
@ -10330,7 +10330,7 @@ void command_sensetrap(Client *c, const Seperator *sep)
{
if(c->HasSkill(SkillSenseTraps))
{
if(ComparativeDistanceNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if(DistanceSquaredNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
c->Message(13, "%s is too far away.", target->GetCleanName());
return;
@ -10355,7 +10355,7 @@ void command_picklock(Client *c, const Seperator *sep)
{
if(c->HasSkill(SkillPickLock))
{
if(ComparativeDistanceNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
if(DistanceSquaredNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse))
{
c->Message(13, "%s is too far away.", target->GetCleanName());
return;

View File

@ -70,7 +70,7 @@ void Corpse::SendLootReqErrorPacket(Client* client, uint8 response) {
safe_delete(outapp);
}
Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std::string in_charname, const xyz_heading& position, std::string time_of_death, bool rezzed, bool was_at_graveyard) {
Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std::string in_charname, const glm::vec4& position, std::string time_of_death, bool rezzed, bool was_at_graveyard) {
uint32 item_count = database.GetCharacterCorpseItemCount(in_dbid);
char *buffer = new char[sizeof(PlayerCorpse_Struct) + (item_count * sizeof(player_lootitem::ServerLootItem_Struct))];
PlayerCorpse_Struct *pcs = (PlayerCorpse_Struct*)buffer;
@ -435,7 +435,7 @@ std::list<uint32> Corpse::MoveItemToCorpse(Client *client, ItemInst *item, int16
}
// To be called from LoadFromDBData
Corpse::Corpse(uint32 in_dbid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, const xyz_heading& position, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture,uint32 in_rezexp, bool wasAtGraveyard)
Corpse::Corpse(uint32 in_dbid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, const glm::vec4& position, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture,uint32 in_rezexp, bool wasAtGraveyard)
: Mob("Unnamed_Corpse",
"",
0,
@ -1328,7 +1328,7 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) {
client->Message(13, "That corpse is locked by a GM.");
return false;
}
if (!CheckDistance || (ComparativeDistanceNoZ(m_Position, client->GetPosition()) <= dist2)) {
if (!CheckDistance || (DistanceSquaredNoZ(m_Position, client->GetPosition()) <= dist2)) {
GMMove(client->GetX(), client->GetY(), client->GetZ());
is_corpse_changed = true;
}
@ -1343,7 +1343,7 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) {
std::list<std::string>::iterator itr;
for(itr = client->consent_list.begin(); itr != client->consent_list.end(); ++itr) {
if(strcmp(this->GetOwnerName(), itr->c_str()) == 0) {
if (!CheckDistance || (ComparativeDistanceNoZ(m_Position, client->GetPosition()) <= dist2)) {
if (!CheckDistance || (DistanceSquaredNoZ(m_Position, client->GetPosition()) <= dist2)) {
GMMove(client->GetX(), client->GetY(), client->GetZ());
is_corpse_changed = true;
}

View File

@ -41,10 +41,10 @@ class Corpse : public Mob {
Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000);
Corpse(Client* client, int32 in_rezexp);
Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, const xyz_heading& position, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false);
Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, const glm::vec4& position, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false);
~Corpse();
static Corpse* LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std::string in_charname, const xyz_heading& position, std::string time_of_death, bool rezzed, bool was_at_graveyard);
static Corpse* LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std::string in_charname, const glm::vec4& position, std::string time_of_death, bool rezzed, bool was_at_graveyard);
/* Corpse: General */
virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill) { return true; }

View File

@ -71,10 +71,10 @@ Doors::Doors(const Door* door) :
client_version_mask = door->client_version_mask;
}
Doors::Doors(const char *dmodel, const xyz_heading& position, uint8 dopentype, uint16 dsize) :
Doors::Doors(const char *dmodel, const glm::vec4& position, uint8 dopentype, uint16 dsize) :
close_timer(5000),
m_Position(position),
m_Destination(xyz_heading::Origin())
m_Destination(glm::vec4())
{
db_id = database.GetDoorsCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion());
door_id = database.GetDoorsDBCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion());
@ -410,7 +410,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger)
{
sender->KeyRingAdd(playerkey);
}
sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading);
sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.x, m_Destination.y, m_Destination.z, m_Destination.w);
}
else if (( !IsDoorOpen() || opentype == 58 ) && (keyneeded && ((keyneeded == playerkey) || sender->GetGM())))
{
@ -420,22 +420,22 @@ void Doors::HandleClick(Client* sender, uint8 trigger)
}
if(database.GetZoneID(dest_zone) == zone->GetZoneID())
{
sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading);
sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.x, m_Destination.y, m_Destination.z, m_Destination.w);
}
else
{
sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading);
sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, m_Destination.x, m_Destination.y, m_Destination.z, m_Destination.w);
}
}
if (( !IsDoorOpen() || opentype == 58 ) && (!keyneeded))
{
if(database.GetZoneID(dest_zone) == zone->GetZoneID())
{
sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading);
sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.x, m_Destination.y, m_Destination.z, m_Destination.w);
}
else
{
sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading);
sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, m_Destination.x, m_Destination.y, m_Destination.z, m_Destination.w);
}
}
}
@ -697,11 +697,11 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
void Doors::SetLocation(float x, float y, float z)
{
entity_list.DespawnAllDoors();
m_Position = xyz_location(x, y, z);
m_Position = glm::vec4(x, y, z, m_Position.w);
entity_list.RespawnAllDoors();
}
void Doors::SetPosition(const xyz_heading& position) {
void Doors::SetPosition(const glm::vec4& position) {
entity_list.DespawnAllDoors();
m_Position = position;
entity_list.RespawnAllDoors();

View File

@ -17,7 +17,7 @@ class Doors : public Entity
{
public:
Doors(const Door* door);
Doors(const char *dmodel, const xyz_heading& position, uint8 dopentype = 58, uint16 dsize = 100);
Doors(const char *dmodel, const glm::vec4& position, uint8 dopentype = 58, uint16 dsize = 100);
~Doors();
bool IsDoor() const { return true; }
void HandleClick(Client* sender, uint8 trigger);
@ -29,7 +29,7 @@ public:
char* GetDoorName() { return door_name; }
uint32 GetDoorParam() { return door_param; }
int GetInvertState() { return invert_state; }
const xyz_heading GetPosition() const{ return m_Position; }
const glm::vec4 GetPosition() const{ return m_Position; }
int GetIncline() { return incline; }
bool triggered;
void SetOpenState(bool st) { isopen = st; }
@ -51,7 +51,7 @@ public:
void SetEntityID(uint32 entity) { entity_id = entity; }
void DumpDoor();
const xyz_heading GetDestination() const { return m_Destination; }
const glm::vec4 GetDestination() const { return m_Destination; }
uint8 IsLDoNDoor() { return is_ldon_door; }
uint32 GetClientVersionMask() { return client_version_mask; }
@ -61,7 +61,7 @@ public:
void ForceClose(Mob *sender, bool alt_mode=false);
void ToggleState(Mob *sender);
void SetPosition(const xyz_heading& position);
void SetPosition(const glm::vec4& position);
void SetLocation(float x, float y, float z);
void SetIncline(int in);
void SetDoorName(const char* name);
@ -75,7 +75,7 @@ private:
uint8 door_id;
char zone_name[32];
char door_name[32];
xyz_heading m_Position;
glm::vec4 m_Position;
int incline;
uint8 opentype;
uint32 guild_id;
@ -94,7 +94,7 @@ private:
char dest_zone[16];
int dest_instance_id;
xyz_heading m_Destination;
glm::vec4 m_Destination;
uint8 is_ldon_door;
uint32 client_version_mask;

View File

@ -674,7 +674,7 @@ void EntityList::AETaunt(Client* taunter, float range)
zdiff *= -1;
if (zdiff < 10
&& taunter->IsAttackAllowed(them)
&& ComparativeDistanceNoZ(taunter->GetPosition(), them->GetPosition()) <= range) {
&& DistanceSquaredNoZ(taunter->GetPosition(), them->GetPosition()) <= range) {
if (taunter->CheckLosFN(them)) {
taunter->Taunt(them, true);
}
@ -721,10 +721,10 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_
continue;
if (spells[spell_id].targettype == ST_Ring) {
dist_targ = ComparativeDistance(static_cast<xyz_location>(curmob->GetPosition()), caster->GetTargetRingLocation());
dist_targ = DistanceSquared(static_cast<glm::vec3>(curmob->GetPosition()), caster->GetTargetRingLocation());
}
else if (center) {
dist_targ = ComparativeDistance(curmob->GetPosition(), center->GetPosition());
dist_targ = DistanceSquared(curmob->GetPosition(), center->GetPosition());
}
if (dist_targ > dist2) //make sure they are in range
@ -796,7 +796,7 @@ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool a
continue;
if (curmob == caster && !affect_caster) //watch for caster too
continue;
if (ComparativeDistance(center->GetPosition(), curmob->GetPosition()) > dist2) //make sure they are in range
if (DistanceSquared(center->GetPosition(), curmob->GetPosition()) > dist2) //make sure they are in range
continue;
//Only npcs mgb should hit are client pets...
@ -838,7 +838,7 @@ void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool aff
continue;
if (curmob == caster && !affect_caster) //watch for caster too
continue;
if (ComparativeDistance(center->GetPosition(), curmob->GetPosition()) > dist2) //make sure they are in range
if (DistanceSquared(center->GetPosition(), curmob->GetPosition()) > dist2) //make sure they are in range
continue;
if (isnpc && curmob->IsNPC()) { //check npc->npc casting
FACTION_VALUE f = curmob->GetReverseFactionCon(caster);
@ -888,7 +888,7 @@ void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool I
&& curmob != attacker //this is not needed unless NPCs can use this
&&(attacker->IsAttackAllowed(curmob))
&& curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */
&& (ComparativeDistance(curmob->GetPosition(), attacker->GetPosition()) <= dist2)
&& (DistanceSquared(curmob->GetPosition(), attacker->GetPosition()) <= dist2)
) {
attacker->Attack(curmob, Hand, false, false, IsFromSpell);
hit++;

View File

@ -219,7 +219,7 @@ XS(XS__spawn)
int npc_type = (int)SvIV(ST(0));
int grid = (int)SvIV(ST(1));
int unused = (int)SvIV(ST(2));
auto position = xyz_heading((float)SvNV(ST(3)), (float)SvNV(ST(4)), (float)SvNV(ST(5)), 0.0f);
auto position = glm::vec4((float)SvNV(ST(3)), (float)SvNV(ST(4)), (float)SvNV(ST(5)), 0.0f);
Mob *r = quest_manager.spawn2(npc_type, grid, unused, position);
RETVAL = (r != nullptr) ? r->GetID() : 0;
@ -241,7 +241,7 @@ XS(XS__spawn2)
int npc_type = (int)SvIV(ST(0));
int grid = (int)SvIV(ST(1));
int unused = (int)SvIV(ST(2));
auto position = xyz_heading((float)SvNV(ST(3)), (float)SvNV(ST(4)), (float)SvNV(ST(5)), (float)SvNV(ST(6)));
auto position = glm::vec4((float)SvNV(ST(3)), (float)SvNV(ST(4)), (float)SvNV(ST(5)), (float)SvNV(ST(6)));
Mob *r = quest_manager.spawn2(npc_type, grid, unused, position);
RETVAL = (r != nullptr) ? r->GetID() : 0;
@ -270,7 +270,7 @@ XS(XS__unique_spawn)
if(items == 7)
heading = (float)SvNV(ST(6));
Mob *r = quest_manager.unique_spawn(npc_type, grid, unused, xyz_heading(x, y, z, heading));
Mob *r = quest_manager.unique_spawn(npc_type, grid, unused, glm::vec4(x, y, z, heading));
RETVAL = (r != nullptr) ? r->GetID() : 0;
XSprePUSH; PUSHu((UV)RETVAL);
@ -1317,7 +1317,7 @@ XS(XS__rebind)
Perl_croak(aTHX_ "Usage: rebind(zoneid, x, y, z)");
int zoneid = (int)SvIV(ST(0));
auto location = xyz_location((float)SvNV(ST(1)),(float)SvNV(ST(2)),(float)SvNV(ST(3)));
auto location = glm::vec3((float)SvNV(ST(1)),(float)SvNV(ST(2)),(float)SvNV(ST(3)));
quest_manager.rebind(zoneid, location);
@ -1388,7 +1388,7 @@ XS(XS__moveto)
else
saveguard = false;
quest_manager.moveto(xyz_heading(x, y, z, h), saveguard);
quest_manager.moveto(glm::vec4(x, y, z, h), saveguard);
XSRETURN_EMPTY;
}
@ -1743,7 +1743,7 @@ XS(XS__summonburriedplayercorpse)
bool RETVAL;
uint32 char_id = (int)SvIV(ST(0));
auto position = xyz_heading((float)SvIV(ST(1)), (float)SvIV(ST(2)), (float)SvIV(ST(3)),(float)SvIV(ST(4)));
auto position = glm::vec4((float)SvIV(ST(1)), (float)SvIV(ST(2)), (float)SvIV(ST(3)),(float)SvIV(ST(4)));
RETVAL = quest_manager.summonburriedplayercorpse(char_id, position);
@ -1761,7 +1761,7 @@ XS(XS__summonallplayercorpses)
bool RETVAL;
uint32 char_id = (int)SvIV(ST(0));
auto position = xyz_heading((float)SvIV(ST(1)),(float)SvIV(ST(2)),(float)SvIV(ST(3)),(float)SvIV(ST(4)));
auto position = glm::vec4((float)SvIV(ST(1)),(float)SvIV(ST(2)),(float)SvIV(ST(3)),(float)SvIV(ST(4)));
RETVAL = quest_manager.summonallplayercorpses(char_id, position);
@ -2660,10 +2660,10 @@ XS(XS__CreateGroundObject)
uint16 id = 0;
if(items == 5)
id = quest_manager.CreateGroundObject(itemid, xyz_heading(x, y, z, heading));
id = quest_manager.CreateGroundObject(itemid, glm::vec4(x, y, z, heading));
else{
uint32 decay_time = (uint32)SvIV(ST(5));
id = quest_manager.CreateGroundObject(itemid, xyz_heading(x, y, z, heading), decay_time);
id = quest_manager.CreateGroundObject(itemid, glm::vec4(x, y, z, heading), decay_time);
}
XSRETURN_IV(id);
@ -2691,7 +2691,7 @@ XS(XS__CreateGroundObjectFromModel)
if (items > 6)
decay_time = (uint32)SvIV(ST(6));
id = quest_manager.CreateGroundObjectFromModel(modelname, xyz_heading(x, y, z, heading), type, decay_time);
id = quest_manager.CreateGroundObjectFromModel(modelname, glm::vec4(x, y, z, heading), type, decay_time);
XSRETURN_IV(id);
}
@ -2966,12 +2966,12 @@ XS(XS__MovePCInstance)
if (items == 4)
{
quest_manager.MovePCInstance(zoneid, instanceid, xyz_heading(x, y, z, 0.0f));
quest_manager.MovePCInstance(zoneid, instanceid, glm::vec4(x, y, z, 0.0f));
}
else
{
float heading = (float)SvNV(ST(5));
quest_manager.MovePCInstance(zoneid, instanceid, xyz_heading(x, y, z, heading));
quest_manager.MovePCInstance(zoneid, instanceid, glm::vec4(x, y, z, heading));
}
XSRETURN_EMPTY;

View File

@ -847,10 +847,10 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket *app, Client *client)
memset(&nd, 0, sizeof(nd));
memcpy(nd.name, door->GetDoorName(), 32);
auto position = door->GetPosition();
nd.xPos = position.m_X;
nd.yPos = position.m_Y;
nd.zPos = position.m_Z;
nd.heading = position.m_Heading;
nd.xPos = position.x;
nd.yPos = position.y;
nd.zPos = position.z;
nd.heading = position.w;
nd.incline = door->GetIncline();
nd.size = door->GetSize();
nd.doorId = door->GetDoorID();
@ -1442,7 +1442,7 @@ void EntityList::QueueCloseClients(Mob *sender, const EQApplicationPacket *app,
|| (filter2 == FilterShowGroupOnly && (sender == ent ||
(ent->GetGroup() && ent->GetGroup()->IsGroupMember(sender))))
|| (filter2 == FilterShowSelfOnly && ent == sender))
&& (ComparativeDistance(ent->GetPosition(), sender->GetPosition()) <= dist2)) {
&& (DistanceSquared(ent->GetPosition(), sender->GetPosition()) <= dist2)) {
ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
}
}
@ -1552,13 +1552,13 @@ Client *EntityList::GetClientByWID(uint32 iWID)
return nullptr;
}
Client *EntityList::GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient)
Client *EntityList::GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient)
{
std::vector<Client *> ClientsInRange;
for (auto it = client_list.begin();it != client_list.end(); ++it)
if ((it->second != ExcludeClient) && (ComparativeDistance(static_cast<xyz_location>(it->second->GetPosition()), location) <= Distance))
if ((it->second != ExcludeClient) && (DistanceSquared(static_cast<glm::vec3>(it->second->GetPosition()), location) <= Distance))
ClientsInRange.push_back(it->second);
if (ClientsInRange.empty())
@ -1584,7 +1584,7 @@ Corpse *EntityList::GetCorpseByOwnerWithinRange(Client *client, Mob *center, int
auto it = corpse_list.begin();
while (it != corpse_list.end()) {
if (it->second->IsPlayerCorpse())
if (ComparativeDistanceNoZ(center->GetPosition(), it->second->GetPosition()) < range &&
if (DistanceSquaredNoZ(center->GetPosition(), it->second->GetPosition()) < range &&
strcasecmp(it->second->GetOwnerName(), client->GetName()) == 0)
return it->second;
++it;
@ -1921,7 +1921,7 @@ void EntityList::MessageClose_StringID(Mob *sender, bool skipsender, float dist,
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
c = it->second;
if(c && ComparativeDistance(c->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || c != sender))
if(c && DistanceSquared(c->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || c != sender))
c->Message_StringID(type, string_id, message1, message2, message3, message4, message5, message6, message7, message8, message9);
}
}
@ -1937,7 +1937,7 @@ void EntityList::FilteredMessageClose_StringID(Mob *sender, bool skipsender,
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
c = it->second;
if (c && ComparativeDistance(c->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || c != sender))
if (c && DistanceSquared(c->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || c != sender))
c->FilteredMessage_StringID(sender, type, filter, string_id,
message1, message2, message3, message4, message5,
message6, message7, message8, message9);
@ -1985,7 +1985,7 @@ void EntityList::MessageClose(Mob* sender, bool skipsender, float dist, uint32 t
auto it = client_list.begin();
while (it != client_list.end()) {
if (ComparativeDistance(it->second->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || it->second != sender))
if (DistanceSquared(it->second->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || it->second != sender))
it->second->Message(type, buffer);
++it;
}
@ -2460,7 +2460,7 @@ void EntityList::SendPositionUpdates(Client *client, uint32 cLastUpdate,
//bool Grouped = client->HasGroup() && mob->IsClient() && (client->GetGroup() == mob->CastToClient()->GetGroup());
//if (range == 0 || (iterator.GetData() == alwayssend) || Grouped || (mob->DistNoRootNoZ(*client) <= range)) {
if (range == 0 || (it->second == alwayssend) || mob->IsClient() || (ComparativeDistance(mob->GetPosition(), client->GetPosition()) <= range)) {
if (range == 0 || (it->second == alwayssend) || mob->IsClient() || (DistanceSquared(mob->GetPosition(), client->GetPosition()) <= range)) {
mob->MakeSpawnUpdate(ppu);
}
if(mob && mob->IsClient() && mob->GetID()>0) {
@ -2619,8 +2619,8 @@ void EntityList::FindPathsToAllNPCs()
auto it = npc_list.begin();
while (it != npc_list.end()) {
Map::Vertex Node0 = zone->pathing->GetPathNodeCoordinates(0, false);
Map::Vertex Dest(it->second->GetX(), it->second->GetY(), it->second->GetZ());
glm::vec3 Node0 = zone->pathing->GetPathNodeCoordinates(0, false);
glm::vec3 Dest(it->second->GetX(), it->second->GetY(), it->second->GetZ());
std::deque<int> Route = zone->pathing->FindRoute(Node0, Dest);
if (Route.size() == 0)
printf("Unable to find a route to %s\n", it->second->GetName());
@ -3069,14 +3069,13 @@ void EntityList::OpenDoorsNear(NPC *who)
for (auto it = door_list.begin();it != door_list.end(); ++it) {
Doors *cdoor = it->second;
if (!cdoor || cdoor->IsDoorOpen())
continue;
continue;
auto diff = who->GetPosition() - cdoor->GetPosition();
diff.ABS_XYZ();
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y;
float curdist = diff.x * diff.x + diff.y * diff.y;
if (diff.m_Z * diff.m_Z < 10 && curdist <= 100)
if (diff.z * diff.z < 10 && curdist <= 100)
cdoor->NPCOpen(who);
}
}
@ -3088,20 +3087,20 @@ void EntityList::SendAlarm(Trap *trap, Mob *currenttarget, uint8 kos)
for (auto it = npc_list.begin();it != npc_list.end(); ++it) {
NPC *cur = it->second;
auto diff = cur->GetPosition() - trap->m_Position;
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z;
auto diff = glm::vec3(cur->GetPosition()) - trap->m_Position;
float curdist = diff.x * diff.x + diff.y * diff.y + diff.z * diff.z;
if (cur->GetOwner() || cur->IsEngaged() || curdist > preSquareDistance )
continue;
if (kos) {
uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) {
cur->AddToHateList(currenttarget,1);
}
}
else
cur->AddToHateList(currenttarget,1);
}
else
cur->AddToHateList(currenttarget,1);
}
}
@ -3138,7 +3137,7 @@ struct quest_proximity_event {
int area_type;
};
void EntityList::ProcessMove(Client *c, const xyz_location& location)
void EntityList::ProcessMove(Client *c, const glm::vec3& location)
{
float last_x = c->ProximityX();
float last_y = c->ProximityY();
@ -3160,9 +3159,9 @@ void EntityList::ProcessMove(Client *c, const xyz_location& location)
last_z < l->min_z || last_z > l->max_z) {
old_in = false;
}
if (location.m_X < l->min_x || location.m_X > l->max_x ||
location.m_Y < l->min_y || location.m_Y > l->max_y ||
location.m_Z < l->min_z || location.m_Z > l->max_z) {
if (location.x < l->min_x || location.x > l->max_x ||
location.y < l->min_y || location.y > l->max_y ||
location.z < l->min_z || location.z > l->max_z) {
new_in = false;
}
@ -3195,9 +3194,9 @@ void EntityList::ProcessMove(Client *c, const xyz_location& location)
old_in = false;
}
if (location.m_X < a.min_x || location.m_X > a.max_x ||
location.m_Y < a.min_y || location.m_Y > a.max_y ||
location.m_Z < a.min_z || location.m_Z > a.max_z ) {
if (location.x < a.min_x || location.x > a.max_x ||
location.y < a.min_y || location.y > a.max_y ||
location.z < a.min_z || location.z > a.max_z ) {
new_in = false;
}
@ -3546,7 +3545,7 @@ void EntityList::RadialSetLogging(Mob *around, bool enabled, bool clients,
continue;
}
if (ComparativeDistance(around->GetPosition(), mob->GetPosition()) > range2)
if (DistanceSquared(around->GetPosition(), mob->GetPosition()) > range2)
continue;
if (enabled)
@ -3630,9 +3629,9 @@ bool Entity::CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z,
if (zone->zonemap == nullptr)
return true;
Map::Vertex myloc;
Map::Vertex oloc;
Map::Vertex hit;
glm::vec3 myloc;
glm::vec3 oloc;
glm::vec3 hit;
myloc.x = cur_x;
myloc.y = cur_y;
@ -3666,7 +3665,7 @@ void EntityList::QuestJournalledSayClose(Mob *sender, Client *QuestInitiator,
// Use the old method for all other nearby clients
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
c = it->second;
if(c && (c != QuestInitiator) && ComparativeDistance(c->GetPosition(), sender->GetPosition()) <= dist2)
if(c && (c != QuestInitiator) && DistanceSquared(c->GetPosition(), sender->GetPosition()) <= dist2)
c->Message_StringID(10, GENERIC_SAY, mobname, message);
}
}
@ -3791,46 +3790,46 @@ void EntityList::GroupMessage(uint32 gid, const char *from, const char *message)
}
}
uint16 EntityList::CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time)
uint16 EntityList::CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time)
{
const Item_Struct *is = database.GetItem(itemid);
if (!is)
return 0;
return 0;
ItemInst *i = new ItemInst(is, is->MaxCharges);
if (!i)
return 0;
ItemInst *i = new ItemInst(is, is->MaxCharges);
if (!i)
return 0;
Object *object = new Object(i, position.m_X, position.m_Y, position.m_Z, position.m_Heading,decay_time);
entity_list.AddObject(object, true);
Object *object = new Object(i, position.x, position.y, position.z, position.w,decay_time);
entity_list.AddObject(object, true);
safe_delete(i);
if (!object)
return 0;
safe_delete(i);
if (!object)
return 0;
return object->GetID();
return object->GetID();
}
uint16 EntityList::CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type, uint32 decay_time)
uint16 EntityList::CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type, uint32 decay_time)
{
if (!model)
return 0;
return 0;
Object *object = new Object(model, position.m_X, position.m_Y, position.m_Z, position.m_Heading, type);
entity_list.AddObject(object, true);
Object *object = new Object(model, position.x, position.y, position.z, position.w, type);
entity_list.AddObject(object, true);
if (!object)
return 0;
if (!object)
return 0;
return object->GetID();
return object->GetID();
}
uint16 EntityList::CreateDoor(const char *model, const xyz_heading& position, uint8 opentype, uint16 size)
uint16 EntityList::CreateDoor(const char *model, const glm::vec4& position, uint8 opentype, uint16 size)
{
if (!model)
return 0; // fell through everything, this is bad/incomplete from perl
return 0; // fell through everything, this is bad/incomplete from perl
Doors *door = new Doors(model, position, opentype, size);
Doors *door = new Doors(model, position, opentype, size);
RemoveAllDoors();
zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
entity_list.AddDoor(door);
@ -3868,7 +3867,7 @@ Mob *EntityList::GetTargetForMez(Mob *caster)
continue;
}
if (ComparativeDistance(caster->GetPosition(), d->GetPosition()) > 22250) { //only pick targets within 150 range
if (DistanceSquared(caster->GetPosition(), d->GetPosition()) > 22250) { //only pick targets within 150 range
++it;
continue;
}

View File

@ -155,7 +155,7 @@ public:
Client *GetClientByCharID(uint32 iCharID);
Client *GetClientByWID(uint32 iWID);
Client *GetClient(uint32 ip, uint16 port);
Client *GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient = nullptr);
Client *GetRandomClient(const glm::vec3& location, float Distance, Client *ExcludeClient = nullptr);
Group *GetGroupByMob(Mob* mob);
Group *GetGroupByClient(Client* client);
Group *GetGroupByID(uint32 id);
@ -203,7 +203,7 @@ public:
void MobProcess();
void TrapProcess();
void BeaconProcess();
void ProcessMove(Client *c, const xyz_location& location);
void ProcessMove(Client *c, const glm::vec3& location);
void ProcessMove(NPC *n, float x, float y, float z);
void AddArea(int id, int type, float min_x, float max_x, float min_y, float max_y, float min_z, float max_z);
void RemoveArea(int id);
@ -394,9 +394,9 @@ public:
void SaveAllClientsTaskState();
void ReloadAllClientsTaskState(int TaskID=0);
uint16 CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time = 300000);
uint16 CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type = 0x00, uint32 decay_time = 0);
uint16 CreateDoor(const char *model, const xyz_heading& position, uint8 type = 0, uint16 size = 100);
uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000);
uint16 CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0);
uint16 CreateDoor(const char *model, const glm::vec4& position, uint8 type = 0, uint16 size = 100);
void ZoneWho(Client *c, Who_All_Struct* Who);
void UnMarkNPC(uint16 ID);

View File

@ -152,17 +152,17 @@ void Mob::CalculateNewFearpoint()
{
int Node = zone->pathing->GetRandomPathNode();
Map::Vertex Loc = zone->pathing->GetPathNodeCoordinates(Node);
glm::vec3 Loc = zone->pathing->GetPathNodeCoordinates(Node);
++Loc.z;
Map::Vertex CurrentPosition(GetX(), GetY(), GetZ());
glm::vec3 CurrentPosition(GetX(), GetY(), GetZ());
std::deque<int> Route = zone->pathing->FindRoute(CurrentPosition, Loc);
if(Route.size() > 0)
{
m_FearWalkTarget = xyz_location(Loc.x, Loc.y, Loc.z);
m_FearWalkTarget = glm::vec3(Loc.x, Loc.y, Loc.z);
curfp = true;
mlog(PATHING__DEBUG, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z);
@ -192,7 +192,7 @@ void Mob::CalculateNewFearpoint()
}
}
if (curfp)
m_FearWalkTarget = xyz_location(ranx, rany, ranz);
m_FearWalkTarget = glm::vec3(ranx, rany, ranz);
else //Break fear
BuffFadeByEffect(SE_Fear);
}

View File

@ -175,7 +175,7 @@ bool Client::CanFish() {
if(zone->zonemap != nullptr && zone->watermap != nullptr && RuleB(Watermap, CheckForWaterWhenFishing)) {
xyz_location rodPosition;
glm::vec3 rodPosition;
// Tweak Rod and LineLength if required
const float RodLength = RuleR(Watermap, FishingRodLength);
const float LineLength = RuleR(Watermap, FishingLineLength);
@ -184,17 +184,17 @@ bool Client::CanFish() {
HeadingDegrees = (int) ((GetHeading()*360)/256);
HeadingDegrees = HeadingDegrees % 360;
rodPosition.m_X = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f);
rodPosition.m_Y = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f);
rodPosition.x = m_Position.x + RodLength * sin(HeadingDegrees * M_PI/180.0f);
rodPosition.y = m_Position.y + RodLength * cos(HeadingDegrees * M_PI/180.0f);
// Do BestZ to find where the line hanging from the rod intersects the water (if it is water).
// and go 1 unit into the water.
Map::Vertex dest;
dest.x = rodPosition.m_X;
dest.y = rodPosition.m_Y;
dest.z = m_Position.m_Z+10;
glm::vec3 dest;
dest.x = rodPosition.x;
dest.y = rodPosition.y;
dest.z = m_Position.z+10;
rodPosition.m_Z = zone->zonemap->FindBestZ(dest, nullptr) + 4;
rodPosition.z = zone->zonemap->FindBestZ(dest, nullptr) + 4;
bool in_lava = zone->watermap->InLava(rodPosition);
bool in_water = zone->watermap->InWater(rodPosition) || zone->watermap->InVWater(rodPosition);
//Message(0, "Rod is at %4.3f, %4.3f, %4.3f, InWater says %d, InLava says %d", RodX, RodY, RodZ, in_water, in_lava);
@ -202,7 +202,7 @@ bool Client::CanFish() {
Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something?
return false;
}
if((!in_water) || (m_Position.m_Z-rodPosition.m_Z)>LineLength) { //Didn't hit the water OR the water is too far below us
if((!in_water) || (m_Position.z-rodPosition.z)>LineLength) { //Didn't hit the water OR the water is too far below us
Message_StringID(MT_Skills, FISHING_LAND); //Trying to catch land sharks perhaps?
return false;
}
@ -274,7 +274,7 @@ void Client::GoFish()
const NPCType* tmp = database.GetNPCType(npc_id);
if(tmp != nullptr) {
auto positionNPC = GetPosition();
positionNPC.m_X = positionNPC.m_X + 3;
positionNPC.x = positionNPC.x + 3;
NPC* npc = new NPC(tmp, nullptr, positionNPC, FlyMode3);
npc->AddLootTable();

View File

@ -758,7 +758,7 @@ void Group::CastGroupSpell(Mob* caster, uint16 spell_id) {
}
else if(members[z] != nullptr)
{
distance = ComparativeDistance(caster->GetPosition(), members[z]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[z]->GetPosition());
if(distance <= range2 && distance >= min_range2) {
members[z]->CalcSpellPowerDistanceMod(spell_id, distance);
caster->SpellOnTarget(spell_id, members[z]);
@ -798,7 +798,7 @@ void Group::GroupBardPulse(Mob* caster, uint16 spell_id) {
}
else if(members[z] != nullptr)
{
distance = ComparativeDistance(caster->GetPosition(), members[z]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[z]->GetPosition());
if(distance <= range2) {
members[z]->BardPulse(spell_id, caster);
#ifdef GROUP_BUFF_PETS
@ -1197,7 +1197,7 @@ void Group::HealGroup(uint32 heal_amt, Mob* caster, float range)
for(; gi < MAX_GROUP_MEMBERS; gi++)
{
if(members[gi]){
distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi]->GetPosition());
if(distance <= range2){
numMem += 1;
}
@ -1208,7 +1208,7 @@ void Group::HealGroup(uint32 heal_amt, Mob* caster, float range)
for(gi = 0; gi < MAX_GROUP_MEMBERS; gi++)
{
if(members[gi]){
distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi]->GetPosition());
if(distance <= range2){
members[gi]->HealDamage(heal_amt, caster);
members[gi]->SendHPUpdate();
@ -1235,7 +1235,7 @@ void Group::BalanceHP(int32 penalty, float range, Mob* caster, int32 limit)
for(; gi < MAX_GROUP_MEMBERS; gi++)
{
if(members[gi]){
distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi]->GetPosition());
if(distance <= range2){
dmgtaken_tmp = members[gi]->GetMaxHP() - members[gi]->GetHP();
@ -1253,7 +1253,7 @@ void Group::BalanceHP(int32 penalty, float range, Mob* caster, int32 limit)
for(gi = 0; gi < MAX_GROUP_MEMBERS; gi++)
{
if(members[gi]){
distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi]->GetPosition());
if(distance <= range2){
if((members[gi]->GetMaxHP() - dmgtaken) < 1){ //this way the ability will never kill someone
members[gi]->SetHP(1); //but it will come darn close
@ -1284,7 +1284,7 @@ void Group::BalanceMana(int32 penalty, float range, Mob* caster, int32 limit)
for(; gi < MAX_GROUP_MEMBERS; gi++)
{
if(members[gi] && (members[gi]->GetMaxMana() > 0)){
distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi]->GetPosition());
if(distance <= range2){
manataken_tmp = members[gi]->GetMaxMana() - members[gi]->GetMana();
@ -1306,7 +1306,7 @@ void Group::BalanceMana(int32 penalty, float range, Mob* caster, int32 limit)
for(gi = 0; gi < MAX_GROUP_MEMBERS; gi++)
{
if(members[gi]){
distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi]->GetPosition());
if(distance <= range2){
if((members[gi]->GetMaxMana() - manataken) < 1){
members[gi]->SetMana(1);

View File

@ -158,7 +158,7 @@ Mob* HateList::GetClosestEntOnHateList(Mob *hater) {
auto iterator = list.begin();
while (iterator != list.end()) {
this_distance = ComparativeDistanceNoZ((*iterator)->entity_on_hatelist->GetPosition(), hater->GetPosition());
this_distance = DistanceSquaredNoZ((*iterator)->entity_on_hatelist->GetPosition(), hater->GetPosition());
if ((*iterator)->entity_on_hatelist != nullptr && this_distance <= close_distance) {
close_distance = this_distance;
close_entity = (*iterator)->entity_on_hatelist;
@ -308,7 +308,7 @@ Mob *HateList::GetEntWithMostHateOnList(Mob *center)
continue;
}
auto hateEntryPosition = xyz_location(cur->entity_on_hatelist->GetX(), cur->entity_on_hatelist->GetY(), cur->entity_on_hatelist->GetZ());
auto hateEntryPosition = glm::vec3(cur->entity_on_hatelist->GetX(), cur->entity_on_hatelist->GetY(), cur->entity_on_hatelist->GetZ());
if (center->IsNPC() && center->CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) {
if (!zone->watermap->InLiquid(hateEntryPosition)) {
skipped_count++;
@ -435,7 +435,7 @@ Mob *HateList::GetEntWithMostHateOnList(Mob *center)
{
struct_HateList *cur = (*iterator);
if (center->IsNPC() && center->CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) {
if (!zone->watermap->InLiquid(cur->entity_on_hatelist->GetPosition())) {
if(!zone->watermap->InLiquid(glm::vec3(cur->entity_on_hatelist->GetPosition()))) {
skipped_count++;
++iterator;
continue;
@ -592,7 +592,7 @@ void HateList::SpellCast(Mob *caster, uint32 spell_id, float range, Mob* ae_cent
struct_HateList *h = (*iterator);
if (range > 0)
{
dist_targ = ComparativeDistance(center->GetPosition(), h->entity_on_hatelist->GetPosition());
dist_targ = DistanceSquared(center->GetPosition(), h->entity_on_hatelist->GetPosition());
if (dist_targ <= range && dist_targ >= min_range2)
{
id_list.push_back(h->entity_on_hatelist->GetID());

View File

@ -28,7 +28,7 @@
std::map<uint16, const NPCType *> Horse::horse_types;
LinkedList<NPCType *> horses_auto_delete;
Horse::Horse(Client *_owner, uint16 spell_id, const xyz_heading& position)
Horse::Horse(Client *_owner, uint16 spell_id, const glm::vec4& position)
: NPC(GetHorseType(spell_id), nullptr, position, FlyMode3)
{
//give the horse its proper name.

View File

@ -29,7 +29,7 @@ struct NewSpawn_Struct;
class Horse : public NPC {
public:
Horse(Client *owner, uint16 spell_id, const xyz_heading& position);
Horse(Client *owner, uint16 spell_id, const glm::vec4& position);
virtual void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho);

View File

@ -242,17 +242,17 @@ void Lua_Client::SetBindPoint(int to_zone, int to_instance) {
void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x) {
Lua_Safe_Call_Void();
self->SetBindPoint(to_zone, to_instance, xyz_location(new_x,0.0f,0.0f));
self->SetBindPoint(to_zone, to_instance, glm::vec3(new_x,0.0f,0.0f));
}
void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y) {
Lua_Safe_Call_Void();
self->SetBindPoint(to_zone, to_instance, xyz_location(new_x, new_y, 0.0f));
self->SetBindPoint(to_zone, to_instance, glm::vec3(new_x, new_y, 0.0f));
}
void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y, float new_z) {
Lua_Safe_Call_Void();
self->SetBindPoint(to_zone, to_instance, xyz_location(new_x, new_y, new_z));
self->SetBindPoint(to_zone, to_instance, glm::vec3(new_x, new_y, new_z));
}
float Lua_Client::GetBindX() {

View File

@ -20,49 +20,49 @@ const char *Lua_Door::GetDoorName() {
float Lua_Door::GetX() {
Lua_Safe_Call_Real();
return self->GetPosition().m_X;
return self->GetPosition().x;
}
float Lua_Door::GetY() {
Lua_Safe_Call_Real();
return self->GetPosition().m_Y;
return self->GetPosition().y;
}
float Lua_Door::GetZ() {
Lua_Safe_Call_Real();
return self->GetPosition().m_Z;
return self->GetPosition().z;
}
float Lua_Door::GetHeading() {
Lua_Safe_Call_Real();
return self->GetPosition().m_Heading;
return self->GetPosition().w;
}
void Lua_Door::SetX(float x) {
Lua_Safe_Call_Void();
auto position = self->GetPosition();
position.m_X = x;
position.x = x;
self->SetPosition(position);
}
void Lua_Door::SetY(float y) {
Lua_Safe_Call_Void();
auto position = self->GetPosition();
position.m_Y = y;
position.y = y;
self->SetPosition(position);
}
void Lua_Door::SetZ(float z) {
Lua_Safe_Call_Void();
auto position = self->GetPosition();
position.m_Z = z;
position.z = z;
self->SetPosition(position);
}
void Lua_Door::SetHeading(float h) {
Lua_Safe_Call_Void();
auto position = self->GetPosition();
position.m_Heading = h;
position.w = h;
self->SetPosition(position);
}

View File

@ -298,12 +298,12 @@ void Lua_EntityList::MessageGroup(Lua_Mob who, bool skip_close, uint32 type, con
Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist) {
Lua_Safe_Call_Class(Lua_Client);
return self->GetRandomClient(xyz_location(x, y, z), dist);
return self->GetRandomClient(glm::vec3(x, y, z), dist);
}
Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist, Lua_Client exclude) {
Lua_Safe_Call_Class(Lua_Client);
return self->GetRandomClient(xyz_location(x, y, z), dist, exclude);
return self->GetRandomClient(glm::vec3(x, y, z), dist, exclude);
}
Lua_Mob_List Lua_EntityList::GetMobList() {

View File

@ -251,12 +251,12 @@ void unregister_spell_event(int evt, int spell_id) {
}
Lua_Mob lua_spawn2(int npc_type, int grid, int unused, double x, double y, double z, double heading) {
auto position = xyz_heading(x, y, z, heading);
auto position = glm::vec4(x, y, z, heading);
return Lua_Mob(quest_manager.spawn2(npc_type, grid, unused, position));
}
Lua_Mob lua_unique_spawn(int npc_type, int grid, int unused, double x, double y, double z, double heading = 0.0) {
auto position = xyz_heading(x, y, z, heading);
auto position = glm::vec4(x, y, z, heading);
return Lua_Mob(quest_manager.unique_spawn(npc_type, grid, unused, position));
}
@ -421,15 +421,15 @@ void lua_pause(int duration) {
}
void lua_move_to(float x, float y, float z) {
quest_manager.moveto(xyz_heading(x, y, z, 0.0f), false);
quest_manager.moveto(glm::vec4(x, y, z, 0.0f), false);
}
void lua_move_to(float x, float y, float z, float h) {
quest_manager.moveto(xyz_heading(x, y, z, h), false);
quest_manager.moveto(glm::vec4(x, y, z, h), false);
}
void lua_move_to(float x, float y, float z, float h, bool save_guard_spot) {
quest_manager.moveto(xyz_heading(x, y, z, h), save_guard_spot);
quest_manager.moveto(glm::vec4(x, y, z, h), save_guard_spot);
}
void lua_path_resume() {
@ -485,11 +485,11 @@ void lua_toggle_spawn_event(int event_id, bool enable, bool strict, bool reset)
}
void lua_summon_burried_player_corpse(uint32 char_id, float x, float y, float z, float h) {
quest_manager.summonburriedplayercorpse(char_id, xyz_heading(x, y, z, h));
quest_manager.summonburriedplayercorpse(char_id, glm::vec4(x, y, z, h));
}
void lua_summon_all_player_corpses(uint32 char_id, float x, float y, float z, float h) {
quest_manager.summonallplayercorpses(char_id, xyz_heading(x, y, z, h));
quest_manager.summonallplayercorpses(char_id, glm::vec4(x, y, z, h));
}
int lua_get_player_burried_corpse_count(uint32 char_id) {
@ -685,23 +685,23 @@ int lua_get_level(int type) {
}
void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h) {
quest_manager.CreateGroundObject(item_id, xyz_heading(x, y, z, h));
quest_manager.CreateGroundObject(item_id, glm::vec4(x, y, z, h));
}
void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h, uint32 decay_time) {
quest_manager.CreateGroundObject(item_id, xyz_heading(x, y, z, h), decay_time);
quest_manager.CreateGroundObject(item_id, glm::vec4(x, y, z, h), decay_time);
}
void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h) {
quest_manager.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, h));
quest_manager.CreateGroundObjectFromModel(model, glm::vec4(x, y, z, h));
}
void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type) {
quest_manager.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, h), type);
quest_manager.CreateGroundObjectFromModel(model, glm::vec4(x, y, z, h), type);
}
void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type, uint32 decay_time) {
quest_manager.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, h), type, decay_time);
quest_manager.CreateGroundObjectFromModel(model, glm::vec4(x, y, z, h), type, decay_time);
}
void lua_create_door(const char *model, float x, float y, float z, float h, int open_type, int size) {
@ -1391,7 +1391,7 @@ void lua_create_npc(luabind::adl::object table, float x, float y, float z, float
LuaCreateNPCParse(raid_target, bool, false);
LuaCreateNPCParse(probability, uint8, 0);
NPC* npc = new NPC(npc_type, nullptr, xyz_heading(x, y, z, heading), FlyMode3);
NPC* npc = new NPC(npc_type, nullptr, glm::vec4(x, y, z, heading), FlyMode3);
npc->GiveNPCTypeData(npc_type);
entity_list.AddNPC(npc);
}

View File

@ -674,22 +674,22 @@ double Lua_Mob::GetHeading() {
double Lua_Mob::GetWaypointX() {
Lua_Safe_Call_Real();
return self->GetCurrentWayPoint().m_X;
return self->GetCurrentWayPoint().x;
}
double Lua_Mob::GetWaypointY() {
Lua_Safe_Call_Real();
return self->GetCurrentWayPoint().m_Y;
return self->GetCurrentWayPoint().y;
}
double Lua_Mob::GetWaypointZ() {
Lua_Safe_Call_Real();
return self->GetCurrentWayPoint().m_Z;
return self->GetCurrentWayPoint().z;
}
double Lua_Mob::GetWaypointH() {
Lua_Safe_Call_Real();
return self->GetCurrentWayPoint().m_Heading;
return self->GetCurrentWayPoint().w;
}
double Lua_Mob::GetWaypointPause() {

View File

@ -269,7 +269,7 @@ void Lua_NPC::PauseWandering(int pause_time) {
void Lua_NPC::MoveTo(float x, float y, float z, float h, bool save) {
Lua_Safe_Call_Void();
auto position = xyz_heading(x, y, z, h);
auto position = glm::vec4(x, y, z, h);
self->MoveTo(position, save);
}
@ -315,37 +315,37 @@ int Lua_NPC::GetSpawnPointID() {
float Lua_NPC::GetSpawnPointX() {
Lua_Safe_Call_Real();
return self->GetSpawnPoint().m_X;
return self->GetSpawnPoint().x;
}
float Lua_NPC::GetSpawnPointY() {
Lua_Safe_Call_Real();
return self->GetSpawnPoint().m_Y;
return self->GetSpawnPoint().y;
}
float Lua_NPC::GetSpawnPointZ() {
Lua_Safe_Call_Real();
return self->GetSpawnPoint().m_Z;
return self->GetSpawnPoint().z;
}
float Lua_NPC::GetSpawnPointH() {
Lua_Safe_Call_Real();
return self->GetSpawnPoint().m_Heading;
return self->GetSpawnPoint().w;
}
float Lua_NPC::GetGuardPointX() {
Lua_Safe_Call_Real();
return self->GetGuardPoint().m_X;
return self->GetGuardPoint().x;
}
float Lua_NPC::GetGuardPointY() {
Lua_Safe_Call_Real();
return self->GetGuardPoint().m_Y;
return self->GetGuardPoint().y;
}
float Lua_NPC::GetGuardPointZ() {
Lua_Safe_Call_Real();
return self->GetGuardPoint().m_Z;
return self->GetGuardPoint().z;
}
void Lua_NPC::SetPrimSkill(int skill_id) {

View File

@ -62,17 +62,17 @@ Map::~Map() {
}
}
float Map::FindBestZ(Vertex &start, Vertex *result) const {
float Map::FindBestZ(glm::vec3 &start, glm::vec3 *result) const {
if (!imp)
return false;
Vertex tmp;
glm::vec3 tmp;
if(!result)
result = &tmp;
start.z += RuleI(Map, FindBestZHeightAdjust);
Vertex from(start.x, start.y, start.z);
Vertex to(start.x, start.y, BEST_Z_INVALID);
glm::vec3 from(start.x, start.y, start.z);
glm::vec3 to(start.x, start.y, BEST_Z_INVALID);
float hit_distance;
bool hit = false;
@ -93,19 +93,19 @@ float Map::FindBestZ(Vertex &start, Vertex *result) const {
return BEST_Z_INVALID;
}
bool Map::LineIntersectsZone(Vertex start, Vertex end, float step, Vertex *result) const {
bool Map::LineIntersectsZone(glm::vec3 start, glm::vec3 end, float step, glm::vec3 *result) const {
if(!imp)
return false;
return imp->rm->raycast((const RmReal*)&start, (const RmReal*)&end, (RmReal*)result, nullptr, nullptr);
}
bool Map::LineIntersectsZoneNoZLeaps(Vertex start, Vertex end, float step_mag, Vertex *result) const {
bool Map::LineIntersectsZoneNoZLeaps(glm::vec3 start, glm::vec3 end, float step_mag, glm::vec3 *result) const {
if (!imp)
return false;
float z = BEST_Z_INVALID;
Vertex step;
Vertex cur;
glm::vec3 step;
glm::vec3 cur;
cur.x = start.x;
cur.y = start.y;
cur.z = start.z;
@ -139,11 +139,11 @@ bool Map::LineIntersectsZoneNoZLeaps(Vertex start, Vertex end, float step_mag, V
while(cur.x != end.x || cur.y != end.y || cur.z != end.z)
{
steps++;
Vertex me;
glm::vec3 me;
me.x = cur.x;
me.y = cur.y;
me.z = cur.z;
Vertex hit;
glm::vec3 hit;
float best_z = FindBestZ(me, &hit);
float diff = best_z - z;
@ -184,7 +184,7 @@ bool Map::LineIntersectsZoneNoZLeaps(Vertex start, Vertex end, float step_mag, V
return false;
}
bool Map::CheckLoS(Vertex myloc, Vertex oloc) const {
bool Map::CheckLoS(glm::vec3 myloc, glm::vec3 oloc) const {
if(!imp)
return false;
@ -250,22 +250,22 @@ bool Map::LoadV1(FILE *f) {
return false;
}
std::vector<Vertex> verts;
std::vector<glm::vec3> verts;
std::vector<uint32> indices;
for(uint32 i = 0; i < face_count; ++i) {
Vertex a;
Vertex b;
Vertex c;
glm::vec3 a;
glm::vec3 b;
glm::vec3 c;
float normals[4];
if(fread(&a, sizeof(Vertex), 1, f) != 1) {
if(fread(&a, sizeof(glm::vec3), 1, f) != 1) {
return false;
}
if(fread(&b, sizeof(Vertex), 1, f) != 1) {
if(fread(&b, sizeof(glm::vec3), 1, f) != 1) {
return false;
}
if(fread(&c, sizeof(Vertex), 1, f) != 1) {
if(fread(&c, sizeof(glm::vec3), 1, f) != 1) {
return false;
}
@ -309,7 +309,7 @@ struct ModelEntry
uint32 v1, v2, v3;
uint8 vis;
};
std::vector<Map::Vertex> verts;
std::vector<glm::vec3> verts;
std::vector<Poly> polys;
};
@ -376,7 +376,7 @@ bool Map::LoadV2(FILE *f) {
units_per_vertex = *(float*)buf;
buf += sizeof(float);
std::vector<Vertex> verts;
std::vector<glm::vec3> verts;
std::vector<uint32> indices;
for (uint32 i = 0; i < vert_count; ++i) {
@ -393,7 +393,7 @@ bool Map::LoadV2(FILE *f) {
z = *(float*)buf;
buf += sizeof(float);
Vertex vert(x, y, z);
glm::vec3 vert(x, y, z);
verts.push_back(vert);
}
@ -434,7 +434,7 @@ bool Map::LoadV2(FILE *f) {
float z = *(float*)buf;
buf += sizeof(float);
me->verts[j] = Vertex(x, y, z);
me->verts[j] = glm::vec3(x, y, z);
}
me->polys.resize(poly_count);
@ -596,7 +596,7 @@ bool Map::LoadV2(FILE *f) {
for (size_t k = 0; k < model->polys.size(); ++k) {
auto &poly = model->polys[k];
Vertex v1, v2, v3;
glm::vec3 v1, v2, v3;
v1 = model->verts[poly.v1];
v2 = model->verts[poly.v2];
@ -618,7 +618,7 @@ bool Map::LoadV2(FILE *f) {
RotateVertex(v2, 0, y_rot * 3.14159f / 180.0f, 0);
RotateVertex(v3, 0, y_rot * 3.14159f / 180.0f, 0);
Vertex correction(p_x, p_y, p_z);
glm::vec3 correction(p_x, p_y, p_z);
RotateVertex(correction, x_rot * 3.14159f / 180.0f, 0, 0);
@ -724,10 +724,10 @@ bool Map::LoadV2(FILE *f) {
float QuadVertex4Z = QuadVertex1Z;
uint32 current_vert = (uint32)verts.size() + 3;
verts.push_back(Vertex(QuadVertex1X, QuadVertex1Y, QuadVertex1Z));
verts.push_back(Vertex(QuadVertex2X, QuadVertex2Y, QuadVertex2Z));
verts.push_back(Vertex(QuadVertex3X, QuadVertex3Y, QuadVertex3Z));
verts.push_back(Vertex(QuadVertex4X, QuadVertex4Y, QuadVertex4Z));
verts.push_back(glm::vec3(QuadVertex1X, QuadVertex1Y, QuadVertex1Z));
verts.push_back(glm::vec3(QuadVertex2X, QuadVertex2Y, QuadVertex2Z));
verts.push_back(glm::vec3(QuadVertex3X, QuadVertex3Y, QuadVertex3Z));
verts.push_back(glm::vec3(QuadVertex4X, QuadVertex4Y, QuadVertex4Z));
indices.push_back(current_vert);
indices.push_back(current_vert - 2);
@ -790,7 +790,7 @@ bool Map::LoadV2(FILE *f) {
}
else {
i1 = (uint32)verts.size();
verts.push_back(Vertex(QuadVertex1X, QuadVertex1Y, QuadVertex1Z));
verts.push_back(glm::vec3(QuadVertex1X, QuadVertex1Y, QuadVertex1Z));
cur_verts[std::make_tuple(QuadVertex1X, QuadVertex1Y, QuadVertex1Z)] = i1;
}
@ -801,7 +801,7 @@ bool Map::LoadV2(FILE *f) {
}
else {
i2 = (uint32)verts.size();
verts.push_back(Vertex(QuadVertex2X, QuadVertex2Y, QuadVertex2Z));
verts.push_back(glm::vec3(QuadVertex2X, QuadVertex2Y, QuadVertex2Z));
cur_verts[std::make_tuple(QuadVertex2X, QuadVertex2Y, QuadVertex2Z)] = i2;
}
@ -812,7 +812,7 @@ bool Map::LoadV2(FILE *f) {
}
else {
i3 = (uint32)verts.size();
verts.push_back(Vertex(QuadVertex3X, QuadVertex3Y, QuadVertex3Z));
verts.push_back(glm::vec3(QuadVertex3X, QuadVertex3Y, QuadVertex3Z));
cur_verts[std::make_tuple(QuadVertex3X, QuadVertex3Y, QuadVertex3Z)] = i3;
}
@ -823,7 +823,7 @@ bool Map::LoadV2(FILE *f) {
}
else {
i4 = (uint32)verts.size();
verts.push_back(Vertex(QuadVertex4X, QuadVertex4Y, QuadVertex4Z));
verts.push_back(glm::vec3(QuadVertex4X, QuadVertex4Y, QuadVertex4Z));
cur_verts[std::make_tuple(QuadVertex4X, QuadVertex4Y, QuadVertex4Z)] = i4;
}
@ -859,8 +859,8 @@ bool Map::LoadV2(FILE *f) {
return true;
}
void Map::RotateVertex(Vertex &v, float rx, float ry, float rz) {
Vertex nv = v;
void Map::RotateVertex(glm::vec3 &v, float rx, float ry, float rz) {
glm::vec3 nv = v;
nv.y = (cos(rx) * v.y) - (sin(rx) * v.z);
nv.z = (sin(rx) * v.y) + (cos(rx) * v.z);
@ -878,13 +878,13 @@ void Map::RotateVertex(Vertex &v, float rx, float ry, float rz) {
v = nv;
}
void Map::ScaleVertex(Vertex &v, float sx, float sy, float sz) {
void Map::ScaleVertex(glm::vec3 &v, float sx, float sy, float sz) {
v.x = v.x * sx;
v.y = v.y * sy;
v.z = v.z * sz;
}
void Map::TranslateVertex(Vertex &v, float tx, float ty, float tz) {
void Map::TranslateVertex(glm::vec3 &v, float tx, float ty, float tz) {
v.x = v.x + tx;
v.y = v.y + ty;
v.z = v.z + tz;

View File

@ -30,40 +30,19 @@
class Map
{
public:
#pragma pack(1)
struct Vertex
{
Vertex() : x(0.0f), y(0.0f), z(0.0f) { }
Vertex(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { }
~Vertex() { }
bool operator==(const Vertex &v) const
{
return((v.x == x) && (v.y == y) && (v.z == z));
}
operator xyz_location() const
{
return xyz_location(x,y,z);
}
float x;
float y;
float z;
};
#pragma pack()
Map();
~Map();
float FindBestZ(Vertex &start, Vertex *result) const;
bool LineIntersectsZone(Vertex start, Vertex end, float step, Vertex *result) const;
bool LineIntersectsZoneNoZLeaps(Vertex start, Vertex end, float step_mag, Vertex *result) const;
bool CheckLoS(Vertex myloc, Vertex oloc) const;
float FindBestZ(glm::vec3 &start, glm::vec3 *result) const;
bool LineIntersectsZone(glm::vec3 start, glm::vec3 end, float step, glm::vec3 *result) const;
bool LineIntersectsZoneNoZLeaps(glm::vec3 start, glm::vec3 end, float step_mag, glm::vec3 *result) const;
bool CheckLoS(glm::vec3 myloc, glm::vec3 oloc) const;
bool Load(std::string filename);
static Map *LoadMapFile(std::string file);
private:
void RotateVertex(Vertex &v, float rx, float ry, float rz);
void ScaleVertex(Vertex &v, float sx, float sy, float sz);
void TranslateVertex(Vertex &v, float tx, float ty, float tz);
void RotateVertex(glm::vec3 &v, float rx, float ry, float rz);
void ScaleVertex(glm::vec3 &v, float sx, float sy, float sz);
void TranslateVertex(glm::vec3 &v, float tx, float ty, float tz);
bool LoadV1(FILE *f);
bool LoadV2(FILE *f);

View File

@ -20,7 +20,7 @@
extern volatile bool ZoneLoaded;
Merc::Merc(const NPCType* d, float x, float y, float z, float heading)
: NPC(d, nullptr, xyz_heading(x, y, z, heading), 0, false), endupkeep_timer(1000), rest_timer(1), confidence_timer(6000), check_target_timer(2000)
: NPC(d, nullptr, glm::vec4(x, y, z, heading), 0, false), endupkeep_timer(1000), rest_timer(1), confidence_timer(6000), check_target_timer(2000)
{
base_hp = d->max_hp;
base_mana = d->Mana;
@ -1318,7 +1318,7 @@ bool Merc::IsMercCasterCombatRange(Mob *target) {
// half the max so the merc doesn't always stop at max range to allow combat movement
range *= .5;
float targetDistance = ComparativeDistanceNoZ(m_Position, target->GetPosition());
float targetDistance = DistanceSquaredNoZ(m_Position, target->GetPosition());
if(targetDistance > range)
result = false;
@ -1480,7 +1480,7 @@ void Merc::AI_Process() {
if(IsMercCasterCombatRange(GetTarget()))
atCombatRange = true;
}
else if(ComparativeDistance(m_Position, GetTarget()->GetPosition()) <= meleeDistance) {
else if(DistanceSquared(m_Position, GetTarget()->GetPosition()) <= meleeDistance) {
atCombatRange = true;
}
@ -1513,7 +1513,7 @@ void Merc::AI_Process() {
return;
}
}
else if(!IsMoving() && GetClass() != ROGUE && (ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) < GetTarget()->GetSize()))
else if(!IsMoving() && GetClass() != ROGUE && (DistanceSquaredNoZ(m_Position, GetTarget()->GetPosition()) < GetTarget()->GetSize()))
{
// If we are not a rogue trying to backstab, let's try to adjust our melee range so we don't appear to be bunched up
float newX = 0;
@ -1701,7 +1701,7 @@ void Merc::AI_Process() {
if(follow)
{
float dist = ComparativeDistance(m_Position, follow->GetPosition());
float dist = DistanceSquared(m_Position, follow->GetPosition());
float speed = GetRunspeed();
if(dist < GetFollowDistance() + 1000)
@ -1938,7 +1938,7 @@ bool Merc::AIDoSpellCast(uint16 spellid, Mob* tar, int32 mana_cost, uint32* oDon
if (mercSpell.type & SpellType_Escape) {
dist2 = 0;
} else
dist2 = ComparativeDistance(m_Position, tar->GetPosition());
dist2 = DistanceSquared(m_Position, tar->GetPosition());
if (((((spells[spellid].targettype==ST_GroupTeleport && mercSpell.type==SpellType_Heal)
|| spells[spellid].targettype==ST_AECaster
@ -2435,7 +2435,7 @@ void Merc::CheckHateList() {
if(MercOwner && MercOwner->GetTarget() && MercOwner->GetTarget()->IsNPC() && (MercOwner->GetTarget()->GetHateAmount(MercOwner) || MercOwner->CastToClient()->AutoAttackEnabled()) && IsAttackAllowed(MercOwner->GetTarget())) {
float range = g->HasRole(MercOwner, RolePuller) ? RuleI(Mercs, AggroRadiusPuller) : RuleI(Mercs, AggroRadius);
range = range * range;
if(ComparativeDistanceNoZ(m_Position, MercOwner->GetTarget()->GetPosition()) < range) {
if(DistanceSquaredNoZ(m_Position, MercOwner->GetTarget()->GetPosition()) < range) {
AddToHateList(MercOwner->GetTarget(), 1);
}
}
@ -2445,7 +2445,7 @@ void Merc::CheckHateList() {
for(std::list<NPC*>::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) {
NPC* npc = *itr;
float dist = ComparativeDistanceNoZ(m_Position, npc->GetPosition());
float dist = DistanceSquaredNoZ(m_Position, npc->GetPosition());
int radius = RuleI(Mercs, AggroRadius);
radius *= radius;
if(dist <= radius) {
@ -2457,7 +2457,7 @@ void Merc::CheckHateList() {
if(!hate_list.IsEntOnHateList(npc)) {
float range = g->HasRole(groupMember, RolePuller) ? RuleI(Mercs, AggroRadiusPuller) : RuleI(Mercs, AggroRadius);
range *= range;
if(ComparativeDistanceNoZ(m_Position, npc->GetPosition()) < range) {
if(DistanceSquaredNoZ(m_Position, npc->GetPosition()) < range) {
hate_list.AddEntToHateList(npc, 1);
}
}
@ -2499,7 +2499,7 @@ bool Merc::CheckAENuke(Merc* caster, Mob* tar, uint16 spell_id, uint8 &numTarget
for(std::list<NPC*>::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) {
NPC* npc = *itr;
if(ComparativeDistanceNoZ(npc->GetPosition(), tar->GetPosition()) <= spells[spell_id].aoerange * spells[spell_id].aoerange) {
if(DistanceSquaredNoZ(npc->GetPosition(), tar->GetPosition()) <= spells[spell_id].aoerange * spells[spell_id].aoerange) {
if(!npc->IsMezzed()) {
numTargets++;
}
@ -4098,7 +4098,7 @@ bool Merc::CheckAETaunt() {
for(std::list<NPC*>::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) {
NPC* npc = *itr;
float dist = ComparativeDistanceNoZ(m_Position, npc->GetPosition());
float dist = DistanceSquaredNoZ(m_Position, npc->GetPosition());
int range = GetActSpellRange(mercSpell.spellid, spells[mercSpell.spellid].range);
range *= range;
@ -4201,7 +4201,7 @@ bool Merc::CheckConfidence() {
AggroRange = AggroRange * AggroRange;
if(ComparativeDistance(m_Position, mob->GetPosition()) > AggroRange) continue;
if(DistanceSquared(m_Position, mob->GetPosition()) > AggroRange) continue;
CurrentCon = this->GetLevelCon(mob->GetLevel());
switch(CurrentCon) {
@ -5150,7 +5150,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) {
}
//check for merchant too far away
if(ComparativeDistance(m_Position, merchant->GetPosition()) > USE_NPC_RANGE2) {
if(DistanceSquared(m_Position, merchant->GetPosition()) > USE_NPC_RANGE2) {
SendMercResponsePackets(18);
return false;
}

View File

@ -49,7 +49,7 @@ Mob::Mob(const char* in_name,
uint32 in_npctype_id,
float in_size,
float in_runspeed,
const xyz_heading& position,
const glm::vec4& position,
uint8 in_light,
uint8 in_texture,
uint8 in_helmtexture,
@ -99,8 +99,8 @@ Mob::Mob(const char* in_name,
gravity_timer(1000),
viral_timer(0),
m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f),
m_TargetLocation(xyz_location::Origin()),
m_TargetV(xyz_location::Origin()),
m_TargetLocation(glm::vec3()),
m_TargetV(glm::vec3()),
flee_timer(FLEE_CHECK_TIMER),
m_Position(position)
{
@ -112,7 +112,7 @@ Mob::Mob(const char* in_name,
AI_Init();
SetMoving(false);
moved=false;
m_RewindLocation = xyz_location::Origin();
m_RewindLocation = glm::vec3();
move_tic_count = 0;
_egnode = nullptr;
@ -243,7 +243,7 @@ Mob::Mob(const char* in_name,
}
}
m_Delta = xyz_heading::Origin();
m_Delta = glm::vec4();
animation = 0;
logging_enabled = false;
@ -316,7 +316,7 @@ Mob::Mob(const char* in_name,
wandertype=0;
pausetype=0;
cur_wp = 0;
m_CurrentWayPoint = xyz_heading::Origin();
m_CurrentWayPoint = glm::vec4();
cur_wp_pause = 0;
patrol=0;
follow=0;
@ -363,7 +363,7 @@ Mob::Mob(const char* in_name,
nimbus_effect3 = 0;
m_targetable = true;
m_TargetRing = xyz_location::Origin();
m_TargetRing = glm::vec3();
flymode = FlyMode3;
// Pathing
@ -882,10 +882,10 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName));
}
ns->spawn.heading = FloatToEQ19(m_Position.m_Heading);
ns->spawn.x = FloatToEQ19(m_Position.m_X);//((int32)x_pos)<<3;
ns->spawn.y = FloatToEQ19(m_Position.m_Y);//((int32)y_pos)<<3;
ns->spawn.z = FloatToEQ19(m_Position.m_Z);//((int32)z_pos)<<3;
ns->spawn.heading = FloatToEQ19(m_Position.w);
ns->spawn.x = FloatToEQ19(m_Position.x);//((int32)x_pos)<<3;
ns->spawn.y = FloatToEQ19(m_Position.y);//((int32)y_pos)<<3;
ns->spawn.z = FloatToEQ19(m_Position.z);//((int32)z_pos)<<3;
ns->spawn.spawnId = GetID();
ns->spawn.curHp = static_cast<uint8>(GetHPRatio());
ns->spawn.max_hp = 100; //this field needs a better name
@ -1210,13 +1210,13 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) {
void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
memset(spu,0xff,sizeof(PlayerPositionUpdateServer_Struct));
spu->spawn_id = GetID();
spu->x_pos = FloatToEQ19(m_Position.m_X);
spu->y_pos = FloatToEQ19(m_Position.m_Y);
spu->z_pos = FloatToEQ19(m_Position.m_Z);
spu->x_pos = FloatToEQ19(m_Position.x);
spu->y_pos = FloatToEQ19(m_Position.y);
spu->z_pos = FloatToEQ19(m_Position.z);
spu->delta_x = NewFloatToEQ13(0);
spu->delta_y = NewFloatToEQ13(0);
spu->delta_z = NewFloatToEQ13(0);
spu->heading = FloatToEQ19(m_Position.m_Heading);
spu->heading = FloatToEQ19(m_Position.w);
spu->animation = 0;
spu->delta_heading = NewFloatToEQ13(0);
spu->padding0002 =0;
@ -1229,13 +1229,13 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
// this is for SendPosUpdate()
void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
spu->spawn_id = GetID();
spu->x_pos = FloatToEQ19(m_Position.m_X);
spu->y_pos = FloatToEQ19(m_Position.m_Y);
spu->z_pos = FloatToEQ19(m_Position.m_Z);
spu->delta_x = NewFloatToEQ13(m_Delta.m_X);
spu->delta_y = NewFloatToEQ13(m_Delta.m_Y);
spu->delta_z = NewFloatToEQ13(m_Delta.m_Z);
spu->heading = FloatToEQ19(m_Position.m_Heading);
spu->x_pos = FloatToEQ19(m_Position.x);
spu->y_pos = FloatToEQ19(m_Position.y);
spu->z_pos = FloatToEQ19(m_Position.z);
spu->delta_x = NewFloatToEQ13(m_Delta.x);
spu->delta_y = NewFloatToEQ13(m_Delta.y);
spu->delta_z = NewFloatToEQ13(m_Delta.z);
spu->heading = FloatToEQ19(m_Position.w);
spu->padding0002 =0;
spu->padding0006 =7;
spu->padding0014 =0x7f;
@ -1244,7 +1244,7 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
spu->animation = animation;
else
spu->animation = pRunAnimSpeed;//animation;
spu->delta_heading = NewFloatToEQ13(m_Delta.m_Heading);
spu->delta_heading = NewFloatToEQ13(m_Delta.w);
}
void Mob::ShowStats(Client* client)
@ -1360,11 +1360,11 @@ void Mob::GMMove(float x, float y, float z, float heading, bool SendUpdate) {
entity_list.ProcessMove(CastToNPC(), x, y, z);
}
m_Position.m_X = x;
m_Position.m_Y = y;
m_Position.m_Z = z;
if (m_Position.m_Heading != 0.01)
this->m_Position.m_Heading = heading;
m_Position.x = x;
m_Position.y = y;
m_Position.z = z;
if (m_Position.w != 0.01)
this->m_Position.w = heading;
if(IsNPC())
CastToNPC()->SaveGuardSpot(true);
if(SendUpdate)
@ -2408,7 +2408,7 @@ bool Mob::HateSummon() {
entity_list.MessageClose(this, true, 500, MT_Say, "%s says,'You will not evade me, %s!' ", GetCleanName(), target->GetCleanName() );
if (target->IsClient()) {
target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, target->GetHeading(), 0, SummonPC);
target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Position.x, m_Position.y, m_Position.z, target->GetHeading(), 0, SummonPC);
}
else {
#ifdef BOTS
@ -2419,7 +2419,7 @@ bool Mob::HateSummon() {
}
#endif //BOTS
target->GMMove(m_Position.m_X, m_Position.m_Y, m_Position.m_Z, target->GetHeading());
target->GMMove(m_Position.x, m_Position.y, m_Position.z, target->GetHeading());
}
return true;
@ -2833,12 +2833,12 @@ void Mob::SetNextIncHPEvent( int inchpevent )
nextinchpevent = inchpevent;
}
//warp for quest function,from sandy
void Mob::Warp(const xyz_location& location)
void Mob::Warp(const glm::vec3& location)
{
if(IsNPC())
entity_list.ProcessMove(CastToNPC(), location.m_X, location.m_Y, location.m_Z);
entity_list.ProcessMove(CastToNPC(), location.x, location.y, location.z);
m_Position = location;
m_Position = glm::vec4(location, m_Position.w);
Mob* target = GetTarget();
if (target)
@ -3055,11 +3055,11 @@ float Mob::FindGroundZ(float new_x, float new_y, float z_offset)
float ret = -999999;
if (zone->zonemap != nullptr)
{
Map::Vertex me;
me.x = m_Position.m_X;
me.y = m_Position.m_Y;
me.z = m_Position.m_Z + z_offset;
Map::Vertex hit;
glm::vec3 me;
me.x = m_Position.x;
me.y = m_Position.y;
me.z = m_Position.z + z_offset;
glm::vec3 hit;
float best_z = zone->zonemap->FindBestZ(me, &hit);
if (best_z != -999999)
{
@ -3075,11 +3075,11 @@ float Mob::GetGroundZ(float new_x, float new_y, float z_offset)
float ret = -999999;
if (zone->zonemap != 0)
{
Map::Vertex me;
me.x = m_Position.m_X;
me.y = m_Position.m_Y;
me.z = m_Position.m_Z+z_offset;
Map::Vertex hit;
glm::vec3 me;
me.x = m_Position.x;
me.y = m_Position.y;
me.z = m_Position.z+z_offset;
glm::vec3 hit;
float best_z = zone->zonemap->FindBestZ(me, &hit);
if (best_z != -999999)
{
@ -3173,7 +3173,7 @@ void Mob::TriggerDefensiveProcs(const ItemInst* weapon, Mob *on, uint16 hand, in
}
}
void Mob::SetDelta(const xyz_heading& delta) {
void Mob::SetDelta(const glm::vec4& delta) {
m_Delta = delta;
}

View File

@ -78,7 +78,7 @@ public:
uint32 in_npctype_id,
float in_size,
float in_runspeed,
const xyz_heading& position,
const glm::vec4& position,
uint8 in_light,
uint8 in_texture,
uint8 in_helmtexture,
@ -294,10 +294,10 @@ public:
inline virtual uint32 GetNimbusEffect2() const { return nimbus_effect2; }
inline virtual uint32 GetNimbusEffect3() const { return nimbus_effect3; }
void RemoveNimbusEffect(int effectid);
inline const xyz_location& GetTargetRingLocation() const { return m_TargetRing; }
inline float GetTargetRingX() const { return m_TargetRing.m_X; }
inline float GetTargetRingY() const { return m_TargetRing.m_Y; }
inline float GetTargetRingZ() const { return m_TargetRing.m_Z; }
inline const glm::vec3& GetTargetRingLocation() const { return m_TargetRing; }
inline float GetTargetRingX() const { return m_TargetRing.x; }
inline float GetTargetRingY() const { return m_TargetRing.y; }
inline float GetTargetRingZ() const { return m_TargetRing.z; }
inline bool HasEndurUpkeep() const { return endur_upkeep; }
inline void SetEndurUpkeep(bool val) { endur_upkeep = val; }
@ -399,19 +399,19 @@ public:
((static_cast<float>(cur_mana) / max_mana) * 100); }
virtual int32 CalcMaxMana();
uint32 GetNPCTypeID() const { return npctype_id; }
inline const xyz_heading GetPosition() const { return m_Position; }
inline const float GetX() const { return m_Position.m_X; }
inline const float GetY() const { return m_Position.m_Y; }
inline const float GetZ() const { return m_Position.m_Z; }
inline const float GetHeading() const { return m_Position.m_Heading; }
inline const glm::vec4 GetPosition() const { return m_Position; }
inline const float GetX() const { return m_Position.x; }
inline const float GetY() const { return m_Position.y; }
inline const float GetZ() const { return m_Position.z; }
inline const float GetHeading() const { return m_Position.w; }
inline const float GetSize() const { return size; }
inline const float GetBaseSize() const { return base_size; }
inline const float GetTarX() const { return m_TargetLocation.m_X; }
inline const float GetTarY() const { return m_TargetLocation.m_Y; }
inline const float GetTarZ() const { return m_TargetLocation.m_Z; }
inline const float GetTarVX() const { return m_TargetV.m_X; }
inline const float GetTarVY() const { return m_TargetV.m_Y; }
inline const float GetTarVZ() const { return m_TargetV.m_Z; }
inline const float GetTarX() const { return m_TargetLocation.x; }
inline const float GetTarY() const { return m_TargetLocation.y; }
inline const float GetTarZ() const { return m_TargetLocation.z; }
inline const float GetTarVX() const { return m_TargetV.x; }
inline const float GetTarVY() const { return m_TargetV.y; }
inline const float GetTarVZ() const { return m_TargetV.z; }
inline const float GetTarVector() const { return tar_vector; }
inline const uint8 GetTarNDX() const { return tar_ndx; }
bool IsBoat() const;
@ -426,9 +426,9 @@ public:
virtual inline int32 GetPrimaryFaction() const { return 0; }
//Movement
void Warp(const xyz_location& location);
void Warp(const glm::vec3& location);
inline bool IsMoving() const { return moving; }
virtual void SetMoving(bool move) { moving = move; m_Delta = xyz_heading::Origin(); }
virtual void SetMoving(bool move) { moving = move; m_Delta = glm::vec4(); }
virtual void GoToBind(uint8 bindnum = 0) { }
virtual void Gate();
float GetWalkspeed() const { return(_GetMovementSpeed(-47)); }
@ -438,15 +438,15 @@ public:
bool IsRunning() const { return m_is_running; }
void SetRunning(bool val) { m_is_running = val; }
virtual void GMMove(float x, float y, float z, float heading = 0.01, bool SendUpdate = true);
void SetDelta(const xyz_heading& delta);
void SetDelta(const glm::vec4& delta);
void SetTargetDestSteps(uint8 target_steps) { tar_ndx = target_steps; }
void SendPosUpdate(uint8 iSendToSelf = 0);
void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu);
void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu);
void SendPosition();
void SetFlyMode(uint8 flymode);
inline void Teleport(Map::Vertex NewPosition) { m_Position.m_X = NewPosition.x; m_Position.m_Y = NewPosition.y;
m_Position.m_Z = NewPosition.z; };
inline void Teleport(glm::vec3 NewPosition) { m_Position.x = NewPosition.x; m_Position.y = NewPosition.y;
m_Position.z = NewPosition.z; };
//AI
static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel);
@ -467,8 +467,8 @@ public:
bool IsEngaged() { return(!hate_list.IsHateListEmpty()); }
bool HateSummon();
void FaceTarget(Mob* MobToFace = 0);
void SetHeading(float iHeading) { if(m_Position.m_Heading != iHeading) { pLastChange = Timer::GetCurrentTime();
m_Position.m_Heading = iHeading; } }
void SetHeading(float iHeading) { if(m_Position.w != iHeading) { pLastChange = Timer::GetCurrentTime();
m_Position.w = iHeading; } }
void WipeHateList();
void AddFeignMemory(Client* attacker);
void RemoveFromFeignMemory(Client* attacker);
@ -814,10 +814,10 @@ public:
void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; }
// calculate interruption of spell via movement of mob
void SaveSpellLoc() {m_SpellLocation = m_Position; }
inline float GetSpellX() const {return m_SpellLocation.m_X;}
inline float GetSpellY() const {return m_SpellLocation.m_Y;}
inline float GetSpellZ() const {return m_SpellLocation.m_Z;}
void SaveSpellLoc() { m_SpellLocation = glm::vec3(m_Position); }
inline float GetSpellX() const {return m_SpellLocation.x;}
inline float GetSpellY() const {return m_SpellLocation.y;}
inline float GetSpellZ() const {return m_SpellLocation.z;}
inline bool IsGrouped() const { return isgrouped; }
void SetGrouped(bool v);
inline bool IsRaidGrouped() const { return israidgrouped; }
@ -869,7 +869,7 @@ public:
Shielders_Struct shielder[MAX_SHIELDERS];
Trade* trade;
inline xyz_heading GetCurrentWayPoint() const { return m_CurrentWayPoint; }
inline glm::vec4 GetCurrentWayPoint() const { return m_CurrentWayPoint; }
inline float GetCWPP() const { return(static_cast<float>(cur_wp_pause)); }
inline int GetCWP() const { return(cur_wp); }
void SetCurrentWP(uint16 waypoint) { cur_wp = waypoint; }
@ -1013,7 +1013,7 @@ protected:
uint8 level;
uint8 orig_level;
uint32 npctype_id;
xyz_heading m_Position;
glm::vec4 m_Position;
uint16 animation;
float base_size;
float size;
@ -1046,7 +1046,7 @@ protected:
virtual int16 GetFocusEffect(focusType type, uint16 spell_id) { return 0; }
void CalculateNewFearpoint();
float FindGroundZ(float new_x, float new_y, float z_offset=0.0);
Map::Vertex UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChange, bool &NodeReached);
glm::vec3 UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChange, bool &NodeReached);
void PrintRoute();
virtual float GetSympatheticProcChances(uint16 spell_id, int16 ProcRateMod, int32 ItemProcRate = 0);
@ -1062,7 +1062,7 @@ protected:
char clean_name[64];
char lastname[64];
xyz_heading m_Delta;
glm::vec4 m_Delta;
uint8 light;
@ -1083,7 +1083,7 @@ protected:
//spell casting vars
Timer spellend_timer;
uint16 casting_spell_id;
xyz_location m_SpellLocation;
glm::vec3 m_SpellLocation;
int attacked_count;
bool delaytimer;
uint16 casting_spell_targetid;
@ -1102,7 +1102,7 @@ protected:
bool ActiveProjectileATK;
tProjatk ProjectileAtk[MAX_SPELL_PROJECTILE];
xyz_location m_RewindLocation;
glm::vec3 m_RewindLocation;
Timer rewind_timer;
@ -1199,18 +1199,18 @@ protected:
int pausetype;
int cur_wp;
xyz_heading m_CurrentWayPoint;
glm::vec4 m_CurrentWayPoint;
int cur_wp_pause;
int patrol;
xyz_location m_FearWalkTarget;
glm::vec3 m_FearWalkTarget;
bool curfp;
// Pathing
//
Map::Vertex PathingDestination;
Map::Vertex PathingLastPosition;
glm::vec3 PathingDestination;
glm::vec3 PathingLastPosition;
int PathingLoopCount;
int PathingLastNodeVisited;
std::deque<int> Route;
@ -1239,13 +1239,13 @@ protected:
bool pet_owner_client; //Flags regular and pets as belonging to a client
EGNode *_egnode; //the EG node we are in
xyz_location m_TargetLocation;
glm::vec3 m_TargetLocation;
uint8 tar_ndx;
float tar_vector;
xyz_location m_TargetV;
glm::vec3 m_TargetV;
float test_vector;
xyz_location m_TargetRing;
glm::vec3 m_TargetRing;
uint32 m_spellHitsLeft[38]; // Used to track which spells will have their numhits incremented when spell finishes casting, 38 Buffslots
int flymode;

View File

@ -67,7 +67,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
dist2 = 0; //DistNoRoot(*this); //WTF was up with this...
}
else
dist2 = ComparativeDistance(m_Position, tar->GetPosition());
dist2 = DistanceSquared(m_Position, tar->GetPosition());
bool checked_los = false; //we do not check LOS until we are absolutely sure we need to, and we only do it once.
@ -401,7 +401,7 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float
if (t1 > iRange
|| t2 > iRange
|| t3 > iRange
|| ComparativeDistance(mob->GetPosition(), caster->GetPosition()) > iRange2
|| DistanceSquared(mob->GetPosition(), caster->GetPosition()) > iRange2
//this call should seem backwards:
|| !mob->CheckLosFN(caster)
|| mob->GetReverseFactionCon(caster) >= FACTION_KINDLY
@ -493,7 +493,7 @@ void Mob::AI_Start(uint32 iMoveDelay) {
pAssistRange = 70;
hate_list.WipeHateList();
m_Delta = xyz_heading::Origin();
m_Delta = glm::vec4();
pRunAnimSpeed = 0;
pLastChange = Timer::GetCurrentTime();
}
@ -622,7 +622,7 @@ void Client::AI_SpellCast()
if(!targ)
return;
float dist = ComparativeDistanceNoZ(m_Position, targ->GetPosition());
float dist = DistanceSquaredNoZ(m_Position, targ->GetPosition());
std::vector<uint32> valid_spells;
std::vector<uint32> slots;
@ -784,17 +784,17 @@ void Client::AI_Process()
if(AImovement_timer->Check()) {
animation = GetRunspeed() * 21;
// Check if we have reached the last fear point
if((ABS(GetX()-m_FearWalkTarget.m_X) < 0.1) && (ABS(GetY()-m_FearWalkTarget.m_Y) <0.1)) {
if((ABS(GetX()-m_FearWalkTarget.x) < 0.1) && (ABS(GetY()-m_FearWalkTarget.y) <0.1)) {
// Calculate a new point to run to
CalculateNewFearpoint();
}
if(!RuleB(Pathing, Fear) || !zone->pathing)
CalculateNewPosition2(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z, GetFearSpeed(), true);
CalculateNewPosition2(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, GetFearSpeed(), true);
else
{
bool WaypointChanged, NodeReached;
Map::Vertex Goal = UpdatePath(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z,
glm::vec3 Goal = UpdatePath(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z,
GetFearSpeed(), WaypointChanged, NodeReached);
if(WaypointChanged)
@ -950,7 +950,7 @@ void Client::AI_Process()
else
{
bool WaypointChanged, NodeReached;
Map::Vertex Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
GetRunspeed(), WaypointChanged, NodeReached);
if(WaypointChanged)
@ -997,7 +997,7 @@ void Client::AI_Process()
if(owner == nullptr)
return;
float dist = ComparativeDistance(m_Position, owner->GetPosition());
float dist = DistanceSquared(m_Position, owner->GetPosition());
if (dist >= 100)
{
float speed = dist >= 225 ? GetRunspeed() : GetWalkspeed();
@ -1052,17 +1052,17 @@ void Mob::AI_Process() {
} else {
if(AImovement_timer->Check()) {
// Check if we have reached the last fear point
if((ABS(GetX()-m_FearWalkTarget.m_X) < 0.1) && (ABS(GetY()-m_FearWalkTarget.m_Y) <0.1)) {
if((ABS(GetX()-m_FearWalkTarget.x) < 0.1) && (ABS(GetY()-m_FearWalkTarget.y) <0.1)) {
// Calculate a new point to run to
CalculateNewFearpoint();
}
if(!RuleB(Pathing, Fear) || !zone->pathing)
CalculateNewPosition2(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z, GetFearSpeed(), true);
CalculateNewPosition2(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, GetFearSpeed(), true);
else
{
bool WaypointChanged, NodeReached;
Map::Vertex Goal = UpdatePath(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z,
glm::vec3 Goal = UpdatePath(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z,
GetFearSpeed(), WaypointChanged, NodeReached);
if(WaypointChanged)
@ -1129,15 +1129,15 @@ void Mob::AI_Process() {
float tether_range = static_cast<float>(GetSpecialAbilityParam(TETHER, 0));
tether_range = tether_range > 0.0f ? tether_range * tether_range : pAggroRange * pAggroRange;
if(ComparativeDistanceNoZ(m_Position, npcSpawnPoint) > tether_range) {
GMMove(npcSpawnPoint.m_X, npcSpawnPoint.m_Y, npcSpawnPoint.m_Z, npcSpawnPoint.m_Heading);
if(DistanceSquaredNoZ(m_Position, npcSpawnPoint) > tether_range) {
GMMove(npcSpawnPoint.x, npcSpawnPoint.y, npcSpawnPoint.z, npcSpawnPoint.w);
}
} else if(GetSpecialAbility(LEASH)) {
float leash_range = static_cast<float>(GetSpecialAbilityParam(LEASH, 0));
leash_range = leash_range > 0.0f ? leash_range * leash_range : pAggroRange * pAggroRange;
if(ComparativeDistanceNoZ(m_Position, npcSpawnPoint) > leash_range) {
GMMove(npcSpawnPoint.m_X, npcSpawnPoint.m_Y, npcSpawnPoint.m_Z, npcSpawnPoint.m_Heading);
if(DistanceSquaredNoZ(m_Position, npcSpawnPoint) > leash_range) {
GMMove(npcSpawnPoint.x, npcSpawnPoint.y, npcSpawnPoint.z, npcSpawnPoint.w);
SetHP(GetMaxHP());
BuffFadeAll();
WipeHateList();
@ -1371,7 +1371,7 @@ void Mob::AI_Process() {
//we cannot reach our target...
//underwater stuff only works with water maps in the zone!
if(IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) {
auto targetPosition = xyz_location(target->GetX(), target->GetY(), target->GetZ());
auto targetPosition = glm::vec3(target->GetX(), target->GetY(), target->GetZ());
if(!zone->watermap->InLiquid(targetPosition)) {
Mob *tar = hate_list.GetEntWithMostHateOnList(this);
if(tar == target) {
@ -1410,7 +1410,7 @@ void Mob::AI_Process() {
{
bool WaypointChanged, NodeReached;
Map::Vertex Goal = UpdatePath(target->GetX(), target->GetY(), target->GetZ(),
glm::vec3 Goal = UpdatePath(target->GetX(), target->GetY(), target->GetZ(),
GetRunspeed(), WaypointChanged, NodeReached);
if(WaypointChanged)
@ -1492,7 +1492,7 @@ void Mob::AI_Process() {
//if(owner->IsClient())
// printf("Pet start pos: (%f, %f, %f)\n", GetX(), GetY(), GetZ());
float dist = ComparativeDistance(m_Position, owner->GetPosition());
float dist = DistanceSquared(m_Position, owner->GetPosition());
if (dist >= 400)
{
float speed = GetWalkspeed();
@ -1547,7 +1547,7 @@ void Mob::AI_Process() {
if (!follow) SetFollowID(0);
else
{
float dist2 = ComparativeDistance(m_Position, follow->GetPosition());
float dist2 = DistanceSquared(m_Position, follow->GetPosition());
int followdist = GetFollowDistance();
if (dist2 >= followdist) // Default follow distance is 100
@ -1724,15 +1724,15 @@ void NPC::AI_DoMovement() {
} // endif (movetimercompleted==true)
else if (!(AIwalking_timer->Enabled()))
{ // currently moving
if (m_CurrentWayPoint.m_X == GetX() && m_CurrentWayPoint.m_Y == GetY())
if (m_CurrentWayPoint.x == GetX() && m_CurrentWayPoint.y == GetY())
{ // are we there yet? then stop
mlog(AI__WAYPOINTS, "We have reached waypoint %d (%.3f,%.3f,%.3f) on grid %d", cur_wp, GetX(), GetY(), GetZ(), GetGrid());
SetWaypointPause();
if(GetAppearance() != eaStanding)
SetAppearance(eaStanding, false);
SetMoving(false);
if (m_CurrentWayPoint.m_Heading >= 0.0) {
SetHeading(m_CurrentWayPoint.m_Heading);
if (m_CurrentWayPoint.w >= 0.0) {
SetHeading(m_CurrentWayPoint.w);
}
SendPosition();
@ -1748,12 +1748,12 @@ void NPC::AI_DoMovement() {
else
{ // not at waypoint yet, so keep moving
if(!RuleB(Pathing, AggroReturnToGrid) || !zone->pathing || (DistractedFromGrid == 0))
CalculateNewPosition2(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, walksp, true);
CalculateNewPosition2(m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, walksp, true);
else
{
bool WaypointChanged;
bool NodeReached;
Map::Vertex Goal = UpdatePath(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, walksp, WaypointChanged, NodeReached);
glm::vec3 Goal = UpdatePath(m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, walksp, WaypointChanged, NodeReached);
if(WaypointChanged)
tar_ndx = 20;
@ -1786,13 +1786,13 @@ void NPC::AI_DoMovement() {
{
bool CP2Moved;
if(!RuleB(Pathing, Guard) || !zone->pathing)
CP2Moved = CalculateNewPosition2(m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z, walksp);
CP2Moved = CalculateNewPosition2(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, walksp);
else
{
if(!((m_Position.m_X == m_GuardPoint.m_X) && (m_Position.m_Y == m_GuardPoint.m_Y) && (m_Position.m_Z == m_GuardPoint.m_Z)))
if(!((m_Position.x == m_GuardPoint.x) && (m_Position.y == m_GuardPoint.y) && (m_Position.z == m_GuardPoint.z)))
{
bool WaypointChanged, NodeReached;
Map::Vertex Goal = UpdatePath(m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z, walksp, WaypointChanged, NodeReached);
glm::vec3 Goal = UpdatePath(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, walksp, WaypointChanged, NodeReached);
if(WaypointChanged)
tar_ndx = 20;
@ -1808,13 +1808,13 @@ void NPC::AI_DoMovement() {
if (!CP2Moved)
{
if(moved) {
mlog(AI__WAYPOINTS, "Reached guard point (%.3f,%.3f,%.3f)", m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z);
mlog(AI__WAYPOINTS, "Reached guard point (%.3f,%.3f,%.3f)", m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z);
ClearFeignMemory();
moved=false;
SetMoving(false);
if (GetTarget() == nullptr || ComparativeDistance(m_Position, GetTarget()->GetPosition()) >= 5*5 )
if (GetTarget() == nullptr || DistanceSquared(m_Position, GetTarget()->GetPosition()) >= 5*5 )
{
SetHeading(m_GuardPoint.m_Heading);
SetHeading(m_GuardPoint.w);
} else {
FaceTarget(GetTarget());
}

View File

@ -56,7 +56,7 @@ extern Zone* zone;
extern volatile bool ZoneLoaded;
extern EntityList entity_list;
NPC::NPC(const NPCType* d, Spawn2* in_respawn, const xyz_heading& position, int iflymode, bool IsCorpse)
NPC::NPC(const NPCType* d, Spawn2* in_respawn, const glm::vec4& position, int iflymode, bool IsCorpse)
: Mob(d->name,
d->lastname,
d->max_hp,
@ -662,8 +662,8 @@ bool NPC::Process()
DoGravityEffect();
}
if(reface_timer->Check() && !IsEngaged() && (m_GuardPoint.m_X == GetX() && m_GuardPoint.m_Y == GetY() && m_GuardPoint.m_Z == GetZ())) {
SetHeading(m_GuardPoint.m_Heading);
if(reface_timer->Check() && !IsEngaged() && (m_GuardPoint.x == GetX() && m_GuardPoint.y == GetY() && m_GuardPoint.z == GetZ())) {
SetHeading(m_GuardPoint.w);
SendPosition();
reface_timer->Disable();
}
@ -768,7 +768,7 @@ bool NPC::DatabaseCastAccepted(int spell_id) {
return false;
}
NPC* NPC::SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client) {
NPC* NPC::SpawnNPC(const char* spawncommand, const glm::vec4& position, Client* client) {
if(spawncommand == 0 || spawncommand[0] == 0) {
return 0;
}

View File

@ -95,10 +95,10 @@ struct Item_Struct;
class NPC : public Mob
{
public:
static NPC* SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client = nullptr);
static NPC* SpawnNPC(const char* spawncommand, const glm::vec4& position, Client* client = nullptr);
static int8 GetAILevel(bool iForceReRead = false);
NPC(const NPCType* data, Spawn2* respawn, const xyz_heading& position, int iflymode, bool IsCorpse = false);
NPC(const NPCType* data, Spawn2* respawn, const glm::vec4& position, int iflymode, bool IsCorpse = false);
virtual ~NPC();
@ -162,7 +162,7 @@ public:
FACTION_VALUE CheckNPCFactionAlly(int32 other_faction);
virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther);
void GoToBind(uint8 bindnum = 0) { GMMove(m_SpawnPoint.m_X, m_SpawnPoint.m_Y, m_SpawnPoint.m_Z, m_SpawnPoint.m_Heading); }
void GoToBind(uint8 bindnum = 0) { GMMove(m_SpawnPoint.x, m_SpawnPoint.y, m_SpawnPoint.z, m_SpawnPoint.w); }
void Gate();
void GetPetState(SpellBuff_Struct *buffs, uint32 *items, char *name);
@ -210,8 +210,8 @@ public:
uint32 GetSp2() const { return spawn_group; }
uint32 GetSpawnPointID() const;
xyz_heading const GetSpawnPoint() const { return m_SpawnPoint; }
xyz_heading const GetGuardPoint() const { return m_GuardPoint; }
glm::vec4 const GetSpawnPoint() const { return m_SpawnPoint; }
glm::vec4 const GetGuardPoint() const { return m_GuardPoint; }
EmuAppearance GetGuardPointAnim() const { return guard_anim; }
void SaveGuardPointAnim(EmuAppearance anim) { guard_anim = anim; }
@ -248,7 +248,7 @@ public:
void SetNPCFactionID(int32 in) { npc_faction_id = in; database.GetFactionIdsForNPC(npc_faction_id, &faction_list, &primary_faction); }
xyz_heading m_SpawnPoint;
glm::vec4 m_SpawnPoint;
uint32 GetMaxDMG() const {return max_dmg;}
uint32 GetMinDMG() const {return min_dmg;}
@ -282,15 +282,15 @@ public:
void StopWandering();
void ResumeWandering();
void PauseWandering(int pausetime);
void MoveTo(const xyz_heading& position, bool saveguardspot);
void GetClosestWaypoint(std::list<wplist> &wp_list, int count, const xyz_location& location);
void MoveTo(const glm::vec4& position, bool saveguardspot);
void GetClosestWaypoint(std::list<wplist> &wp_list, int count, const glm::vec3& location);
uint32 GetEquipment(uint8 material_slot) const; // returns item id
int32 GetEquipmentMaterial(uint8 material_slot) const;
void NextGuardPosition();
void SaveGuardSpot(bool iClearGuardSpot = false);
inline bool IsGuarding() const { return(m_GuardPoint.m_Heading != 0); }
inline bool IsGuarding() const { return(m_GuardPoint.w != 0); }
void SaveGuardSpotCharm();
void RestoreGuardSpotCharm();
void AI_SetRoambox(float iDist, float iRoamDist, uint32 iDelay = 2500, uint32 iMinDelay = 2500);
@ -473,8 +473,8 @@ protected:
void _ClearWaypints();
int max_wp;
int save_wp;
xyz_heading m_GuardPoint;
xyz_heading m_GuardPointSaved;
glm::vec4 m_GuardPoint;
glm::vec4 m_GuardPointSaved;
EmuAppearance guard_anim;
float roambox_max_x;
float roambox_max_y;

View File

@ -21,7 +21,7 @@
extern Zone *zone;
float VertexDistance(Map::Vertex a, Map::Vertex b)
float VectorDistance(glm::vec3 a, glm::vec3 b)
{
float xdist = a.x - b.x;
float ydist = a.y - b.y;
@ -29,7 +29,7 @@ float VertexDistance(Map::Vertex a, Map::Vertex b)
return sqrtf(xdist * xdist + ydist * ydist + zdist * zdist);
}
float VertexDistanceNoRoot(Map::Vertex a, Map::Vertex b)
float VectorDistanceNoRoot(glm::vec3 a, glm::vec3 b)
{
float xdist = a.x - b.x;
float ydist = a.y - b.y;
@ -187,9 +187,9 @@ void PathManager::PrintPathing()
}
}
Map::Vertex PathManager::GetPathNodeCoordinates(int NodeNumber, bool BestZ)
glm::vec3 PathManager::GetPathNodeCoordinates(int NodeNumber, bool BestZ)
{
Map::Vertex Result;
glm::vec3 Result;
if(NodeNumber < Head.PathNodeCount)
{
@ -283,7 +283,7 @@ std::deque<int> PathManager::FindRoute(int startID, int endID)
AStarEntry.Teleport = PathNodes[CurrentNode.PathNodeID].Neighbours[i].Teleport;
// HCost is the estimated cost to get from this node to the end.
AStarEntry.HCost = VertexDistance(PathNodes[PathNodes[CurrentNode.PathNodeID].Neighbours[i].id].v,
AStarEntry.HCost = VectorDistance(PathNodes[PathNodes[CurrentNode.PathNodeID].Neighbours[i].id].v,
PathNodes[endID].v);
AStarEntry.GCost = CurrentNode.GCost + PathNodes[CurrentNode.PathNodeID].Neighbours[i].distance;
@ -335,9 +335,9 @@ std::deque<int> PathManager::FindRoute(int startID, int endID)
}
bool CheckLOSBetweenPoints(Map::Vertex start, Map::Vertex end) {
bool CheckLOSBetweenPoints(glm::vec3 start, glm::vec3 end) {
Map::Vertex hit;
glm::vec3 hit;
if((zone->zonemap) && (zone->zonemap->LineIntersectsZone(start, end, 1, &hit)))
return false;
@ -350,7 +350,7 @@ auto path_compare = [](const PathNodeSortStruct& a, const PathNodeSortStruct& b)
return a.Distance < b.Distance;
};
std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
std::deque<int> PathManager::FindRoute(glm::vec3 Start, glm::vec3 End)
{
_log(PATHING__DEBUG, "FindRoute(%8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f)", Start.x, Start.y, Start.z, End.x, End.y, End.z);
@ -376,7 +376,7 @@ std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
(ABS(Start.z - PathNodes[i].v.z) <= CandidateNodeRangeZ))
{
TempNode.id = i;
TempNode.Distance = VertexDistanceNoRoot(Start, PathNodes[i].v);
TempNode.Distance = VectorDistanceNoRoot(Start, PathNodes[i].v);
SortedByDistance.push_back(TempNode);
}
@ -415,7 +415,7 @@ std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
(ABS(End.z - PathNodes[i].v.z) <= CandidateNodeRangeZ))
{
TempNode.id = i;
TempNode.Distance = VertexDistanceNoRoot(End, PathNodes[i].v);
TempNode.Distance = VectorDistanceNoRoot(End, PathNodes[i].v);
SortedByDistance.push_back(TempNode);
}
}
@ -587,7 +587,7 @@ void PathManager::SpawnPathNodes()
npc_type->CHA = 150;
npc_type->findable = 1;
auto position = xyz_heading(PathNodes[i].v.x, PathNodes[i].v.y, PathNodes[i].v.z, 0.0f);
auto position = glm::vec4(PathNodes[i].v.x, PathNodes[i].v.y, PathNodes[i].v.z, 0.0f);
NPC* npc = new NPC(npc_type, nullptr, position, FlyMode1);
npc->GiveNPCTypeData(npc_type);
@ -652,19 +652,19 @@ void PathManager::SimpleMeshTest()
fflush(stdout);
}
Map::Vertex Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChanged, bool &NodeReached)
glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChanged, bool &NodeReached)
{
WaypointChanged = false;
NodeReached = false;
Map::Vertex NodeLoc;
glm::vec3 NodeLoc;
Map::Vertex From(GetX(), GetY(), GetZ());
glm::vec3 From(GetX(), GetY(), GetZ());
Map::Vertex HeadPosition(From.x, From.y, From.z + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION);
glm::vec3 HeadPosition(From.x, From.y, From.z + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION);
Map::Vertex To(ToX, ToY, ToZ);
glm::vec3 To(ToX, ToY, ToZ);
bool SameDestination = (To == PathingDestination);
@ -754,7 +754,7 @@ Map::Vertex Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &
&& PathingLOSCheckTimer->Check()))
{
mlog(PATHING__DEBUG, " Checking distance to target.");
float Distance = VertexDistanceNoRoot(From, To);
float Distance = VectorDistanceNoRoot(From, To);
mlog(PATHING__DEBUG, " Distance between From and To (NoRoot) is %8.3f", Distance);
@ -847,7 +847,7 @@ Map::Vertex Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &
{
mlog(PATHING__DEBUG, " Checking distance to target.");
float Distance = VertexDistanceNoRoot(From, To);
float Distance = VectorDistanceNoRoot(From, To);
mlog(PATHING__DEBUG, " Distance between From and To (NoRoot) is %8.3f", Distance);
@ -887,7 +887,7 @@ Map::Vertex Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &
// Check if we now have LOS etc to the new destination.
if(PathingLOSCheckTimer->Check())
{
float Distance = VertexDistanceNoRoot(From, To);
float Distance = VectorDistanceNoRoot(From, To);
if((Distance <= RuleR(Pathing, MinDistanceForLOSCheckShort))
&& (ABS(From.z - To.z) <= RuleR(Pathing, ZDiffThreshold)))
@ -1039,7 +1039,7 @@ Map::Vertex Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &
WaypointChanged = true;
float Distance = VertexDistanceNoRoot(From, To);
float Distance = VectorDistanceNoRoot(From, To);
if((Distance <= RuleR(Pathing, MinDistanceForLOSCheckLong))
&& (ABS(From.z - To.z) <= RuleR(Pathing, ZDiffThreshold)))
@ -1090,7 +1090,7 @@ Map::Vertex Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &
}
int PathManager::FindNearestPathNode(Map::Vertex Position)
int PathManager::FindNearestPathNode(glm::vec3 Position)
{
// Find the nearest PathNode we have LOS to.
@ -1114,7 +1114,7 @@ int PathManager::FindNearestPathNode(Map::Vertex Position)
(ABS(Position.z - PathNodes[i].v.z) <= CandidateNodeRangeZ))
{
TempNode.id = i;
TempNode.Distance = VertexDistanceNoRoot(Position, PathNodes[i].v);
TempNode.Distance = VectorDistanceNoRoot(Position, PathNodes[i].v);
SortedByDistance.push_back(TempNode);
}
@ -1140,11 +1140,11 @@ int PathManager::FindNearestPathNode(Map::Vertex Position)
return ClosestPathNodeToStart;
}
bool PathManager::NoHazards(Map::Vertex From, Map::Vertex To)
bool PathManager::NoHazards(glm::vec3 From, glm::vec3 To)
{
// Test the Z coordinate at the mid point.
//
Map::Vertex MidPoint((From.x + To.x) / 2, (From.y + To.y) / 2, From.z);
glm::vec3 MidPoint((From.x + To.x) / 2, (From.y + To.y) / 2, From.z);
float NewZ = zone->zonemap->FindBestZ(MidPoint, nullptr);
@ -1164,10 +1164,10 @@ bool PathManager::NoHazards(Map::Vertex From, Map::Vertex To)
return true;
}
bool PathManager::NoHazardsAccurate(Map::Vertex From, Map::Vertex To)
bool PathManager::NoHazardsAccurate(glm::vec3 From, glm::vec3 To)
{
float stepx, stepy, stepz, curx, cury, curz;
Map::Vertex cur = From;
glm::vec3 cur = From;
float last_z = From.z;
float step_size = 1.0;
@ -1185,7 +1185,7 @@ bool PathManager::NoHazardsAccurate(Map::Vertex From, Map::Vertex To)
stepy = (stepy / factor)*step_size;
stepz = (stepz / factor)*step_size;
Map::Vertex TestPoint(curx, cury, curz);
glm::vec3 TestPoint(curx, cury, curz);
float NewZ = zone->zonemap->FindBestZ(TestPoint, nullptr);
if (ABS(NewZ - last_z) > 5.0f)
{
@ -1197,18 +1197,18 @@ bool PathManager::NoHazardsAccurate(Map::Vertex From, Map::Vertex To)
if (zone->watermap)
{
auto from = xyz_location(From.x, From.y, From.z);
auto to = xyz_location(To.x, To.y, To.z);
auto from = glm::vec3(From.x, From.y, From.z);
auto to = glm::vec3(To.x, To.y, To.z);
if (zone->watermap->InLiquid(from) || zone->watermap->InLiquid(to))
{
break;
}
auto testPointNewZ = xyz_location(TestPoint.x, TestPoint.y, NewZ);
auto testPointNewZ = glm::vec3(TestPoint.x, TestPoint.y, NewZ);
if (zone->watermap->InLiquid(testPointNewZ))
{
Map::Vertex TestPointWater(TestPoint.x, TestPoint.y, NewZ - 0.5f);
Map::Vertex TestPointWaterDest = TestPointWater;
Map::Vertex hit;
glm::vec3 TestPointWater(TestPoint.x, TestPoint.y, NewZ - 0.5f);
glm::vec3 TestPointWaterDest = TestPointWater;
glm::vec3 hit;
TestPointWaterDest.z -= 500;
float best_z2 = -999990;
if (zone->zonemap->LineIntersectsZone(TestPointWater, TestPointWaterDest, 1.0f, &hit))
@ -1576,7 +1576,7 @@ int32 PathManager::AddNode(float x, float y, float z, float best_z, int32 reques
npc_type->CHA = 150;
npc_type->findable = 1;
auto position = xyz_heading(new_node.v.x, new_node.v.y, new_node.v.z, 0.0f);
auto position = glm::vec4(new_node.v.x, new_node.v.y, new_node.v.z, 0.0f);
NPC* npc = new NPC(npc_type, nullptr, position, FlyMode1);
npc->GiveNPCTypeData(npc_type);
entity_list.AddNPC(npc, true, true);
@ -1637,7 +1637,7 @@ int32 PathManager::AddNode(float x, float y, float z, float best_z, int32 reques
npc_type->CHA = 150;
npc_type->findable = 1;
auto position = xyz_heading(new_node.v.x, new_node.v.y, new_node.v.z, 0.0f);
auto position = glm::vec4(new_node.v.x, new_node.v.y, new_node.v.z, 0.0f);
NPC* npc = new NPC(npc_type, nullptr, position, FlyMode1);
npc->GiveNPCTypeData(npc_type);
entity_list.AddNPC(npc, true, true);
@ -1797,7 +1797,7 @@ void PathManager::ConnectNodeToNode(int32 Node1, int32 Node2, int32 teleport, in
a->Neighbours[a_i].id = b->id;
a->Neighbours[a_i].DoorID = doorid;
a->Neighbours[a_i].Teleport = teleport;
a->Neighbours[a_i].distance = VertexDistance(a->v, b->v);
a->Neighbours[a_i].distance = VectorDistance(a->v, b->v);
break;
}
}
@ -1812,7 +1812,7 @@ void PathManager::ConnectNodeToNode(int32 Node1, int32 Node2, int32 teleport, in
b->Neighbours[b_i].id = a->id;
b->Neighbours[b_i].DoorID = doorid;
b->Neighbours[b_i].Teleport = teleport;
b->Neighbours[b_i].distance = VertexDistance(a->v, b->v);
b->Neighbours[b_i].distance = VectorDistance(a->v, b->v);
break;
}
}
@ -1882,7 +1882,7 @@ void PathManager::ConnectNode(int32 Node1, int32 Node2, int32 teleport, int32 do
a->Neighbours[a_i].id = b->id;
a->Neighbours[a_i].DoorID = doorid;
a->Neighbours[a_i].Teleport = teleport;
a->Neighbours[a_i].distance = VertexDistance(a->v, b->v);
a->Neighbours[a_i].distance = VectorDistance(a->v, b->v);
break;
}
}
@ -1998,7 +1998,7 @@ void PathManager::MoveNode(Client *c)
if(zone->zonemap)
{
Map::Vertex loc(c->GetX(), c->GetY(), c->GetZ());
glm::vec3 loc(c->GetX(), c->GetY(), c->GetZ());
Node->bestz = zone->zonemap->FindBestZ(loc, nullptr);
}
else
@ -2069,14 +2069,14 @@ bool PathManager::NodesConnected(PathNode *a, PathNode *b)
return false;
}
bool PathManager::CheckLosFN(Map::Vertex a, Map::Vertex b)
bool PathManager::CheckLosFN(glm::vec3 a, glm::vec3 b)
{
if(zone->zonemap)
{
Map::Vertex hit;
glm::vec3 hit;
Map::Vertex myloc;
Map::Vertex oloc;
glm::vec3 myloc;
glm::vec3 oloc;
myloc.x = a.x;
myloc.y = a.y;
@ -2119,7 +2119,7 @@ void PathManager::ProcessNodesAndSave(std::string filename)
if(!NodesConnected(&PathNodes[x], &PathNodes[y]))
{
if(VertexDistance(PathNodes[x].v, PathNodes[y].v) <= 200)
if(VectorDistance(PathNodes[x].v, PathNodes[y].v) <= 200)
{
if(CheckLosFN(PathNodes[x].v, PathNodes[y].v))
{

View File

@ -30,7 +30,7 @@ struct NeighbourNode {
struct PathNode {
uint16 id;
Map::Vertex v;
glm::vec3 v;
float bestz;
NeighbourNode Neighbours[PATHNODENEIGHBOURS];
};
@ -60,17 +60,17 @@ public:
static PathManager *LoadPathFile(const char *ZoneName);
bool loadPaths(FILE *fp);
void PrintPathing();
std::deque<int> FindRoute(Map::Vertex Start, Map::Vertex End);
std::deque<int> FindRoute(glm::vec3 Start, glm::vec3 End);
std::deque<int> FindRoute(int startID, int endID);
Map::Vertex GetPathNodeCoordinates(int NodeNumber, bool BestZ = true);
bool CheckLosFN(Map::Vertex a, Map::Vertex b);
glm::vec3 GetPathNodeCoordinates(int NodeNumber, bool BestZ = true);
bool CheckLosFN(glm::vec3 a, glm::vec3 b);
void SpawnPathNodes();
void MeshTest();
void SimpleMeshTest();
int FindNearestPathNode(Map::Vertex Position);
bool NoHazards(Map::Vertex From, Map::Vertex To);
bool NoHazardsAccurate(Map::Vertex From, Map::Vertex To);
int FindNearestPathNode(glm::vec3 Position);
bool NoHazards(glm::vec3 From, glm::vec3 To);
bool NoHazardsAccurate(glm::vec3 From, glm::vec3 To);
void OpenDoors(int Node1, int Node2, Mob* ForWho);
PathNode* FindPathNodeByCoordinates(float x, float y, float z);

View File

@ -1072,7 +1072,7 @@ XS(XS_Client_SetBindPoint)
new_z = (float)SvNV(ST(5));
}
THIS->SetBindPoint(to_zone, to_instance, xyz_location(new_x, new_y, new_z));
THIS->SetBindPoint(to_zone, to_instance, glm::vec3(new_x, new_y, new_z));
}
XSRETURN_EMPTY;
}
@ -5963,7 +5963,7 @@ XS(XS_Client_SilentMessage)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");
if(THIS->GetTarget() != NULL){
if(THIS->GetTarget()->IsNPC()){
if (ComparativeDistanceNoZ(THIS->GetPosition(), THIS->GetTarget()->GetPosition()) <= 200) {
if (DistanceSquaredNoZ(THIS->GetPosition(), THIS->GetTarget()->GetPosition()) <= 200) {
if(THIS->GetTarget()->CastToNPC()->IsMoving() && !THIS->GetTarget()->CastToNPC()->IsOnHatelist(THIS->GetTarget()))
THIS->GetTarget()->CastToNPC()->PauseWandering(RuleI(NPC, SayPauseTimeInSec));
THIS->ChannelMessageReceived(8, 0, 100, SvPV_nolen(ST(1)));

View File

@ -138,7 +138,7 @@ XS(XS_Doors_GetX)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetPosition().m_X;
RETVAL = THIS->GetPosition().x;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -164,7 +164,7 @@ XS(XS_Doors_GetY)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetPosition().m_Y;
RETVAL = THIS->GetPosition().y;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -190,7 +190,7 @@ XS(XS_Doors_GetZ)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetPosition().m_Z;
RETVAL = THIS->GetPosition().z;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -216,7 +216,7 @@ XS(XS_Doors_GetHeading)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetPosition().m_Heading;
RETVAL = THIS->GetPosition().w;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -567,7 +567,7 @@ XS(XS_Doors_SetX)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
auto position = THIS->GetPosition();
position.m_X = x;
position.x = x;
THIS->SetPosition(position);
}
XSRETURN_EMPTY;
@ -593,7 +593,7 @@ XS(XS_Doors_SetY)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
auto position = THIS->GetPosition();
position.m_Y = y;
position.y = y;
THIS->SetPosition(position);
}
XSRETURN_EMPTY;
@ -619,7 +619,7 @@ XS(XS_Doors_SetZ)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
auto position = THIS->GetPosition();
position.m_Z = z;
position.z = z;
THIS->SetPosition(position);
}
XSRETURN_EMPTY;
@ -645,7 +645,7 @@ XS(XS_Doors_SetHeading)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
auto position = THIS->GetPosition();
position.m_Heading = heading;
position.w = heading;
THIS->SetPosition(position);
}
XSRETURN_EMPTY;

View File

@ -1875,7 +1875,7 @@ XS(XS_EntityList_GetRandomClient)
c = INT2PTR(Client *,tmp);
}
}
RETVAL = entity_list.GetRandomClient(xyz_location(x, y, z), d * d, c);
RETVAL = entity_list.GetRandomClient(glm::vec3(x, y, z), d * d, c);
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "Client", (void*)RETVAL);
}

View File

@ -3551,7 +3551,7 @@ XS(XS_Mob_GetWaypointX)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetCurrentWayPoint().m_X;
RETVAL = THIS->GetCurrentWayPoint().x;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -3577,7 +3577,7 @@ XS(XS_Mob_GetWaypointY)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetCurrentWayPoint().m_Y;
RETVAL = THIS->GetCurrentWayPoint().y;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -3603,7 +3603,7 @@ XS(XS_Mob_GetWaypointZ)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetCurrentWayPoint().m_Z;
RETVAL = THIS->GetCurrentWayPoint().z;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -3629,7 +3629,7 @@ XS(XS_Mob_GetWaypointH)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetCurrentWayPoint().m_Heading;
RETVAL = THIS->GetCurrentWayPoint().w;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -7662,7 +7662,7 @@ XS(XS_Mob_SetDeltas)
Perl_croak(aTHX_ "Usage: Mob::SetDeltas(THIS, delta_x, delta_y, delta_z, delta_h)");
{
Mob * THIS;
auto delta = xyz_heading((float)SvNV(ST(1)), (float)SvNV(ST(2)), (float)SvNV(ST(3)), (float)SvNV(ST(4)));
auto delta = glm::vec4((float)SvNV(ST(1)), (float)SvNV(ST(2)), (float)SvNV(ST(3)), (float)SvNV(ST(4)));
if (sv_derived_from(ST(0), "Mob")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));

View File

@ -1345,7 +1345,7 @@ XS(XS_NPC_MoveTo)
if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
auto position = xyz_heading(mtx, mty, mtz, mth);
auto position = glm::vec4(mtx, mty, mtz, mth);
THIS->MoveTo(position, saveguard);
}
XSRETURN_EMPTY;
@ -1546,7 +1546,7 @@ XS(XS_NPC_GetSpawnPointX)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetSpawnPoint().m_X;
RETVAL = THIS->GetSpawnPoint().x;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -1573,7 +1573,7 @@ XS(XS_NPC_GetSpawnPointY)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetSpawnPoint().m_Y;
RETVAL = THIS->GetSpawnPoint().y;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -1600,7 +1600,7 @@ XS(XS_NPC_GetSpawnPointZ)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetSpawnPoint().m_Z;
RETVAL = THIS->GetSpawnPoint().z;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -1627,7 +1627,7 @@ XS(XS_NPC_GetSpawnPointH)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetSpawnPoint().m_Heading;
RETVAL = THIS->GetSpawnPoint().w;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -1654,7 +1654,7 @@ XS(XS_NPC_GetGuardPointX)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetGuardPoint().m_X;
RETVAL = THIS->GetGuardPoint().x;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -1681,7 +1681,7 @@ XS(XS_NPC_GetGuardPointY)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetGuardPoint().m_Y;
RETVAL = THIS->GetGuardPoint().y;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);
@ -1708,7 +1708,7 @@ XS(XS_NPC_GetGuardPointZ)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetGuardPoint().m_Z;
RETVAL = THIS->GetGuardPoint().z;
XSprePUSH; PUSHn((double)RETVAL);
}
XSRETURN(1);

View File

@ -361,28 +361,28 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
// get a random npc id from the spawngroups assigned to this zone
auto query = StringFormat("SELECT npcID "
"FROM (spawnentry INNER JOIN spawn2 ON spawn2.spawngroupID = spawnentry.spawngroupID) "
"INNER JOIN npc_types ON npc_types.id = spawnentry.npcID "
"WHERE spawn2.zone = '%s' AND npc_types.bodytype NOT IN (11, 33, 66, 67) "
"AND npc_types.race NOT IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 44, "
"55, 67, 71, 72, 73, 77, 78, 81, 90, 92, 93, 94, 106, 112, 114, 127, 128, "
"130, 139, 141, 183, 236, 237, 238, 239, 254, 266, 329, 330, 378, 379, "
"380, 381, 382, 383, 404, 522) "
"ORDER BY RAND() LIMIT 1", zone->GetShortName());
auto results = database.QueryDatabase(query);
"FROM (spawnentry INNER JOIN spawn2 ON spawn2.spawngroupID = spawnentry.spawngroupID) "
"INNER JOIN npc_types ON npc_types.id = spawnentry.npcID "
"WHERE spawn2.zone = '%s' AND npc_types.bodytype NOT IN (11, 33, 66, 67) "
"AND npc_types.race NOT IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 44, "
"55, 67, 71, 72, 73, 77, 78, 81, 90, 92, 93, 94, 106, 112, 114, 127, 128, "
"130, 139, 141, 183, 236, 237, 238, 239, 254, 266, 329, 330, 378, 379, "
"380, 381, 382, 383, 404, 522) "
"ORDER BY RAND() LIMIT 1", zone->GetShortName());
auto results = database.QueryDatabase(query);
if (!results.Success()) {
// if the database query failed
// if the database query failed
LogFile->write(EQEmuLog::Error, "Error querying database for monster summoning pet in zone %s (%s)", zone->GetShortName(), results.ErrorMessage().c_str());
}
if (results.RowCount() != 0) {
auto row = results.begin();
monsterid = atoi(row[0]);
}
if (results.RowCount() != 0) {
auto row = results.begin();
monsterid = atoi(row[0]);
}
// since we don't have any monsters, just make it look like an earth pet for now
if (monsterid == 0)
monsterid = 567;
// since we don't have any monsters, just make it look like an earth pet for now
if (monsterid == 0)
monsterid = 567;
// give the summoned pet the attributes of the monster we found
const NPCType* monster = database.GetNPCType(monsterid);
@ -430,7 +430,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
into walls or objects (+10), this sometimes creates the "ghost" effect. I changed to +2 (as close as I
could get while it still looked good). I also noticed this can happen if an NPC is spawned on the same spot of another or in a related bad spot.*/
Pet::Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 power)
: NPC(type_data, 0, owner->GetPosition() + xy_location(2, 2), FlyMode3)
: NPC(type_data, 0, owner->GetPosition() + glm::vec4(2.0f, 2.0f, 0.0f, 0.0f), FlyMode3)
{
GiveNPCTypeData(type_data);
typeofpet = type;
@ -449,31 +449,31 @@ bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetR
if (petpower <= 0)
query = StringFormat("SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset "
"FROM pets WHERE type='%s' AND petpower<=0", pet_type);
"FROM pets WHERE type='%s' AND petpower<=0", pet_type);
else
query = StringFormat("SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset "
"FROM pets WHERE type='%s' AND petpower<=%d ORDER BY petpower DESC LIMIT 1",
pet_type, petpower);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetPoweredPetEntry query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
"FROM pets WHERE type='%s' AND petpower<=%d ORDER BY petpower DESC LIMIT 1",
pet_type, petpower);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetPoweredPetEntry query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
if (results.RowCount() != 1)
return false;
if (results.RowCount() != 1)
return false;
auto row = results.begin();
auto row = results.begin();
into->npc_type = atoi(row[0]);
into->temporary = atoi(row[1]);
into->petpower = atoi(row[2]);
into->petcontrol = atoi(row[3]);
into->petnaming = atoi(row[4]);
into->monsterflag = atoi(row[5]);
into->equipmentset = atoi(row[6]);
into->npc_type = atoi(row[0]);
into->temporary = atoi(row[1]);
into->petpower = atoi(row[2]);
into->petcontrol = atoi(row[3]);
into->petnaming = atoi(row[4]);
into->monsterflag = atoi(row[5]);
into->equipmentset = atoi(row[6]);
return true;
return true;
}
Mob* Mob::GetPet() {
@ -653,41 +653,41 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) {
// all of the result rows. Check if we have something in the slot
// already. If no, add the item id to the equipment array.
while (curset >= 0 && depth < 5) {
std::string query = StringFormat("SELECT nested_set FROM pets_equipmentset WHERE set_id = '%s'", curset);
std::string query = StringFormat("SELECT nested_set FROM pets_equipmentset WHERE set_id = '%s'", curset);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
LogFile->write(EQEmuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
}
if (results.RowCount() != 1) {
// invalid set reference, it doesn't exist
LogFile->write(EQEmuLog::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset);
return false;
}
if (results.RowCount() != 1) {
// invalid set reference, it doesn't exist
LogFile->write(EQEmuLog::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset);
return false;
}
auto row = results.begin();
nextset = atoi(row[0]);
auto row = results.begin();
nextset = atoi(row[0]);
query = StringFormat("SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%s'", curset);
results = QueryDatabase(query);
if (!results.Success())
LogFile->write(EQEmuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
else {
for (row = results.begin(); row != results.end(); ++row)
{
slot = atoi(row[0]);
query = StringFormat("SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%s'", curset);
results = QueryDatabase(query);
if (!results.Success())
LogFile->write(EQEmuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
else {
for (row = results.begin(); row != results.end(); ++row)
{
slot = atoi(row[0]);
if (slot >= EmuConstants::EQUIPMENT_SIZE)
continue;
if (slot >= EmuConstants::EQUIPMENT_SIZE)
continue;
if (items[slot] == 0)
items[slot] = atoi(row[1]);
}
}
if (items[slot] == 0)
items[slot] = atoi(row[1]);
}
}
curset = nextset;
depth++;
curset = nextset;
depth++;
}
return true;

View File

@ -1,210 +1,118 @@
#include "position.h"
#include <algorithm>
#include <string>
#include <cmath>
#include "position.h"
#include "../common/string_util.h"
#include <algorithm>
xy_location::xy_location(float x, float y) :
m_X(x),
m_Y(y) {
std::string to_string(const glm::vec4 &position) {
return StringFormat("(%.3f, %.3f, %.3f, %.3f)", position.x,position.y,position.z,position.w);
}
xy_location xy_location::operator -(const xy_location& rhs) const {
xy_location minus(m_X - rhs.m_X, m_Y - rhs.m_Y);
return minus;
std::string to_string(const glm::vec3 &position){
return StringFormat("(%.3f, %.3f, %.3f)", position.x,position.y,position.z);
}
xy_location xy_location::operator +(const xy_location& rhs) const {
xy_location addition(m_X + rhs.m_X, m_Y + rhs.m_Y);
return addition;
std::string to_string(const glm::vec2 &position){
return StringFormat("(%.3f, %.3f)", position.x,position.y);
}
xyz_heading::xyz_heading(float x, float y, float z, float heading) :
m_X(x),
m_Y(y),
m_Z(z),
m_Heading(heading) {
bool IsOrigin(const glm::vec2 &position) {
return position.x == 0.0f && position.y == 0.0f;
}
xyz_heading::xyz_heading(const xyz_heading& locationDir) :
m_X(locationDir.m_X),
m_Y(locationDir.m_Y),
m_Z(locationDir.m_Z),
m_Heading(locationDir.m_Heading) {
bool IsOrigin(const glm::vec3 &position) {
return position.x == 0.0f && position.y == 0.0f && position.z == 0.0f;
}
xyz_heading::xyz_heading(const xyz_location& locationDir, float heading) :
m_X(locationDir.m_X),
m_Y(locationDir.m_Y),
m_Z(locationDir.m_Z),
m_Heading(heading) {
}
xyz_heading::xyz_heading(const xy_location& locationDir, float z, float heading) :
m_X(locationDir.m_X),
m_Y(locationDir.m_Y),
m_Z(z),
m_Heading(heading) {
}
xyz_heading::xyz_heading(const xy_location locationDir, float z, float heading) :
m_X(locationDir.m_X),
m_Y(locationDir.m_Y),
m_Z(z),
m_Heading(heading) {
}
xyz_heading::operator xyz_location() const {
return xyz_location(m_X,m_Y,m_Z);
}
xyz_heading::operator xy_location() const {
return xy_location(m_X,m_Y);
}
const xyz_heading xyz_heading::operator +(const xyz_location& rhs) const{
return xyz_heading(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z, m_Heading);
}
const xyz_heading xyz_heading::operator +(const xy_location& rhs) const{
return xyz_heading(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z, m_Heading);
}
const xyz_heading xyz_heading::operator -(const xyz_location& rhs) const{
return xyz_heading(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z, m_Heading);
}
void xyz_heading::ABS_XYZ(void) {
m_X = abs(m_X);
m_Y = abs(m_Y);
m_Z = abs(m_Z);
}
xyz_location::xyz_location(float x, float y, float z) :
m_X(x),
m_Y(y),
m_Z(z) {
}
xyz_location::xyz_location(double x, double y, double z) :
m_X(static_cast<float>(x)),
m_Y(static_cast<float>(y)),
m_Z(static_cast<float>(z)) {
}
xyz_location::operator xy_location() const {
return xy_location(m_X, m_Y);
}
xyz_location xyz_location::operator -(const xyz_location& rhs) const {
return xyz_location(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z);
}
xyz_location xyz_location::operator +(const xyz_location& rhs) const {
return xyz_location(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z);
}
void xyz_location::ABS_XYZ(void) {
m_X = abs(m_X);
m_Y = abs(m_Y);
m_Z = abs(m_Z);
}
std::string to_string(const xyz_heading &position) {
return StringFormat("(%.3f, %.3f, %.3f, %.3f)", position.m_X,position.m_Y,position.m_Z,position.m_Heading);
}
std::string to_string(const xyz_location &position){
return StringFormat("(%.3f, %.3f, %.3f)", position.m_X,position.m_Y,position.m_Z);
}
std::string to_string(const xy_location &position){
return StringFormat("(%.3f, %.3f)", position.m_X,position.m_Y);
bool IsOrigin(const glm::vec4 &position) {
return position.x == 0.0f && position.y == 0.0f && position.z == 0.0f;
}
/**
* Produces the non square root'ed distance between the two points within the XY plane.
*/
float ComparativeDistance(const xy_location& point1, const xy_location& point2) {
float DistanceSquared(const glm::vec2& point1, const glm::vec2& point2) {
auto diff = point1 - point2;
return diff.m_X * diff.m_X + diff.m_Y * diff.m_Y;
return diff.x * diff.x + diff.y * diff.y;
}
/**
* Produces the distance between the two points on the XY plane.
*/
float Distance(const xy_location& point1, const xy_location& point2) {
return sqrt(ComparativeDistance(point1, point2));
float Distance(const glm::vec2& point1, const glm::vec2& point2) {
return sqrt(DistanceSquared(point1, point2));
}
/**
* Produces the non square root'ed distance between the two points.
*/
float ComparativeDistance(const xyz_location& point1, const xyz_location& point2) {
float DistanceSquared(const glm::vec3& point1, const glm::vec3& point2) {
auto diff = point1 - point2;
return diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z;
return diff.x * diff.x + diff.y * diff.y + diff.z * diff.z;
}
/**
* Produces the non square root'ed distance between the two points.
*/
float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2) {
return ComparativeDistance(static_cast<xyz_location>(point1), static_cast<xyz_location>(point2));
float DistanceSquared(const glm::vec4& point1, const glm::vec4& point2) {
return DistanceSquared(static_cast<glm::vec3>(point1), static_cast<glm::vec3>(point2));
}
/**
* Produces the distance between the two points.
*/
float Distance(const xyz_location& point1, const xyz_location& point2) {
return sqrt(ComparativeDistance(point1, point2));
float Distance(const glm::vec3& point1, const glm::vec3& point2) {
return sqrt(DistanceSquared(point1, point2));
}
/**
* Produces the distance between the two points.
*/
float Distance(const xyz_heading& point1, const xyz_heading& point2) {
return Distance(static_cast<xyz_location>(point1), static_cast<xyz_location>(point2));
float Distance(const glm::vec4& point1, const glm::vec4& point2) {
return Distance(static_cast<glm::vec3>(point1), static_cast<glm::vec3>(point2));
}
/**
* Produces the distance between the two points within the XY plane.
*/
float DistanceNoZ(const xyz_location& point1, const xyz_location& point2) {
return Distance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
float DistanceNoZ(const glm::vec3& point1, const glm::vec3& point2) {
return Distance(static_cast<glm::vec2>(point1),static_cast<glm::vec2>(point2));
}
/**
* Produces the distance between the two points within the XY plane.
*/
float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2) {
return Distance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
float DistanceNoZ(const glm::vec4& point1, const glm::vec4& point2) {
return Distance(static_cast<glm::vec2>(point1),static_cast<glm::vec2>(point2));
}
/**
* Produces the non square root'ed distance between the two points within the XY plane.
*/
float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& point2) {
return ComparativeDistance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
float DistanceSquaredNoZ(const glm::vec3& point1, const glm::vec3& point2) {
return DistanceSquared(static_cast<glm::vec2>(point1),static_cast<glm::vec2>(point2));
}
/**
* Produces the non square root'ed distance between the two points within the XY plane.
*/
float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2) {
return ComparativeDistance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
float DistanceSquaredNoZ(const glm::vec4& point1, const glm::vec4& point2) {
return DistanceSquared(static_cast<glm::vec2>(point1),static_cast<glm::vec2>(point2));
}
/**
* Determines if 'position' is within (inclusive) the axis aligned
* box (3 dimensional) formed from the points minimum and maximum.
*/
bool IsWithinAxisAlignedBox(const xyz_location &position, const xyz_location &minimum, const xyz_location &maximum) {
auto actualMinimum = xyz_location(std::min(minimum.m_X, maximum.m_X), std::min(minimum.m_Y, maximum.m_Y),std::min(minimum.m_Z, maximum.m_Z));
auto actualMaximum = xyz_location(std::max(minimum.m_X, maximum.m_X), std::max(minimum.m_Y, maximum.m_Y),std::max(minimum.m_Z, maximum.m_Z));
bool IsWithinAxisAlignedBox(const glm::vec3 &position, const glm::vec3 &minimum, const glm::vec3 &maximum) {
auto actualMinimum = glm::vec3(std::min(minimum.x, maximum.x), std::min(minimum.y, maximum.y),std::min(minimum.z, maximum.z));
auto actualMaximum = glm::vec3(std::max(minimum.x, maximum.x), std::max(minimum.y, maximum.y),std::max(minimum.z, maximum.z));
bool xcheck = position.m_X >= actualMinimum.m_X && position.m_X <= actualMaximum.m_X;
bool ycheck = position.m_Y >= actualMinimum.m_Y && position.m_Y <= actualMaximum.m_Y;
bool zcheck = position.m_Z >= actualMinimum.m_Z && position.m_Z <= actualMaximum.m_Z;
bool xcheck = position.x >= actualMinimum.x && position.x <= actualMaximum.x;
bool ycheck = position.y >= actualMinimum.y && position.y <= actualMaximum.y;
bool zcheck = position.z >= actualMinimum.z && position.z <= actualMaximum.z;
return xcheck && ycheck && zcheck;
}
@ -213,12 +121,12 @@ bool IsWithinAxisAlignedBox(const xyz_location &position, const xyz_location &mi
* Determines if 'position' is within (inclusive) the axis aligned
* box (2 dimensional) formed from the points minimum and maximum.
*/
bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &minimum, const xy_location &maximum) {
auto actualMinimum = xy_location(std::min(minimum.m_X, maximum.m_X), std::min(minimum.m_Y, maximum.m_Y));
auto actualMaximum = xy_location(std::max(minimum.m_X, maximum.m_X), std::max(minimum.m_Y, maximum.m_Y));
bool IsWithinAxisAlignedBox(const glm::vec2 &position, const glm::vec2 &minimum, const glm::vec2 &maximum) {
auto actualMinimum = glm::vec2(std::min(minimum.x, maximum.x), std::min(minimum.y, maximum.y));
auto actualMaximum = glm::vec2(std::max(minimum.x, maximum.x), std::max(minimum.y, maximum.y));
bool xcheck = position.m_X >= actualMinimum.m_X && position.m_X <= actualMaximum.m_X;
bool ycheck = position.m_Y >= actualMinimum.m_Y && position.m_Y <= actualMaximum.m_Y;
bool xcheck = position.x >= actualMinimum.x && position.x <= actualMaximum.x;
bool ycheck = position.y >= actualMinimum.y && position.y <= actualMaximum.y;
return xcheck && ycheck;
}
@ -226,11 +134,11 @@ bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &mini
/**
* Gives the heading directly 180 degrees from the
* current heading.
* Takes the EQfloat from the xyz_heading and returns
* Takes the EQfloat from the glm::vec4 and returns
* an EQFloat.
*/
float GetReciprocalHeading(const xyz_heading& point1) {
return GetReciprocalHeading(point1.m_Heading);
float GetReciprocalHeading(const glm::vec4& point1) {
return GetReciprocalHeading(point1.w);
}
/**

View File

@ -19,91 +19,34 @@
#define POSITION_H
#include <string>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
class xy_location {
public:
float m_X;
float m_Y;
std::string to_string(const glm::vec4 &position);
std::string to_string(const glm::vec3 &position);
std::string to_string(const glm::vec2 &position);
xy_location(float x = 0.0f, float y = 0.0f);
bool IsWithinAxisAlignedBox(const glm::vec3 &position, const glm::vec3 &minimum, const glm::vec3 &maximum);
bool IsWithinAxisAlignedBox(const glm::vec2 &position, const glm::vec2 &minimum, const glm::vec2 &maximum);
xy_location operator -(const xy_location& rhs) const;
xy_location operator +(const xy_location& rhs) const;
};
bool IsOrigin(const glm::vec2 &position);
bool IsOrigin(const glm::vec3 &position);
bool IsOrigin(const glm::vec4 &position);
class xyz_location {
public:
float m_X;
float m_Y;
float m_Z;
float DistanceSquared(const glm::vec2& point1, const glm::vec2& point2);
float Distance(const glm::vec2& point1, const glm::vec2& point2);
float DistanceSquared(const glm::vec3& point1, const glm::vec3& point2);
float Distance(const glm::vec3& point1, const glm::vec3& point2);
float DistanceNoZ(const glm::vec3& point1, const glm::vec3& point2);
float DistanceSquaredNoZ(const glm::vec3& point1, const glm::vec3& point2);
static const xyz_location& Origin() {static xyz_location origin; return origin;}
float DistanceSquared(const glm::vec4& point1, const glm::vec4& point2);
float Distance(const glm::vec4& point1, const glm::vec4& point2);
float DistanceNoZ(const glm::vec4& point1, const glm::vec4& point2);
float DistanceSquaredNoZ(const glm::vec4& point1, const glm::vec4& point2);
xyz_location(float x = 0.0f, float y = 0.0f, float z = 0.0f);
xyz_location(double x, double y, double z);
operator xy_location() const;
xyz_location operator -(const xyz_location& rhs) const;
xyz_location operator +(const xyz_location& rhs) const;
void ABS_XYZ();
bool isOrigin() const { return m_X == 0 && m_Y == 0 && m_Z == 0;}
};
class xyz_heading {
public:
float m_X;
float m_Y;
float m_Z;
float m_Heading;
static const xyz_heading& Origin() {static xyz_heading origin; return origin;}
xyz_heading(float x = 0.0f, float y = 0.0f, float z = 0.0f, float heading = 0.0f);
xyz_heading(const xyz_heading& locationDir);
xyz_heading(const xyz_location& locationDir, float heading = 0.0f);
explicit xyz_heading(const xy_location& locationDir, float z, float heading);
explicit xyz_heading(const xy_location locationDir, float z, float heading);
operator xyz_location() const;
operator xy_location() const;
const xyz_heading operator +(const xyz_location& rhs) const;
const xyz_heading operator +(const xy_location& rhs) const;
const xyz_heading operator -(const xyz_location& rhs) const;
void ABS_XYZ();
bool isOrigin() const { return m_X == 0.0f && m_Y == 0.0f && m_Z == 0.0f;}
};
std::string to_string(const xyz_heading &position);
std::string to_string(const xyz_location &position);
std::string to_string(const xy_location &position);
bool IsWithinAxisAlignedBox(const xyz_location &position, const xyz_location &minimum, const xyz_location &maximum);
bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &minimum, const xy_location &maximum);
float ComparativeDistance(const xy_location& point1, const xy_location& point2);
float Distance(const xy_location& point1, const xy_location& point2);
float ComparativeDistance(const xyz_location& point1, const xyz_location& point2);
float Distance(const xyz_location& point1, const xyz_location& point2);
float DistanceNoZ(const xyz_location& point1, const xyz_location& point2);
float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& point2);
float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2);
float Distance(const xyz_heading& point1, const xyz_heading& point2);
float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2);
float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2);
float GetReciprocalHeading(const xyz_heading& point1);
float GetReciprocalHeading(const glm::vec4& point1);
float GetReciprocalHeading(const float heading);
#endif

View File

@ -201,7 +201,7 @@ void QuestManager::write(const char *file, const char *str) {
fclose (pFile);
}
Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const xyz_heading& position) {
Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const glm::vec4& position) {
const NPCType* tmp = 0;
if (tmp = database.GetNPCType(npc_type))
{
@ -218,7 +218,7 @@ Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const xyz_heading&
return nullptr;
}
Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, const xyz_heading& position) {
Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, const glm::vec4& position) {
Mob *other = entity_list.GetMobByNpcTypeID(npc_type);
if(other != nullptr) {
return other;
@ -300,7 +300,7 @@ Mob* QuestManager::spawn_from_spawn2(uint32 spawn2_id)
database.UpdateSpawn2Timeleft(spawn2_id, zone->GetInstanceID(), 0);
found_spawn->SetCurrentNPCID(npcid);
auto position = xyz_heading(found_spawn->GetX(), found_spawn->GetY(), found_spawn->GetZ(), found_spawn->GetHeading());
auto position = glm::vec4(found_spawn->GetX(), found_spawn->GetY(), found_spawn->GetZ(), found_spawn->GetHeading());
NPC* npc = new NPC(tmp, found_spawn, position, FlyMode3);
found_spawn->SetNPCPointer(npc);
@ -1486,7 +1486,7 @@ void QuestManager::ding() {
}
void QuestManager::rebind(int zoneid, const xyz_location& location) {
void QuestManager::rebind(int zoneid, const glm::vec3& location) {
QuestManagerCurrentQuestVars();
if(initiator && initiator->IsClient()) {
initiator->SetBindPoint(zoneid, 0, location);
@ -1517,7 +1517,7 @@ void QuestManager::pause(int duration) {
owner->CastToNPC()->PauseWandering(duration);
}
void QuestManager::moveto(const xyz_heading& position, bool saveguardspot) {
void QuestManager::moveto(const glm::vec4& position, bool saveguardspot) {
QuestManagerCurrentQuestVars();
if (!owner || !owner->IsNPC())
return;
@ -1698,7 +1698,7 @@ void QuestManager::sethp(int hpperc) {
owner->Damage(owner, newhp, SPELL_UNKNOWN, SkillHandtoHand, false, 0, false);
}
bool QuestManager::summonburriedplayercorpse(uint32 char_id, const xyz_heading& position) {
bool QuestManager::summonburriedplayercorpse(uint32 char_id, const glm::vec4& position) {
bool Result = false;
if(char_id <= 0)
@ -1711,7 +1711,7 @@ bool QuestManager::summonburriedplayercorpse(uint32 char_id, const xyz_heading&
return true;
}
bool QuestManager::summonallplayercorpses(uint32 char_id, const xyz_heading& position) {
bool QuestManager::summonallplayercorpses(uint32 char_id, const glm::vec4& position) {
if(char_id <= 0)
return false;
@ -2307,14 +2307,14 @@ int QuestManager::getlevel(uint8 type)
return 0;
}
uint16 QuestManager::CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time)
uint16 QuestManager::CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time)
{
uint16 entid = 0; //safety check
entid = entity_list.CreateGroundObject(itemid, position, decay_time);
return entid;
}
uint16 QuestManager::CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type, uint32 decay_time)
uint16 QuestManager::CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type, uint32 decay_time)
{
uint16 entid = 0; //safety check
entid = entity_list.CreateGroundObjectFromModel(model, position, type, decay_time);
@ -2582,12 +2582,12 @@ void QuestManager::RemoveAllFromInstance(uint16 instance_id)
}
}
void QuestManager::MovePCInstance(int zone_id, int instance_id, const xyz_heading& position)
void QuestManager::MovePCInstance(int zone_id, int instance_id, const glm::vec4& position)
{
QuestManagerCurrentQuestVars();
if(initiator)
{
initiator->MovePC(zone_id, instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading);
initiator->MovePC(zone_id, instance_id, position.x, position.y, position.z, position.w);
}
}
@ -2836,7 +2836,7 @@ void QuestManager::SendMail(const char *to, const char *from, const char *subjec
uint16 QuestManager::CreateDoor(const char* model, float x, float y, float z, float heading, uint8 opentype, uint16 size)
{
uint16 entid = 0; //safety check
entid = entity_list.CreateDoor(model, xyz_heading(x, y, z, heading), opentype, size);
entid = entity_list.CreateDoor(model, glm::vec4(x, y, z, heading), opentype, size);
return entid;
}

View File

@ -57,8 +57,8 @@ public:
void me(const char *str);
void summonitem(uint32 itemid, int16 charges = -1);
void write(const char *file, const char *str);
Mob* spawn2(int npc_type, int grid, int unused, const xyz_heading& position);
Mob* unique_spawn(int npc_type, int grid, int unused, const xyz_heading& position);
Mob* spawn2(int npc_type, int grid, int unused, const glm::vec4& position);
Mob* unique_spawn(int npc_type, int grid, int unused, const glm::vec4& position);
Mob* spawn_from_spawn2(uint32 spawn2_id);
void enable_spawn2(uint32 spawn2_id);
void disable_spawn2(uint32 spawn2_id);
@ -132,11 +132,11 @@ public:
void targlobal(const char *varname, const char *value, const char *duration, int npcid, int charid, int zoneid);
void delglobal(const char *varname);
void ding();
void rebind(int zoneid, const xyz_location& location);
void rebind(int zoneid, const glm::vec3& location);
void start(int wp);
void stop();
void pause(int duration);
void moveto(const xyz_heading& position, bool saveguardspot);
void moveto(const glm::vec4& position, bool saveguardspot);
void resume();
void addldonpoints(int32 points, uint32 theme);
void addldonwin(int32 wins, uint32 theme);
@ -157,8 +157,8 @@ public:
void set_zone_flag(int zone_id);
void clear_zone_flag(int zone_id);
void sethp(int hpperc);
bool summonburriedplayercorpse(uint32 char_id, const xyz_heading& position);
bool summonallplayercorpses(uint32 char_id, const xyz_heading& position);
bool summonburriedplayercorpse(uint32 char_id, const glm::vec4& position);
bool summonallplayercorpses(uint32 char_id, const glm::vec4& position);
uint32 getplayerburriedcorpsecount(uint32 char_id);
bool buryplayercorpse(uint32 char_id);
void forcedooropen(uint32 doorid, bool altmode);
@ -208,8 +208,8 @@ public:
void enabletitle(int titleset);
bool checktitle(int titlecheck);
void removetitle(int titlecheck);
uint16 CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time = 300000);
uint16 CreateGroundObjectFromModel(const char* model, const xyz_heading& position, uint8 type = 0x00, uint32 decay_time = 0);
uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000);
uint16 CreateGroundObjectFromModel(const char* model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0);
void ModifyNPCStat(const char *identifier, const char *newValue);
void UpdateSpawnTimer(uint32 id, uint32 newTime);
void MerchantSetItem(uint32 NPCid, uint32 itemid, uint32 quantity = 0);
@ -224,7 +224,7 @@ public:
//void RemoveGroupFromInstance(uint16 instance_id); //potentially useful but not implmented at this time.
//void RemoveRaidFromInstance(uint16 instance_id); //potentially useful but not implmented at this time.
void RemoveAllFromInstance(uint16 instance_id);
void MovePCInstance(int zone_id, int instance_id, const xyz_heading& position);
void MovePCInstance(int zone_id, int instance_id, const glm::vec4& position);
void FlagInstanceByGroupLeader(uint32 zone, int16 version);
void FlagInstanceByRaidLeader(uint32 zone, int16 version);
const char* varlink(char* perltext, int item_id);

View File

@ -489,7 +489,7 @@ void Raid::CastGroupSpell(Mob* caster, uint16 spellid, uint32 gid)
else if(members[x].member != nullptr)
{
if(members[x].GroupNumber == gid){
distance = ComparativeDistance(caster->GetPosition(), members[x].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[x].member->GetPosition());
if(distance <= range2){
caster->SpellOnTarget(spellid, members[x].member);
#ifdef GROUP_BUFF_PETS
@ -537,7 +537,7 @@ void Raid::HealGroup(uint32 heal_amt, Mob* caster, uint32 gid, float range)
if(members[gi].member){
if(members[gi].GroupNumber == gid)
{
distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi].member->GetPosition());
if(distance <= range2){
numMem += 1;
}
@ -551,7 +551,7 @@ void Raid::HealGroup(uint32 heal_amt, Mob* caster, uint32 gid, float range)
if(members[gi].member){
if(members[gi].GroupNumber == gid)
{
distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi].member->GetPosition());
if(distance <= range2){
members[gi].member->SetHP(members[gi].member->GetHP() + heal_amt);
members[gi].member->SendHPUpdate();
@ -581,7 +581,7 @@ void Raid::BalanceHP(int32 penalty, uint32 gid, float range, Mob* caster, int32
if(members[gi].member){
if(members[gi].GroupNumber == gid)
{
distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi].member->GetPosition());
if(distance <= range2){
dmgtaken_tmp = members[gi].member->GetMaxHP() - members[gi].member->GetHP();
@ -602,7 +602,7 @@ void Raid::BalanceHP(int32 penalty, uint32 gid, float range, Mob* caster, int32
if(members[gi].member){
if(members[gi].GroupNumber == gid)
{
distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi].member->GetPosition());
if(distance <= range2){
if((members[gi].member->GetMaxHP() - dmgtaken) < 1){//this way the ability will never kill someone
members[gi].member->SetHP(1); //but it will come darn close
@ -637,7 +637,7 @@ void Raid::BalanceMana(int32 penalty, uint32 gid, float range, Mob* caster, int3
if(members[gi].GroupNumber == gid)
{
if (members[gi].member->GetMaxMana() > 0) {
distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi].member->GetPosition());
if(distance <= range2){
manataken_tmp = members[gi].member->GetMaxMana() - members[gi].member->GetMana();
@ -660,7 +660,7 @@ void Raid::BalanceMana(int32 penalty, uint32 gid, float range, Mob* caster, int3
if(members[gi].member){
if(members[gi].GroupNumber == gid)
{
distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[gi].member->GetPosition());
if(distance <= range2){
if((members[gi].member->GetMaxMana() - manataken) < 1){
members[gi].member->SetMana(1);
@ -791,7 +791,7 @@ void Raid::GroupBardPulse(Mob* caster, uint16 spellid, uint32 gid){
else if(members[z].member != nullptr)
{
if(members[z].GroupNumber == gid){
distance = ComparativeDistance(caster->GetPosition(), members[z].member->GetPosition());
distance = DistanceSquared(caster->GetPosition(), members[z].member->GetPosition());
if(distance <= range2) {
members[z].member->BardPulse(spellid, caster);
#ifdef GROUP_BUFF_PETS

View File

@ -218,7 +218,7 @@ bool Spawn2::Process() {
database.UpdateSpawn2Timeleft(spawn2_id, zone->GetInstanceID(), 0);
currentnpcid = npcid;
NPC* npc = new NPC(tmp, this, xyz_heading(x, y, z, heading), FlyMode3);
NPC* npc = new NPC(tmp, this, glm::vec4(x, y, z, heading), FlyMode3);
npc->mod_prespawn(this);
@ -414,13 +414,13 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2
return newSpawn;
}
bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, const xyz_heading& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value)
bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value)
{
std::string query = StringFormat("INSERT INTO spawn2 (spawngroupID, zone, x, y, z, heading, "
"respawntime, variance, _condition, cond_value) "
"VALUES (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)",
spawngroup, zone, position.m_X, position.m_Y, position.m_Z, position.m_Heading,
spawngroup, zone, position.x, position.y, position.z, position.w,
respawn, variance, condition, cond_value);
auto results = QueryDatabase(query);
if (!results.Success()) {

View File

@ -769,7 +769,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
float range = RangeItem->Range + AmmoItem->Range + GetRangeDistTargetSizeMod(GetTarget());
mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", range);
range *= range;
float dist = ComparativeDistance(m_Position, other->GetPosition());
float dist = DistanceSquared(m_Position, other->GetPosition());
if(dist > range) {
mlog(COMBAT__RANGED, "Ranged attack out of range... client should catch this. (%f > %f).\n", dist, range);
Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase.
@ -1219,9 +1219,9 @@ void NPC::RangedAttack(Mob* other)
min_range = static_cast<float>(sa_min_range);
max_range *= max_range;
if(ComparativeDistance(m_Position, other->GetPosition()) > max_range)
if(DistanceSquared(m_Position, other->GetPosition()) > max_range)
return;
else if(ComparativeDistance(m_Position, other->GetPosition()) < (min_range * min_range))
else if(DistanceSquared(m_Position, other->GetPosition()) < (min_range * min_range))
return;
if(!other || !IsAttackAllowed(other) ||
@ -1408,7 +1408,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
float range = item->Range + GetRangeDistTargetSizeMod(other);
mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", range);
range *= range;
float dist = ComparativeDistance(m_Position, other->GetPosition());
float dist = DistanceSquared(m_Position, other->GetPosition());
if(dist > range) {
mlog(COMBAT__RANGED, "Throwing attack out of range... client should catch this. (%f > %f).\n", dist, range);
Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase.

View File

@ -362,7 +362,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, uint16 slot,
casting_spell_type = type;
SaveSpellLoc();
mlog(SPELLS__CASTING, "Casting %d Started at (%.3f,%.3f,%.3f)", spell_id, m_SpellLocation.m_X, m_SpellLocation.m_Y, m_SpellLocation.m_Z);
mlog(SPELLS__CASTING, "Casting %d Started at (%.3f,%.3f,%.3f)", spell_id, m_SpellLocation.x, m_SpellLocation.y, m_SpellLocation.z);
// if this spell doesn't require a target, or if it's an optional target
// and a target wasn't provided, then it's us; unless TGB is on and this
@ -533,8 +533,8 @@ bool Mob::DoCastingChecks()
return false;
}
if (zone->IsSpellBlocked(spell_id, GetPosition())) {
const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition());
if(zone->IsSpellBlocked(spell_id, glm::vec3(GetPosition()))) {
const char *msg = zone->GetSpellBlockedMessage(spell_id, glm::vec3(GetPosition()));
if (msg) {
Message(13, msg);
return false;
@ -1918,8 +1918,8 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16
if(IsClient() && !CastToClient()->GetGM()){
if(zone->IsSpellBlocked(spell_id, GetPosition())){
const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition());
if(zone->IsSpellBlocked(spell_id, glm::vec3(GetPosition()))){
const char *msg = zone->GetSpellBlockedMessage(spell_id, glm::vec3(GetPosition()));
if(msg){
Message(13, msg);
return false;
@ -2002,7 +2002,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16
}
if(spell_target != nullptr && spell_target != this) {
//casting a spell on somebody but ourself, make sure they are in range
float dist2 = ComparativeDistance(m_Position, spell_target->GetPosition());
float dist2 = DistanceSquared(m_Position, spell_target->GetPosition());
float range2 = range * range;
float min_range2 = spells[spell_id].min_range * spells[spell_id].min_range;
if(dist2 > range2) {
@ -2344,7 +2344,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, uint16 slot) {
range = GetActSpellRange(spell_id, spells[spell_id].range, true);
if(spell_target != nullptr && spell_target != this) {
//casting a spell on somebody but ourself, make sure they are in range
float dist2 = ComparativeDistance(m_Position, spell_target->GetPosition());
float dist2 = DistanceSquared(m_Position, spell_target->GetPosition());
float range2 = range * range;
if(dist2 > range2) {
//target is out of range.
@ -3856,9 +3856,9 @@ void Corpse::CastRezz(uint16 spellid, Mob* Caster)
rezz->zone_id = zone->GetZoneID();
rezz->instance_id = zone->GetInstanceID();
rezz->spellid = spellid;
rezz->x = this->m_Position.m_X;
rezz->y = this->m_Position.m_Y;
rezz->z = this->m_Position.m_Z;
rezz->x = this->m_Position.x;
rezz->y = this->m_Position.y;
rezz->z = this->m_Position.z;
rezz->unknown000 = 0x00000000;
rezz->unknown020 = 0x00000000;
rezz->unknown088 = 0x00000000;

View File

@ -53,7 +53,7 @@ Trap::Trap() :
Entity(),
respawn_timer(600000),
chkarea_timer(500),
m_Position(xyz_location::Origin())
m_Position(glm::vec3())
{
trap_id = 0;
maxzdiff = 0;
@ -144,8 +144,8 @@ void Trap::Trigger(Mob* trigger)
{
if ((tmp = database.GetNPCType(effectvalue)))
{
auto randomOffset = xyz_heading(zone->random.Int(-5, 5),zone->random.Int(-5, 5),zone->random.Int(-5, 5), zone->random.Int(0, 249));
auto spawnPosition = randomOffset + m_Position;
auto randomOffset = glm::vec4(zone->random.Int(-5, 5),zone->random.Int(-5, 5),zone->random.Int(-5, 5), zone->random.Int(0, 249));
auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
NPC* new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3);
new_npc->AddLootTable();
entity_list.AddNPC(new_npc);
@ -167,8 +167,8 @@ void Trap::Trigger(Mob* trigger)
{
if ((tmp = database.GetNPCType(effectvalue)))
{
auto randomOffset = xyz_heading(zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(0, 249));
auto spawnPosition = randomOffset + m_Position;
auto randomOffset = glm::vec4(zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(0, 249));
auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
NPC* new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3);
new_npc->AddLootTable();
entity_list.AddNPC(new_npc);
@ -216,16 +216,16 @@ Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) {
for (auto it = trap_list.begin(); it != trap_list.end(); ++it) {
cur = it->second;
if(cur->disarmed)
continue;
continue;
auto diff = searcher->GetPosition() - cur->m_Position;
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z;
auto diff = glm::vec3(searcher->GetPosition()) - cur->m_Position;
float curdist = diff.x * diff.x + diff.y * diff.y + diff.z * diff.z;
if (curdist < max_dist2 && curdist < dist)
{
dist = curdist;
current_trap = cur;
}
if (curdist < max_dist2 && curdist < dist)
{
dist = curdist;
current_trap = cur;
}
}
return current_trap;
@ -239,11 +239,11 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) {
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
Client* cur = it->second;
auto diff = cur->GetPosition() - trap->m_Position;
diff.ABS_XYZ();
auto diff = glm::vec3(cur->GetPosition()) - trap->m_Position;
diff.z = std::abs(diff.z);
if ((diff.m_X*diff.m_X + diff.m_Y*diff.m_Y) <= maxdist
&& diff.m_Z < trap->maxzdiff)
if ((diff.x*diff.x + diff.y*diff.y) <= maxdist
&& diff.z < trap->maxzdiff)
{
if (zone->random.Roll(trap->chance))
return(cur);
@ -259,33 +259,33 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) {
//todo: rewrite this to not need direct access to trap members.
bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
std::string query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, "
"maxzdiff, radius, chance, message, respawn_time, respawn_var, level "
"FROM traps WHERE zone='%s' AND version=%u", zonename, version);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in LoadTraps query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
std::string query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, "
"maxzdiff, radius, chance, message, respawn_time, respawn_var, level "
"FROM traps WHERE zone='%s' AND version=%u", zonename, version);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "Error in LoadTraps query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
}
for (auto row = results.begin(); row != results.end(); ++row) {
Trap* trap = new Trap();
trap->trap_id = atoi(row[0]);
trap->m_Position = xyz_location(atof(row[1]), atof(row[2]), atof(row[3]));
trap->effect = atoi(row[4]);
trap->effectvalue = atoi(row[5]);
trap->effectvalue2 = atoi(row[6]);
trap->skill = atoi(row[7]);
trap->maxzdiff = atof(row[8]);
trap->radius = atof(row[9]);
trap->chance = atoi(row[10]);
trap->message = row[11];
trap->respawn_time = atoi(row[12]);
trap->respawn_var = atoi(row[13]);
trap->level = atoi(row[14]);
entity_list.AddTrap(trap);
trap->CreateHiddenTrigger();
}
for (auto row = results.begin(); row != results.end(); ++row) {
Trap* trap = new Trap();
trap->trap_id = atoi(row[0]);
trap->m_Position = glm::vec3(atof(row[1]), atof(row[2]), atof(row[3]));
trap->effect = atoi(row[4]);
trap->effectvalue = atoi(row[5]);
trap->effectvalue2 = atoi(row[6]);
trap->skill = atoi(row[7]);
trap->maxzdiff = atof(row[8]);
trap->radius = atof(row[9]);
trap->chance = atoi(row[10]);
trap->message = row[11];
trap->respawn_time = atoi(row[12]);
trap->respawn_var = atoi(row[13]);
trap->level = atoi(row[14]);
entity_list.AddTrap(trap);
trap->CreateHiddenTrigger();
}
return true;
}
@ -312,7 +312,7 @@ void Trap::CreateHiddenTrigger()
make_npc->trackable = 0;
make_npc->level = level;
strcpy(make_npc->special_abilities, "19,1^20,1^24,1^25,1");
NPC* npca = new NPC(make_npc, nullptr, xyz_heading(m_Position, 0.0f), FlyMode3);
NPC* npca = new NPC(make_npc, nullptr, glm::vec4(m_Position, 0.0f), FlyMode3);
npca->GiveNPCTypeData(make_npc);
entity_list.AddNPC(npca);

View File

@ -54,7 +54,7 @@ public:
Timer respawn_timer; //Respawn Time when Trap's been disarmed
Timer chkarea_timer;
uint32 trap_id; //Database ID of trap
xyz_location m_Position;
glm::vec3 m_Position;
float maxzdiff; //maximum z diff to be triggerable
float radius; //radius around trap to be triggerable
uint8 chance; //%chance that the trap is triggered each 'tick'

View File

@ -26,11 +26,11 @@ public:
virtual ~WaterMap() { }
static WaterMap* LoadWaterMapfile(std::string zone_name);
virtual WaterRegionType ReturnRegionType(const xyz_location& location) const { return RegionTypeNormal; }
virtual bool InWater(const xyz_location& location) const { return false; }
virtual bool InVWater(const xyz_location& location) const { return false; }
virtual bool InLava(const xyz_location& location) const { return false; }
virtual bool InLiquid(const xyz_location& location) const { return false; }
virtual WaterRegionType ReturnRegionType(const glm::vec3& location) const = 0;
virtual bool InWater(const glm::vec3& location) const = 0;
virtual bool InVWater(const glm::vec3& location) const = 0;
virtual bool InLava(const glm::vec3& location) const = 0;
virtual bool InLiquid(const glm::vec3& location) const = 0;
protected:
virtual bool Load(FILE *fp) { return false; }

View File

@ -10,24 +10,24 @@ WaterMapV1::~WaterMapV1() {
}
}
WaterRegionType WaterMapV1::ReturnRegionType(float y, float x, float z) const {
return BSPReturnRegionType(1, y, x, z);
WaterRegionType WaterMapV1::ReturnRegionType(const glm::vec3& location) const {
return BSPReturnRegionType(1, location);
}
bool WaterMapV1::InWater(float y, float x, float z) const {
return ReturnRegionType(y, x, z) == RegionTypeWater;
bool WaterMapV1::InWater(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypeWater;
}
bool WaterMapV1::InVWater(float y, float x, float z) const {
return ReturnRegionType(y, x, z) == RegionTypeVWater;
bool WaterMapV1::InVWater(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypeVWater;
}
bool WaterMapV1::InLava(float y, float x, float z) const {
return ReturnRegionType(y, x, z) == RegionTypeLava;
bool WaterMapV1::InLava(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypeLava;
}
bool WaterMapV1::InLiquid(float y, float x, float z) const {
return InWater(y, x, z) || InLava(y, x, z);
bool WaterMapV1::InLiquid(const glm::vec3& location) const {
return InWater(location) || InLava(location);
}
bool WaterMapV1::Load(FILE *fp) {
@ -48,7 +48,7 @@ bool WaterMapV1::Load(FILE *fp) {
return true;
}
WaterRegionType WaterMapV1::BSPReturnRegionType(int32 node_number, float y, float x, float z) const {
WaterRegionType WaterMapV1::BSPReturnRegionType(int32 node_number, const glm::vec3& location) const {
float distance;
const ZBSP_Node *current_node = &BSP_Root[node_number - 1];
@ -58,9 +58,9 @@ WaterRegionType WaterMapV1::BSPReturnRegionType(int32 node_number, float y, floa
return (WaterRegionType)current_node->special;
}
distance = (x * current_node->normal[0]) +
(y * current_node->normal[1]) +
(z * current_node->normal[2]) +
distance = (location.x * current_node->normal[0]) +
(location.y * current_node->normal[1]) +
(location.z * current_node->normal[2]) +
current_node->splitdistance;
if (distance == 0.0f) {
@ -71,12 +71,12 @@ WaterRegionType WaterMapV1::BSPReturnRegionType(int32 node_number, float y, floa
if (current_node->left == 0) {
return(RegionTypeNormal);
}
return BSPReturnRegionType(current_node->left, y, x, z);
return BSPReturnRegionType(current_node->left, location);
}
if (current_node->right == 0) {
return(RegionTypeNormal);
}
return BSPReturnRegionType(current_node->right, y, x, z);
return BSPReturnRegionType(current_node->right, location);
}

View File

@ -19,17 +19,17 @@ public:
WaterMapV1();
~WaterMapV1();
virtual WaterRegionType ReturnRegionType(float y, float x, float z) const;
virtual bool InWater(float y, float x, float z) const;
virtual bool InVWater(float y, float x, float z) const;
virtual bool InLava(float y, float x, float z) const;
virtual bool InLiquid(float y, float x, float z) const;
virtual WaterRegionType ReturnRegionType(const glm::vec3& location) const;
virtual bool InWater(const glm::vec3& location) const;
virtual bool InVWater(const glm::vec3& location) const;
virtual bool InLava(const glm::vec3& location) const;
virtual bool InLiquid(const glm::vec3& location) const;
protected:
virtual bool Load(FILE *fp);
private:
WaterRegionType BSPReturnRegionType(int32 node_number, float y, float x, float z) const;
WaterRegionType BSPReturnRegionType(int32 node_number, const glm::vec3& location) const;
ZBSP_Node* BSP_Root;
friend class WaterMap;

View File

@ -6,30 +6,30 @@ WaterMapV2::WaterMapV2() {
WaterMapV2::~WaterMapV2() {
}
WaterRegionType WaterMapV2::ReturnRegionType(const xyz_location& location) const {
WaterRegionType WaterMapV2::ReturnRegionType(const glm::vec3& location) const {
size_t sz = regions.size();
for(size_t i = 0; i < sz; ++i) {
auto const &region = regions[i];
if (region.second.ContainsPoint(glm::vec3(location.m_X, location.m_Y, location.m_Z))) {
if (region.second.ContainsPoint(glm::vec3(location.x, location.y, location.z))) {
return region.first;
}
}
return RegionTypeNormal;
}
bool WaterMapV2::InWater(const xyz_location& location) const {
bool WaterMapV2::InWater(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypeWater;
}
bool WaterMapV2::InVWater(const xyz_location& location) const {
bool WaterMapV2::InVWater(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypeVWater;
}
bool WaterMapV2::InLava(const xyz_location& location) const {
bool WaterMapV2::InLava(const glm::vec3& location) const {
return ReturnRegionType(location) == RegionTypeLava;
}
bool WaterMapV2::InLiquid(const xyz_location& location) const {
bool WaterMapV2::InLiquid(const glm::vec3& location) const {
return InWater(location) || InLava(location);
}

View File

@ -12,11 +12,11 @@ public:
WaterMapV2();
~WaterMapV2();
virtual WaterRegionType ReturnRegionType(const xyz_location& location) const;
virtual bool InWater(const xyz_location& location) const;
virtual bool InVWater(const xyz_location& location) const;
virtual bool InLava(const xyz_location& location) const;
virtual bool InLiquid(const xyz_location& location) const;
virtual WaterRegionType ReturnRegionType(const glm::vec3& location) const;
virtual bool InWater(const glm::vec3& location) const;
virtual bool InVWater(const glm::vec3& location) const;
virtual bool InLava(const glm::vec3& location) const;
virtual bool InLiquid(const glm::vec3& location) const;
protected:
virtual bool Load(FILE *fp);

File diff suppressed because it is too large Load Diff

View File

@ -771,11 +771,11 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
pvpzone = false;
if(database.GetServerType() == 1)
pvpzone = true;
database.GetZoneLongName(short_name, &long_name, file_name, &m_SafePoint.m_X, &m_SafePoint.m_Y, &m_SafePoint.m_Z, &pgraveyard_id, &pMaxClients);
database.GetZoneLongName(short_name, &long_name, file_name, &m_SafePoint.x, &m_SafePoint.y, &m_SafePoint.z, &pgraveyard_id, &pMaxClients);
if(graveyard_id() > 0)
{
LogFile->write(EQEmuLog::Debug, "Graveyard ID is %i.", graveyard_id());
bool GraveYardLoaded = database.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_Graveyard.m_X, &m_Graveyard.m_Y, &m_Graveyard.m_Z, &m_Graveyard.m_Heading);
bool GraveYardLoaded = database.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_Graveyard.x, &m_Graveyard.y, &m_Graveyard.z, &m_Graveyard.w);
if(GraveYardLoaded)
LogFile->write(EQEmuLog::Debug, "Loaded a graveyard for zone %s: graveyard zoneid is %u at %s.", short_name, graveyard_zoneid(), to_string(m_Graveyard).c_str());
else
@ -1514,7 +1514,7 @@ void Zone::SetTime(uint8 hour, uint8 minute)
}
}
ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, uint32 to, Client* client, float max_distance) {
ZonePoint* Zone::GetClosestZonePoint(const glm::vec3& location, uint32 to, Client* client, float max_distance) {
LinkedListIterator<ZonePoint*> iterator(zone_point_list);
ZonePoint* closest_zp = 0;
float closest_dist = FLT_MAX;
@ -1532,7 +1532,7 @@ ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, uint32 to, Cl
if (zp->target_zone_id == to)
{
auto dist = Distance(xy_location(zp->x,zp->y), location);
auto dist = Distance(glm::vec2(zp->x, zp->y), glm::vec2(location));
if ((zp->x == 999999 || zp->x == -999999) && (zp->y == 999999 || zp->y == -999999))
dist = 0;
@ -1548,7 +1548,7 @@ ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, uint32 to, Cl
if(closest_dist > 400.0f && closest_dist < max_distance2)
{
if(client)
client->CheatDetected(MQZoneUnknownDest, location.m_X, location.m_Y, location.m_Z); // Someone is trying to use /zone
client->CheatDetected(MQZoneUnknownDest, location.x, location.y, location.z); // Someone is trying to use /zone
LogFile->write(EQEmuLog::Status, "WARNING: Closest zone point for zone id %d is %f, you might need to update your zone_points table if you dont arrive at the right spot.", to, closest_dist);
LogFile->write(EQEmuLog::Status, "<Real Zone Points>. %s", to_string(location).c_str());
}
@ -1557,14 +1557,14 @@ ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, uint32 to, Cl
closest_zp = nullptr;
if(!closest_zp)
closest_zp = GetClosestZonePointWithoutZone(location.m_X, location.m_Y, location.m_Z, client);
closest_zp = GetClosestZonePointWithoutZone(location.x, location.y, location.z, client);
return closest_zp;
}
ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, const char* to_name, Client* client, float max_distance) {
ZonePoint* Zone::GetClosestZonePoint(const glm::vec3& location, const char* to_name, Client* client, float max_distance) {
if(to_name == nullptr)
return GetClosestZonePointWithoutZone(location.m_X, location.m_Y, location.m_Z, client, max_distance);
return GetClosestZonePointWithoutZone(location.x, location.y, location.z, client, max_distance);
return GetClosestZonePoint(location, database.GetZoneID(to_name), client, max_distance);
}
@ -1813,7 +1813,7 @@ bool Zone::HasGraveyard() {
return Result;
}
void Zone::SetGraveyard(uint32 zoneid, const xyz_heading& graveyardPosition) {
void Zone::SetGraveyard(uint32 zoneid, const glm::vec4& graveyardPosition) {
pgraveyard_zoneid = zoneid;
m_Graveyard = graveyardPosition;
}
@ -1842,7 +1842,7 @@ void Zone::ClearBlockedSpells()
}
}
bool Zone::IsSpellBlocked(uint32 spell_id, const xyz_location& location)
bool Zone::IsSpellBlocked(uint32 spell_id, const glm::vec3& location)
{
if (blocked_spells)
{
@ -1908,7 +1908,7 @@ bool Zone::IsSpellBlocked(uint32 spell_id, const xyz_location& location)
return false;
}
const char* Zone::GetSpellBlockedMessage(uint32 spell_id, const xyz_location& location)
const char* Zone::GetSpellBlockedMessage(uint32 spell_id, const glm::vec3& location)
{
if(blocked_spells)
{
@ -2164,7 +2164,7 @@ void Zone::DoAdventureActions()
const NPCType* tmp = database.GetNPCType(ds->data_id);
if(tmp)
{
NPC* npc = new NPC(tmp, nullptr, xyz_heading(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), FlyMode3);
NPC* npc = new NPC(tmp, nullptr, glm::vec4(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), FlyMode3);
npc->AddLootTable();
entity_list.AddNPC(npc);
npc->Shout("Rarrrgh!");

View File

@ -100,9 +100,9 @@ public:
inline Timer* GetInstanceTimer() { return Instance_Timer; }
inline xyz_location GetSafePoint() { return m_SafePoint; }
inline glm::vec3 GetSafePoint() { return m_SafePoint; }
inline const uint32& graveyard_zoneid() { return pgraveyard_zoneid; }
inline xyz_heading GetGraveyardPoint() { return m_Graveyard; }
inline glm::vec4 GetGraveyardPoint() { return m_Graveyard; }
inline const uint32& graveyard_id() { return pgraveyard_id; }
inline const uint32& GetMaxClients() { return pMaxClients; }
@ -118,8 +118,8 @@ public:
void ReloadStaticData();
uint32 CountSpawn2();
ZonePoint* GetClosestZonePoint(const xyz_location& location, const char* to_name, Client *client, float max_distance = 40000.0f);
ZonePoint* GetClosestZonePoint(const xyz_location& location, uint32 to, Client *client, float max_distance = 40000.0f);
ZonePoint* GetClosestZonePoint(const glm::vec3& location, const char* to_name, Client *client, float max_distance = 40000.0f);
ZonePoint* GetClosestZonePoint(const glm::vec3& location, uint32 to, Client *client, float max_distance = 40000.0f);
ZonePoint* GetClosestZonePointWithoutZone(float x, float y, float z, Client *client, float max_distance = 40000.0f);
SpawnGroupList spawn_group_list;
@ -227,12 +227,12 @@ public:
uint8 lootvar;
bool HasGraveyard();
void SetGraveyard(uint32 zoneid, const xyz_heading& graveyardPosition);
void SetGraveyard(uint32 zoneid, const glm::vec4& graveyardPosition);
void LoadBlockedSpells(uint32 zoneid);
void ClearBlockedSpells();
bool IsSpellBlocked(uint32 spell_id, const xyz_location& location);
const char *GetSpellBlockedMessage(uint32 spell_id, const xyz_location& location);
bool IsSpellBlocked(uint32 spell_id, const glm::vec3& location);
const char *GetSpellBlockedMessage(uint32 spell_id, const glm::vec3& location);
int GetTotalBlockedSpells() { return totalBS; }
inline bool HasMap() { return zonemap != nullptr; }
inline bool HasWaterMap() { return watermap != nullptr; }
@ -270,7 +270,7 @@ private:
char* long_name;
char* map_name;
bool pvpzone;
xyz_location m_SafePoint;
glm::vec3 m_SafePoint;
uint32 pMaxClients;
bool can_bind;
bool is_city;
@ -281,7 +281,7 @@ private:
uint8 zone_type;
bool allow_mercs;
uint32 pgraveyard_id, pgraveyard_zoneid;
xyz_heading m_Graveyard;
glm::vec4 m_Graveyard;
int default_ruleset;
int totalBS;

View File

@ -1230,14 +1230,14 @@ bool ZoneDatabase::SaveCharacterLanguage(uint32 character_id, uint32 lang_id, ui
return true;
}
bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, const xyz_heading& position, uint8 is_home){
bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, const glm::vec4& position, uint8 is_home){
if (zone_id <= 0) {
return false;
}
/* Save Home Bind Point */
std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading, is_home);
" VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, position.x, position.y, position.z, position.w, is_home);
LogFile->write(EQEmuLog::Debug, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u position: %s ishome: %u", character_id, zone_id, instance_id, to_string(position).c_str(), is_home);
auto results = QueryDatabase(query);
if (!results.RowsAffected()) {
@ -2527,11 +2527,11 @@ void ZoneDatabase::DeleteMerchantTemp(uint32 npcid, uint32 slot){
}
bool ZoneDatabase::UpdateZoneSafeCoords(const char* zonename, const xyz_location& location) {
bool ZoneDatabase::UpdateZoneSafeCoords(const char* zonename, const glm::vec3& location) {
std::string query = StringFormat("UPDATE zone SET safe_x='%f', safe_y='%f', safe_z='%f' "
"WHERE short_name='%s';",
location.m_X, location.m_Y, location.m_Z, zonename);
location.x, location.y, location.z, zonename);
auto results = QueryDatabase(query);
if (!results.Success() || results.RowsAffected() == 0)
return false;
@ -2723,8 +2723,8 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked
memset(&into[index], 0, sizeof(ZoneSpellsBlocked));
into[index].spellid = atoi(row[1]);
into[index].type = atoi(row[2]);
into[index].m_Location = xyz_location(atof(row[3]), atof(row[4]), atof(row[5]));
into[index].m_Difference = xyz_location(atof(row[6]), atof(row[7]), atof(row[8]));
into[index].m_Location = glm::vec3(atof(row[3]), atof(row[4]), atof(row[5]));
into[index].m_Difference = glm::vec3(atof(row[6]), atof(row[7]), atof(row[8]));
strn0cpy(into[index].message, row[9], 255);
}
@ -2803,7 +2803,7 @@ void ZoneDatabase::QGlobalPurge()
database.QueryDatabase(query);
}
void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoor_name, const xyz_heading& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize){
void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoor_name, const glm::vec4& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize){
std::string query = StringFormat("REPLACE INTO doors (id, doorid, zone, version, name, "
"pos_x, pos_y, pos_z, heading, opentype, guild, lockpick, "
@ -2811,7 +2811,7 @@ void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoo
"VALUES('%i', '%i', '%s', '%i', '%s', '%f', '%f', "
"'%f', '%f', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i')",
ddoordbid, ddoorid, zone->GetShortName(), zone->GetInstanceVersion(),
ddoor_name, position.m_X, position.m_Y, position.m_Z, position.m_Heading,
ddoor_name, position.x, position.y, position.z, position.w,
dopentype, dguildid, dlockpick, dkeyitem, ddoor_param, dinvert, dincline, dsize);
auto results = QueryDatabase(query);
if (!results.Success())
@ -3398,23 +3398,23 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
return zone_id;
}
uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, const xyz_heading& position) {
uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, const glm::vec4& position) {
std::string query = StringFormat("INSERT INTO `graveyard` "
"SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f",
graveyard_zone_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading);
graveyard_zone_id, position.x, position.y, position.z, position.w);
auto results = QueryDatabase(query);
if (results.Success())
return results.LastInsertedID();
return 0;
}
uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, uint16 instance_id, const xyz_heading& position) {
uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, uint16 instance_id, const glm::vec4& position) {
std::string query = StringFormat("UPDATE `character_corpses` "
"SET `zone_id` = %u, `instance_id` = 0, "
"`x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f, "
"`was_at_graveyard` = 1 "
"WHERE `id` = %d",
zone_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading, dbid);
zone_id, position.x, position.y, position.z, position.w, dbid);
QueryDatabase(query);
return dbid;
}
@ -3429,7 +3429,7 @@ uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){
return 0;
}
uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const char* char_name, uint32 zone_id, uint16 instance_id, PlayerCorpse_Struct* dbpc, const xyz_heading& position, bool is_rezzed) {
uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const char* char_name, uint32 zone_id, uint16 instance_id, PlayerCorpse_Struct* dbpc, const glm::vec4& position, bool is_rezzed) {
std::string query = StringFormat("UPDATE `character_corpses` "
"SET `charname` = '%s', `zone_id` = %u, `instance_id` = %u, `charid` = %d, "
"`x` = %1.1f,`y` = %1.1f,`z` = %1.1f, `heading` = %1.1f, "
@ -3444,7 +3444,7 @@ uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const c
"`wc_7` = %u, `wc_8` = %u, `wc_9` = %u "
"WHERE `id` = %u",
EscapeString(char_name).c_str(), zone_id, instance_id, char_id,
position.m_X, position.m_Y, position.m_Z, position.m_Heading,
position.x, position.y, position.z, position.w,
dbpc->locked, dbpc->exp, dbpc->size, dbpc->level, dbpc->race,
dbpc->gender, dbpc->class_, dbpc->deity, dbpc->texture,
dbpc->helmtexture, dbpc->copper, dbpc->silver, dbpc->gold,
@ -3465,7 +3465,7 @@ void ZoneDatabase::MarkCorpseAsRezzed(uint32 db_id) {
auto results = QueryDatabase(query);
}
uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position) {
uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const glm::vec4& position) {
/* Dump Basic Corpse Data */
std::string query = StringFormat("INSERT INTO `character_corpses` "
"SET `charname` = '%s', `zone_id` = %u, `instance_id` = %u, `charid` = %d,"
@ -3481,7 +3481,7 @@ uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, ui
"`wc_3` = %u, `wc_4` = %u, `wc_5` = %u, `wc_6` = %u,"
"`wc_7` = %u,`wc_8` = %u,`wc_9` = %u",
EscapeString(charname).c_str(), zoneid, instanceid, charid,
position.m_X, position.m_Y, position.m_Z, position.m_Heading,
position.x, position.y, position.z, position.w,
dbpc->locked, dbpc->exp, dbpc->size, dbpc->level, dbpc->race,
dbpc->gender, dbpc->class_, dbpc->deity, dbpc->texture,
dbpc->helmtexture, dbpc->copper, dbpc->silver, dbpc->gold,
@ -3710,7 +3710,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct
return true;
}
Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, const xyz_heading& position) {
Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, const glm::vec4& position) {
Corpse* corpse = nullptr;
std::string query = StringFormat("SELECT `id`, `charname`, `time_of_death`, `is_rezzed` "
"FROM `character_corpses` "
@ -3742,13 +3742,13 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z
return corpse;
}
bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, const xyz_heading& position) {
bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, const glm::vec4& position) {
Corpse* corpse = nullptr;
int CorpseCount = 0;
std::string query = StringFormat(
"UPDATE character_corpses SET zone_id = %i, instance_id = %i, x = %f, y = %f, z = %f, heading = %f, is_buried = 0, was_at_graveyard = 0 WHERE charid = %i",
dest_zone_id, dest_instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading, char_id
dest_zone_id, dest_instance_id, position.x, position.y, position.z, position.w, char_id
);
auto results = QueryDatabase(query);
@ -3782,14 +3782,14 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id
return (CorpseCount > 0);
}
bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, const xyz_heading& position) {
bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, const glm::vec4& position) {
std::string query = StringFormat("UPDATE `character_corpses` "
"SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, "
"`x` = %f, `y` = %f, `z` = %f, `heading` = %f, "
"`time_of_death` = Now(), `was_at_graveyard` = 0 "
"WHERE `id` = %u",
new_zone_id, new_instance_id,
position.m_X, position.m_Y, position.m_Z, position.m_Heading, db_id);
position.x, position.y, position.z, position.w, db_id);
auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0)
return true;
@ -3805,7 +3805,7 @@ Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) {
);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
auto position = xyz_heading(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]));
auto position = glm::vec4(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]));
NewCorpse = Corpse::LoadCharacterCorpseEntity(
atoul(row[0]), // id uint32 in_dbid
atoul(row[1]), // charid uint32 in_charid
@ -3831,7 +3831,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
auto position = xyz_heading(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]));
auto position = glm::vec4(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]));
entity_list.AddCorpse(
Corpse::LoadCharacterCorpseEntity(
atoul(row[0]), // id uint32 in_dbid

View File

@ -130,8 +130,8 @@ struct PetInfo {
struct ZoneSpellsBlocked {
uint32 spellid;
int8 type;
xyz_location m_Location;
xyz_location m_Difference;
glm::vec3 m_Location;
glm::vec3 m_Difference;
char message[256];
};
@ -273,7 +273,7 @@ public:
bool LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp);
/* Character Data Saves */
bool SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, const xyz_heading& position, uint8 is_home);
bool SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, const glm::vec4& position, uint8 is_home);
bool SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp);
bool SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level);
@ -305,24 +305,24 @@ public:
uint32 GetCharacterCorpseItemCount(uint32 corpse_id);
bool LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct* pcs);
Corpse* LoadCharacterCorpse(uint32 player_corpse_id);
Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position);
Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
void MarkCorpseAsRezzed(uint32 dbid);
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
bool BuryCharacterCorpse(uint32 dbid);
bool BuryAllCharacterCorpses(uint32 charid);
bool DeleteCharacterCorpse(uint32 dbid);
bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position);
bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position);
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, const xyz_heading& position);
bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, const glm::vec4& position);
bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID);
bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id);
uint32 GetCharacterBuriedCorpseCount(uint32 char_id);
uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const xyz_heading& position);
uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, const xyz_heading& position);
uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const glm::vec4& position);
uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, const glm::vec4& position);
uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id);
uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position);
uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position, bool rezzed = false);
uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const glm::vec4& position);
uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const glm::vec4& position, bool rezzed = false);
uint32 GetFirstCorpseID(uint32 char_id);
uint32 GetCharacterCorpseCount(uint32 char_id);
uint32 GetCharacterCorpseID(uint32 char_id, uint8 corpse);
@ -353,7 +353,7 @@ public:
bool GetZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct *data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city, bool &is_hotzone, bool &allow_mercs, uint8 &zone_type, int &ruleset, char **map_filename);
bool SaveZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct* zd);
bool LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,const char* zonename, uint32 version);
bool UpdateZoneSafeCoords(const char* zonename, const xyz_location& location);
bool UpdateZoneSafeCoords(const char* zonename, const glm::vec3& location);
uint8 GetUseCFGSafeCoords();
int getZoneShutDownDelay(uint32 zoneID, uint32 version);
@ -362,7 +362,7 @@ public:
bool LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list);
bool PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version, uint32 repopdelay = 0);
Spawn2* LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2id, uint32 timeleft);
bool CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, const xyz_heading& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value);
bool CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value);
void UpdateSpawn2Timeleft(uint32 id, uint16 instance_id,uint32 timeleft);
uint32 GetSpawnTimeLeft(uint32 id, uint16 instance_id);
void UpdateSpawn2Status(uint32 id, uint8 new_status);
@ -371,14 +371,14 @@ public:
uint32 GetFreeGrid(uint16 zoneid);
void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too, uint16 zoneid);
void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid);
void AddWP(Client *c, uint32 gridid, uint32 wpnum, const xyz_heading& position, uint32 pause, uint16 zoneid);
uint32 AddWPForSpawn(Client *c, uint32 spawn2id, const xyz_heading& position, uint32 pause, int type1, int type2, uint16 zoneid);
void AddWP(Client *c, uint32 gridid, uint32 wpnum, const glm::vec4& position, uint32 pause, uint16 zoneid);
uint32 AddWPForSpawn(Client *c, uint32 spawn2id, const glm::vec4& position, uint32 pause, int type1, int type2, uint16 zoneid);
void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0);
void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, const xyz_location& location, uint32 script = 0, uint16 zoneid = 0);
void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, const glm::vec3& location, uint32 script = 0, uint16 zoneid = 0);
uint8 GetGridType(uint32 grid, uint32 zoneid);
uint8 GetGridType2(uint32 grid, uint16 zoneid);
bool GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp);
void AssignGrid(Client *client, const xy_location& location, uint32 id);
void AssignGrid(Client *client, const glm::vec2& location, uint32 id);
int GetHighestGrid(uint32 zoneid);
int GetHighestWaypoint(uint32 zoneid, uint32 gridid);
@ -450,7 +450,7 @@ public:
int32 GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version);
int32 GetDoorsCountPlusOne(const char *zone_name, int16 version);
int32 GetDoorsDBCountPlusOne(const char *zone_name, int16 version);
void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, const xyz_heading& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize);
void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, const glm::vec4& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize);
/* Blocked Spells */
int32 GetBlockedSpellsCount(uint32 zoneid);

View File

@ -124,7 +124,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
return;
}
zone_point = zone->GetClosestZonePoint(GetPosition(), target_zone_id, this, ZONEPOINT_ZONE_RANGE);
zone_point = zone->GetClosestZonePoint(glm::vec3(GetPosition()), target_zone_id, this, ZONEPOINT_ZONE_RANGE);
//if we didnt get a zone point, or its to a different zone,
//then we assume this is invalid.
if(!zone_point || zone_point->target_zone_id != target_zone_id) {
@ -198,9 +198,9 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
dest_z = safe_z;
break;
case GMSummon:
dest_x = m_ZoneSummonLocation.m_X;
dest_y = m_ZoneSummonLocation.m_Y;
dest_z = m_ZoneSummonLocation.m_Z;
dest_x = m_ZoneSummonLocation.x;
dest_y = m_ZoneSummonLocation.y;
dest_z = m_ZoneSummonLocation.z;
ignorerestrictions = 1;
break;
case GateToBindPoint:
@ -216,9 +216,9 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
break;
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
//recycle zonesummon variables
dest_x = m_ZoneSummonLocation.m_X;
dest_y = m_ZoneSummonLocation.m_Y;
dest_z = m_ZoneSummonLocation.m_Z;
dest_x = m_ZoneSummonLocation.x;
dest_y = m_ZoneSummonLocation.y;
dest_z = m_ZoneSummonLocation.z;
break;
case ZoneUnsolicited: //client came up with this on its own.
//client requested a zoning... what are the cases when this could happen?
@ -350,10 +350,10 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
//set the player's coordinates in the new zone so they have them
//when they zone into it
m_Position.m_X = dest_x; //these coordinates will now be saved when ~client is called
m_Position.m_Y = dest_y;
m_Position.m_Z = dest_z;
m_Position.m_Heading = dest_h; // Cripp: fix for zone heading
m_Position.x = dest_x; //these coordinates will now be saved when ~client is called
m_Position.y = dest_y;
m_Position.z = dest_z;
m_Position.w = dest_h; // Cripp: fix for zone heading
m_pp.heading = dest_h;
m_pp.zone_id = zone_id;
m_pp.zoneInstance = instance_id;
@ -394,7 +394,7 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
//reset to unsolicited.
zone_mode = ZoneUnsolicited;
m_ZoneSummonLocation = xyz_location::Origin();
m_ZoneSummonLocation = glm::vec3();
zonesummon_id = 0;
zonesummon_ignorerestrictions = 0;
}
@ -491,53 +491,56 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
return;
}
iZoneNameLength = strlen(pZoneName);
xyz_heading safePoint;
glm::vec3 safePoint;
switch(zm) {
case EvacToSafeCoords:
case ZoneToSafeCoords:
safePoint = zone->GetSafePoint();
x = safePoint.m_X;
y = safePoint.m_Y;
z = safePoint.m_Z;
safePoint = zone->GetSafePoint();
x = safePoint.x;
y = safePoint.y;
z = safePoint.z;
SetHeading(heading);
break;
case GMSummon:
m_ZoneSummonLocation = m_Position = xyz_heading(x,y,z,heading);
m_Position = glm::vec4(x, y, z, heading);
m_ZoneSummonLocation = glm::vec3(m_Position);
SetHeading(heading);
zonesummon_id = zoneID;
zonesummon_ignorerestrictions = 1;
break;
case ZoneSolicited:
m_ZoneSummonLocation = xyz_location(x,y,z);
m_ZoneSummonLocation = glm::vec3(x,y,z);
SetHeading(heading);
zonesummon_id = zoneID;
zonesummon_ignorerestrictions = ignorerestrictions;
break;
case GateToBindPoint:
x = m_Position.m_X = m_pp.binds[0].x;
y = m_Position.m_Y = m_pp.binds[0].y;
z = m_Position.m_Z = m_pp.binds[0].z;
x = m_Position.x = m_pp.binds[0].x;
y = m_Position.y = m_pp.binds[0].y;
z = m_Position.z = m_pp.binds[0].z;
heading = m_pp.binds[0].heading;
break;
case ZoneToBindPoint:
x = m_Position.m_X = m_pp.binds[0].x;
y = m_Position.m_Y = m_pp.binds[0].y;
z = m_Position.m_Z = m_pp.binds[0].z;
x = m_Position.x = m_pp.binds[0].x;
y = m_Position.y = m_pp.binds[0].y;
z = m_Position.z = m_pp.binds[0].z;
heading = m_pp.binds[0].heading;
zonesummon_ignorerestrictions = 1;
LogFile->write(EQEmuLog::Debug, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading);
break;
case SummonPC:
m_ZoneSummonLocation = m_Position = xyz_location(x, y, z);
m_ZoneSummonLocation = glm::vec3(x, y, z);
m_Position = glm::vec4(m_ZoneSummonLocation, 0.0f);
SetHeading(heading);
break;
case Rewind:
LogFile->write(EQEmuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_RewindLocation.m_X, m_RewindLocation.m_Y, m_RewindLocation.m_Z, zone->GetShortName());
m_ZoneSummonLocation = m_Position = xyz_location(x, y, z);
LogFile->write(EQEmuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.x, m_Position.y, m_Position.z, m_RewindLocation.x, m_RewindLocation.y, m_RewindLocation.z, zone->GetShortName());
m_ZoneSummonLocation = glm::vec3(x, y, z);
m_Position = glm::vec4(m_ZoneSummonLocation, 0.0f);
SetHeading(heading);
break;
default:
@ -647,8 +650,8 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
else {
if(zoneID == GetZoneID()) {
//properly handle proximities
entity_list.ProcessMove(this, m_Position);
m_Proximity = m_Position;
entity_list.ProcessMove(this, glm::vec3(m_Position));
m_Proximity = glm::vec3(m_Position);
//send out updates to people in zone.
SendPosition();
@ -677,7 +680,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
{
if(zm != EvacToSafeCoords && zm != ZoneToSafeCoords && zm != ZoneToBindPoint)
{
m_ZoneSummonLocation = xyz_location::Origin();
m_ZoneSummonLocation = glm::vec3();
zonesummon_id = 0;
zonesummon_ignorerestrictions = 0;
zone_mode = ZoneUnsolicited;
@ -710,22 +713,22 @@ void NPC::Gate() {
Mob::Gate();
}
void Client::SetBindPoint(int to_zone, int to_instance, const xyz_location& location) {
void Client::SetBindPoint(int to_zone, int to_instance, const glm::vec3& location) {
if (to_zone == -1) {
m_pp.binds[0].zoneId = zone->GetZoneID();
m_pp.binds[0].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0;
m_pp.binds[0].x = m_Position.m_X;
m_pp.binds[0].y = m_Position.m_Y;
m_pp.binds[0].z = m_Position.m_Z;
m_pp.binds[0].x = m_Position.x;
m_pp.binds[0].y = m_Position.y;
m_pp.binds[0].z = m_Position.z;
}
else {
m_pp.binds[0].zoneId = to_zone;
m_pp.binds[0].instance_id = to_instance;
m_pp.binds[0].x = location.m_X;
m_pp.binds[0].y = location.m_Y;
m_pp.binds[0].z = location.m_Z;
m_pp.binds[0].x = location.x;
m_pp.binds[0].y = location.y;
m_pp.binds[0].z = location.z;
}
auto regularBindPoint = xyz_heading(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f);
auto regularBindPoint = glm::vec4(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f);
database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, regularBindPoint, 0);
}
@ -778,12 +781,12 @@ void Client::LoadZoneFlags() {
// Retrieve all waypoints for this grid
std::string query = StringFormat("SELECT zoneID from zone_flags WHERE charID=%d", CharacterID());
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str());
return;
}
if (!results.Success()) {
LogFile->write(EQEmuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str());
return;
}
for(auto row = results.begin(); row != results.end(); ++row)
for(auto row = results.begin(); row != results.end(); ++row)
zone_flags.insert(atoi(row[0]));
}