Core/Misc: calculate rotation fields from orientation in some places it's impossible to get:

- SmartScripts: SMART_ACTION_SUMMON_GO
- Spell Effects:
  * SPELL_EFFECT_DUEL
  * SPELL_EFFECT_SUMMON_OBJECT_WILD
  * SPELL_EFFECT_SUMMON_OBJECT_SLOT1
  * SPELL_EFFECT_SUMMON_OBJECT_SLOT2
  * SPELL_EFFECT_SUMMON_OBJECT_SLOT3
  * SPELL_EFFECT_SUMMON_OBJECT_SLOT4
- Command Scripts: .gobject add

Closes #17891

(cherry picked from commit 14445d2202)
This commit is contained in:
ariel-
2016-09-03 22:30:51 +02:00
committed by joschiwald
parent dd0df772df
commit b239afb0ef
3 changed files with 19 additions and 17 deletions

View File

@@ -1305,7 +1305,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
continue;
Position pos = (*itr)->GetPositionWithOffset(Position(e.target.x, e.target.y, e.target.z, e.target.o));
GetBaseObject()->SummonGameObject(e.action.summonGO.entry, pos, G3D::Quat(), e.action.summonGO.despawnTime);
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(pos.GetOrientation(), 0.f, 0.f);
GetBaseObject()->SummonGameObject(e.action.summonGO.entry, pos, rot, e.action.summonGO.despawnTime);
}
delete targets;
@@ -1314,7 +1315,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (e.GetTargetType() != SMART_TARGET_POSITION)
break;
GetBaseObject()->SummonGameObject(e.action.summonGO.entry, Position(e.target.x, e.target.y, e.target.z, e.target.o), G3D::Quat(), e.action.summonGO.despawnTime);
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(e.target.o, 0.f, 0.f);
GetBaseObject()->SummonGameObject(e.action.summonGO.entry, Position(e.target.x, e.target.y, e.target.z, e.target.o), rot, e.action.summonGO.despawnTime);
break;
}
case SMART_ACTION_KILL_UNIT:

View File

@@ -3151,7 +3151,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
uint32 gameobject_id = effectInfo->MiscValue;
GameObject* pGameObj = new GameObject;
GameObject* pGameObj = new GameObject();
WorldObject* target = focusObject;
if (!target)
@@ -3165,7 +3165,8 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
Map* map = target->GetMap();
if (!pGameObj->Create(gameobject_id, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), G3D::Quat(), 255, GO_STATE_READY))
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(target->GetOrientation(), 0.f, 0.f);
if (!pGameObj->Create(gameobject_id, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), rot, 255, GO_STATE_READY))
{
delete pGameObj;
return;
@@ -3190,8 +3191,8 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
{
GameObject* linkedGO = new GameObject;
if (linkedGO->Create(linkedEntry, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), G3D::Quat(), 255, GO_STATE_READY))
GameObject* linkedGO = new GameObject();
if (linkedGO->Create(linkedEntry, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), rot, 255, GO_STATE_READY))
{
linkedGO->CopyPhaseFrom(m_caster);
@@ -3204,11 +3205,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
map->AddToMap(linkedGO);
}
else
{
delete linkedGO;
linkedGO = NULL;
return;
}
}
}
@@ -3793,7 +3790,8 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
};
Map* map = m_caster->GetMap();
if (!pGameObj->Create(gameobject_id, map, m_caster->GetPhaseMask(), pos, G3D::Quat(), 0, GO_STATE_READY))
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(pos.GetOrientation(), 0.f, 0.f);
if (!pGameObj->Create(gameobject_id, map, m_caster->GetPhaseMask(), pos, rot, 0, GO_STATE_READY))
{
delete pGameObj;
return;
@@ -4128,7 +4126,8 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
Map* map = m_caster->GetMap();
if (!go->Create(go_id, map, m_caster->GetPhaseMask(), Position(x, y, z, m_caster->GetOrientation()), G3D::Quat(), 255, GO_STATE_READY))
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(m_caster->GetOrientation(), 0.f, 0.f);
if (!go->Create(go_id, map, m_caster->GetPhaseMask(), Position(x, y, z, m_caster->GetOrientation()), rot, 255, GO_STATE_READY))
{
delete go;
return;

View File

@@ -118,10 +118,9 @@ public:
if (!objectId)
return false;
char* spawntimeSecs = strtok(NULL, " ");
const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
char* spawntimeSecs = strtok(nullptr, " ");
GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
if (!objectInfo)
{
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
@@ -141,8 +140,10 @@ public:
Player* player = handler->GetSession()->GetPlayer();
Map* map = player->GetMap();
GameObject* object = new GameObject;
if (!object->Create(objectInfo->entry, map, 0, *player, G3D::Quat(), 255, GO_STATE_READY))
GameObject* object = new GameObject();
G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(player->GetOrientation(), 0.f, 0.f);
if (!object->Create(objectInfo->entry, map, 0, *player, rot, 255, GO_STATE_READY))
{
delete object;
return false;