ElunaLuaEngine / Eluna

Eluna Lua Engine © for WoW Emulators
https://elunaluaengine.github.io
GNU General Public License v3.0
369 stars 355 forks source link

[Bug] UNIT_FIELD_FLAG_IMMUNE_TO_NPC causes creature to not attack #366

Open tikki100 opened 3 years ago

tikki100 commented 3 years ago

Hi there!

TrinityCore here.

When setting a creatures unit_flags in either creature_template to 512 or through pUnit:SetUInt32Value(59, 512) the creature no longer attacks players. Instead, it just stands passively and takes damage.

When the creature is immune to NPC, it is supposed to ignore all NPCs around it but not players. My best bet is that this is caused by an error in the Eluna AI

local function Brain_GhoulOnSpawn(event, pUnit)
    pUnit:SetUInt32Value(59, 512)
    pUnit:SendUnitSay("Spawned",0)
end

RegisterCreatureEvent(50302, 5,Brain_GhoulOnSpawn)
anzz1 commented 2 years ago

This is not a Eluna issue but a core issue. That function you do just calls the core to set unit's flags and the core handles it from there onwards. Eluna does not have an "AI" by itself.

Rochet2 commented 2 years ago

Eluna does not have an "AI" by itself.

Not entirely true. As it is now, registering a creature event will override the creature's AI with Eluna specific C++ AI class that has the hooks for different events. So it is possible that the Eluna AI class needs to be modified / updated if the AI handles the interactions. See https://github.com/ElunaLuaEngine/Eluna/blob/master/ElunaCreatureAI.h Moving away from the AI class would be nice though.

Need to investigate more on what is the default behavior and if eluna affects that. It is possible that the core should just handle it. But its also possible that the AI class Eluna uses is bypassing that check for example.

Foereaper commented 3 months ago

We're currently not updating the AI of the creature at all when the immune to npc flag is set. Logic needs to be revised, or like rochet said, possibly remove the AI class entirely.