mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 17:26:30 +00:00
Merge branch 'master' into nats
Conflicts: zone/loottables.cpp
This commit is contained in:
@@ -68,6 +68,7 @@ SET(zone_sources
|
||||
exp.cpp
|
||||
fearpath.cpp
|
||||
forage.cpp
|
||||
global_loot_manager.cpp
|
||||
groups.cpp
|
||||
guild.cpp
|
||||
guild_mgr.cpp
|
||||
@@ -159,6 +160,7 @@ SET(zone_headers
|
||||
errmsg.h
|
||||
event_codes.h
|
||||
forage.h
|
||||
global_loot_manager.h
|
||||
groups.h
|
||||
guild_mgr.h
|
||||
hate_list.h
|
||||
|
||||
+10
-4
@@ -360,7 +360,7 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit)
|
||||
Mob *attacker = other;
|
||||
Mob *defender = this;
|
||||
|
||||
bool InFront = attacker->InFrontMob(this, attacker->GetX(), attacker->GetY());
|
||||
bool InFront = !attacker->BehindMob(this, attacker->GetX(), attacker->GetY());
|
||||
|
||||
/*
|
||||
This special ability adds a negative modifer to the defenders riposte/block/parry/chance
|
||||
@@ -3614,13 +3614,13 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const
|
||||
a->special = 2;
|
||||
else
|
||||
a->special = 0;
|
||||
a->meleepush_xy = attacker ? attacker->GetHeading() * 2.0f : 0.0f;
|
||||
a->meleepush_xy = attacker ? attacker->GetHeading() : 0.0f;
|
||||
if (RuleB(Combat, MeleePush) && damage > 0 && !IsRooted() &&
|
||||
(IsClient() || zone->random.Roll(RuleI(Combat, MeleePushChance)))) {
|
||||
a->force = EQEmu::skills::GetSkillMeleePushForce(skill_used);
|
||||
// update NPC stuff
|
||||
auto new_pos = glm::vec3(m_Position.x + (a->force * std::sin(a->meleepush_xy) + m_Delta.x),
|
||||
m_Position.y + (a->force * std::cos(a->meleepush_xy) + m_Delta.y), m_Position.z);
|
||||
auto new_pos = glm::vec3(m_Position.x + (a->force * std::cos(a->meleepush_xy) + m_Delta.x),
|
||||
m_Position.y + (a->force * std::sin(a->meleepush_xy) + m_Delta.y), m_Position.z);
|
||||
if (zone->zonemap && zone->zonemap->CheckLoS(glm::vec3(m_Position), new_pos)) { // If we have LoS on the new loc it should be reachable.
|
||||
if (IsNPC()) {
|
||||
// Is this adequate?
|
||||
@@ -4448,6 +4448,12 @@ void Mob::DoRiposte(Mob *defender)
|
||||
if (!defender)
|
||||
return;
|
||||
|
||||
// so ahhh the angle you can riposte is larger than the angle you can hit :P
|
||||
if (!defender->IsFacingMob(this)) {
|
||||
defender->Message_StringID(MT_TooFarAway, CANT_SEE_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
defender->Attack(this, EQEmu::inventory::slotPrimary, true);
|
||||
if (HasDied())
|
||||
return;
|
||||
|
||||
+8
-6
@@ -336,6 +336,8 @@ Client::Client(EQStreamInterface* ieqs)
|
||||
for (int i = 0; i < InnateSkillMax; ++i)
|
||||
m_pp.InnateSkills[i] = InnateDisabled;
|
||||
|
||||
temp_pvp = false;
|
||||
|
||||
AI_Init();
|
||||
}
|
||||
|
||||
@@ -462,8 +464,8 @@ void Client::SendZoneInPackets()
|
||||
if (!GetHideMe()) entity_list.QueueClients(this, outapp, true);
|
||||
safe_delete(outapp);
|
||||
SetSpawned();
|
||||
if (GetPVP()) //force a PVP update until we fix the spawn struct
|
||||
SendAppearancePacket(AT_PVP, GetPVP(), true, false);
|
||||
if (GetPVP(false)) //force a PVP update until we fix the spawn struct
|
||||
SendAppearancePacket(AT_PVP, GetPVP(false), true, false);
|
||||
|
||||
//Send AA Exp packet:
|
||||
if (GetLevel() >= 51)
|
||||
@@ -1955,7 +1957,7 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
||||
ns->spawn.gm = GetGM() ? 1 : 0;
|
||||
ns->spawn.guildID = GuildID();
|
||||
// ns->spawn.linkdead = IsLD() ? 1 : 0;
|
||||
// ns->spawn.pvp = GetPVP() ? 1 : 0;
|
||||
// ns->spawn.pvp = GetPVP(false) ? 1 : 0;
|
||||
ns->spawn.show_name = true;
|
||||
|
||||
|
||||
@@ -8889,9 +8891,9 @@ void Client::CheckRegionTypeChanges()
|
||||
return;
|
||||
|
||||
if (last_region_type == RegionTypePVP)
|
||||
SetPVP(true, false);
|
||||
else if (GetPVP())
|
||||
SetPVP(false, false);
|
||||
temp_pvp = true;
|
||||
else if (temp_pvp)
|
||||
temp_pvp = false;
|
||||
}
|
||||
|
||||
void Client::ProcessAggroMeter()
|
||||
|
||||
+2
-1
@@ -395,7 +395,7 @@ public:
|
||||
void SetGM(bool toggle);
|
||||
void SetPVP(bool toggle, bool message = true);
|
||||
|
||||
inline bool GetPVP() const { return m_pp.pvp != 0; }
|
||||
inline bool GetPVP(bool inc_temp = true) const { return m_pp.pvp != 0 || (inc_temp && temp_pvp); }
|
||||
inline bool GetGM() const { return m_pp.gm != 0; }
|
||||
|
||||
inline void SetBaseClass(uint32 i) { m_pp.class_=i; }
|
||||
@@ -1466,6 +1466,7 @@ private:
|
||||
PetInfo m_suspendedminion; // pet data for our suspended minion.
|
||||
MercInfo m_mercinfo[MAXMERCS]; // current mercenary
|
||||
InspectMessage_Struct m_inspect_message;
|
||||
bool temp_pvp;
|
||||
|
||||
void NPCSpawn(const Seperator* sep);
|
||||
uint32 GetEXPForLevel(uint16 level);
|
||||
|
||||
@@ -4408,7 +4408,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading);
|
||||
auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading));
|
||||
boat->SetDelta(boat_delta);
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
@@ -4418,7 +4418,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
|
||||
safe_delete(outapp);
|
||||
|
||||
/* Update the boat's position on the server, without sending an update */
|
||||
boat->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ19toFloat(ppu->heading), false);
|
||||
boat->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading), false);
|
||||
return;
|
||||
}
|
||||
else return;
|
||||
@@ -4563,7 +4563,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
/* Update internal state */
|
||||
m_Delta = glm::vec4(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, EQ10toFloat(ppu->delta_heading));
|
||||
|
||||
if (IsTracking() && ((m_Position.x != ppu->x_pos) || (m_Position.y != ppu->y_pos))) {
|
||||
if (zone->random.Real(0, 100) < 70)//should be good
|
||||
@@ -4616,7 +4616,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
|
||||
}
|
||||
}
|
||||
|
||||
float new_heading = EQ19toFloat(ppu->heading);
|
||||
float new_heading = EQ12toFloat(ppu->heading);
|
||||
int32 new_animation = ppu->animation;
|
||||
|
||||
/* Update internal server position from what the client has sent */
|
||||
@@ -4635,7 +4635,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
|
||||
if (is_client_moving || new_heading != m_Position.w || new_animation != animation) {
|
||||
|
||||
animation = ppu->animation;
|
||||
m_Position.w = EQ19toFloat(ppu->heading);
|
||||
m_Position.w = EQ12toFloat(ppu->heading);
|
||||
|
||||
/* Broadcast update to other clients */
|
||||
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
|
||||
+20
-37
@@ -1962,57 +1962,40 @@ void Client::CalcRestState() {
|
||||
|
||||
void Client::DoTracking()
|
||||
{
|
||||
if(TrackingID == 0)
|
||||
if (TrackingID == 0)
|
||||
return;
|
||||
|
||||
Mob *m = entity_list.GetMob(TrackingID);
|
||||
|
||||
if(!m || m->IsCorpse())
|
||||
{
|
||||
if (!m || m->IsCorpse()) {
|
||||
Message_StringID(MT_Skills, TRACK_LOST_TARGET);
|
||||
|
||||
TrackingID = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
float RelativeHeading = GetHeading() - CalculateHeadingToTarget(m->GetX(), m->GetY());
|
||||
|
||||
if(RelativeHeading < 0)
|
||||
RelativeHeading += 256;
|
||||
if (RelativeHeading < 0)
|
||||
RelativeHeading += 512;
|
||||
|
||||
if((RelativeHeading <= 16) || (RelativeHeading >= 240))
|
||||
{
|
||||
if (RelativeHeading > 480)
|
||||
Message_StringID(MT_Skills, TRACK_STRAIGHT_AHEAD, m->GetCleanName());
|
||||
}
|
||||
else if((RelativeHeading > 16) && (RelativeHeading <= 48))
|
||||
{
|
||||
Message_StringID(MT_Skills, TRACK_AHEAD_AND_TO, m->GetCleanName(), "right");
|
||||
}
|
||||
else if((RelativeHeading > 48) && (RelativeHeading <= 80))
|
||||
{
|
||||
Message_StringID(MT_Skills, TRACK_TO_THE, m->GetCleanName(), "right");
|
||||
}
|
||||
else if((RelativeHeading > 80) && (RelativeHeading <= 112))
|
||||
{
|
||||
Message_StringID(MT_Skills, TRACK_BEHIND_AND_TO, m->GetCleanName(), "right");
|
||||
}
|
||||
else if((RelativeHeading > 112) && (RelativeHeading <= 144))
|
||||
{
|
||||
Message_StringID(MT_Skills, TRACK_BEHIND_YOU, m->GetCleanName());
|
||||
}
|
||||
else if((RelativeHeading > 144) && (RelativeHeading <= 176))
|
||||
{
|
||||
Message_StringID(MT_Skills, TRACK_BEHIND_AND_TO, m->GetCleanName(), "left");
|
||||
}
|
||||
else if((RelativeHeading > 176) && (RelativeHeading <= 208))
|
||||
{
|
||||
Message_StringID(MT_Skills, TRACK_TO_THE, m->GetCleanName(), "left");
|
||||
}
|
||||
else if((RelativeHeading > 208) && (RelativeHeading < 240))
|
||||
{
|
||||
else if (RelativeHeading > 416)
|
||||
Message_StringID(MT_Skills, TRACK_AHEAD_AND_TO, m->GetCleanName(), "left");
|
||||
}
|
||||
else if (RelativeHeading > 352)
|
||||
Message_StringID(MT_Skills, TRACK_TO_THE, m->GetCleanName(), "left");
|
||||
else if (RelativeHeading > 288)
|
||||
Message_StringID(MT_Skills, TRACK_BEHIND_AND_TO, m->GetCleanName(), "left");
|
||||
else if (RelativeHeading > 224)
|
||||
Message_StringID(MT_Skills, TRACK_BEHIND_YOU, m->GetCleanName());
|
||||
else if (RelativeHeading > 160)
|
||||
Message_StringID(MT_Skills, TRACK_BEHIND_AND_TO, m->GetCleanName(), "right");
|
||||
else if (RelativeHeading > 96)
|
||||
Message_StringID(MT_Skills, TRACK_TO_THE, m->GetCleanName(), "right");
|
||||
else if (RelativeHeading > 32)
|
||||
Message_StringID(MT_Skills, TRACK_AHEAD_AND_TO, m->GetCleanName(), "right");
|
||||
else if (RelativeHeading >= 0)
|
||||
Message_StringID(MT_Skills, TRACK_STRAIGHT_AHEAD, m->GetCleanName());
|
||||
}
|
||||
|
||||
void Client::HandleRespawnFromHover(uint32 Option)
|
||||
|
||||
+33
-12
@@ -360,9 +360,11 @@ int command_init(void)
|
||||
command_add("showbonusstats", "[item|spell|all] Shows bonus stats for target from items or spells. Shows both by default.", 50, command_showbonusstats) ||
|
||||
command_add("showbuffs", "- List buffs active on your target or you if no target", 50, command_showbuffs) ||
|
||||
command_add("shownumhits", "Shows buffs numhits for yourself.", 0, command_shownumhits) ||
|
||||
command_add("shownpcgloballoot", "Show GlobalLoot entires on this npc", 50, command_shownpcgloballoot) ||
|
||||
command_add("showskills", "- Show the values of your or your player target's skills", 50, command_showskills) ||
|
||||
command_add("showspellslist", "Shows spell list of targeted NPC", 100, command_showspellslist) ||
|
||||
command_add("showstats", "- Show details about you or your target", 50, command_showstats) ||
|
||||
command_add("showzonegloballoot", "Show GlobalLoot entires on this zone", 50, command_showzonegloballoot) ||
|
||||
command_add("shutdown", "- Shut this zone process down", 150, command_shutdown) ||
|
||||
command_add("size", "[size] - Change size of you or your target", 50, command_size) ||
|
||||
command_add("spawn", "[name] [race] [level] [material] [hp] [gender] [class] [priweapon] [secweapon] [merchantid] - Spawn an NPC", 10, command_spawn) ||
|
||||
@@ -2462,7 +2464,9 @@ void command_npctypespawn(Client *c, const Seperator *sep)
|
||||
if (npc && sep->IsNumber(2))
|
||||
npc->SetNPCFactionID(atoi(sep->arg[2]));
|
||||
|
||||
npc->AddLootTable();
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(npc);
|
||||
}
|
||||
else
|
||||
@@ -3861,6 +3865,12 @@ void command_showstats(Client *c, const Seperator *sep)
|
||||
c->ShowStats(c);
|
||||
}
|
||||
|
||||
void command_showzonegloballoot(Client *c, const Seperator *sep)
|
||||
{
|
||||
c->Message(0, "GlobalLoot for %s (%d:%d)", zone->GetShortName(), zone->GetZoneID(), zone->GetInstanceVersion());
|
||||
zone->ShowZoneGlobalLoot(c);
|
||||
}
|
||||
|
||||
void command_mystats(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (c->GetTarget() && c->GetPet()) {
|
||||
@@ -8753,7 +8763,7 @@ void command_object(Client *c, const Seperator *sep)
|
||||
od.x = c->GetX();
|
||||
od.y = c->GetY();
|
||||
od.z = c->GetZ() - (c->GetSize() * 0.625f);
|
||||
od.heading = c->GetHeading() * 2.0f; // GetHeading() is half of actual. Compensate by doubling.
|
||||
od.heading = c->GetHeading();
|
||||
|
||||
std::string query;
|
||||
if (id) {
|
||||
@@ -8858,11 +8868,9 @@ void command_object(Client *c, const Seperator *sep)
|
||||
|
||||
// Bump player back to avoid getting stuck inside new object
|
||||
|
||||
// GetHeading() returns half of the actual heading, for some reason, so we'll double it here for
|
||||
// computation
|
||||
x2 = 10.0f * sin(c->GetHeading() * 2.0f / 256.0f * 3.14159265f);
|
||||
y2 = 10.0f * cos(c->GetHeading() * 2.0f / 256.0f * 3.14159265f);
|
||||
c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading() * 2);
|
||||
x2 = 10.0f * sin(c->GetHeading() / 256.0f * 3.14159265f);
|
||||
y2 = 10.0f * cos(c->GetHeading() / 256.0f * 3.14159265f);
|
||||
c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading());
|
||||
|
||||
c->Message(0, "Spawning object with tentative id %u at location (%.1f, %.1f, %.1f heading %.1f). Use "
|
||||
"'#object Save' to save to database when satisfied with placement.",
|
||||
@@ -9180,14 +9188,13 @@ void command_object(Client *c, const Seperator *sep)
|
||||
(c->GetSize() *
|
||||
0.625f); // Compensate for #loc bumping up Z coordinate by 62.5% of character's size.
|
||||
|
||||
o->SetHeading(c->GetHeading() * 2.0f); // Compensate for GetHeading() returning half of actual
|
||||
o->SetHeading(c->GetHeading());
|
||||
|
||||
// Bump player back to avoid getting stuck inside object
|
||||
|
||||
// GetHeading() returns half of the actual heading, for some reason
|
||||
x2 = 10.0f * sin(c->GetHeading() * 2.0f / 256.0f * 3.14159265f);
|
||||
y2 = 10.0f * cos(c->GetHeading() * 2.0f / 256.0f * 3.14159265f);
|
||||
c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading() * 2.0f);
|
||||
x2 = 10.0f * std::sin(c->GetHeading() / 256.0f * 3.14159265f);
|
||||
y2 = 10.0f * std::cos(c->GetHeading() / 256.0f * 3.14159265f);
|
||||
c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading());
|
||||
} // Move to x, y, z [h]
|
||||
else {
|
||||
od.x = atof(sep->arg[3]);
|
||||
@@ -10445,6 +10452,20 @@ void command_shownumhits(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
void command_shownpcgloballoot(Client *c, const Seperator *sep)
|
||||
{
|
||||
auto tar = c->GetTarget();
|
||||
|
||||
if (!tar || !tar->IsNPC()) {
|
||||
c->Message(0, "You must target an NPC to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto npc = tar->CastToNPC();
|
||||
c->Message(0, "GlobalLoot for %s (%d)", npc->GetName(), npc->GetNPCTypeID());
|
||||
zone->ShowNPCGlobalLoot(c, npc);
|
||||
}
|
||||
|
||||
void command_tune(Client *c, const Seperator *sep)
|
||||
{
|
||||
//Work in progress - Kayen
|
||||
|
||||
@@ -267,10 +267,12 @@ void command_setxp(Client *c, const Seperator *sep);
|
||||
void command_showbonusstats(Client *c, const Seperator *sep);
|
||||
void command_showbuffs(Client *c, const Seperator *sep);
|
||||
void command_shownumhits(Client *c, const Seperator *sep);
|
||||
void command_shownpcgloballoot(Client *c, const Seperator *sep);
|
||||
void command_showpetspell(Client *c, const Seperator *sep);
|
||||
void command_showskills(Client *c, const Seperator *sep);
|
||||
void command_showspellslist(Client *c, const Seperator *sep);
|
||||
void command_showstats(Client *c, const Seperator *sep);
|
||||
void command_showzonegloballoot(Client *c, const Seperator *sep);
|
||||
void command_shutdown(Client *c, const Seperator *sep);
|
||||
void command_size(Client *c, const Seperator *sep);
|
||||
void command_spawn(Client *c, const Seperator *sep);
|
||||
|
||||
+14
-11
@@ -277,20 +277,23 @@ void Client::GoFish()
|
||||
food_id = database.GetZoneFishing(m_pp.zone_id, fishing_skill, npc_id, npc_chance);
|
||||
|
||||
//check for add NPC
|
||||
if(npc_chance > 0 && npc_id) {
|
||||
if(npc_chance < zone->random.Int(0, 99)) {
|
||||
const NPCType* tmp = database.LoadNPCTypesData(npc_id);
|
||||
if(tmp != nullptr) {
|
||||
auto positionNPC = GetPosition();
|
||||
positionNPC.x = positionNPC.x + 3;
|
||||
auto npc = new NPC(tmp, nullptr, positionNPC, FlyMode3);
|
||||
npc->AddLootTable();
|
||||
if (npc_chance > 0 && npc_id) {
|
||||
if (npc_chance < zone->random.Int(0, 99)) {
|
||||
const NPCType *tmp = database.LoadNPCTypesData(npc_id);
|
||||
if (tmp != nullptr) {
|
||||
auto positionNPC = GetPosition();
|
||||
positionNPC.x = positionNPC.x + 3;
|
||||
auto npc = new NPC(tmp, nullptr, positionNPC, FlyMode3);
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
|
||||
npc->AddToHateList(this, 1, 0, false); // no help yelling
|
||||
npc->AddToHateList(this, 1, 0, false); // no help yelling
|
||||
|
||||
entity_list.AddNPC(npc);
|
||||
entity_list.AddNPC(npc);
|
||||
|
||||
Message(MT_Emote, "You fish up a little more than you bargained for...");
|
||||
Message(MT_Emote,
|
||||
"You fish up a little more than you bargained for...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "global_loot_manager.h"
|
||||
#include "npc.h"
|
||||
#include "client.h"
|
||||
|
||||
std::vector<int> GlobalLootManager::GetGlobalLootTables(NPC *mob) const
|
||||
{
|
||||
// we may be able to add a cache here if performance is an issue, but for now
|
||||
// just return NRVO'd vector
|
||||
// The cache would have to be keyed by NPCType and level (for NPCs with Max Level set)
|
||||
std::vector<int> tables;
|
||||
|
||||
for (auto &e : m_entries) {
|
||||
if (e.PassesRules(mob)) {
|
||||
tables.push_back(e.GetLootTableID());
|
||||
}
|
||||
}
|
||||
|
||||
return tables;
|
||||
}
|
||||
|
||||
void GlobalLootManager::ShowZoneGlobalLoot(Client *to) const
|
||||
{
|
||||
for (auto &e : m_entries)
|
||||
to->Message(0, " %s : %d table %d", e.GetDescription().c_str(), e.GetID(), e.GetLootTableID());
|
||||
}
|
||||
|
||||
void GlobalLootManager::ShowNPCGlobalLoot(Client *to, NPC *who) const
|
||||
{
|
||||
for (auto &e : m_entries) {
|
||||
if (e.PassesRules(who))
|
||||
to->Message(0, " %s : %d table %d", e.GetDescription().c_str(), e.GetID(), e.GetLootTableID());
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalLootEntry::PassesRules(NPC *mob) const
|
||||
{
|
||||
bool bRace = false;
|
||||
bool bPassesRace = false;
|
||||
bool bBodyType = false;
|
||||
bool bPassesBodyType = false;
|
||||
bool bClass = false;
|
||||
bool bPassesClass = false;
|
||||
|
||||
for (auto &r : m_rules) {
|
||||
switch (r.type) {
|
||||
case GlobalLoot::RuleTypes::LevelMin:
|
||||
if (mob->GetLevel() < r.value)
|
||||
return false;
|
||||
break;
|
||||
case GlobalLoot::RuleTypes::LevelMax:
|
||||
if (mob->GetLevel() > r.value)
|
||||
return false;
|
||||
break;
|
||||
case GlobalLoot::RuleTypes::Raid: // value == 0 must not be raid, value != 0 must be raid
|
||||
if (mob->IsRaidTarget() && !r.value)
|
||||
return false;
|
||||
if (!mob->IsRaidTarget() && r.value)
|
||||
return false;
|
||||
break;
|
||||
case GlobalLoot::RuleTypes::Rare:
|
||||
if (mob->IsRareSpawn() && !r.value)
|
||||
return false;
|
||||
if (!mob->IsRareSpawn() && r.value)
|
||||
return false;
|
||||
break;
|
||||
case GlobalLoot::RuleTypes::Race: // can have multiple races per rule set
|
||||
bRace = true; // we must pass race
|
||||
if (mob->GetRace() == r.value)
|
||||
bPassesRace = true;
|
||||
break;
|
||||
case GlobalLoot::RuleTypes::Class: // can have multiple classes per rule set
|
||||
bClass = true; // we must pass class
|
||||
if (mob->GetClass() == r.value)
|
||||
bPassesClass = true;
|
||||
break;
|
||||
case GlobalLoot::RuleTypes::BodyType: // can have multiple bodytypes per rule set
|
||||
bBodyType = true; // we must pass BodyType
|
||||
if (mob->GetBodyType() == r.value)
|
||||
bPassesBodyType = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bRace && !bPassesRace)
|
||||
return false;
|
||||
|
||||
if (bClass && !bPassesClass)
|
||||
return false;
|
||||
|
||||
if (bBodyType && !bPassesBodyType)
|
||||
return false;
|
||||
|
||||
// we abort as early as possible if we fail a rule, so if we get here, we passed
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef GLOBAL_LOOT_MANAGER_H
|
||||
#define GLOBAL_LOOT_MANAGER_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class NPC;
|
||||
class Client;
|
||||
|
||||
namespace GlobalLoot {
|
||||
|
||||
enum class RuleTypes {
|
||||
LevelMin = 0,
|
||||
LevelMax = 1,
|
||||
Race = 2,
|
||||
Class = 3,
|
||||
BodyType = 4,
|
||||
Rare = 5,
|
||||
Raid = 6,
|
||||
Max
|
||||
};
|
||||
|
||||
struct Rule {
|
||||
RuleTypes type;
|
||||
int value;
|
||||
Rule(RuleTypes t, int v) : type(t), value(v) { }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
class GlobalLootEntry {
|
||||
int m_id;
|
||||
int m_loottable_id;
|
||||
std::string m_description;
|
||||
std::vector<GlobalLoot::Rule> m_rules;
|
||||
public:
|
||||
GlobalLootEntry(int id, int loottable, std::string des)
|
||||
: m_id(id), m_loottable_id(loottable), m_description(std::move(des))
|
||||
{ }
|
||||
bool PassesRules(NPC *mob) const;
|
||||
inline int GetLootTableID() const { return m_loottable_id; }
|
||||
inline int GetID() const { return m_id; }
|
||||
inline const std::string &GetDescription() const { return m_description; }
|
||||
inline void SetLootTableID(int in) { m_loottable_id = in; }
|
||||
inline void SetID(int in) { m_id = in; }
|
||||
inline void SetDescription(const std::string &in) { m_description = in; }
|
||||
inline void AddRule(GlobalLoot::RuleTypes rule, int value) { m_rules.emplace_back(rule, value); }
|
||||
};
|
||||
|
||||
class GlobalLootManager {
|
||||
std::vector<GlobalLootEntry> m_entries;
|
||||
|
||||
public:
|
||||
std::vector<int> GetGlobalLootTables(NPC *mob) const;
|
||||
inline void Clear() { m_entries.clear(); }
|
||||
inline void AddEntry(GlobalLootEntry &in) { m_entries.push_back(in); }
|
||||
void ShowZoneGlobalLoot(Client *to) const;
|
||||
void ShowNPCGlobalLoot(Client *to, NPC *who) const;
|
||||
};
|
||||
|
||||
#endif /* !GLOBAL_LOOT_MANAGER_H */
|
||||
+93
-12
@@ -27,6 +27,7 @@
|
||||
#include "npc.h"
|
||||
#include "zonedb.h"
|
||||
#include "nats_manager.h"
|
||||
#include "global_loot_manager.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
@@ -40,10 +41,14 @@ extern NatsManager nats;
|
||||
// Queries the loottable: adds item & coin to the npc
|
||||
void ZoneDatabase::AddLootTableToNPC(NPC* npc,uint32 loottable_id, ItemList* itemlist, uint32* copper, uint32* silver, uint32* gold, uint32* plat) {
|
||||
const LootTable_Struct* lts = nullptr;
|
||||
*copper = 0;
|
||||
*silver = 0;
|
||||
*gold = 0;
|
||||
*plat = 0;
|
||||
// global loot passes nullptr for these
|
||||
bool bGlobal = copper == nullptr && silver == nullptr && gold == nullptr && plat == nullptr;
|
||||
if (!bGlobal) {
|
||||
*copper = 0;
|
||||
*silver = 0;
|
||||
*gold = 0;
|
||||
*plat = 0;
|
||||
}
|
||||
|
||||
lts = database.GetLootTable(loottable_id);
|
||||
if (!lts)
|
||||
@@ -58,17 +63,19 @@ void ZoneDatabase::AddLootTableToNPC(NPC* npc,uint32 loottable_id, ItemList* ite
|
||||
}
|
||||
|
||||
uint32 cash = 0;
|
||||
if(max_cash > 0 && lts->avgcoin > 0 && EQEmu::ValueWithin(lts->avgcoin, min_cash, max_cash)) {
|
||||
float upper_chance = (float)(lts->avgcoin - min_cash) / (float)(max_cash - min_cash);
|
||||
float avg_cash_roll = (float)zone->random.Real(0.0, 1.0);
|
||||
if (!bGlobal) {
|
||||
if(max_cash > 0 && lts->avgcoin > 0 && EQEmu::ValueWithin(lts->avgcoin, min_cash, max_cash)) {
|
||||
float upper_chance = (float)(lts->avgcoin - min_cash) / (float)(max_cash - min_cash);
|
||||
float avg_cash_roll = (float)zone->random.Real(0.0, 1.0);
|
||||
|
||||
if(avg_cash_roll < upper_chance) {
|
||||
cash = zone->random.Int(lts->avgcoin, max_cash);
|
||||
if(avg_cash_roll < upper_chance) {
|
||||
cash = zone->random.Int(lts->avgcoin, max_cash);
|
||||
} else {
|
||||
cash = zone->random.Int(min_cash, lts->avgcoin);
|
||||
}
|
||||
} else {
|
||||
cash = zone->random.Int(min_cash, lts->avgcoin);
|
||||
cash = zone->random.Int(min_cash, max_cash);
|
||||
}
|
||||
} else {
|
||||
cash = zone->random.Int(min_cash, max_cash);
|
||||
}
|
||||
|
||||
if(cash != 0) {
|
||||
@@ -83,6 +90,7 @@ void ZoneDatabase::AddLootTableToNPC(NPC* npc,uint32 loottable_id, ItemList* ite
|
||||
|
||||
*copper = cash;
|
||||
}
|
||||
|
||||
uint32 global_loot_multiplier = RuleI(Zone, GlobalLootMultiplier);
|
||||
|
||||
// Do items
|
||||
@@ -448,3 +456,76 @@ void NPC::AddLootTable(uint32 ldid) {
|
||||
database.AddLootTableToNPC(this,ldid, &itemlist, &copper, &silver, &gold, &platinum);
|
||||
}
|
||||
}
|
||||
|
||||
void NPC::CheckGlobalLootTables()
|
||||
{
|
||||
auto tables = zone->GetGlobalLootTables(this);
|
||||
|
||||
for (auto &id : tables)
|
||||
database.AddLootTableToNPC(this, id, &itemlist, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void ZoneDatabase::LoadGlobalLoot()
|
||||
{
|
||||
auto query = StringFormat("SELECT id, loottable_id, description, min_level, max_level, rare, raid, race, "
|
||||
"class, bodytype, zone FROM global_loot WHERE enabled = 1");
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success() || results.RowCount() == 0)
|
||||
return;
|
||||
|
||||
// we might need this, lets not keep doing it in a loop
|
||||
auto zoneid = std::to_string(zone->GetZoneID());
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
// checking zone limits
|
||||
if (row[10]) {
|
||||
auto zones = SplitString(row[10], '|');
|
||||
|
||||
auto it = std::find(zones.begin(), zones.end(), zoneid);
|
||||
if (it == zones.end()) // not in here, skip
|
||||
continue;
|
||||
}
|
||||
|
||||
GlobalLootEntry e(atoi(row[0]), atoi(row[1]), row[2] ? row[2] : "");
|
||||
|
||||
auto min_level = atoi(row[3]);
|
||||
if (min_level)
|
||||
e.AddRule(GlobalLoot::RuleTypes::LevelMin, min_level);
|
||||
|
||||
auto max_level = atoi(row[4]);
|
||||
if (max_level)
|
||||
e.AddRule(GlobalLoot::RuleTypes::LevelMax, max_level);
|
||||
|
||||
// null is not used
|
||||
if (row[5])
|
||||
e.AddRule(GlobalLoot::RuleTypes::Rare, atoi(row[5]));
|
||||
|
||||
// null is not used
|
||||
if (row[6])
|
||||
e.AddRule(GlobalLoot::RuleTypes::Raid, atoi(row[6]));
|
||||
|
||||
if (row[7]) {
|
||||
auto races = SplitString(row[7], '|');
|
||||
|
||||
for (auto &r : races)
|
||||
e.AddRule(GlobalLoot::RuleTypes::Race, std::stoi(r));
|
||||
}
|
||||
|
||||
if (row[8]) {
|
||||
auto classes = SplitString(row[8], '|');
|
||||
|
||||
for (auto &c : classes)
|
||||
e.AddRule(GlobalLoot::RuleTypes::Class, std::stoi(c));
|
||||
}
|
||||
|
||||
if (row[9]) {
|
||||
auto bodytypes = SplitString(row[9], '|');
|
||||
|
||||
for (auto &b : bodytypes)
|
||||
e.AddRule(GlobalLoot::RuleTypes::Class, std::stoi(b));
|
||||
}
|
||||
|
||||
zone->AddGlobalLootEntry(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+32
-34
@@ -268,6 +268,7 @@ Mob::Mob(const char* in_name,
|
||||
IsFullHP = (cur_hp == max_hp);
|
||||
qglobal = 0;
|
||||
spawned = false;
|
||||
rare_spawn = false;
|
||||
|
||||
InitializeBuffSlots();
|
||||
|
||||
@@ -1110,7 +1111,7 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
||||
strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName));
|
||||
}
|
||||
|
||||
ns->spawn.heading = FloatToEQ19(m_Position.w);
|
||||
ns->spawn.heading = FloatToEQ12(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;
|
||||
@@ -1518,12 +1519,12 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu) {
|
||||
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.w);
|
||||
spu->delta_x = FloatToEQ13(0);
|
||||
spu->delta_y = FloatToEQ13(0);
|
||||
spu->delta_z = FloatToEQ13(0);
|
||||
spu->heading = FloatToEQ12(m_Position.w);
|
||||
spu->animation = 0;
|
||||
spu->delta_heading = NewFloatToEQ13(0);
|
||||
spu->delta_heading = FloatToEQ10(0);
|
||||
spu->padding0002 = 0;
|
||||
spu->padding0006 = 7;
|
||||
spu->padding0014 = 0x7f;
|
||||
@@ -1537,10 +1538,10 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
|
||||
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->delta_x = FloatToEQ13(m_Delta.x);
|
||||
spu->delta_y = FloatToEQ13(m_Delta.y);
|
||||
spu->delta_z = FloatToEQ13(m_Delta.z);
|
||||
spu->heading = FloatToEQ12(m_Position.w);
|
||||
spu->padding0002 = 0;
|
||||
spu->padding0006 = 7;
|
||||
spu->padding0014 = 0x7f;
|
||||
@@ -1554,7 +1555,7 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
|
||||
else
|
||||
spu->animation = pRunAnimSpeed;//animation;
|
||||
|
||||
spu->delta_heading = NewFloatToEQ13(m_Delta.w);
|
||||
spu->delta_heading = FloatToEQ10(m_Delta.w);
|
||||
}
|
||||
|
||||
void Mob::ShowStats(Client* client)
|
||||
@@ -2441,18 +2442,18 @@ float Mob::MobAngle(Mob *other, float ourx, float oury) const {
|
||||
float mobx = -(other->GetX()); // mob xloc (inverse because eq)
|
||||
float moby = other->GetY(); // mob yloc
|
||||
float heading = other->GetHeading(); // mob heading
|
||||
heading = (heading * 360.0f) / 256.0f; // convert to degrees
|
||||
heading = (heading * 360.0f) / 512.0f; // convert to degrees
|
||||
if (heading < 270)
|
||||
heading += 90;
|
||||
else
|
||||
heading -= 270;
|
||||
|
||||
heading = heading * 3.1415f / 180.0f; // convert to radians
|
||||
vectorx = mobx + (10.0f * cosf(heading)); // create a vector based on heading
|
||||
vectory = moby + (10.0f * sinf(heading)); // of mob length 10
|
||||
vectorx = mobx + (10.0f * std::cos(heading)); // create a vector based on heading
|
||||
vectory = moby + (10.0f * std::sin(heading)); // of mob length 10
|
||||
|
||||
// length of mob to player vector
|
||||
lengthb = (float) sqrtf(((-ourx - mobx) * (-ourx - mobx)) + ((oury - moby) * (oury - moby)));
|
||||
lengthb = (float) std::sqrt(((-ourx - mobx) * (-ourx - mobx)) + ((oury - moby) * (oury - moby)));
|
||||
|
||||
// calculate dot product to get angle
|
||||
// Handle acos domain errors due to floating point rounding errors
|
||||
@@ -2465,7 +2466,7 @@ float Mob::MobAngle(Mob *other, float ourx, float oury) const {
|
||||
else if (dotp < -1)
|
||||
return 180.0f;
|
||||
|
||||
angle = acosf(dotp);
|
||||
angle = std::acos(dotp);
|
||||
angle = angle * 180.0f / 3.1415f;
|
||||
|
||||
return angle;
|
||||
@@ -2634,7 +2635,7 @@ bool Mob::PlotPositionAroundTarget(Mob* target, float &x_dest, float &y_dest, fl
|
||||
look_heading = target->GetHeading();
|
||||
|
||||
// Convert to sony heading to radians
|
||||
look_heading = (look_heading / 256.0f) * 6.283184f;
|
||||
look_heading = (look_heading / 512.0f) * 6.283184f;
|
||||
|
||||
float tempX = 0;
|
||||
float tempY = 0;
|
||||
@@ -4682,16 +4683,16 @@ void Mob::DoKnockback(Mob *caster, uint32 pushback, uint32 pushup)
|
||||
spu->x_pos = FloatToEQ19(GetX());
|
||||
spu->y_pos = FloatToEQ19(GetY());
|
||||
spu->z_pos = FloatToEQ19(GetZ());
|
||||
spu->delta_x = NewFloatToEQ13(static_cast<float>(new_x));
|
||||
spu->delta_y = NewFloatToEQ13(static_cast<float>(new_y));
|
||||
spu->delta_z = NewFloatToEQ13(static_cast<float>(pushup));
|
||||
spu->heading = FloatToEQ19(GetHeading());
|
||||
spu->delta_x = FloatToEQ13(static_cast<float>(new_x));
|
||||
spu->delta_y = FloatToEQ13(static_cast<float>(new_y));
|
||||
spu->delta_z = FloatToEQ13(static_cast<float>(pushup));
|
||||
spu->heading = FloatToEQ12(GetHeading());
|
||||
spu->padding0002 =0;
|
||||
spu->padding0006 =7;
|
||||
spu->padding0014 =0x7f;
|
||||
spu->padding0018 =0x5df27;
|
||||
spu->animation = 0;
|
||||
spu->delta_heading = NewFloatToEQ13(0);
|
||||
spu->delta_heading = FloatToEQ10(0);
|
||||
outapp_push->priority = 6;
|
||||
entity_list.QueueClients(this, outapp_push, true);
|
||||
CastToClient()->FastQueuePacket(&outapp_push);
|
||||
@@ -5011,7 +5012,7 @@ void Mob::DoGravityEffect()
|
||||
}
|
||||
|
||||
if(IsClient())
|
||||
this->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), cur_x, cur_y, new_ground, GetHeading()*2); // I know the heading thing is weird(chance of movepc to halve the heading value, too lazy to figure out why atm)
|
||||
this->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), cur_x, cur_y, new_ground, GetHeading());
|
||||
else
|
||||
this->GMMove(cur_x, cur_y, new_ground, GetHeading());
|
||||
}
|
||||
@@ -5648,8 +5649,7 @@ bool Mob::IsFacingMob(Mob *other)
|
||||
if (!other)
|
||||
return false;
|
||||
float angle = HeadingAngleToMob(other);
|
||||
// what the client uses appears to be 2x our internal heading
|
||||
float heading = GetHeading() * 2.0f;
|
||||
float heading = GetHeading();
|
||||
|
||||
if (angle > 472.0 && heading < 40.0)
|
||||
angle = heading;
|
||||
@@ -5663,15 +5663,13 @@ bool Mob::IsFacingMob(Mob *other)
|
||||
}
|
||||
|
||||
// All numbers derived from the client
|
||||
float Mob::HeadingAngleToMob(Mob *other)
|
||||
float Mob::HeadingAngleToMob(float other_x, float other_y)
|
||||
{
|
||||
float mob_x = other->GetX();
|
||||
float mob_y = other->GetY();
|
||||
float this_x = GetX();
|
||||
float this_y = GetY();
|
||||
|
||||
float y_diff = std::abs(this_y - mob_y);
|
||||
float x_diff = std::abs(this_x - mob_x);
|
||||
float y_diff = std::abs(this_y - other_y);
|
||||
float x_diff = std::abs(this_x - other_x);
|
||||
if (y_diff < 0.0000009999999974752427)
|
||||
y_diff = 0.0000009999999974752427;
|
||||
|
||||
@@ -5679,13 +5677,13 @@ float Mob::HeadingAngleToMob(Mob *other)
|
||||
|
||||
// return the right thing based on relative quadrant
|
||||
// I'm sure this could be improved for readability, but whatever
|
||||
if (this_y >= mob_y) {
|
||||
if (mob_x >= this_x)
|
||||
if (this_y >= other_y) {
|
||||
if (other_x >= this_x)
|
||||
return (90.0f - angle + 90.0f) * 511.5f * 0.0027777778f;
|
||||
if (mob_x <= this_x)
|
||||
if (other_x <= this_x)
|
||||
return (angle + 180.0f) * 511.5f * 0.0027777778f;
|
||||
}
|
||||
if (this_y > mob_y || mob_x > this_x)
|
||||
if (this_y > other_y || other_x > this_x)
|
||||
return angle * 511.5f * 0.0027777778f;
|
||||
else
|
||||
return (90.0f - angle + 270.0f) * 511.5f * 0.0027777778f;
|
||||
|
||||
+6
-2
@@ -177,7 +177,8 @@ public:
|
||||
inline bool InFrontMob(Mob *other = 0, float ourx = 0.0f, float oury = 0.0f) const
|
||||
{ return (!other || other == this) ? true : MobAngle(other, ourx, oury) < 56.0f; }
|
||||
bool IsFacingMob(Mob *other); // kind of does the same as InFrontMob, but derived from client
|
||||
float HeadingAngleToMob(Mob *other); // to keep consistent with client generated messages
|
||||
float HeadingAngleToMob(Mob *other) { return HeadingAngleToMob(other->GetX(), other->GetY()); }
|
||||
float HeadingAngleToMob(float other_x, float other_y); // to keep consistent with client generated messages
|
||||
virtual void RangedAttack(Mob* other) { }
|
||||
virtual void ThrowingAttack(Mob* other) { }
|
||||
// 13 = Primary (default), 14 = secondary
|
||||
@@ -689,6 +690,8 @@ public:
|
||||
void SetFollowDistance(uint32 dist) { follow_dist = dist; }
|
||||
uint32 GetFollowID() const { return follow; }
|
||||
uint32 GetFollowDistance() const { return follow_dist; }
|
||||
inline bool IsRareSpawn() const { return rare_spawn; }
|
||||
inline void SetRareSpawn(bool in) { rare_spawn = in; }
|
||||
|
||||
virtual void Message(uint32 type, const char* message, ...) { }
|
||||
virtual void Message_StringID(uint32 type, uint32 string_id, uint32 distance = 0) { }
|
||||
@@ -968,7 +971,7 @@ public:
|
||||
inline bool IsBlind() { return spellbonuses.IsBlind; }
|
||||
|
||||
inline bool CheckAggro(Mob* other) {return hate_list.IsEntOnHateList(other);}
|
||||
float CalculateHeadingToTarget(float in_x, float in_y);
|
||||
float CalculateHeadingToTarget(float in_x, float in_y) {return HeadingAngleToMob(in_x, in_y); }
|
||||
bool CalculateNewPosition(float x, float y, float z, int speed, bool checkZ = false, bool calcHeading = true);
|
||||
virtual bool CalculateNewPosition2(float x, float y, float z, int speed, bool checkZ = true, bool calcHeading = true);
|
||||
float CalculateDistance(float x, float y, float z);
|
||||
@@ -1225,6 +1228,7 @@ protected:
|
||||
uint32 follow;
|
||||
uint32 follow_dist;
|
||||
bool no_target_hotkey;
|
||||
bool rare_spawn;
|
||||
|
||||
uint32 m_PlayerState;
|
||||
uint32 GetPlayerState() { return m_PlayerState; }
|
||||
|
||||
@@ -245,6 +245,8 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, const glm::vec4& position, int if
|
||||
roambox_delay = 1000;
|
||||
p_depop = false;
|
||||
loottable_id = d->loottable_id;
|
||||
skip_global_loot = d->skip_global_loot;
|
||||
rare_spawn = d->rare_spawn;
|
||||
|
||||
no_target_hotkey = d->no_target_hotkey;
|
||||
|
||||
@@ -938,6 +940,7 @@ bool NPC::SpawnZoneController(){
|
||||
npc_type->d_melee_texture2 = 0;
|
||||
npc_type->merchanttype = 0;
|
||||
npc_type->bodytype = 11;
|
||||
npc_type->skip_global_loot = true;
|
||||
|
||||
if (RuleB(Zone, EnableZoneControllerGlobals)) {
|
||||
npc_type->qglobal = true;
|
||||
@@ -2148,6 +2151,8 @@ void NPC::LevelScale() {
|
||||
if(level > 15 && level <= 25)
|
||||
scale_adjust = 2;
|
||||
|
||||
AC += (int)(AC * scaling);
|
||||
ATK += (int)(ATK * scaling);
|
||||
base_hp += (int)(base_hp * scaling);
|
||||
max_hp += (int)(max_hp * scaling);
|
||||
cur_hp = max_hp;
|
||||
|
||||
@@ -185,6 +185,7 @@ public:
|
||||
void AddItem(uint32 itemid, uint16 charges, bool equipitem = true, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0);
|
||||
void AddLootTable();
|
||||
void AddLootTable(uint32 ldid);
|
||||
void CheckGlobalLootTables();
|
||||
void DescribeAggro(Client *towho, Mob *mob, bool verbose);
|
||||
void RemoveItem(uint32 item_id, uint16 quantity = 0, uint16 slot = 0);
|
||||
void CheckMinMaxLevel(Mob *them);
|
||||
@@ -197,6 +198,7 @@ public:
|
||||
uint32 CountLoot();
|
||||
inline uint32 GetLoottableID() const { return loottable_id; }
|
||||
virtual void UpdateEquipmentLight();
|
||||
inline bool DropsGlobalLoot() const { return !skip_global_loot; }
|
||||
|
||||
inline uint32 GetCopper() const { return copper; }
|
||||
inline uint32 GetSilver() const { return silver; }
|
||||
@@ -562,6 +564,7 @@ protected:
|
||||
|
||||
private:
|
||||
uint32 loottable_id;
|
||||
bool skip_global_loot;
|
||||
bool p_depop;
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -150,13 +150,13 @@ float GetReciprocalHeading(const float heading)
|
||||
float result = 0;
|
||||
|
||||
// Convert to radians
|
||||
float h = (heading / 256.0f) * 6.283184f;
|
||||
float h = (heading / 512.0f) * 6.283184f;
|
||||
|
||||
// Calculate the reciprocal heading in radians
|
||||
result = h + 3.141592f;
|
||||
|
||||
// Convert back to eq heading from radians
|
||||
result = (result / 6.283184f) * 256.0f;
|
||||
result = (result / 6.283184f) * 512.0f;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -210,6 +210,8 @@ Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const glm::vec4& p
|
||||
{
|
||||
auto npc = new NPC(tmp, nullptr, position, FlyMode3);
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(npc,true,true);
|
||||
if(grid > 0)
|
||||
{
|
||||
@@ -232,6 +234,8 @@ Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, const glm::v
|
||||
{
|
||||
auto npc = new NPC(tmp, nullptr, position, FlyMode3);
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(npc,true,true);
|
||||
if(grid > 0)
|
||||
{
|
||||
@@ -308,6 +312,8 @@ Mob* QuestManager::spawn_from_spawn2(uint32 spawn2_id)
|
||||
|
||||
found_spawn->SetNPCPointer(npc);
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
npc->SetSp2(found_spawn->SpawnGroupID());
|
||||
entity_list.AddNPC(npc);
|
||||
entity_list.LimitAddNPC(npc);
|
||||
@@ -1656,6 +1662,8 @@ void QuestManager::respawn(int npcTypeID, int grid) {
|
||||
{
|
||||
owner = new NPC(npcType, nullptr, owner->GetPosition(), FlyMode3);
|
||||
owner->CastToNPC()->AddLootTable();
|
||||
if (owner->CastToNPC()->DropsGlobalLoot())
|
||||
owner->CastToNPC()->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(owner->CastToNPC(),true,true);
|
||||
if(grid > 0)
|
||||
owner->CastToNPC()->AssignWaypoints(grid);
|
||||
|
||||
@@ -236,6 +236,8 @@ bool Spawn2::Process() {
|
||||
|
||||
npcthis = npc;
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
npc->SetSp2(spawngroup_id_);
|
||||
npc->SaveGuardPointAnim(anim);
|
||||
npc->SetAppearance((EmuAppearance)anim);
|
||||
|
||||
@@ -2120,16 +2120,16 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
spu->x_pos = FloatToEQ19(GetX());
|
||||
spu->y_pos = FloatToEQ19(GetY());
|
||||
spu->z_pos = FloatToEQ19(GetZ());
|
||||
spu->delta_x = NewFloatToEQ13(new_x);
|
||||
spu->delta_y = NewFloatToEQ13(new_y);
|
||||
spu->delta_z = NewFloatToEQ13(toss_amt);
|
||||
spu->heading = FloatToEQ19(GetHeading());
|
||||
spu->delta_x = FloatToEQ13(new_x);
|
||||
spu->delta_y = FloatToEQ13(new_y);
|
||||
spu->delta_z = FloatToEQ13(toss_amt);
|
||||
spu->heading = FloatToEQ12(GetHeading());
|
||||
spu->padding0002 =0;
|
||||
spu->padding0006 =7;
|
||||
spu->padding0014 =0x7f;
|
||||
spu->padding0018 =0x5df27;
|
||||
spu->animation = 0;
|
||||
spu->delta_heading = NewFloatToEQ13(0);
|
||||
spu->delta_heading = FloatToEQ10(0);
|
||||
outapp_push->priority = 5;
|
||||
entity_list.QueueClients(this, outapp_push, true);
|
||||
if(IsClient())
|
||||
@@ -2659,7 +2659,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
float new_ground = GetGroundZ(my_x, my_y);
|
||||
|
||||
if(caster->IsClient())
|
||||
caster->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), my_x, my_y, new_ground, GetHeading()*2);
|
||||
caster->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), my_x, my_y, new_ground, GetHeading());
|
||||
else
|
||||
caster->GMMove(my_x, my_y, new_ground, GetHeading());
|
||||
}
|
||||
|
||||
+25
-21
@@ -2651,7 +2651,7 @@ void Mob::BardPulse(uint16 spell_id, Mob *caster) {
|
||||
action->source = caster->GetID();
|
||||
action->target = GetID();
|
||||
action->spell = spell_id;
|
||||
action->sequence = (uint32) (GetHeading() * 2); // just some random number
|
||||
action->sequence = (uint32) (GetHeading()); // just some random number
|
||||
action->instrument_mod = caster->GetInstrumentMod(spell_id);
|
||||
action->buff_unknown = 0;
|
||||
action->level = buffs[buffs_i].casterlevel;
|
||||
@@ -2691,16 +2691,16 @@ void Mob::BardPulse(uint16 spell_id, Mob *caster) {
|
||||
spu->x_pos = FloatToEQ19(GetX());
|
||||
spu->y_pos = FloatToEQ19(GetY());
|
||||
spu->z_pos = FloatToEQ19(GetZ());
|
||||
spu->delta_x = NewFloatToEQ13(new_x);
|
||||
spu->delta_y = NewFloatToEQ13(new_y);
|
||||
spu->delta_z = NewFloatToEQ13(spells[spell_id].pushup);
|
||||
spu->heading = FloatToEQ19(GetHeading());
|
||||
spu->delta_x = FloatToEQ13(new_x);
|
||||
spu->delta_y = FloatToEQ13(new_y);
|
||||
spu->delta_z = FloatToEQ13(spells[spell_id].pushup);
|
||||
spu->heading = FloatToEQ12(GetHeading());
|
||||
spu->padding0002 =0;
|
||||
spu->padding0006 =7;
|
||||
spu->padding0014 =0x7f;
|
||||
spu->padding0018 =0x5df27;
|
||||
spu->animation = 0;
|
||||
spu->delta_heading = NewFloatToEQ13(0);
|
||||
spu->delta_heading = FloatToEQ10(0);
|
||||
outapp_push->priority = 6;
|
||||
entity_list.QueueClients(this, outapp_push, true);
|
||||
CastToClient()->FastQueuePacket(&outapp_push);
|
||||
@@ -3535,7 +3535,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
|
||||
action->level = caster_level; // caster level, for animation only
|
||||
action->type = 231; // 231 means a spell
|
||||
action->spell = spell_id;
|
||||
action->sequence = (uint32) (GetHeading() * 2); // just some random number
|
||||
action->sequence = (uint32) (GetHeading()); // just some random number
|
||||
action->instrument_mod = GetInstrumentMod(spell_id);
|
||||
action->buff_unknown = 0;
|
||||
|
||||
@@ -3997,16 +3997,16 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
|
||||
spu->x_pos = FloatToEQ19(spelltar->GetX());
|
||||
spu->y_pos = FloatToEQ19(spelltar->GetY());
|
||||
spu->z_pos = FloatToEQ19(spelltar->GetZ());
|
||||
spu->delta_x = NewFloatToEQ13(new_x);
|
||||
spu->delta_y = NewFloatToEQ13(new_y);
|
||||
spu->delta_z = NewFloatToEQ13(spells[spell_id].pushup);
|
||||
spu->heading = FloatToEQ19(spelltar->GetHeading());
|
||||
spu->delta_x = FloatToEQ13(new_x);
|
||||
spu->delta_y = FloatToEQ13(new_y);
|
||||
spu->delta_z = FloatToEQ13(spells[spell_id].pushup);
|
||||
spu->heading = FloatToEQ12(spelltar->GetHeading());
|
||||
spu->padding0002 =0;
|
||||
spu->padding0006 =7;
|
||||
spu->padding0014 =0x7f;
|
||||
spu->padding0018 =0x5df27;
|
||||
spu->animation = 0;
|
||||
spu->delta_heading = NewFloatToEQ13(0);
|
||||
spu->delta_heading = FloatToEQ10(0);
|
||||
outapp_push->priority = 6;
|
||||
entity_list.QueueClients(this, outapp_push, true);
|
||||
spelltar->CastToClient()->FastQueuePacket(&outapp_push);
|
||||
@@ -5733,8 +5733,8 @@ void Mob::CalcDestFromHeading(float heading, float distance, float MaxZDiff, flo
|
||||
if (!distance) { return; }
|
||||
if (!MaxZDiff) { MaxZDiff = 5; }
|
||||
|
||||
float ReverseHeading = 256 - heading;
|
||||
float ConvertAngle = ReverseHeading * 1.40625f;
|
||||
float ReverseHeading = 512 - heading;
|
||||
float ConvertAngle = ReverseHeading * 360.0f / 512.0f;
|
||||
if (ConvertAngle <= 270)
|
||||
ConvertAngle = ConvertAngle + 90;
|
||||
else
|
||||
@@ -5742,8 +5742,8 @@ void Mob::CalcDestFromHeading(float heading, float distance, float MaxZDiff, flo
|
||||
|
||||
float Radian = ConvertAngle * (3.1415927f / 180.0f);
|
||||
|
||||
float CircleX = distance * cos(Radian);
|
||||
float CircleY = distance * sin(Radian);
|
||||
float CircleX = distance * std::cos(Radian);
|
||||
float CircleY = distance * std::sin(Radian);
|
||||
dX = CircleX + StartX;
|
||||
dY = CircleY + StartY;
|
||||
dZ = FindGroundZ(dX, dY, MaxZDiff);
|
||||
@@ -5808,7 +5808,8 @@ void Mob::BeamDirectional(uint16 spell_id, int16 resist_adjust)
|
||||
maxtarget_count++;
|
||||
}
|
||||
|
||||
if (maxtarget_count >= spells[spell_id].aemaxtargets)
|
||||
// not sure if we need this check, but probably do, need to check if it should be default limited or not
|
||||
if (spells[spell_id].aemaxtargets && maxtarget_count >= spells[spell_id].aemaxtargets)
|
||||
return;
|
||||
}
|
||||
++iter;
|
||||
@@ -5823,8 +5824,10 @@ void Mob::ConeDirectional(uint16 spell_id, int16 resist_adjust)
|
||||
if (IsBeneficialSpell(spell_id) && IsClient())
|
||||
beneficial_targets = true;
|
||||
|
||||
float angle_start = spells[spell_id].directional_start + (GetHeading() * 360.0f / 256.0f);
|
||||
float angle_end = spells[spell_id].directional_end + (GetHeading() * 360.0f / 256.0f);
|
||||
float heading = GetHeading() * 360.0f / 512.0f; // convert to degrees
|
||||
|
||||
float angle_start = spells[spell_id].directional_start + heading;
|
||||
float angle_end = spells[spell_id].directional_end + heading;
|
||||
|
||||
while (angle_start > 360.0f)
|
||||
angle_start -= 360.0f;
|
||||
@@ -5845,7 +5848,7 @@ void Mob::ConeDirectional(uint16 spell_id, int16 resist_adjust)
|
||||
}
|
||||
|
||||
float heading_to_target =
|
||||
(CalculateHeadingToTarget((*iter)->GetX(), (*iter)->GetY()) * 360.0f / 256.0f);
|
||||
(CalculateHeadingToTarget((*iter)->GetX(), (*iter)->GetY()) * 360.0f / 512.0f);
|
||||
|
||||
while (heading_to_target < 0.0f)
|
||||
heading_to_target += 360.0f;
|
||||
@@ -5889,7 +5892,8 @@ void Mob::ConeDirectional(uint16 spell_id, int16 resist_adjust)
|
||||
}
|
||||
}
|
||||
|
||||
if (maxtarget_count >= spells[spell_id].aemaxtargets)
|
||||
// my SHM breath could hit all 5 dummies I could summon in arena
|
||||
if (spells[spell_id].aemaxtargets && maxtarget_count >= spells[spell_id].aemaxtargets)
|
||||
return;
|
||||
|
||||
++iter;
|
||||
|
||||
+5
-1
@@ -170,6 +170,8 @@ void Trap::Trigger(Mob* trigger)
|
||||
auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
|
||||
auto new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3);
|
||||
new_npc->AddLootTable();
|
||||
if (new_npc->DropsGlobalLoot())
|
||||
new_npc->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(new_npc);
|
||||
new_npc->AddToHateList(trigger,1);
|
||||
}
|
||||
@@ -193,6 +195,8 @@ void Trap::Trigger(Mob* trigger)
|
||||
auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
|
||||
auto new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3);
|
||||
new_npc->AddLootTable();
|
||||
if (new_npc->DropsGlobalLoot())
|
||||
new_npc->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(new_npc);
|
||||
new_npc->AddToHateList(trigger,1);
|
||||
}
|
||||
@@ -558,4 +562,4 @@ void Trap::UpdateTrap(bool respawn, bool repopnow)
|
||||
{
|
||||
database.SetTrapData(this, repopnow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,27 +435,6 @@ float Mob::CalculateDistance(float x, float y, float z) {
|
||||
return (float)sqrtf(((m_Position.x - x)*(m_Position.x - x)) + ((m_Position.y - y)*(m_Position.y - y)) + ((m_Position.z - z)*(m_Position.z - z)));
|
||||
}
|
||||
|
||||
float Mob::CalculateHeadingToTarget(float in_x, float in_y) {
|
||||
float angle;
|
||||
|
||||
if (in_x - m_Position.x > 0)
|
||||
angle = -90 + atan((float)(in_y - m_Position.y) / (float)(in_x - m_Position.x)) * 180 / M_PI;
|
||||
else if (in_x - m_Position.x < 0)
|
||||
angle = +90 + atan((float)(in_y - m_Position.y) / (float)(in_x - m_Position.x)) * 180 / M_PI;
|
||||
else // Added?
|
||||
{
|
||||
if (in_y - m_Position.y > 0)
|
||||
angle = 0;
|
||||
else
|
||||
angle = 180;
|
||||
}
|
||||
if (angle < 0)
|
||||
angle += 360;
|
||||
if (angle > 360)
|
||||
angle -= 360;
|
||||
return (256 * (360 - angle) / 360.0f);
|
||||
}
|
||||
|
||||
bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ, bool calcHeading) {
|
||||
if (GetID() == 0)
|
||||
return true;
|
||||
|
||||
@@ -968,6 +968,8 @@ bool Zone::Init(bool iStaticZone) {
|
||||
|
||||
LoadAlternateAdvancement();
|
||||
|
||||
database.LoadGlobalLoot();
|
||||
|
||||
//Load merchant data
|
||||
zone->GetMerchantDataForZoneLoad();
|
||||
|
||||
@@ -2229,6 +2231,8 @@ void Zone::DoAdventureActions()
|
||||
{
|
||||
NPC* npc = new NPC(tmp, nullptr, glm::vec4(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), FlyMode3);
|
||||
npc->AddLootTable();
|
||||
if (npc->DropsGlobalLoot())
|
||||
npc->CheckGlobalLootTables();
|
||||
entity_list.AddNPC(npc);
|
||||
npc->Shout("Rarrrgh!");
|
||||
did_adventure_actions = true;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "spawn2.h"
|
||||
#include "spawngroup.h"
|
||||
#include "aa_ability.h"
|
||||
#include "global_loot_manager.h"
|
||||
|
||||
struct ZonePoint
|
||||
{
|
||||
@@ -269,6 +270,11 @@ public:
|
||||
void UpdateHotzone();
|
||||
std::unordered_map<int, item_tick_struct> tick_items;
|
||||
|
||||
inline std::vector<int> GetGlobalLootTables(NPC *mob) const { return m_global_loot.GetGlobalLootTables(mob); }
|
||||
inline void AddGlobalLootEntry(GlobalLootEntry &in) { return m_global_loot.AddEntry(in); }
|
||||
inline void ShowZoneGlobalLoot(Client *to) { m_global_loot.ShowZoneGlobalLoot(to); }
|
||||
inline void ShowNPCGlobalLoot(Client *to, NPC *who) { m_global_loot.ShowNPCGlobalLoot(to, who); }
|
||||
|
||||
// random object that provides random values for the zone
|
||||
EQEmu::Random random;
|
||||
|
||||
@@ -347,6 +353,8 @@ private:
|
||||
QGlobalCache *qGlobals;
|
||||
|
||||
Timer hotzone_timer;
|
||||
|
||||
GlobalLootManager m_global_loot;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+6
-1
@@ -1969,7 +1969,9 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
|
||||
"npc_types.charm_attack_delay, "
|
||||
"npc_types.charm_accuracy_rating, "
|
||||
"npc_types.charm_avoidance_rating, "
|
||||
"npc_types.charm_atk "
|
||||
"npc_types.charm_atk, "
|
||||
"npc_types.skip_global_loot, "
|
||||
"npc_types.rare_spawn "
|
||||
"FROM npc_types %s",
|
||||
where_condition.c_str()
|
||||
);
|
||||
@@ -2156,6 +2158,9 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
|
||||
temp_npctype_data->charm_avoidance_rating = atoi(row[105]);
|
||||
temp_npctype_data->charm_atk = atoi(row[106]);
|
||||
|
||||
temp_npctype_data->skip_global_loot = atoi(row[107]) != 0;
|
||||
temp_npctype_data->rare_spawn = atoi(row[108]) != 0;
|
||||
|
||||
// If NPC with duplicate NPC id already in table,
|
||||
// free item we attempted to add.
|
||||
if (zone->npctable.find(temp_npctype_data->npc_id) != zone->npctable.end()) {
|
||||
|
||||
@@ -424,6 +424,7 @@ public:
|
||||
uint32 GetMaxNPCSpellsID();
|
||||
uint32 GetMaxNPCSpellsEffectsID();
|
||||
bool GetAuraEntry(uint16 spell_id, AuraRecord &record);
|
||||
void LoadGlobalLoot();
|
||||
|
||||
DBnpcspells_Struct* GetNPCSpells(uint32 iDBSpellsID);
|
||||
DBnpcspellseffects_Struct* GetNPCSpellsEffects(uint32 iDBSpellsEffectsID);
|
||||
|
||||
@@ -141,6 +141,8 @@ struct NPCType
|
||||
bool ignore_despawn;
|
||||
bool show_name; // should default on
|
||||
bool untargetable;
|
||||
bool skip_global_loot;
|
||||
bool rare_spawn;
|
||||
};
|
||||
|
||||
namespace player_lootitem {
|
||||
|
||||
Reference in New Issue
Block a user