mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Core/Phases: Preliminary work with correctly implementing the phase system in 4.3.4
Put here for peer review.
This commit is contained in:
@@ -934,6 +934,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto phase : handler->GetSession()->GetPlayer()->GetPhases())
|
||||
v->SetInPhase(phase, false, true);
|
||||
|
||||
map->AddToMap(v->ToCreature());
|
||||
|
||||
return true;
|
||||
@@ -962,13 +965,14 @@ public:
|
||||
|
||||
std::set<uint32> terrainswap;
|
||||
std::set<uint32> phaseId;
|
||||
std::set<uint32> worldMapSwap;
|
||||
|
||||
terrainswap.insert((uint32)atoi(t));
|
||||
|
||||
if (p)
|
||||
phaseId.insert((uint32)atoi(p));
|
||||
|
||||
handler->GetSession()->SendSetPhaseShift(phaseId, terrainswap);
|
||||
handler->GetSession()->SendSetPhaseShift(phaseId, terrainswap, worldMapSwap);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1393,7 +1397,7 @@ public:
|
||||
if (unit && unit->GetTypeId() == TYPEID_PLAYER)
|
||||
player = unit->ToPlayer();
|
||||
|
||||
player->GetPhaseMgr().SendDebugReportToPlayer(handler->GetSession()->GetPlayer());
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -152,12 +152,15 @@ public:
|
||||
GameObject* object = new GameObject;
|
||||
uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
|
||||
if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMgr().GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
|
||||
if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMask(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
|
||||
{
|
||||
delete object;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto phase : player->GetPhases())
|
||||
object->SetInPhase(phase, false, true);
|
||||
|
||||
if (spawntimeSecs)
|
||||
{
|
||||
uint32 value = atoi((char*)spawntimeSecs);
|
||||
@@ -165,7 +168,7 @@ public:
|
||||
}
|
||||
|
||||
// fill the gameobject data and save to the db
|
||||
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMask());
|
||||
// delete the old object and do a clean load from DB with a fresh new GameObject instance.
|
||||
// this is required to avoid weird behavior and memory leaks
|
||||
delete object;
|
||||
|
||||
@@ -1277,14 +1277,9 @@ public:
|
||||
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (target)
|
||||
{
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
target->ToPlayer()->GetPhaseMgr().SetCustomPhase(phasemask);
|
||||
else
|
||||
target->SetPhaseMask(phasemask, true);
|
||||
}
|
||||
target->SetPhaseMask(phasemask, true);
|
||||
else
|
||||
handler->GetSession()->GetPlayer()->GetPhaseMgr().SetCustomPhase(phasemask);
|
||||
handler->GetSession()->GetPlayer()->SetPhaseMask(phasemask, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT);
|
||||
CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
|
||||
data.id = id;
|
||||
data.phaseMask = chr->GetPhaseMgr().GetPhaseMaskForSpawn();
|
||||
data.phaseMask = chr->GetPhaseMask();
|
||||
data.posX = chr->GetTransOffsetX();
|
||||
data.posY = chr->GetTransOffsetY();
|
||||
data.posZ = chr->GetTransOffsetZ();
|
||||
@@ -251,20 +251,23 @@ public:
|
||||
|
||||
Creature* creature = trans->CreateNPCPassenger(guid, &data);
|
||||
|
||||
creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMask());
|
||||
|
||||
sObjectMgr->AddCreatureToGrid(guid, &data);
|
||||
return true;
|
||||
}
|
||||
|
||||
Creature* creature = new Creature();
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMask(), id, x, y, z, o))
|
||||
{
|
||||
delete creature;
|
||||
return false;
|
||||
}
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
for (auto phase : chr->GetPhases())
|
||||
creature->SetInPhase(phase, false, true);
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
|
||||
|
||||
uint32 db_guid = creature->GetDBTableGUIDLow();
|
||||
|
||||
|
||||
@@ -694,7 +694,7 @@ public:
|
||||
}
|
||||
// re-create
|
||||
Creature* wpCreature2 = new Creature();
|
||||
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
||||
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMask(), VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature2;
|
||||
@@ -702,7 +702,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
for (auto phase : chr->GetPhases())
|
||||
wpCreature2->SetInPhase(phase, false, true);
|
||||
|
||||
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
/// @todo Should we first use "Create" then use "LoadFromDB"?
|
||||
if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map))
|
||||
@@ -918,13 +921,16 @@ public:
|
||||
float o = chr->GetOrientation();
|
||||
|
||||
Creature* wpCreature = new Creature();
|
||||
if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
|
||||
if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMask(), id, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete wpCreature;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto phase : chr->GetPhases())
|
||||
wpCreature->SetInPhase(phase, false, true);
|
||||
|
||||
// Set "wpguid" column to the visual waypoint
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
|
||||
|
||||
@@ -934,7 +940,7 @@ public:
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetDBTableGUIDLow(), map))
|
||||
{
|
||||
@@ -982,14 +988,17 @@ public:
|
||||
Map* map = chr->GetMap();
|
||||
|
||||
Creature* creature = new Creature();
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMask(), id, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete creature;
|
||||
return false;
|
||||
}
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
for (auto phase : chr->GetPhases())
|
||||
creature->SetInPhase(phase, false, true);
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
|
||||
if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
@@ -1031,14 +1040,17 @@ public:
|
||||
Map* map = chr->GetMap();
|
||||
|
||||
Creature* creature = new Creature();
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMask(), id, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
delete creature;
|
||||
return false;
|
||||
}
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMgr().GetPhaseMaskForSpawn());
|
||||
for (auto phase : chr->GetPhases())
|
||||
creature->SetInPhase(phase, false, true);
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
|
||||
if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
|
||||
@@ -380,7 +380,7 @@ class boss_halion : public CreatureScript
|
||||
if (events.IsInPhase(PHASE_THREE))
|
||||
{
|
||||
// Don't consider copied damage.
|
||||
if (!me->InSamePhase(attacker))
|
||||
if (!me->IsInPhase(attacker))
|
||||
return;
|
||||
|
||||
if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER)))
|
||||
@@ -541,7 +541,7 @@ class boss_twilight_halion : public CreatureScript
|
||||
if (events.IsInPhase(PHASE_THREE))
|
||||
{
|
||||
// Don't consider copied damage.
|
||||
if (!me->InSamePhase(attacker))
|
||||
if (!me->IsInPhase(attacker))
|
||||
return;
|
||||
|
||||
if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER)))
|
||||
|
||||
@@ -90,7 +90,6 @@ public:
|
||||
delete go;
|
||||
return;
|
||||
}
|
||||
|
||||
instance->AddToMap(go);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,8 @@ public:
|
||||
{
|
||||
summon->AI()->AttackStart(me->GetVictim());
|
||||
summon->CastSpell((Unit*)NULL, SPELL_ZURAMAT_ADD_2);
|
||||
summon->SetPhaseMask(17, true);
|
||||
summon->SetInPhase(169, true, true); // Normal phase
|
||||
summon->SetInPhase(173, true, true); // Void phase
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -170,6 +170,9 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId)
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto phase : player->GetPhases())
|
||||
go->SetInPhase(phase, false, true);
|
||||
|
||||
go->SetRespawnTime(0);
|
||||
|
||||
if (!map->AddToMap(go))
|
||||
@@ -204,6 +207,9 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId)
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto phase : player->GetPhases())
|
||||
go->SetInPhase(phase, false, true);
|
||||
|
||||
go->SetRespawnTime(0);
|
||||
|
||||
if (!map->AddToMap(go))
|
||||
|
||||
Reference in New Issue
Block a user