Modcraft - The community dedicated to quality WoW modding!
Wrath of the Lich King Modding => Serverside Modding => Topic started by: deep6ixed on November 01, 2014, 01:25:58 am
-
Okay, i'm very new to c++, but I have a question about how to set a phasemask via c++
here is the script i have so far:
void OnPlayerEnter(Player* player) OVERRIDE
{
if player->HasSpell(95000)
Set a specific creature spawn with a specific guid to x01;
}
I know the method is SetPhaseMask(Mask, false) but how do you specify the GUID of the spawn to modify?
-
Okay after some digging, I think it's this:
void OnPlayerEnter(Player* player) OVERRIDE
{
if player->HasSpell(95000)
Creature* temp = instance->GetCreature(CreatureGUID);
temp -> SetPhaseMask(x01, false);
}
Am i close or way the hell off?
-
Why do you use x01 instead of 1?
-
Your right, it should be 1, guess all the flag work I do in dbcs got me thinking wrong.
-
Not sure how about the GUID thing.
Maybe you could spawn an invisible GO on that place and use this:
if (Creature *npc = go->FindNearestCreature(/*entry here*/, /*distance*/30, /*alive*/true))
{
uint64 guid = npc->GetGUID();
}
-
What I'm doing is attempting to make a player housing script using instances. That part works fine, now I spawned everything on the map with a phase of 32, and if the player has unlocked say the banker, when he enters, it shifts the phase from 32 to 1.
-
Luzifix did this for Schattenhain, didn't he?
Afaik they set some points/coordinates and create a shape, like an areatrigger, from it.
If a players coordinates are in this shape (or maybe they really did it with an dynamic areatrigger? dunno), the players phase will change.
That means, that you will probably need at least the basics of 3d math to calculate the shape.
-
I'm using instancing, so all I do is use the OnEnter event.
-
I'm using instancing, so all I do is use the OnEnter event.
-
Uhm, isn't an instance bound to a map?
-
Yeah, an instance is bound to a map. Ive made a separate map for player housing, and when you enter it should shift all the creatures / Gameobjects that your character can use to your phase.
-
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.
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.
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,
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.
-
This script is run inside of an instance, modifying the database would modify all copies of the instance. The script I wrote modifies the spawn flag for that specific instance. and if a server reload happens, the script will rerun as the player enters the instance upon login.