diff options
author | megamage <none@none> | 2009-02-01 16:46:57 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-02-01 16:46:57 -0600 |
commit | 05c07aa74a38e73006ba7106574290179942692c (patch) | |
tree | 70cd33698562658805c3643c22890ce23263c3a8 | |
parent | cd0071ae620f2634f609df8b83b24687f073733e (diff) |
[7214] Phase system continue development - Commands and fixes.
* Fixed creature/gameobject save from game (used in commands code only)
* Implement .modify phase (for player), .npc setphase (for creature/pet), .gobject phase (for gameobjects) commands
for set phasemask of selected object. In player/pet case temporary until in game phase switch/re-login/GM-mode change.
In creature/gameobject case change saved in DB.
* Add to .gps output phasemask value print. Allow use .gps command with creature/gameobject shift-link
(work for objects loaded in game in command time).
Author: VladimirMangos
--HG--
branch : trunk
-rw-r--r-- | sql/mangos.sql | 8 | ||||
-rw-r--r-- | src/game/Chat.cpp | 52 | ||||
-rw-r--r-- | src/game/Chat.h | 4 | ||||
-rw-r--r-- | src/game/Creature.cpp | 1 | ||||
-rw-r--r-- | src/game/GameObject.cpp | 1 | ||||
-rw-r--r-- | src/game/Level1.cpp | 11 | ||||
-rw-r--r-- | src/game/Level2.cpp | 91 | ||||
-rw-r--r-- | src/shared/revision_nr.h | 2 |
8 files changed, 165 insertions, 5 deletions
diff --git a/sql/mangos.sql b/sql/mangos.sql index 6cd60c935d8..0b07d89ff77 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -22,7 +22,7 @@ DROP TABLE IF EXISTS `db_version`; CREATE TABLE `db_version` ( `version` varchar(120) default NULL, - `required_7209_01_mangos_spell_bonus_data` bit(1) default NULL + `required_7214_02_mangos_mangos_string` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -299,9 +299,11 @@ INSERT INTO `command` VALUES ('gobject delete',2,'Syntax: .gobject delete #go_guid\r\nDelete gameobject with guid #go_guid.'), ('gobject move',2,'Syntax: .gobject move #goguid [#x #y #z]\r\n\r\nMove gameobject #goguid to character coordinates (or to (#x,#y,#z) coordinates if its provide).'), ('gobject near ',3,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'), +('gobject phase',3,'Syntax: .gobject phase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.'), ('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'), ('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'), ('goname',1,'Syntax: .goname $charactername\r\n\r\nTeleport to the given character. Either specify the character name or click on the character\'s portrait, e.g. when you are in a group.'), +('gps',1,'Syntax: .gps [$name|$shift-link]\r\n\r\nDisplay the position information for a selected character or creature (also if player name $name provided then for named player, or if creature/gameobject shift-link provided then pointed creature/gameobject if it loaded). Position information includes X, Y, Z, and orientation, map Id and zone Id'), ('gps',1,'Syntax: .gps\r\n\r\nDisplay the position information for a selected character or creature. Position information includes X, Y, Z, and orientation, map Id and zone Id'), ('groupgo',1,'Syntax: .groupgo $charactername\r\n\r\nTeleport the given character and his group to you.'), ('guid',2,'Syntax: .guid\r\n\r\nDisplay the GUID for the selected character.'), @@ -369,6 +371,7 @@ INSERT INTO `command` VALUES ('modify money',1,'Syntax:\r\n.modify money #money\r\n.money #money\r\n\r\nAdd or remove money to the selected player. If no player is selected, modify your money.\r\n\r\n #gold can be negative to remove money.'), ('modify morph',2,'Syntax: .modify morph #displayid\r\n\r\nChange your current model id to #displayid.'), ('modify mount',1,'Syntax:\r\n.modify mount #id #speed\r\nDisplay selected player as mounted at #id creature and set speed to #speed value.'), +('modify phase',3,'Syntax: .modify phase #phasemask\r\n\r\nSelected character phasemask changed to #phasemask with related world vision update. Change active until in game phase changed, or GM-mode enable/disable, or re-login. Character pts pasemask update to same value.'), ('modify rage',1,'Syntax: .modify rage #newrage\r\n\r\nModify the rage of the selected player. If no player is selected, modify your rage.'), ('modify rep',2,'Syntax: .modify rep #repId (#repvalue | $rankname [#delta])\r\nSets the selected players reputation with faction #repId to #repvalue or to $reprank.\r\nIf the reputation rank name is provided, the resulting reputation will be the lowest reputation for that rank plus the delta amount, if specified.\r\nYou can use \'.pinfo rep\' to list all known reputation ids, or use \'.lookup faction $name\' to locate a specific faction id.'), ('modify runicpower',1,'Syntax: .modify runicpower #newrunicpower\r\n\r\nModify the runic power of the selected player. If no player is selected, modify your runic power.'), @@ -395,6 +398,7 @@ INSERT INTO `command` VALUES ('npc info',3,'Syntax: .npc info\r\n\r\nDisplay a list of details for the selected creature.\r\n\r\nThe list includes:\r\n- GUID, Faction, NPC flags, Entry ID, Model ID,\r\n- Level,\r\n- Health (current/maximum),\r\n\r\n- Field flags, dynamic flags, faction template, \r\n- Position information,\r\n- and the creature type, e.g. if the creature is a vendor.'), ('npc move',2,'Syntax: .npc move [#creature_guid]\r\n\r\nMove the targeted creature spawn point to your coordinates.'), ('npc name',2,'Syntax: .npc name $name\r\n\r\nChange the name of the selected creature or character to $name.\r\n\r\nCommand disabled.'), +('npc phase',3,'Syntax: .npc phase #phasemask\r\n\r\nSelected unit or pet phasemask changed to #phasemask with related world vision update for players. In creature case state saved to DB and persistent. In pet case change active until in game phase changed for owner, owner re-login, or GM-mode enable/disable..'), ('npc playemote',3,'Syntax: .npc playemote #emoteid\r\n\r\nMake the selected creature emote with an emote of id #emoteid.'), ('npc setmodel',2,'Syntax: .npc setmodel #displayid\r\n\r\nChange the model id of the selected creature to #displayid.'), ('npc setmovetype',2,'Syntax: .npc setmovetype [#creature_guid] stay/random/way [NODEL]\r\n\r\nSet for creature pointed by #creature_guid (or selected if #creature_guid not provided) movement type and move it to respawn position (if creature alive). Any existing waypoints for creature will be removed from the database if you do not use NODEL. If the creature is dead then movement type will applied at creature respawn.\r\nMake sure you use NODEL, if you want to keep the waypoints.'), @@ -2329,7 +2333,7 @@ INSERT INTO `mangos_string` VALUES (57,'Using World DB: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (58,'Using script library: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (100,'Global notify: ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(101,'Map: %u (%s) Zone: %u (%s) Area: %u (%s)\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(101,'Map: %u (%s) Zone: %u (%s) Area: %u (%s) Phase: %u\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (102,'%s is already being teleported.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (103,'You can summon a player to your instance only if he is in your party with you as leader.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (104,'You cannot go to the player\'s instance because you are in a party now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 6d9da4ac9af..03f78c3938c 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -150,6 +150,7 @@ ChatCommand * ChatHandler::getCommandTable() { "drunk", SEC_MODERATOR, false, &ChatHandler::HandleDrunkCommand, "", NULL }, { "standstate", SEC_GAMEMASTER, false, &ChatHandler::HandleStandStateCommand, "", NULL }, { "morph", SEC_GAMEMASTER, false, &ChatHandler::HandleMorphCommand, "", NULL }, + { "phase", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyPhaseCommand, "", NULL }, { "gender", SEC_ADMINISTRATOR, false, &ChatHandler::HandleModifyGenderCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -457,6 +458,7 @@ ChatCommand * ChatHandler::getCommandTable() { "info", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcInfoCommand, "", NULL }, { "playemote", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcPlayEmoteCommand, "", NULL }, { "follow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFollowCommand, "", NULL }, + { "setphase", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcSetPhaseCommand, "", NULL }, { "unfollow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL }, { "whisper", SEC_MODERATOR, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL }, { "yell", SEC_MODERATOR, false, &ChatHandler::HandleNpcYellCommand, "", NULL }, @@ -490,12 +492,13 @@ ChatCommand * ChatHandler::getCommandTable() { { "add", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectCommand, "", NULL }, { "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleDelObjectCommand, "", NULL }, - { "target", SEC_GAMEMASTER, false, &ChatHandler::HandleTargetObjectCommand, "", NULL }, - { "turn", SEC_GAMEMASTER, false, &ChatHandler::HandleTurnObjectCommand, "", NULL }, { "move", SEC_GAMEMASTER, false, &ChatHandler::HandleMoveObjectCommand, "", NULL }, { "near", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNearObjectCommand, "", NULL }, { "activate", SEC_GAMEMASTER, false, &ChatHandler::HandleActivateObjectCommand, "", NULL }, { "addtemp", SEC_GAMEMASTER, false, &ChatHandler::HandleTempGameObjectCommand, "", NULL }, + { "setphase", SEC_GAMEMASTER, false, &ChatHandler::HandleGOPhaseCommand, "", NULL }, + { "target", SEC_GAMEMASTER, false, &ChatHandler::HandleTargetObjectCommand, "", NULL }, + { "turn", SEC_GAMEMASTER, false, &ChatHandler::HandleTurnObjectCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -1405,6 +1408,51 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text) return objmgr.GetGameTele(cId); } +enum GuidLinkType +{ + SPELL_LINK_CREATURE = 0, + SPELL_LINK_GAMEOBJECT = 1 +}; + +static char const* const guidKeys[] = +{ + "Hcreature", + "Hgameobject", + 0 +}; + +uint64 ChatHandler::extractGuidFromLink(char* text) +{ + int type = 0; + + // |color|Hcreature:creature_guid|h[name]|h|r + // |color|Hgameobject:go_guid|h[name]|h|r + char* idS = extractKeyFromLink(text,guidKeys,&type); + if(!idS) + return 0; + + uint32 lowguid = (uint32)atol(idS); + + switch(type) + { + case SPELL_LINK_CREATURE: + { + if(CreatureData const* data = objmgr.GetCreatureData(lowguid) ) + return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT); + else + return 0; + } + case SPELL_LINK_GAMEOBJECT: + if(GameObjectData const* data = objmgr.GetGOData(lowguid) ) + return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_GAMEOBJECT); + else + return 0; + } + + // unknown type? + return 0; +} + const char *ChatHandler::GetName() const { return m_session->GetPlayer()->GetName(); diff --git a/src/game/Chat.h b/src/game/Chat.h index 8faea36e9fc..6ee75789db4 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -185,6 +185,7 @@ class ChatHandler bool HandleModifyHonorCommand (const char* args); bool HandleModifyRepCommand(const char* args); bool HandleModifyArenaCommand(const char* args); + bool HandleModifyPhaseCommand(const char* args); bool HandleModifyGenderCommand(const char* args); bool HandleNpcAddCommand(const char* args); @@ -200,6 +201,7 @@ class ChatHandler bool HandleNpcSayCommand(const char* args); bool HandleNpcSetModelCommand(const char* args); bool HandleNpcSetMoveTypeCommand(const char* args); + bool HandleNpcSetPhaseCommand(const char* args); bool HandleNpcSpawnDistCommand(const char* args); bool HandleNpcSpawnTimeCommand(const char* args); bool HandleNpcTameCommand(const char* args); @@ -326,6 +328,7 @@ class ChatHandler bool HandleTargetObjectCommand(const char* args); bool HandleDelObjectCommand(const char* args); bool HandleMoveObjectCommand(const char* args); + bool HandleGOPhaseCommand(const char* args); bool HandleTurnObjectCommand(const char* args); bool HandleObjectStateCommand(const char* args); bool HandlePInfoCommand(const char* args); @@ -505,6 +508,7 @@ class ChatHandler char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL); uint32 extractSpellIdFromLink(char* text); + uint64 extractGuidFromLink(char* text); GameTele const* extractGameTeleFromLink(char* text); bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline = false); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index d77e053a5e3..8134cd71de5 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1245,6 +1245,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) << GetEntry() << "," << mapid <<"," << (uint32)spawnMask << "," + << (uint32)GetPhaseMask() << "," << displayId <<"," << GetEquipmentId() <<"," << GetPositionX() << "," diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 03b5bdc5644..41dae609b43 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -552,6 +552,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) << GetEntry() << ", " << mapid << ", " << (uint32)spawnMask << ", " + << (uint32)GetPhaseMask() << "," << GetFloatValue(GAMEOBJECT_POS_X) << ", " << GetFloatValue(GAMEOBJECT_POS_Y) << ", " << GetFloatValue(GAMEOBJECT_POS_Z) << ", " diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index e31d6fe6170..60ef0fc98c9 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -653,6 +653,8 @@ bool ChatHandler::HandleVisibleCommand(const char* args) return false; } + + bool ChatHandler::HandleGPSCommand(const char* args) { WorldObject *obj = NULL; @@ -664,6 +666,13 @@ bool ChatHandler::HandleGPSCommand(const char* args) if(!obj) { + uint64 guid = extractGuidFromLink((char*)args); + if(guid) + obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*m_session->GetPlayer(),guid,TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT); + } + + if(!obj) + { SendSysMessage(LANG_PLAYER_NOT_FOUND); SetSentErrorMessage(true); return false; @@ -711,6 +720,7 @@ bool ChatHandler::HandleGPSCommand(const char* args) obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ), zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ), area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ), + obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); @@ -723,6 +733,7 @@ bool ChatHandler::HandleGPSCommand(const char* args) obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), + obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index e1c43c49b93..b43c4a971f5 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1754,6 +1754,27 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args) return true; } +//set temporary phase mask for player +bool ChatHandler::HandleModifyPhaseCommand(const char* args) +{ + if (!*args) + return false; + + uint32 phasemask = (uint32)atoi((char*)args); + + Unit *target = getSelectedUnit(); + if(!target) + target = m_session->GetPlayer(); + + // check online security + else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0)) + return false; + + target->SetPhaseMask(phasemask,true); + + return true; +} + //show info of player bool ChatHandler::HandlePInfoCommand(const char* args) { @@ -4410,3 +4431,73 @@ bool ChatHandler::HandleNpcAddFormationCommand(const char* args) return true; } + +//change phasemask of creature or pet +bool ChatHandler::HandleNpcSetPhaseCommand(const char* args) +{ + if (!*args) + return false; + + uint32 phasemask = (uint32) atoi((char*)args); + if ( phasemask == 0 ) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Creature* pCreature = getSelectedCreature(); + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->SetPhaseMask(phasemask,true); + + if(!pCreature->isPet()) + pCreature->SaveToDB(); + + return true; +} + +//set pahsemask for selected object +bool ChatHandler::HandleGOPhaseCommand(const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameobject"); + if(!cId) + return false; + + uint32 lowguid = atoi(cId); + if(!lowguid) + return false; + + GameObject* obj = NULL; + // by DB guid + if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) + obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if(!obj) + { + PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + if (!*args) + return false; + + uint32 phasemask = (uint32) atoi((char*)args); + if ( phasemask == 0 ) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + obj->SetPhaseMask(phasemask,true); + obj->SaveToDB(); + return true; +} diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 240ed33d8ad..4b3b3fa5d97 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7213" + #define REVISION_NR "7214" #endif // __REVISION_NR_H__ |