1
Serverside Modding / Re: [QUESTION] C++ Question SetPhaseMask
« on: November 30, 2014, 09:49:40 am »
Hi, I haven't worked on TrinityCore for 3 months now, but I'll give you a definite answer. I worked on a creature deathsystem, on the technical side I decided to phase all the creatures instead of kill/delete them from the DB, to avoid abuse. So I messed with phasing and found that your solution is right but only works untill the next server restart because you're changing the phase of a creature in memory only, not through the Database.
Like I said, this is only a temporary solution, if you want to permanently add a NPC to a phase then this little snippet of code is required.
I've tested this snippet and it works.
So, here is your slightly corrected code,
Again, the executing to database is if you want to make the NPC stay there permanently, just remove the SQL line if you want the NPC to be temporary.
Code: [Select]
void OnPlayerEnter(Player* player) OVERRIDE
{
if player->HasSpell(95000)
Creature* temp = instance->GetCreature(CreatureGUID);
temp -> SetPhaseMask(x01, false);
}
Like I said, this is only a temporary solution, if you want to permanently add a NPC to a phase then this little snippet of code is required.
Code: [Select]
killed->SetPhaseMask(8, true); //Put NPC in phase 8
WorldDatabase.PExecute("UPDATE creature SET phaseMask = 8 WHERE guid = %u;", killed->GetGUIDLow()); // Update the database to set the creature's phase mask.
I've tested this snippet and it works.
So, here is your slightly corrected code,
Code: [Select]
void OnPlayerEnter(Player* player)
{
if (player->HasSpell(95000))
Creature* temp = instance->GetCreature(CreatureGUIDLow);
temp -> SetPhaseMask(1, true);
WorldDatabase.PExecute("UPDATE creature SET phaseMask = 1 WHERE guid = %u;", killed->GetGUIDLow());
}
Again, the executing to database is if you want to make the NPC stay there permanently, just remove the SQL line if you want the NPC to be temporary.