mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[10314] Implement commands for work with areatriggers in game.
* all teleport commands support new areatrigger and areatriger-target shiftlinks
* .go trigger now let select areatrigger or areatrigger target as teleport point
* New commands:
.trigger - show detail info about areatrigger including all requirements
for teleport with shift-links to items/keys/quest
.trigger active - show all currently activated by character areatriggers
.trigger near - show near areatriggers
* .lookup item now show [usable] postfix if item can be used/equipped by selected character.
This commit is contained in:
parent
835efe7f6a
commit
685edfe7e2
12 changed files with 509 additions and 67 deletions
|
|
@ -141,6 +141,263 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||
return true;
|
||||
}
|
||||
|
||||
void ChatHandler::ShowTriggerTargetListHelper( uint32 id, AreaTrigger const* at, bool subpart /*= false*/ )
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
char dist_buf[50];
|
||||
if(!subpart)
|
||||
{
|
||||
float dist = m_session->GetPlayer()->GetDistance2d(at->target_X, at->target_Y);
|
||||
snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist);
|
||||
}
|
||||
else
|
||||
dist_buf[0] = '\0';
|
||||
|
||||
PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CHAT,
|
||||
subpart ? " -> " : "", id, id, at->target_mapId, at->target_X, at->target_Y, at->target_Z, dist_buf);
|
||||
}
|
||||
else
|
||||
PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CONSOLE,
|
||||
subpart ? " -> " : "", id, at->target_mapId, at->target_X, at->target_Y, at->target_Z);
|
||||
}
|
||||
|
||||
void ChatHandler::ShowTriggerListHelper( AreaTriggerEntry const * atEntry )
|
||||
{
|
||||
|
||||
char const* tavern = sObjectMgr.IsTavernAreaTrigger(atEntry->id) ? GetMangosString(LANG_TRIGGER_TAVERN) : "";
|
||||
char const* quest = sObjectMgr.GetQuestForAreaTrigger(atEntry->id) ? GetMangosString(LANG_TRIGGER_QUEST) : "";
|
||||
|
||||
if (m_session)
|
||||
{
|
||||
float dist = m_session->GetPlayer()->GetDistance2d(atEntry->x, atEntry->y);
|
||||
char dist_buf[50];
|
||||
snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist);
|
||||
|
||||
PSendSysMessage(LANG_TRIGGER_LIST_CHAT,
|
||||
atEntry->id, atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, dist_buf, tavern, quest);
|
||||
}
|
||||
else
|
||||
PSendSysMessage(LANG_TRIGGER_LIST_CONSOLE,
|
||||
atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, tavern, quest);
|
||||
|
||||
if (AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id))
|
||||
ShowTriggerTargetListHelper(atEntry->id, at, true);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleTriggerCommand(const char* args)
|
||||
{
|
||||
AreaTriggerEntry const* atEntry = NULL;
|
||||
|
||||
Player* pl = m_session ? m_session->GetPlayer() : NULL;
|
||||
|
||||
// select by args
|
||||
if (*args)
|
||||
{
|
||||
char *atId = extractKeyFromLink((char*)args, "Hareatrigger");
|
||||
if (!atId)
|
||||
return false;
|
||||
|
||||
int32 i_atId = atoi(atId);
|
||||
|
||||
if (!i_atId)
|
||||
return false;
|
||||
|
||||
atEntry = sAreaTriggerStore.LookupEntry(i_atId);
|
||||
|
||||
if (!atEntry)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// find nearest
|
||||
else
|
||||
{
|
||||
if (!m_session)
|
||||
return false;
|
||||
|
||||
float dist2 = MAP_SIZE*MAP_SIZE;
|
||||
|
||||
Player* pl = m_session->GetPlayer();
|
||||
|
||||
// Search triggers
|
||||
for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id)
|
||||
{
|
||||
AreaTriggerEntry const *atTestEntry = sAreaTriggerStore.LookupEntry (id);
|
||||
if (!atTestEntry)
|
||||
continue;
|
||||
|
||||
if (atTestEntry->mapid != m_session->GetPlayer()->GetMapId())
|
||||
continue;
|
||||
|
||||
float dx = atTestEntry->x - pl->GetPositionX();
|
||||
float dy = atTestEntry->y - pl->GetPositionY();
|
||||
|
||||
float test_dist2 = dx*dx + dy*dy;
|
||||
|
||||
if (test_dist2 >= dist2)
|
||||
continue;
|
||||
|
||||
dist2 = test_dist2;
|
||||
atEntry = atTestEntry;
|
||||
}
|
||||
|
||||
if (!atEntry)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ShowTriggerListHelper(atEntry);
|
||||
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
|
||||
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id);
|
||||
if (at)
|
||||
PSendSysMessage(LANG_TRIGGER_REQ_LEVEL, at->requiredLevel);
|
||||
|
||||
if (uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(atEntry->id))
|
||||
{
|
||||
SendSysMessage(LANG_TRIGGER_EXPLORE_QUEST);
|
||||
ShowQuestListHelper(quest_id, loc_idx, pl);
|
||||
}
|
||||
|
||||
if (at)
|
||||
{
|
||||
if (at->requiredItem || at->requiredItem2)
|
||||
{
|
||||
SendSysMessage(LANG_TRIGGER_REQ_ITEMS);
|
||||
|
||||
if (at->requiredItem)
|
||||
ShowItemListHelper(at->requiredItem, loc_idx, pl);
|
||||
if (at->requiredItem2)
|
||||
ShowItemListHelper(at->requiredItem2, loc_idx, pl);
|
||||
}
|
||||
|
||||
if (at->requiredQuest)
|
||||
{
|
||||
SendSysMessage(LANG_TRIGGER_REQ_QUEST_NORMAL);
|
||||
ShowQuestListHelper(at->requiredQuest, loc_idx, pl);
|
||||
}
|
||||
|
||||
if (at->heroicKey || at->heroicKey2)
|
||||
{
|
||||
SendSysMessage(LANG_TRIGGER_REQ_KEYS_HEROIC);
|
||||
|
||||
if (at->heroicKey)
|
||||
ShowItemListHelper(at->heroicKey, loc_idx, pl);
|
||||
if (at->heroicKey2)
|
||||
ShowItemListHelper(at->heroicKey2, loc_idx, pl);
|
||||
}
|
||||
|
||||
if (at->requiredQuestHeroic)
|
||||
{
|
||||
SendSysMessage(LANG_TRIGGER_REQ_QUEST_HEROIC);
|
||||
ShowQuestListHelper(at->requiredQuestHeroic, loc_idx, pl);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleTriggerActiveCommand(const char* args)
|
||||
{
|
||||
uint32 counter = 0; // Counter for figure out that we found smth.
|
||||
|
||||
Player* pl = m_session->GetPlayer();
|
||||
|
||||
// Search in AreaTable.dbc
|
||||
for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id)
|
||||
{
|
||||
AreaTriggerEntry const *atEntry = sAreaTriggerStore.LookupEntry (id);
|
||||
if (!atEntry)
|
||||
continue;
|
||||
|
||||
if (!IsPointInAreaTriggerZone(atEntry, pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ()))
|
||||
continue;
|
||||
|
||||
ShowTriggerListHelper(atEntry);
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
if (counter == 0) // if counter == 0 then we found nth
|
||||
SendSysMessage (LANG_COMMAND_NOTRIGGERFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleTriggerNearCommand(const char* args)
|
||||
{
|
||||
float distance = (!*args) ? 10.0f : (float)atof(args);
|
||||
float dist2 = distance*distance;
|
||||
uint32 counter = 0; // Counter for figure out that we found smth.
|
||||
|
||||
Player* pl = m_session->GetPlayer();
|
||||
|
||||
// Search triggers
|
||||
for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id)
|
||||
{
|
||||
AreaTriggerEntry const *atEntry = sAreaTriggerStore.LookupEntry (id);
|
||||
if (!atEntry)
|
||||
continue;
|
||||
|
||||
if (atEntry->mapid != m_session->GetPlayer()->GetMapId())
|
||||
continue;
|
||||
|
||||
float dx = atEntry->x - pl->GetPositionX();
|
||||
float dy = atEntry->y - pl->GetPositionY();
|
||||
|
||||
if (dx*dx + dy*dy > dist2)
|
||||
continue;
|
||||
|
||||
ShowTriggerListHelper(atEntry);
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
// Search trigger targets
|
||||
for (uint32 id = 0; id < sAreaTriggerStore.GetNumRows (); ++id)
|
||||
{
|
||||
AreaTriggerEntry const *atEntry = sAreaTriggerStore.LookupEntry (id);
|
||||
if (!atEntry)
|
||||
continue;
|
||||
|
||||
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id);
|
||||
if (!at)
|
||||
continue;
|
||||
|
||||
if (at->target_mapId != m_session->GetPlayer()->GetMapId())
|
||||
continue;
|
||||
|
||||
float dx = at->target_X - pl->GetPositionX();
|
||||
float dy = at->target_Y - pl->GetPositionY();
|
||||
|
||||
if (dx*dx + dy*dy > dist2)
|
||||
continue;
|
||||
|
||||
ShowTriggerTargetListHelper(atEntry->id, at);
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
if (counter == 0) // if counter == 0 then we found nth
|
||||
SendSysMessage (LANG_COMMAND_NOTRIGGERFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static char const* const areatriggerKeys[] =
|
||||
{
|
||||
"Hareatrigger",
|
||||
"Hareatrigger_target",
|
||||
NULL
|
||||
};
|
||||
|
||||
bool ChatHandler::HandleGoTriggerCommand(const char* args)
|
||||
{
|
||||
Player* _player = m_session->GetPlayer();
|
||||
|
|
@ -148,7 +405,9 @@ bool ChatHandler::HandleGoTriggerCommand(const char* args)
|
|||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *atId = strtok((char*)args, " ");
|
||||
int keyIdx; // not index
|
||||
|
||||
char *atId = extractKeyFromLink((char*)args, areatriggerKeys, &keyIdx);
|
||||
if (!atId)
|
||||
return false;
|
||||
|
||||
|
|
@ -157,15 +416,36 @@ bool ChatHandler::HandleGoTriggerCommand(const char* args)
|
|||
if (!i_atId)
|
||||
return false;
|
||||
|
||||
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId);
|
||||
if (!at)
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(i_atId);
|
||||
if (!atEntry)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId);
|
||||
PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return HandleGoHelper(_player, at->mapid, at->x, at->y, &at->z);
|
||||
char* target_str = strtok(NULL, " ");
|
||||
if (target_str)
|
||||
{
|
||||
int l = strlen(target_str);
|
||||
if (strncmp(target_str, "target", l) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target_str != NULL)
|
||||
{
|
||||
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(i_atId);
|
||||
if (!at)
|
||||
{
|
||||
PSendSysMessage(LANG_AREATRIGER_NOT_HAS_TARGET, i_atId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return HandleGoHelper(_player, at->target_mapId, at->target_X, at->target_Y, &at->target_Z);
|
||||
}
|
||||
else
|
||||
return HandleGoHelper(_player, atEntry->mapid, atEntry->x, atEntry->y, &atEntry->z);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGoGraveyardCommand(const char* args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue