mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7489] Update gameobject rotation fields if need.
* Fixed update absent in ".gobject turn" command * Propetly set rotation fields for summoned objects * Check rotation/coordinates fields values at server loading
This commit is contained in:
parent
071a24562a
commit
7589bf7263
6 changed files with 54 additions and 45 deletions
|
|
@ -121,28 +121,11 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
|
||||||
SetFloatValue(GAMEOBJECT_POS_X, x);
|
SetFloatValue(GAMEOBJECT_POS_X, x);
|
||||||
SetFloatValue(GAMEOBJECT_POS_Y, y);
|
SetFloatValue(GAMEOBJECT_POS_Y, y);
|
||||||
SetFloatValue(GAMEOBJECT_POS_Z, z);
|
SetFloatValue(GAMEOBJECT_POS_Z, z);
|
||||||
SetFloatValue(GAMEOBJECT_FACING, ang); //this is not facing angle
|
|
||||||
|
|
||||||
int64 rotation = 0;
|
|
||||||
|
|
||||||
double f_rot1 = sin(ang / 2.0f);
|
|
||||||
int64 i_rot1 = int64(f_rot1 / atan(pow(2.0f, -20.0f)));
|
|
||||||
rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
|
|
||||||
|
|
||||||
//float f_rot2 = sin(0.0f / 2.0f);
|
|
||||||
//int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f));
|
|
||||||
//rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000;
|
|
||||||
|
|
||||||
//float f_rot3 = sin(0.0f / 2.0f);
|
|
||||||
//int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f));
|
|
||||||
//rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000;
|
|
||||||
|
|
||||||
SetUInt64Value(GAMEOBJECT_ROTATION, rotation);
|
|
||||||
|
|
||||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0);
|
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0);
|
||||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1);
|
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1);
|
||||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
|
|
||||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
|
UpdateRotationFields(rotation2,rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3
|
||||||
|
|
||||||
SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size);
|
SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size);
|
||||||
|
|
||||||
|
|
@ -1317,3 +1300,25 @@ const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const
|
||||||
|
|
||||||
return GetName();
|
return GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 /*=0.0f*/)
|
||||||
|
{
|
||||||
|
SetFloatValue(GAMEOBJECT_FACING, GetOrientation());
|
||||||
|
|
||||||
|
int64 rotation = 0;
|
||||||
|
|
||||||
|
double f_rot1 = sin(GetOrientation() / 2.0f);
|
||||||
|
int64 i_rot1 = int64(f_rot1 / atan(pow(2.0f, -20.0f)));
|
||||||
|
rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
|
||||||
|
|
||||||
|
SetUInt64Value(GAMEOBJECT_ROTATION, rotation);
|
||||||
|
|
||||||
|
if(rotation2==0.0f && rotation3==0.0f)
|
||||||
|
{
|
||||||
|
rotation2 = sin(GetOrientation()/2);
|
||||||
|
rotation3 = cos(GetOrientation()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
|
||||||
|
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -441,6 +441,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
|
||||||
|
|
||||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||||
|
|
||||||
|
void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f);
|
||||||
|
|
||||||
void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
|
void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
|
||||||
void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
|
void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
|
||||||
void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
|
void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
|
||||||
|
|
|
||||||
|
|
@ -1787,17 +1787,11 @@ bool ChatHandler::HandleTurnObjectCommand(const char* args)
|
||||||
o = chr->GetOrientation();
|
o = chr->GetOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
float rot2 = sin(o/2);
|
|
||||||
float rot3 = cos(o/2);
|
|
||||||
|
|
||||||
Map* map = obj->GetMap();
|
Map* map = obj->GetMap();
|
||||||
map->Remove(obj,false);
|
map->Remove(obj,false);
|
||||||
|
|
||||||
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
|
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
|
||||||
|
obj->UpdateRotationFields();
|
||||||
obj->SetFloatValue(GAMEOBJECT_FACING, o);
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rot2);
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rot3);
|
|
||||||
|
|
||||||
map->Add(obj);
|
map->Add(obj);
|
||||||
|
|
||||||
|
|
@ -3660,13 +3654,10 @@ bool ChatHandler::HandleGameObjectCommand(const char* args)
|
||||||
float o = float(chr->GetOrientation());
|
float o = float(chr->GetOrientation());
|
||||||
Map *map = chr->GetMap();
|
Map *map = chr->GetMap();
|
||||||
|
|
||||||
float rot2 = sin(o/2);
|
|
||||||
float rot3 = cos(o/2);
|
|
||||||
|
|
||||||
GameObject* pGameObj = new GameObject;
|
GameObject* pGameObj = new GameObject;
|
||||||
uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||||
|
|
||||||
if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0, 0, rot2, rot3, 0, 1))
|
if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1075,6 +1075,24 @@ void ObjectMgr::LoadGameobjects()
|
||||||
int16 gameEvent = fields[16].GetInt16();
|
int16 gameEvent = fields[16].GetInt16();
|
||||||
int16 PoolId = fields[17].GetInt16();
|
int16 PoolId = fields[17].GetInt16();
|
||||||
|
|
||||||
|
if(data.rotation2 < -1.0f || data.rotation2 > 1.0f)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation2 (%f) value, skip",guid,data.id,data.rotation2 );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.rotation3 < -1.0f || data.rotation3 > 1.0f)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation3 (%f) value, skip",guid,data.id,data.rotation3 );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!MapManager::IsValidMapCoord(data.mapid,data.posX,data.posY,data.posZ,data.orientation))
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid coordinates, skip",guid,data.id );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(data.phaseMask==0)
|
if(data.phaseMask==0)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id );
|
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id );
|
||||||
|
|
|
||||||
|
|
@ -793,7 +793,7 @@ void Spell::EffectDummy(uint32 i)
|
||||||
// create before death for get proper coordinates
|
// create before death for get proper coordinates
|
||||||
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(),
|
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(),
|
||||||
creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(),
|
creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(),
|
||||||
creatureTarget->GetOrientation(), 0, 0, 0, 0, 100, 1) )
|
creatureTarget->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1) )
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -4587,7 +4587,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
|
||||||
Map *map = target->GetMap();
|
Map *map = target->GetMap();
|
||||||
|
|
||||||
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map,
|
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map,
|
||||||
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1))
|
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -4635,7 +4635,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
|
||||||
{
|
{
|
||||||
GameObject* linkedGO = new GameObject;
|
GameObject* linkedGO = new GameObject;
|
||||||
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map,
|
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map,
|
||||||
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1))
|
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
|
||||||
{
|
{
|
||||||
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
|
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
|
||||||
linkedGO->SetSpellId(m_spellInfo->Id);
|
linkedGO->SetSpellId(m_spellInfo->Id);
|
||||||
|
|
@ -5260,7 +5260,7 @@ void Spell::EffectDuel(uint32 i)
|
||||||
m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 ,
|
m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 ,
|
||||||
m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 ,
|
m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 ,
|
||||||
m_caster->GetPositionZ(),
|
m_caster->GetPositionZ(),
|
||||||
m_caster->GetOrientation(), 0, 0, 0, 0, 0, 1))
|
m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -5635,9 +5635,6 @@ void Spell::EffectSummonObject(uint32 i)
|
||||||
|
|
||||||
GameObject* pGameObj = new GameObject;
|
GameObject* pGameObj = new GameObject;
|
||||||
|
|
||||||
float rot2 = sin(m_caster->GetOrientation()/2);
|
|
||||||
float rot3 = cos(m_caster->GetOrientation()/2);
|
|
||||||
|
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
// If dest location if present
|
// If dest location if present
|
||||||
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
||||||
|
|
@ -5652,7 +5649,7 @@ void Spell::EffectSummonObject(uint32 i)
|
||||||
|
|
||||||
Map *map = m_caster->GetMap();
|
Map *map = m_caster->GetMap();
|
||||||
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map,
|
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map,
|
||||||
m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0, 0, rot2, rot3, 0, 1))
|
m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -6242,7 +6239,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
|
||||||
GameObject* pGameObj = new GameObject;
|
GameObject* pGameObj = new GameObject;
|
||||||
|
|
||||||
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap,
|
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap,
|
||||||
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1))
|
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -6255,10 +6252,6 @@ void Spell::EffectTransmitted(uint32 effIndex)
|
||||||
case GAMEOBJECT_TYPE_FISHINGNODE:
|
case GAMEOBJECT_TYPE_FISHINGNODE:
|
||||||
{
|
{
|
||||||
m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID());
|
m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID());
|
||||||
// Orientation3
|
|
||||||
pGameObj->SetFloatValue(GAMEOBJECT_PARENTROTATION + 2, 0.88431775569915771 );
|
|
||||||
// Orientation4
|
|
||||||
pGameObj->SetFloatValue(GAMEOBJECT_PARENTROTATION + 3, -0.4668855369091033 );
|
|
||||||
m_caster->AddGameObject(pGameObj); // will removed at spell cancel
|
m_caster->AddGameObject(pGameObj); // will removed at spell cancel
|
||||||
|
|
||||||
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
|
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
|
||||||
|
|
@ -6313,7 +6306,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
|
||||||
{
|
{
|
||||||
GameObject* linkedGO = new GameObject;
|
GameObject* linkedGO = new GameObject;
|
||||||
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap,
|
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap,
|
||||||
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1))
|
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
|
||||||
{
|
{
|
||||||
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
|
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
|
||||||
linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );
|
linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7488"
|
#define REVISION_NR "7489"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue