Merge branch 'master' into shared_tasks

This commit is contained in:
Michael Cook (mackal)
2018-09-03 12:58:47 -04:00
18 changed files with 283 additions and 56 deletions
+1
View File
@@ -885,6 +885,7 @@ public:
void SetStats(uint8 type,int16 set_val);
void IncStats(uint8 type,int16 increase_val);
void DropItem(int16 slot_id, bool recurse = true);
void DropItemQS(EQEmu::ItemInstance* inst, bool pickup);
int GetItemLinkHash(const EQEmu::ItemInstance* inst); // move to ItemData..or make use of the pre-calculated database field
+15 -14
View File
@@ -155,42 +155,43 @@ void Mob::ProcessFlee()
}
}
void Mob::CalculateNewFearpoint()
{
if(RuleB(Pathing, Fear) && zone->pathing)
{
void Mob::CalculateNewFearpoint() {
if (RuleB(Pathing, Fear) && zone->pathing) {
auto Node = zone->pathing->GetRandomLocation();
if (Node.x != 0.0f || Node.y != 0.0f || Node.z != 0.0f) {
++Node.z;
m_FearWalkTarget = Node;
m_FearWalkTarget = Node;
currently_fleeing = true;
return;
}
Log(Logs::Detail, Logs::None, "No path found to selected node. Falling through to old fear point selection.");
Log(Logs::Detail,
Logs::Pathing,
"No path found to selected node. Falling through to old fear point selection.");
}
int loop = 0;
int loop = 0;
float ranx, rany, ranz;
currently_fleeing = true;
while (loop < 100) //Max 100 tries
{
int ran = 250 - (loop*2);
int ran = 250 - (loop * 2);
loop++;
ranx = GetX()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
rany = GetY()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
ranz = FindGroundZ(ranx,rany);
ranx = GetX() + zone->random.Int(0, ran - 1) - zone->random.Int(0, ran - 1);
rany = GetY() + zone->random.Int(0, ran - 1) - zone->random.Int(0, ran - 1);
ranz = FindGroundZ(ranx, rany);
if (ranz == BEST_Z_INVALID)
continue;
float fdist = ranz - GetZ();
if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(),GetY(),GetZ(),ranx,rany,ranz))
{
if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(), GetY(), GetZ(), ranx, rany, ranz)) {
break;
}
}
if (currently_fleeing)
m_FearWalkTarget = glm::vec3(ranx, rany, ranz);
m_FearWalkTarget = glm::vec3(ranx, rany, ranz);
}
+69
View File
@@ -688,10 +688,79 @@ void Client::DropItem(int16 slot_id, bool recurse)
object->StartDecay();
Log(Logs::General, Logs::Inventory, "Item drop handled ut assolet");
DropItemQS(inst, false);
safe_delete(inst);
}
void Client::DropItemQS(EQEmu::ItemInstance* inst, bool pickup) {
if (RuleB(QueryServ, PlayerDropItems)) {
QSPlayerDropItem_Struct qs_audit;
std::list<void*> event_details;
memset(&qs_audit, 0, sizeof(QSPlayerDropItem_Struct));
qs_audit.char_id = this->character_id;
qs_audit.pickup = pickup;
qs_audit.zone_id = this->GetZoneID();
qs_audit.x = (int) this->GetX();
qs_audit.y = (int) this->GetY();
qs_audit.z = (int) this->GetZ();
if (inst) {
auto detail = new QSDropItems_Struct;
detail->item_id = inst->GetID();
detail->charges = inst->IsClassBag() ? 1 : inst->GetCharges();
detail->aug_1 = inst->GetAugmentItemID(1);
detail->aug_2 = inst->GetAugmentItemID(2);
detail->aug_3 = inst->GetAugmentItemID(3);
detail->aug_4 = inst->GetAugmentItemID(4);
detail->aug_5 = inst->GetAugmentItemID(5);
event_details.push_back(detail);
if (inst->IsClassBag()) {
for (uint8 sub_slot = EQEmu::invbag::SLOT_BEGIN; (sub_slot <= EQEmu::invbag::SLOT_END); ++sub_slot) { // this is to catch ALL items
const EQEmu::ItemInstance* bag_inst = inst->GetItem(sub_slot);
if (bag_inst) {
detail = new QSDropItems_Struct;
detail->item_id = bag_inst->GetID();
detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges());
detail->aug_1 = bag_inst->GetAugmentItemID(1);
detail->aug_2 = bag_inst->GetAugmentItemID(2);
detail->aug_3 = bag_inst->GetAugmentItemID(3);
detail->aug_4 = bag_inst->GetAugmentItemID(4);
detail->aug_5 = bag_inst->GetAugmentItemID(5);
event_details.push_back(detail);
}
}
}
}
qs_audit._detail_count = event_details.size();
auto qs_pack = new ServerPacket(
ServerOP_QSPlayerDropItem,
sizeof(QSPlayerDropItem_Struct) +
(sizeof(QSDropItems_Struct) * qs_audit._detail_count));
QSPlayerDropItem_Struct* qs_buf = (QSPlayerDropItem_Struct*) qs_pack->pBuffer;
memcpy(qs_buf, &qs_audit, sizeof(QSPlayerDropItem_Struct));
int offset = 0;
for (auto iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) {
QSDropItems_Struct* detail = reinterpret_cast<QSDropItems_Struct*>(*iter);
qs_buf->items[offset] = *detail;
safe_delete(detail);
}
event_details.clear();
if (worldserver.Connected())
worldserver.SendPacket(qs_pack);
safe_delete(qs_pack);
}
}
// Drop inst
void Client::DropInst(const EQEmu::ItemInstance* inst)
{
+1 -1
View File
@@ -988,7 +988,7 @@ public:
void SendToFixZ(float new_x, float new_y, float new_z);
float GetZOffset() const;
float GetDefaultRaceSize() const;
void FixZ(int32 z_find_offset = 5);
void FixZ(int32 z_find_offset = 5, bool fix_client_z = false);
float GetFixedZ(glm::vec3 destination, int32 z_find_offset = 5);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false);
+58 -24
View File
@@ -466,6 +466,7 @@ void NPC::AI_Init()
roambox_distance = 0;
roambox_destination_x = 0;
roambox_destination_y = 0;
roambox_destination_z = 0;
roambox_min_delay = 2500;
roambox_delay = 2500;
}
@@ -779,44 +780,50 @@ void Client::AI_Process()
}
}
if(RuleB(Combat, EnableFearPathing)){
if(currently_fleeing) {
if (RuleB(Combat, EnableFearPathing)) {
if (currently_fleeing) {
if (fix_z_timer_engaged.Check())
this->FixZ();
if (fix_z_timer.Check())
this->FixZ(5, true);
if(IsRooted()) {
if (IsRooted()) {
//make sure everybody knows were not moving, for appearance sake
if(IsMoving())
{
if(GetTarget())
if (IsMoving()) {
if (GetTarget())
SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
SetCurrentSpeed(0);
}
//continue on to attack code, ensuring that we execute the engaged code
engaged = true;
} else {
if(AI_movement_timer->Check()) {
}
else {
if (AI_movement_timer->Check()) {
int speed = GetFearSpeed();
animation = speed;
speed *= 2;
SetCurrentSpeed(speed);
// Check if we have reached the last fear point
if ((std::abs(GetX() - m_FearWalkTarget.x) < 0.1) &&
(std::abs(GetY() - m_FearWalkTarget.y) < 0.1)) {
(std::abs(GetY() - m_FearWalkTarget.y) < 0.1)) {
// Calculate a new point to run to
CalculateNewFearpoint();
}
if(!RuleB(Pathing, Fear) || !zone->pathing)
if (!RuleB(Pathing, Fear) || !zone->pathing)
CalculateNewPosition(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true);
else
{
bool WaypointChanged, NodeReached;
else {
bool waypoint_changed, node_reached;
glm::vec3 Goal = UpdatePath(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z,
speed, WaypointChanged, NodeReached);
glm::vec3 Goal = UpdatePath(
m_FearWalkTarget.x,
m_FearWalkTarget.y,
m_FearWalkTarget.z,
speed,
waypoint_changed,
node_reached
);
if(WaypointChanged)
if (waypoint_changed)
tar_ndx = 20;
CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed);
@@ -1136,8 +1143,12 @@ void Mob::AI_Process() {
bool WaypointChanged, NodeReached;
glm::vec3 Goal = UpdatePath(
m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z,
GetFearSpeed(), WaypointChanged, NodeReached
m_FearWalkTarget.x,
m_FearWalkTarget.y,
m_FearWalkTarget.z,
GetFearSpeed(),
WaypointChanged,
NodeReached
);
if (WaypointChanged)
@@ -1696,6 +1707,14 @@ void NPC::AI_DoMovement() {
(m_Position.z - 15)
);
/**
* If someone brought us into water when we naturally wouldn't path there, return to spawn
*/
if (zone->watermap->InLiquid(position) && zone->watermap->InLiquid(m_Position)) {
roambox_destination_x = m_SpawnPoint.x;
roambox_destination_y = m_SpawnPoint.y;
}
if (zone->watermap->InLiquid(position)) {
Log(Logs::Detail,
Logs::NPCRoamBox, "%s | My destination is in water and I don't belong there!",
@@ -1706,6 +1725,12 @@ void NPC::AI_DoMovement() {
}
}
glm::vec3 destination;
destination.x = roambox_destination_x;
destination.y = roambox_destination_y;
destination.z = m_Position.z;
roambox_destination_z = GetFixedZ(destination) + this->GetZOffset();
Log(Logs::Detail,
Logs::NPCRoamBox,
"Calculate | NPC: %s distance %.3f | min_x %.3f | max_x %.3f | final_x %.3f | min_y %.3f | max_y %.3f | final_y %.3f",
@@ -1719,11 +1744,20 @@ void NPC::AI_DoMovement() {
roambox_destination_y);
}
if (fix_z_timer.Check()) {
this->FixZ();
}
bool waypoint_changed, node_reached;
if (!CalculateNewPosition(roambox_destination_x, roambox_destination_y, m_Position.z, move_speed, true)) {
glm::vec3 Goal = UpdatePath(
roambox_destination_x,
roambox_destination_y,
roambox_destination_z,
move_speed,
waypoint_changed,
node_reached
);
CalculateNewPosition(Goal.x, Goal.y, Goal.z, move_speed, true);
if (m_Position.x == roambox_destination_x && m_Position.y == roambox_destination_y) {
time_until_can_move = Timer::GetCurrentTime() + RandomTimer(roambox_min_delay, roambox_delay);
SetMoving(false);
this->FixZ();
+1
View File
@@ -540,6 +540,7 @@ protected:
float roambox_distance;
float roambox_destination_x;
float roambox_destination_y;
float roambox_destination_z;
uint32 roambox_delay;
uint32 roambox_min_delay;
+2
View File
@@ -528,6 +528,8 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
if(cursordelete) // delete the item if it's a duplicate lore. We have to do this because the client expects the item packet
sender->DeleteItemInInventory(EQEmu::invslot::slotCursor);
sender->DropItemQS(m_inst, true);
if(!m_ground_spawn)
safe_delete(m_inst);
+22 -14
View File
@@ -793,26 +793,34 @@ float Mob::GetFixedZ(glm::vec3 destination, int32 z_find_offset) {
return new_z;
}
void Mob::FixZ(int32 z_find_offset /*= 5*/) {
void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
glm::vec3 current_loc(m_Position);
float new_z = GetFixedZ(current_loc, z_find_offset);
if (!IsClient() && new_z != m_Position.z) {
if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
if (RuleB(Map, MobZVisualDebug)) {
this->SendAppearanceEffect(78, 0, 0, 0, 0);
}
if (IsClient() && !fix_client_z)
return;
m_Position.z = new_z;
float new_z = GetFixedZ(current_loc, z_find_offset);
if (new_z == m_Position.z)
return;
if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
if (RuleB(Map, MobZVisualDebug)) {
this->SendAppearanceEffect(78, 0, 0, 0, 0);
}
else {
if (RuleB(Map, MobZVisualDebug)) {
this->SendAppearanceEffect(103, 0, 0, 0, 0);
}
Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f",
this->GetCleanName(), std::abs(m_Position.z - new_z));
m_Position.z = new_z;
}
else {
if (RuleB(Map, MobZVisualDebug)) {
this->SendAppearanceEffect(103, 0, 0, 0, 0);
}
Log(Logs::General,
Logs::FixZ,
"%s is failing to find Z %f",
this->GetCleanName(),
std::abs(m_Position.z - new_z));
}
}
+3 -3
View File
@@ -904,10 +904,10 @@ bool Zone::Init(bool iStaticZone) {
RuleManager::Instance()->LoadRules(&database, r_name.c_str());
}
}
zone->zonemap = Map::LoadMapFile(zone->map_name);
zone->zonemap = Map::LoadMapFile(zone->map_name);
zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name);
zone->pathing = IPathfinder::Load(zone->map_name);
zone->pathing = IPathfinder::Load(zone->map_name);
Log(Logs::General, Logs::Status, "Loading spawn conditions...");
if(!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) {