aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Creature.cpp43
-rw-r--r--src/game/Creature.h5
2 files changed, 28 insertions, 20 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index b2261bb4b8d..218d24f060c 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -88,21 +88,6 @@ 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
{
uint8 c = 0;
@@ -740,7 +725,15 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
break;
}
LoadCreaturesAddon();
- SetDisplayId(GetCreatureInfo()->GetRandomValidModelIdIncludingNativeId(GetNativeDisplayId()));
+ CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(GetNativeDisplayId());
+ if (minfo) // Cancel load if no model defined
+ {
+ uint32 display_id = minfo->modelid; // it can be different (for another gender)
+
+ SetDisplayId(display_id);
+ SetNativeDisplayId(display_id);
+ SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
+ }
}
return bResult;
}
@@ -1861,7 +1854,15 @@ void Creature::Respawn(bool force)
else
setDeathState( JUST_ALIVED );
- SetDisplayId(cinfo->GetRandomValidModelIdIncludingNativeId(GetNativeDisplayId()));
+ CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(GetNativeDisplayId());
+ if (minfo) // Cancel load if no model defined
+ {
+ uint32 display_id = minfo->modelid; // it can be different (for another gender)
+
+ SetDisplayId(display_id);
+ SetNativeDisplayId(display_id);
+ SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
+ }
//Call AI respawn virtual function
AI()->JustRespawned();
@@ -2141,6 +2142,14 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
if (GetCharmerOrOwnerGUID())
return false;
+ // don't help players or units controlled or owned by players
+ if (u->GetCharmerOrOwnerPlayerOrPlayerItself())
+ return false;
+
+ // don't help if the unit is fleeing from the enemy player
+ if (!u->isAttackingPlayer() && enemy->GetTypeId() == TYPEID_PLAYER)
+ return false;
+
// only from same creature faction
if (checkfaction)
{
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 781de31b049..bfe9709e081 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -236,9 +236,8 @@ struct CreatureInfo
uint32 MechanicImmuneMask;
uint32 flags_extra;
uint32 ScriptID;
- uint32 GetRandomValidModelIdIncludingNativeId(uint32 native_id) const;
- uint32 GetRandomValidModelId() const;
- uint32 GetFirstValidModelId() const;
+ uint32 GetRandomValidModelId() const;
+ uint32 GetFirstValidModelId() const;
// helpers
SkillType GetRequiredLootSkill() const