mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[10296] Move ChooseDisplayId to Creature class for access from script side
Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
181428e132
commit
7bdf05901d
8 changed files with 62 additions and 60 deletions
|
|
@ -229,7 +229,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
// known valid are: CLASS_WARRIOR,CLASS_PALADIN,CLASS_ROGUE,CLASS_MAGE
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
|
||||
|
||||
uint32 display_id = sObjectMgr.ChooseDisplayId(team, GetCreatureInfo(), data);
|
||||
uint32 display_id = ChooseDisplayId(team, GetCreatureInfo(), data);
|
||||
if (!display_id) // Cancel load if no display id
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u) has no model defined in table `creature_template`, can't load.", Entry);
|
||||
|
|
@ -346,6 +346,57 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data,
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32 Creature::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data /*= NULL*/)
|
||||
{
|
||||
// Use creature model explicit, override template (creature.modelid)
|
||||
if (data && data->modelid_override)
|
||||
return data->modelid_override;
|
||||
|
||||
// use defaults from the template
|
||||
uint32 display_id = 0;
|
||||
|
||||
// models may be categorized as (in this order):
|
||||
// if mod4 && mod3 && mod2 && mod1 use any, by 25%-chance (other gender is selected and replaced after this function)
|
||||
// if mod3 && mod2 && mod1 use mod3 unless mod2 has modelid_alt_model (then all by 33%-chance)
|
||||
// if mod2 use mod2 unless mod2 has modelid_alt_model (then both by 50%-chance)
|
||||
// if mod1 use mod1
|
||||
|
||||
// model selected here may be replaced with other_gender using own function
|
||||
|
||||
if (cinfo->ModelId[3] && cinfo->ModelId[2] && cinfo->ModelId[1] && cinfo->ModelId[0])
|
||||
{
|
||||
display_id = cinfo->ModelId[urand(0,3)];
|
||||
}
|
||||
else if (cinfo->ModelId[2] && cinfo->ModelId[1] && cinfo->ModelId[0])
|
||||
{
|
||||
uint32 modelid_tmp = sObjectMgr.GetCreatureModelAlternativeModel(cinfo->ModelId[1]);
|
||||
display_id = modelid_tmp ? cinfo->ModelId[urand(0,2)] : cinfo->ModelId[2];
|
||||
}
|
||||
else if (cinfo->ModelId[1])
|
||||
{
|
||||
// We use this to eliminate invisible models vs. "dummy" models (infernals, etc).
|
||||
// Where it's expected to select one of two, model must have a alternative model defined (alternative model is normally the same as defined in ModelId1).
|
||||
// Same pattern is used in the above model selection, but the result may be ModelId3 and not ModelId2 as here.
|
||||
uint32 modelid_tmp = sObjectMgr.GetCreatureModelAlternativeModel(cinfo->ModelId[1]);
|
||||
display_id = modelid_tmp ? modelid_tmp : cinfo->ModelId[1];
|
||||
}
|
||||
else if (cinfo->ModelId[0])
|
||||
{
|
||||
display_id = cinfo->ModelId[0];
|
||||
}
|
||||
|
||||
// fail safe, we use creature entry 1 and make error
|
||||
if (!display_id)
|
||||
{
|
||||
sLog.outErrorDb("Call customer support, ChooseDisplayId can not select native model for creature entry %u, model from creature entry 1 will be used instead.", cinfo->Entry);
|
||||
|
||||
if (const CreatureInfo *creatureDefault = sObjectMgr.GetCreatureTemplate(1))
|
||||
display_id = creatureDefault->ModelId[0];
|
||||
}
|
||||
|
||||
return display_id;
|
||||
}
|
||||
|
||||
void Creature::Update(uint32 diff)
|
||||
{
|
||||
if(m_GlobalCooldown <= diff)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue