Rochet2 / TrinityCore

Rochet2's stuff for TC
https://rochet2.github.io
90 stars 143 forks source link

[7.2] DressNPC still working ? #52

Closed hoxton22 closed 7 years ago

hoxton22 commented 7 years ago

Description: Hey ! I don't know if i did something wrong or if dressnpc don't work well since 7.2

Current behaviour: Tell us what happens I apply the example sql file, and spawn the creature with ID 6 and i got this : http://img4.hostingpics.net/pics/547109WoWScrnShot042417153335.jpg

Expected behaviour: Tell us what should happen instead The model is white with all geosets activated instead of armored draenei female

Steps to reproduce the problem:

  1. Apply the example sql file
  2. .npc add 6 (ingame)

Branch(es): 7.2

TC hash/commit:
298d86d9f725241c8a628c554bfef671e200e052

TDB version:
7.2

Operating system:
win10 64bits

Rochet2 commented 7 years ago

Can you test if mirror image works? If it does not, then this should be fixed by TC. If it works, then either the patch needs some tweaking or your installation went wrong somehow.

hoxton22 commented 7 years ago

Yup ! this spell works fine and the target have my stuff and my look http://www.wowhead.com/spell=69828/halls-of-reflection-clone

Rochet2 commented 7 years ago

I tested http://www.wowhead.com/spell=55342/mirror-image and it is not functional The spell you mention uses mirror image packets through and seems to work.

I tried using the packets from the spell 69828 on the spawned NPC, but they did not work. There seems to be something missing, like a flag or something on the NPC, however I cannot see where this change is at.

Need to investigate more and maybe see if TC has changed something related to this - but not today.

hoxton22 commented 7 years ago

Ok ok take your time and thank you :)

Rochet2 commented 7 years ago

Seems that it works only if the UNIT_FLAG2_MIRROR_IMAGE flag is applied to the created NPC only some time after spawning. The NPC model may need to initially be something different than the outfit model.

One solution could be to set a timer on creature create to set the flag and model, but Im not too sure how good that is and it introduces artificial lag. Would be good to wait for some kind of fix to the mirror image spell (By TC etc), since that essentially does the same as this core modification:

The spells that just copy the looks work a bit differently since they can simply set the flag and the model - they completely avoid the issue that having them on when the creature is created will screw up.

I think later this week I may look into making some kind of fix to apply the flags after spawn however.

hoxton22 commented 7 years ago

Ok thank you for this informations and good luck with this !

btw, it is possible to create a script with a function onLoad ? A function used on a npc just after his spawn ?

Rochet2 commented 7 years ago

btw, it is possible to create a script with a function onLoad ? A function used on a npc just after his spawn ?

What does spawning mean though? Respawning? or just the initial spawn when the NPC is first created? You may try to use these for example: https://github.com/TrinityCore/TrinityCore/blob/e941d7e04b41e9f7236db6981b7ddb1d071453ea/src/server/game/AI/CreatureAI.h#L150-L151 https://github.com/TrinityCore/TrinityCore/blob/f097e341f5afcac2dd0ae9dbb265201c0de2a934/src/server/game/AI/CoreAI/UnitAI.h#L130-L132

Initialize AI is probably only when the AI is first made on the initial spawn. JustRespawned should trigger on spawn (and respawn) and reset is called on many occasions when the AI should be reset to default state.

hoxton22 commented 7 years ago

It seems a dirty fix but it could work for the moment

Adding a script for each npc with dressnpc script, will check this tomorrow

Rochet2 commented 7 years ago

I think I have a solution. I will push it soonish.

Rochet2 commented 7 years ago

The way it is now handled is that initially the NPCs have invisible displayid. A timed event is scheduled to be right on next update after spawn and this will change the modelid and apply the mirror image flag on the NPC.

Upon respawning and changing modelids the mirror image flag should be removed. When applying some outfit again, the outfit should be set with SetOutfit followed by new MirrorImageUpdate(creature);

hoxton22 commented 7 years ago

It works fine ! Thank you very much for your script and for the really really fast fix u did !

By the way, i have edited ur script by adding a field 'guild' between feature3 and head, for giving npc tabard based on an existing guild for players

i made a diff with patchworking 2 diff, i don't know if it works but you can see here : https://ghostbin.com/paste/3qo8t, if you want to integrate it or modifying it (the guildpacket part is probably not clean, as i'm not a c++ dev, and i you wonder why, the packet must be send to the player, otherwise there are no guilds informations when you see the npc and the tabard is empty, it only work if u first see a player of the guild before looking at the npc ) or even if you are curious about it !

Thanks again for ur fix =)

Rochet2 commented 6 years ago

Added the guildid thing in https://github.com/Rochet2/TrinityCore/commit/31e5de9988c5419ed6b1d9398f1090273dabce77