SOURCE : http://www.ascentcommunity.com/forums/showthread.php?t=167
AUTOR : joalglok
+ Příkaz na portnutí do GH
+ Příkaz na naspawnování dveří
Dveře po naspawnování mohou otevřít pouze členové guildy
Index: src/ascent-world/Chat.cpp
===================================================================
--- src/ascent-world/Chat.cpp (revision 5002)
+++ src/ascent-world/Chat.cpp (working copy)
@@ -317,6 +317,10 @@
{ "export", 'o', &ChatHandler::HandleGOExport, "Exports the current GO selected", NULL, 0, 0, 0 },
{ "move", 'g', &ChatHandler::HandleGOMove, "Moves gameobject to player xyz", NULL, 0, 0, 0 },
{ "rotate", 'g', &ChatHandler::HandleGORotate, "Rotates gameobject x degrees", NULL, 0, 0, 0 },
+
+ //Puerta de Casa de Guild
+ { "SpawnGuildHouseDoor",'o', &ChatHandler::HandleGOSpawnGuildHouseDoor,"SpawnGuildHouseDoor GuildName - Spawns a special door for use in guild house construction",NULL,0,0,0 },
+
{ NULL, 0, NULL, "", NULL, 0, 0 }
};
dupe_command_table(GameObjectCommandTable, _GameObjectCommandTable);
@@ -504,6 +508,8 @@
{ "save", 's', &ChatHandler::HandleSaveCommand, "Save's your character", NULL, 0, 0, 0},
{ "saveall", 's', &ChatHandler::HandleSaveAllCommand, "Save's all playing characters", NULL, 0, 0, 0},
{ "start", 'm', &ChatHandler::HandleStartCommand, "Teleport's you to a starting location", NULL, 0, 0, 0},
+ //Guild House
+ { "guildhouse", '0', &ChatHandler::HandleGuildHouseCommand,"Teleport's you to your guild's house",NULL,0, 0, 0 },
{ "additem", 'm', &ChatHandler::HandleAddInvItemCommand, "", NULL, 0, 0, 0},
{ "invincible", 'j', &ChatHandler::HandleInvincibleCommand, ".invincible - Toggles INVINCIBILITY (mobs won't attack you)", NULL, 0, 0, 0},
{ "invisible", 'i', &ChatHandler::HandleInvisibleCommand, ".invisible - Toggles INVINCIBILITY and INVISIBILITY (mobs won't attack you and nobody can see you, but they can see your chat messages)", NULL, 0, 0, 0},
Index: src/ascent-world/Chat.h
===================================================================
--- src/ascent-world/Chat.h (revision 5002)
+++ src/ascent-world/Chat.h (working copy)
@@ -210,6 +210,7 @@
bool HandleGMListCommand(const char* args, WorldSession *m_session);
bool HandleGmLogCommentCommand( const char *args , WorldSession *m_session);
bool HandleRatingsCommand( const char *args , WorldSession *m_session );
+ bool HandleGuildHouseCommand(const char* args, WorldSession *m_session);
// Level 1 commands
bool CmdSetValueField(WorldSession *m_session, uint32 field, uint32 fieldmax, const char *fieldname, const char* args);
@@ -304,6 +305,7 @@
bool HandleGOMove(const char * args, WorldSession * m_session);
bool HandleAddAIAgentCommand(const char* args, WorldSession *m_session);
bool HandleListAIAgentCommand(const char* args, WorldSession *m_session);
+ bool HandleGOSpawnGuildHouseDoor(const char *args, WorldSession *m_session);
// Level 3 commands
bool HandleMassSummonCommand(const char* args, WorldSession *m_session);
Index: src/ascent-world/GameObject.cpp
===================================================================
--- src/ascent-world/GameObject.cpp (revision 5002)
+++ src/ascent-world/GameObject.cpp (working copy)
@@ -486,7 +486,11 @@
void GameObject::EventCloseDoor()
{
- SetUInt32Value(GAMEOBJECT_STATE, 0);
+ //Door never Close and never come usable again
+ //SetUInt32Value(GAMEOBJECT_STATE, 0);
+
+ SetUInt32Value(GAMEOBJECT_STATE, 1);
+ SetUInt32Value(GAMEOBJECT_FLAGS, 0);
}
void GameObject::UseFishingNode(Player *player)
Index: src/ascent-world/Level0.cpp
===================================================================
--- src/ascent-world/Level0.cpp (revision 5002)
+++ src/ascent-world/Level0.cpp (working copy)
@@ -145,6 +145,81 @@
return true;
}
+bool ChatHandler::HandleGuildHouseCommand(const char* args, WorldSession *m_session)
+{
+
+ if( m_session == NULL )
+ return false;
+
+
+ Player *m_plyr = m_session->GetPlayer();
+
+
+ if ( m_plyr->IsAttacking() )
+ {
+ RedSystemMessage(m_session, "Can't go to guild house when attacking.");
+ return false;
+ }
+
+ if ( m_plyr->IsMounted() )
+ {
+ RedSystemMessage(m_session, "Can't go to guild house when mounted.");
+ return false;
+ }
+
+ if ( m_plyr->isDead() )
+ {
+ RedSystemMessage(m_session, "Can't go to guild house when dead.");
+ return false;
+ }
+
+ if (m_plyr->GetGuild()!=NULL)
+ {
+ const char* guild = m_plyr->GetGuild()->GetGuildName();
+ QueryResult *result = WorldDatabase.Query( "SELECT * FROM recall ORDER BY name" );
+
+ if( result == NULL)
+ return false;
+
+ do
+ {
+ Field* fields = result->Fetch();
+ const char* locname = fields[1].GetString();
+ uint32 locmap = fields[2].GetUInt32();
+ float x = fields[3].GetFloat();
+ float y = fields[4].GetFloat();
+ float z = fields[5].GetFloat();
+
+ if( strnicmp( const_cast< char* >( guild ), locname, strlen( guild ) ) == 0 )
+ {
+ if( m_plyr!=NULL )
+ {
+ GreenSystemMessage(m_session,"Teleporting you to %s guild's house", guild);
+ m_session->GetPlayer()->SafeTeleport(locmap, 0, LocationVector(x, y, z));
+ delete result;
+ return true;
+ }
+ else
+ {
+ RedSystemMessage(m_session, "The guild %s don't own a house.", guild);
+ delete result;
+ return false;
+ }
+ }
+ }while (result->NextRow());
+
+ delete result;
+ return false;
+ }
+ else
+ {
+ RedSystemMessage(m_session,"You are not in a Guild!");
+ return false;
+ }
+
+}
+
bool ChatHandler::HandleStartCommand(const char* args, WorldSession *m_session)
{
std::string race;
Index: src/ascent-world/Level2.cpp
===================================================================
--- src/ascent-world/Level2.cpp (revision 5002)
+++ src/ascent-world/Level2.cpp (working copy)
@@ -753,6 +753,92 @@
return true;
}
+bool ChatHandler::HandleGOSpawnGuildHouseDoor(const char *args, WorldSession *m_session)
+{
+ if(!*args)
+ return false;
+
+ std::stringstream sstext;
+
+ char* pEntryID = "177444"; //We will use the GO id 177444 because it's a nice door :)
+ //strtok((char*)args, " ");
+
+ uint32 EntryID = atoi(pEntryID);
+
+
+ GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID);
+ if(!goi)
+ {
+ sstext << "GameObject Info '" << EntryID << "' Not Found" << '\';
+ SystemMessage(m_session, sstext.str().c_str());
+ return true;
+ }
+
+ sLog.outDebug("Spawning GO Entry '%u' as a guild house door", EntryID);
+ sstext << "Spawning GameObject as a guild house door, using Entry '" << EntryID << "'" << '\';
+ SystemMessage(m_session, sstext.str().c_str());
+
+ GameObject *go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID);
+
+ Player *chr = m_session->GetPlayer();
+ uint32 mapid = chr->GetMapId();
+ float x = chr->GetPositionX();
+ float y = chr->GetPositionY();
+ float z = chr->GetPositionZ();
+ float o = chr->GetOrientation();
+
+ go->SetInstanceID(chr->GetInstanceID());
+ go->CreateFromProto(EntryID,mapid,x,y,z,o);
+
+ /* fuck blizz coordinate system */
+ go->SetFloatValue(GAMEOBJECT_ROTATION_02, sinf(o / 2));
+ go->SetFloatValue(GAMEOBJECT_ROTATION_03, cosf(o / 2));
+ go->PushToWorld(m_session->GetPlayer()->GetMapMgr());
+
+ // Create spawn instance
+ GOSpawn * gs = new GOSpawn;
+ gs->entry = go->GetEntry();
+ gs->facing = go->GetOrientation();
+ gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION);
+ gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
+ gs->id = objmgr.GenerateGameObjectSpawnID();
+ gs->o = go->GetFloatValue(GAMEOBJECT_ROTATION);
+ gs->o1 = go->GetFloatValue(GAMEOBJECT_ROTATION_01);
+ gs->o2 = go->GetFloatValue(GAMEOBJECT_ROTATION_02);
+ gs->o3 = go->GetFloatValue(GAMEOBJECT_ROTATION_03);
+ go->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.4);
+ gs->x = go->GetPositionX();
+ gs->y = go->GetPositionY();
+ gs->z = go->GetPositionZ();
+ gs->state = go->GetUInt32Value(GAMEOBJECT_STATE);
+
+
+ uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
+ uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());
+
+ m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx,cy)->GOSpawns.push_back(gs);
+ go->m_spawn = gs;
+
+
+
+
+ // Guardar en la DB
+ go->SaveToDB();
+
+ //sGMLog.writefromsession( m_session, "Puerta de casa de guild creada %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, ", saved in DB" : "" );
+
+ //Saves in special Table Guild Door info Table Name="guild_doors"
+
+ std::stringstream ss;
+ ss << "REPLACE INTO guild_doors VALUES("
+ << ((gs == NULL) ? 0 : gs->id) << ",'"
+ << args << "')";
+
+ WorldDatabase.Execute(ss.str().c_str());
+
+ return true;
+}
+
bool ChatHandler::HandleGOInfo(const char *args, WorldSession *m_session)
{
std::string name;
Index: src/ascent-world/MiscHandler.cpp
===================================================================
--- src/ascent-world/MiscHandler.cpp (revision 5002)
+++ src/ascent-world/MiscHandler.cpp (working copy)
@@ -1267,9 +1267,54 @@
obj->EventCloseDoor();
else
{
- obj->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
- obj->SetUInt32Value(GAMEOBJECT_STATE, 0);
- sEventMgr.AddEvent(obj,&GameObject::EventCloseDoor,EVENT_GAMEOBJECT_DOOR_CLOSE,20000,1,0);
+ //Check if door is Guild House Door
+ std::stringstream ss;
+ ss << "SELECT * FROM guild_doors where GoGuid=" << ((obj->m_spawn->id == NULL) ? 0 : obj->m_spawn->id);
+ QueryResult *result = WorldDatabase.Query( ss.str().c_str() );
+
+ bool opendoor = true;
+
+ if( result != NULL)
+ { //Check Player Guild
+ Field* fields = result->Fetch();
+ const char* guildname = fields[1].GetString();
+
+ if ( plyr->IsInGuild() != NULL )
+ {
+ const char* playerguild = plyr->GetGuild()->GetGuildName();
+
+ if ( strnicmp( const_cast< char* >( guildname ), playerguild, strlen( guildname ) ) == 0 )
+ {
+ //plyr->PlaySoundToSet(11706);
+ const LocationVector & loc = plyr->GetPosition();
+ bool res = CollideInterface.IsIndoor(plyr->GetMapId(), loc.x, loc.y, loc.z + 2.0f);
+ if ( res )
+ { SystemMessage("Wellcome to %s Guild House",guildname); }
+ else
+ { SystemMessage("Safe Travel!");}
+ }
+ else if ( playerguild = "<< PUT STAFF GUILD NAME HERE >>" )
+ { SystemMessage("Staff Guild Override - Opening door!"); }
+ else
+ {
+ SystemMessage("You need to be a member of %s to gain access",guildname);
+ opendoor=false;
+ }
+ }
+ else
+ {
+ SystemMessage("You can join %s guild to gain access to this guild house",guildname);
+ opendoor=false;
+ }
+ }
+
+ if ( opendoor )
+ {
+ obj->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
+ obj->SetUInt32Value(GAMEOBJECT_STATE, 0);
+ if(obj->GetMapMgr()->GetMapInfo()->type==INSTANCE_NULL)//dont close doors for instances
+ sEventMgr.AddEvent(obj,&GameObject::EventCloseDoor,EVENT_GAMEOBJECT_DOOR_CLOSE,20000,1,0);
+ }
}
}break;
case GAMEOBJECT_TYPE_FLAGSTAND:
CREATE TABLE `guild_doors` (
`GOGuid` int(10) unsigned NOT NULL,
`GuildName` char(32) DEFAULT NULL,
PRIMARY KEY (`GOGuid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1