diff options
Diffstat (limited to 'src/game/Creature.cpp')
-rw-r--r-- | src/game/Creature.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index dda642c9504..8b55c9da616 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -88,9 +88,24 @@ VendorItem const* VendorItemData::FindItem(uint32 item_id) const return NULL; } +uint32 CreatureInfo::GetRandomValidModelIdIncludingNativeId(uint32 native_id) const +{ + uint8 c = 0; + uint32 modelIDs[5]; + + if (Modelid1) modelIDs[c++] = Modelid1; + if (Modelid2) modelIDs[c++] = Modelid2; + if (Modelid3) modelIDs[c++] = Modelid3; + if (Modelid4) modelIDs[c++] = Modelid4; + if (native_id != Modelid1 && native_id != Modelid2 + && native_id != Modelid3 && native_id != Modelid4) modelIDs[c++] = native_id; + + return ((c>0) ? modelIDs[urand(0,c-1)] : 0); +} + uint32 CreatureInfo::GetRandomValidModelId() const { - uint32 c = 0; + uint8 c = 0; uint32 modelIDs[4]; if (Modelid1) modelIDs[c++] = Modelid1; @@ -724,7 +739,7 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, } LoadCreaturesAddon(); } - SetDisplayId(GetCreatureInfo()->GetRandomValidModelId()); + SetDisplayId(GetCreatureInfo()->GetRandomValidModelIdIncludingNativeId(GetNativeDisplayId())); return bResult; } @@ -1844,7 +1859,7 @@ void Creature::Respawn(bool force) else setDeathState( JUST_ALIVED ); - SetDisplayId(cinfo->GetRandomValidModelId()); + SetDisplayId(cinfo->GetRandomValidModelIdIncludingNativeId(GetNativeDisplayId())); //Call AI respawn virtual function AI()->JustRespawned(); |