[11222] Move possition setup for Creature and subclases before Create call.

Some called from Create code can req. proper pos setup for creature.
Bad side: But in way how currently code orginized impossible setup excetly position for most
Creature sublasses. So in this part need more work.
This commit is contained in:
VladimirMangos 2011-03-06 12:08:55 +03:00
parent c132e54f73
commit 51b4556c4b
7 changed files with 171 additions and 105 deletions

View file

@ -4479,6 +4479,21 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
return;
}
// Summon in dest location
float x, y, z;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
else
// FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position
// if totem have creature_template_addon.auras with persistent point for example or script call
m_caster->GetClosePoint(x, y, z, 0);
spawnCreature->Relocate(x, y, z, -m_caster->GetOrientation());
Map *map = m_caster->GetMap();
uint32 pet_number = sObjectMgr.GeneratePetNumber();
if (!spawnCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(),
@ -4489,18 +4504,12 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
return;
}
// Summon in dest location
float x, y, z;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
if (!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
{
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
else
m_caster->GetClosePoint(x, y, z, spawnCreature->GetObjectBoundingRadius());
spawnCreature->Relocate(x, y, z, -m_caster->GetOrientation());
}
spawnCreature->Relocate(x, y, z, -m_caster->GetOrientation());
spawnCreature->SetSummonPoint(x, y, z, -m_caster->GetOrientation());
if (!spawnCreature->IsPositionValid())
@ -4940,16 +4949,6 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
{
Pet* spawnCreature = new Pet(petType);
Map *map = m_caster->GetMap();
uint32 pet_number = sObjectMgr.GeneratePetNumber();
if (!spawnCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[eff_idx], pet_number))
{
sLog.outError("no such creature entry %u", m_spellInfo->EffectMiscValue[eff_idx]);
delete spawnCreature;
return;
}
float px, py, pz;
// If dest location if present
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
@ -4967,9 +4966,29 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
}
// Summon if dest location not present near caster
else
m_caster->GetClosePoint(px, py, pz,spawnCreature->GetObjectBoundingRadius());
// FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position
// if totem have creature_template_addon.auras with persistent point for example or script call
m_caster->GetClosePoint(px, py, pz, 0);
spawnCreature->Relocate(px, py, pz, m_caster->GetOrientation());
Map *map = m_caster->GetMap();
uint32 pet_number = sObjectMgr.GeneratePetNumber();
if (!spawnCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[eff_idx], pet_number))
{
sLog.outError("no such creature entry %u", m_spellInfo->EffectMiscValue[eff_idx]);
delete spawnCreature;
return;
}
// Summon if dest location not present near caster
if (!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
{
m_caster->GetClosePoint(px, py, pz,spawnCreature->GetObjectBoundingRadius());
spawnCreature->Relocate(px, py, pz, m_caster->GetOrientation());
}
spawnCreature->SetSummonPoint(px, py, pz, m_caster->GetOrientation());
if (!spawnCreature->IsPositionValid())
@ -5427,6 +5446,14 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx)
return;
}
// FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position
// if totem have creature_template_addon.auras with persistent point for example or script call
float px, py, pz;
m_caster->GetClosePoint(px, py, pz, 0);
NewSummon->Relocate(px, py, pz, m_caster->GetOrientation());
Map *map = m_caster->GetMap();
uint32 pet_number = sObjectMgr.GeneratePetNumber();
if(!NewSummon->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(),
@ -5436,7 +5463,6 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx)
return;
}
float px, py, pz;
m_caster->GetClosePoint(px, py, pz, NewSummon->GetObjectBoundingRadius());
NewSummon->Relocate(px, py, pz, m_caster->GetOrientation());
@ -7578,6 +7604,19 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
Totem* pTotem = new Totem;
// FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position
// if totem have creature_template_addon.auras with persistent point for example or script call
float angle = slot < MAX_TOTEM_SLOT ? M_PI_F/MAX_TOTEM_SLOT - (slot*2*M_PI_F/MAX_TOTEM_SLOT) : 0;
float x, y, z;
m_caster->GetClosePoint(x, y, z, 0, 2.0f, angle);
// totem must be at same Z in case swimming caster and etc.
if (fabs( z - m_caster->GetPositionZ() ) > 5)
z = m_caster->GetPositionZ();
pTotem->Relocate(x, y, z, m_caster->GetOrientation());
if (!pTotem->Create(m_caster->GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[eff_idx], team))
{
@ -7592,9 +7631,6 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
pTotem->SetDisplayId(modelid_race);
}
float angle = slot < MAX_TOTEM_SLOT ? M_PI_F/MAX_TOTEM_SLOT - (slot*2*M_PI_F/MAX_TOTEM_SLOT) : 0;
float x, y, z;
m_caster->GetClosePoint(x, y, z, pTotem->GetObjectBoundingRadius(), 2.0f, angle);
// totem must be at same Z in case swimming caster and etc.
@ -8081,6 +8117,21 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction)
// summon new pet
Pet* critter = new Pet(MINI_PET);
float x, y, z;
// If dest location if present
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
else
// FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position
// if pet have creature_template_addon.auras with persistent point for example or script call
m_caster->GetClosePoint(x, y, z, 0);
critter->Relocate(x, y, z, m_caster->GetOrientation());
Map *map = m_caster->GetMap();
uint32 pet_number = sObjectMgr.GeneratePetNumber();
if(!critter->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(),
@ -8091,19 +8142,12 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction)
return;
}
float x, y, z;
// If dest location if present
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
// Summon if dest location not present near caster
if (!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
{
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
// Summon if dest location not present near caster
else
m_caster->GetClosePoint(x, y, z, critter->GetObjectBoundingRadius());
critter->Relocate(x, y, z, m_caster->GetOrientation());
critter->Relocate(x, y, z, m_caster->GetOrientation());
}
critter->SetSummonPoint(x, y, z, m_caster->GetOrientation());
if(!critter->IsPositionValid())