[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:
Chris Miles
2021-02-07 19:52:58 -06:00
committed by GitHub
parent 672c09ee11
commit 694d380e66
8 changed files with 82 additions and 44 deletions
+12 -9
View File
@@ -3604,18 +3604,21 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 hate)
void EntityList::OpenDoorsNear(Mob *who)
{
if (!who->CanOpenDoors()) {
return;
}
for (auto it = door_list.begin();it != door_list.end(); ++it) {
Doors *cdoor = it->second;
if (!cdoor || cdoor->IsDoorOpen())
for (auto &it : door_list) {
Doors *door = it.second;
if (!door || door->IsDoorOpen()) {
continue;
}
auto diff = who->GetPosition() - cdoor->GetPosition();
float curdist = diff.x * diff.x + diff.y * diff.y;
if (diff.z * diff.z < 10 && curdist <= 100)
cdoor->Open(who);
auto diff = who->GetPosition() - door->GetPosition();
float distance = diff.x * diff.x + diff.y * diff.y;
if (diff.z * diff.z < 10 && distance <= 100) {
door->Open(who);
}
}
}