mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-16 01:01:30 +00:00
[Door Opening] Rule to let configure Animal Door Opening (#1231)
* Add rule configuration for letting animals open doors or not * Handle one more spot * Make adjustments and add mob property that serves as a check as to whether a mob entity can open doors or not * Push attribute to mob window
This commit is contained in:
parent
672c09ee11
commit
694d380e66
@ -531,6 +531,7 @@ RULE_INT(NPC, NPCGateDistanceBind, 75, "Distance from bind before NPC will attem
|
|||||||
RULE_BOOL(NPC, NPCHealOnGate, true, "Will the NPC Heal on Gate")
|
RULE_BOOL(NPC, NPCHealOnGate, true, "Will the NPC Heal on Gate")
|
||||||
RULE_BOOL(NPC, UseMeditateBasedManaRegen, false, "Based NPC ooc regen on Meditate skill")
|
RULE_BOOL(NPC, UseMeditateBasedManaRegen, false, "Based NPC ooc regen on Meditate skill")
|
||||||
RULE_REAL(NPC, NPCHealOnGateAmount, 25, "How much the NPC will heal on gate if enabled")
|
RULE_REAL(NPC, NPCHealOnGateAmount, 25, "How much the NPC will heal on gate if enabled")
|
||||||
|
RULE_BOOL(NPC, AnimalsOpenDoors, true, "Determines or not whether animals open doors or not when they approach them")
|
||||||
RULE_CATEGORY_END()
|
RULE_CATEGORY_END()
|
||||||
|
|
||||||
RULE_CATEGORY(Aggro)
|
RULE_CATEGORY(Aggro)
|
||||||
|
|||||||
@ -3604,18 +3604,21 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 hate)
|
|||||||
|
|
||||||
void EntityList::OpenDoorsNear(Mob *who)
|
void EntityList::OpenDoorsNear(Mob *who)
|
||||||
{
|
{
|
||||||
|
if (!who->CanOpenDoors()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = door_list.begin();it != door_list.end(); ++it) {
|
for (auto &it : door_list) {
|
||||||
Doors *cdoor = it->second;
|
Doors *door = it.second;
|
||||||
if (!cdoor || cdoor->IsDoorOpen())
|
if (!door || door->IsDoorOpen()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto diff = who->GetPosition() - cdoor->GetPosition();
|
auto diff = who->GetPosition() - door->GetPosition();
|
||||||
|
float distance = diff.x * diff.x + diff.y * diff.y;
|
||||||
float curdist = diff.x * diff.x + diff.y * diff.y;
|
if (diff.z * diff.z < 10 && distance <= 100) {
|
||||||
|
door->Open(who);
|
||||||
if (diff.z * diff.z < 10 && curdist <= 100)
|
}
|
||||||
cdoor->Open(who);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
zone/mob.cpp
12
zone/mob.cpp
@ -464,6 +464,8 @@ Mob::Mob(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mob_close_scan_timer.Trigger();
|
mob_close_scan_timer.Trigger();
|
||||||
|
|
||||||
|
SetCanOpenDoors(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mob::~Mob()
|
Mob::~Mob()
|
||||||
@ -5960,3 +5962,13 @@ float Mob::HealRotationExtendedHealFrequency()
|
|||||||
return m_target_of_heal_rotation->ExtendedHealFrequency(this);
|
return m_target_of_heal_rotation->ExtendedHealFrequency(this);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool Mob::CanOpenDoors() const
|
||||||
|
{
|
||||||
|
return m_can_open_doors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mob::SetCanOpenDoors(bool can_open)
|
||||||
|
{
|
||||||
|
m_can_open_doors = can_open;
|
||||||
|
}
|
||||||
|
|||||||
@ -1194,6 +1194,9 @@ public:
|
|||||||
int32 GetHPRegen() const;
|
int32 GetHPRegen() const;
|
||||||
int32 GetManaRegen() const;
|
int32 GetManaRegen() const;
|
||||||
|
|
||||||
|
bool CanOpenDoors() const;
|
||||||
|
void SetCanOpenDoors(bool can_open);
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
// Bots HealRotation methods
|
// Bots HealRotation methods
|
||||||
@ -1587,12 +1590,15 @@ protected:
|
|||||||
AuraMgr aura_mgr;
|
AuraMgr aura_mgr;
|
||||||
AuraMgr trap_mgr;
|
AuraMgr trap_mgr;
|
||||||
|
|
||||||
|
bool m_can_open_doors;
|
||||||
|
|
||||||
MobMovementManager *mMovementManager;
|
MobMovementManager *mMovementManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _StopSong(); //this is not what you think it is
|
void _StopSong(); //this is not what you think it is
|
||||||
Mob* target;
|
Mob* target;
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
std::shared_ptr<HealRotation> m_target_of_heal_rotation;
|
std::shared_ptr<HealRotation> m_target_of_heal_rotation;
|
||||||
|
|
||||||
|
|||||||
@ -442,7 +442,11 @@ void Mob::AI_Start(uint32 iMoveDelay) {
|
|||||||
AI_movement_timer = std::unique_ptr<Timer>(new Timer(AImovement_duration));
|
AI_movement_timer = std::unique_ptr<Timer>(new Timer(AImovement_duration));
|
||||||
AI_target_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
|
AI_target_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
|
||||||
AI_feign_remember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
|
AI_feign_remember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
|
||||||
AI_scan_door_open_timer = std::unique_ptr<Timer>(new Timer(AI_scan_door_open_interval));
|
AI_scan_door_open_timer = std::make_unique<Timer>(AI_scan_door_open_interval);
|
||||||
|
|
||||||
|
if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) {
|
||||||
|
SetCanOpenDoors(false);
|
||||||
|
}
|
||||||
|
|
||||||
if(!RuleB(Aggro, NPCAggroMaxDistanceEnabled)) {
|
if(!RuleB(Aggro, NPCAggroMaxDistanceEnabled)) {
|
||||||
hate_list_cleanup_timer.Disable();
|
hate_list_cleanup_timer.Disable();
|
||||||
@ -978,23 +982,25 @@ void Mob::AI_Process() {
|
|||||||
engaged = false;
|
engaged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moving) {
|
if (moving && CanOpenDoors()) {
|
||||||
if (AI_scan_door_open_timer->Check()) {
|
if (AI_scan_door_open_timer->Check()) {
|
||||||
|
|
||||||
auto &door_list = entity_list.GetDoorsList();
|
auto &door_list = entity_list.GetDoorsList();
|
||||||
for (auto itr : door_list) {
|
for (auto itr : door_list) {
|
||||||
Doors *door = itr.second;
|
Doors *door = itr.second;
|
||||||
|
|
||||||
if (door->GetKeyItem())
|
if (door->GetKeyItem()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (door->GetLockpick())
|
if (door->GetLockpick()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (door->IsDoorOpen())
|
if (door->IsDoorOpen()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
float distance = DistanceSquared(this->m_Position, door->GetPosition());
|
float distance = DistanceSquared(m_Position, door->GetPosition());
|
||||||
float distance_scan_door_open = 20;
|
float distance_scan_door_open = 20;
|
||||||
|
|
||||||
if (distance <= (distance_scan_door_open * distance_scan_door_open)) {
|
if (distance <= (distance_scan_door_open * distance_scan_door_open)) {
|
||||||
@ -1003,8 +1009,9 @@ void Mob::AI_Process() {
|
|||||||
* Make sure we're opening a door within height relevance and not platforms
|
* Make sure we're opening a door within height relevance and not platforms
|
||||||
* above or below
|
* above or below
|
||||||
*/
|
*/
|
||||||
if (std::abs(this->m_Position.z - door->GetPosition().z) > 10)
|
if (std::abs(this->m_Position.z - door->GetPosition().z) > 10) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
door->ForceOpen(this);
|
door->ForceOpen(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -225,6 +225,10 @@ inline std::string GetMobAttributeByString(Mob *mob, const std::string &attribut
|
|||||||
return std::to_string(mob->GetMaxBuffSlots());
|
return std::to_string(mob->GetMaxBuffSlots());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attribute == "can_open_doors") {
|
||||||
|
return std::to_string(mob->CanOpenDoors());
|
||||||
|
}
|
||||||
|
|
||||||
if (attribute == "curbuffslots") {
|
if (attribute == "curbuffslots") {
|
||||||
return std::to_string(mob->GetCurrentBuffSlots());
|
return std::to_string(mob->GetCurrentBuffSlots());
|
||||||
}
|
}
|
||||||
@ -770,6 +774,7 @@ void Mob::DisplayInfo(Mob *mob)
|
|||||||
"spells_id",
|
"spells_id",
|
||||||
"curbuffslots",
|
"curbuffslots",
|
||||||
"maxbuffslots",
|
"maxbuffslots",
|
||||||
|
"can_open_doors",
|
||||||
};
|
};
|
||||||
|
|
||||||
window_text += WriteDisplayInfoSection(mob, "NPC Attributes", npc_attributes, 1, true);
|
window_text += WriteDisplayInfoSection(mob, "NPC Attributes", npc_attributes, 1, true);
|
||||||
|
|||||||
@ -409,6 +409,11 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
|
|||||||
AISpellVar.idle_no_sp_recast_min = static_cast<uint32>(RuleI(Spells, AI_IdleNoSpellMinRecast));
|
AISpellVar.idle_no_sp_recast_min = static_cast<uint32>(RuleI(Spells, AI_IdleNoSpellMinRecast));
|
||||||
AISpellVar.idle_no_sp_recast_max = static_cast<uint32>(RuleI(Spells, AI_IdleNoSpellMaxRecast));
|
AISpellVar.idle_no_sp_recast_max = static_cast<uint32>(RuleI(Spells, AI_IdleNoSpellMaxRecast));
|
||||||
AISpellVar.idle_beneficial_chance = static_cast<uint8> (RuleI(Spells, AI_IdleBeneficialChance));
|
AISpellVar.idle_beneficial_chance = static_cast<uint8> (RuleI(Spells, AI_IdleBeneficialChance));
|
||||||
|
|
||||||
|
if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) {
|
||||||
|
m_can_open_doors = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float NPC::GetRoamboxMaxX() const
|
float NPC::GetRoamboxMaxX() const
|
||||||
|
|||||||
@ -643,7 +643,6 @@ private:
|
|||||||
bool skip_global_loot;
|
bool skip_global_loot;
|
||||||
bool skip_auto_scale;
|
bool skip_auto_scale;
|
||||||
bool p_depop;
|
bool p_depop;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user