[DiscordArchive] Do you have a current lua or c++ script already to update or are you expecting a complete solution?
[DiscordArchive] Do you have a current lua or c++ script already to update or are you expecting a complete solution?
Archived author: Bloodfangx • Posted: 2023-08-15T23:01:53.221000+00:00
Original source
Do you have a current lua or c++ script already to update or are you expecting a complete solution?
Archived author: Bloodfangx • Posted: 2023-08-15T23:35:16.748000+00:00
Original source
```cpp
#include "ScriptMgr.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
const int gossipMenu = urand(1000, 100000);
const int questIdToComplete = CHANGE_TO_QUEST_ID;
class gossip_complete_quest : public CreatureScript
{
public:
gossip_complete_quest() : CreatureScript("gossip_complete_quest") { }
bool OnGossipHello(Player* player, Creature* creature) override
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Complete Quest", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Goodbye..", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 99);
player->SEND_GOSSIP_MENU(gossipMenu, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
case GOSSIP_ACTION_INFO_DEF + 1:
player->CompleteQuest(questIdToComplete);
break;
case GOSSIP_ACTION_INFO_DEF + 99:
player->CLOSE_GOSSIP_MENU();
break;
}
return true;
}
};
void AddSC_gossip_complete_quest()
{
new gossip_complete_quest();
}
```
Archived author: Bloodfangx • Posted: 2023-08-15T23:41:56.376000+00:00
Original source
Yeah, you could create a function to send the packet and pass in the npc name
Archived author: Bloodfangx • Posted: 2023-08-15T23:42:04.427000+00:00
Original source
for npc info
Archived author: Bloodfangx • Posted: 2023-08-15T23:42:06.532000+00:00
Original source
or creature info
Archived author: Bloodfangx • Posted: 2023-08-15T23:42:44.757000+00:00
Original source
you would then just call that function in your script
Archived author: Bloodfangx • Posted: 2023-08-15T23:42:53.443000+00:00
Original source
when ever you want it to update the npc name
tring Name, SubName;Archived author: Bloodfangx • Posted: 2023-08-15T23:57:26.760000+00:00
Original source
```cpp
static void SendNpcInfoPacket(Player* player, Creature* creature, const char* npcName)
{
CreatureTemplate const* ci = creature->GetCreatureTemplate();
if (ci)
{
std:
tring Name, SubName;
Name = ci->Name;
SubName = ci->SubName;
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
if (CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(ci->Entry))
{
ObjectMgr::GetLocaleString(cl->Name, loc_idx, Name);
ObjectMgr::GetLocaleString(cl->SubName, loc_idx, SubName);
}
}
// guess size
WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 100);
data << uint32(ci->Entry); // creature entry
data << npcName;
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
data << SubName;
data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0
data << uint32(ci->type_flags); // flags
data << uint32(ci->type); // CreatureType.dbc
data << uint32(ci->family); // CreatureFamily.dbc
data << uint32(ci->rank); // Creature Rank (elite, boss, etc)
data << uint32(ci->KillCredit[0]); // new in 3.1, kill credit
data << uint32(ci->KillCredit[1]); // new in 3.1, kill credit
data << uint32(sObjectMgr->GetCreatureDisplay(ci->Modelid1)); // Modelid1
data << uint32(sObjectMgr->GetCreatureDisplay(ci->Modelid2)); // Modelid2
data << uint32(sObjectMgr->GetCreatureDisplay(ci->Modelid3)); // Modelid3
data << uint32(sObjectMgr->GetCreatureDisplay(ci->Modelid4)); // Modelid4
data << float(ci->ModHealth); // dmg/hp modifier
data << float(ci->ModMana); // dmg/mana modifier
data << uint8(ci->RacialLeader);
CreatureQuestItemList const* items = sObjectMgr->GetCreatureQuestItemList(ci->Entry);
if (items)
for (size_t i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i)
data << (i < items->size() ? uint32((*items)[i]) : uint32(0));
else
for (size_t i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i)
data << uint32(0);
data << uint32(ci->movementId); // CreatureMovementInfo.dbc
player->GetSession()->SendPacket(&data);
}
else
{
WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 4);
data << uint32(ci->Entry | 0x80000000);
player->GetSession()->SendPacket(&data);
}
}
```
try this, i haven't tested it, it may or may not work, I just took the SMSG_CREATURE_QUERY_RESPONSE packet and functionized it to be usable in a script also note it will only update the players local cache and not everyone.
I don't know if it works, I hope its a good starting point good luck.