mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[8968] Implement gossip menu options for GameObject
Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
25688fc8eb
commit
f0e7f01a7b
4 changed files with 40 additions and 24 deletions
|
|
@ -300,27 +300,44 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
|
||||||
sLog.outBasic("string read: %s", code.c_str());
|
sLog.outBasic("string read: %s", code.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
|
|
||||||
|
|
||||||
if (!pCreature)
|
|
||||||
{
|
|
||||||
sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
if (!code.empty())
|
// TODO: determine if scriptCall is needed for GO and also if scriptCall can be same as current, with modified argument WorldObject*
|
||||||
|
|
||||||
|
if (IS_CREATURE_GUID(guid))
|
||||||
{
|
{
|
||||||
if (!Script->GossipSelectWithCode(_player, pCreature, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str()))
|
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
|
||||||
_player->OnGossipSelect(pCreature, gossipListId, menuId);
|
|
||||||
|
if (!pCreature)
|
||||||
|
{
|
||||||
|
sLog.outDebug("WORLD: HandleGossipSelectOptionOpcode - Creature (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!code.empty())
|
||||||
|
{
|
||||||
|
if (!Script->GossipSelectWithCode(_player, pCreature, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str()))
|
||||||
|
_player->OnGossipSelect(pCreature, gossipListId, menuId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!Script->GossipSelect(_player, pCreature, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId)))
|
||||||
|
_player->OnGossipSelect(pCreature, gossipListId, menuId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (IS_GAMEOBJECT_GUID(guid))
|
||||||
{
|
{
|
||||||
if (!Script->GossipSelect(_player, pCreature, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId)))
|
GameObject *pGo = GetPlayer()->GetGameObjectIfCanInteractWith(guid);
|
||||||
_player->OnGossipSelect(pCreature, gossipListId, menuId);
|
|
||||||
|
if (!pGo)
|
||||||
|
{
|
||||||
|
sLog.outDebug("WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_player->OnGossipSelect(pGo, gossipListId, menuId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2117,14 +2117,14 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const
|
GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, uint32 gameobject_type) const
|
||||||
{
|
{
|
||||||
if(GameObject *go = GetMap()->GetGameObject(guid))
|
if (GameObject *go = GetMap()->GetGameObject(guid))
|
||||||
{
|
{
|
||||||
if(go->GetGoType() == type)
|
if (uint32(go->GetGoType()) == gameobject_type || gameobject_type == MAX_GAMEOBJECT_TYPE)
|
||||||
{
|
{
|
||||||
float maxdist;
|
float maxdist;
|
||||||
switch(type)
|
switch(go->GetGoType())
|
||||||
{
|
{
|
||||||
// TODO: find out how the client calculates the maximal usage distance to spellless working
|
// TODO: find out how the client calculates the maximal usage distance to spellless working
|
||||||
// gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
|
// gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
|
||||||
|
|
@ -2140,10 +2140,10 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (go->IsWithinDistInMap(this, maxdist))
|
if (go->IsWithinDistInMap(this, maxdist) && go->isSpawned())
|
||||||
return go;
|
return go;
|
||||||
|
|
||||||
sLog.outError("IsGameObjectOfTypeInRange: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name,
|
sLog.outError("GetGameObjectIfCanInteractWith: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name,
|
||||||
go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this));
|
go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12287,11 +12287,10 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
|
||||||
bCanTalk = false;
|
bCanTalk = false;
|
||||||
break;
|
break;
|
||||||
case GOSSIP_OPTION_GOSSIP:
|
case GOSSIP_OPTION_GOSSIP:
|
||||||
if (pGo->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER || pGo->GetGoType() != GAMEOBJECT_TYPE_GOOBER)
|
if (pGo->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER && pGo->GetGoType() != GAMEOBJECT_TYPE_GOOBER)
|
||||||
bCanTalk = false;
|
bCanTalk = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sLog.outErrorDb("GameObject entry %u are using invalid gossip option %u for menu %u", pGo->GetEntry(), itr->second.option_id, itr->second.menu_id);
|
|
||||||
bCanTalk = false;
|
bCanTalk = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1066,7 +1066,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
|
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
|
||||||
|
|
||||||
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
|
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
|
||||||
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
|
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, uint32 gameobject_type = MAX_GAMEOBJECT_TYPE) const;
|
||||||
|
|
||||||
void UpdateVisibilityForPlayer();
|
void UpdateVisibilityForPlayer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8967"
|
#define REVISION_NR "8968"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue