*Better method for choosing a random model on respawn (should no longer show opposite faction models)
*Attempt to make it so creatures: don't help players or units controlled or owned by players; and don't help if the unit is fleeing from the enemy player --HG-- branch : trunk
This commit is contained in:
+26
-17
@@ -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)
|
||||
{
|
||||
|
||||
+2
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user