Forums WoW Modding Support Archives TrinityCore Discord Archives [DiscordArchive] And you made your code all by yourself no reference wiki or anything?

[DiscordArchive] And you made your code all by yourself no reference wiki or anything?

[DiscordArchive] And you made your code all by yourself no reference wiki or anything?

rektbyfaith
Administrator
0
01-31-2025, 04:58 PM
#1
Archived author: Whomadeit • Posted: 2025-01-31T16:58:06.991000+00:00
Original source

And you made your code all by yourself no reference wiki or anything?
rektbyfaith
01-31-2025, 04:58 PM #1

Archived author: Whomadeit • Posted: 2025-01-31T16:58:06.991000+00:00
Original source

And you made your code all by yourself no reference wiki or anything?

rektbyfaith
Administrator
0
01-31-2025, 04:58 PM
#2
Archived author: Whomadeit • Posted: 2025-01-31T16:58:10.023000+00:00
Original source

I’d be shocked
rektbyfaith
01-31-2025, 04:58 PM #2

Archived author: Whomadeit • Posted: 2025-01-31T16:58:10.023000+00:00
Original source

I’d be shocked

rektbyfaith
Administrator
0
01-31-2025, 04:58 PM
#3
Archived author: Whomadeit • Posted: 2025-01-31T16:58:21.392000+00:00
Original source

lol
rektbyfaith
01-31-2025, 04:58 PM #3

Archived author: Whomadeit • Posted: 2025-01-31T16:58:21.392000+00:00
Original source

lol

rektbyfaith
Administrator
0
01-31-2025, 05:00 PM
#4
Archived author: Whomadeit • Posted: 2025-01-31T17:00:07.787000+00:00
Original source

Like this would work too depends if you want item or npc
rektbyfaith
01-31-2025, 05:00 PM #4

Archived author: Whomadeit • Posted: 2025-01-31T17:00:07.787000+00:00
Original source

Like this would work too depends if you want item or npc

rektbyfaith
Administrator
0
01-31-2025, 05:00 PM
#5
Archived author: Whomadeit • Posted: 2025-01-31T17:00:09.811000+00:00
Original source

#include "Player.h"
#include "ScriptMgr.h"
#include "Creature.h"
#include "ObjectAccessor.h"
#include "Chat.h"

uint64 vendorNpcGuid = 0; // Global variable to track spawned vendor

void SendMenu_show_vendor(Player* player, Item* item)
{
uint32 vendor_id = 1234; // Replace with actual vendor NPC entry

uint32 distance = 2;

// Get player's current position
float playerX = player->GetPositionX();
float playerY = player->GetPositionY();
float playerZ = player->GetPositionZ();
float playerO = player->GetOrientation();

// Calculate summon position a few feet in front of the player
float summonX = playerX + distance * cos(playerO);
float summonY = playerY + distance * sin(playerO);
float summonZ = playerZ;

// Adjust summonZ if terrain height differs
summonZ = player->GetMap()->GetHeight(summonX, summonY, summonZ);

// Face NPC toward player
float npcOrientation = playerO + M_PI;

if (vendorNpcGuid)
{
// Find and despawn existing vendor
if (Creature* existingNpc = ObjectAccessor::GetCreature(*player, vendorNpcGuid))
{
if (existingNpc->IsInWorld())
existingNpc->DespawnOrUnsummon();
}
vendorNpcGuid = 0;
}

// Summon the vendor
if (Creature* summonedNpc = player->SummonCreature(vendor_id, summonX, summonY, summonZ, npcOrientation, TEMPSUMMON_MANUAL_DESPAWN, 300))
{
vendorNpcGuid = summonedNpc->GetGUID(); // Store NPC GUID for later reference
player->GetSession()->SendListInventory(summonedNpc->GetGUID(), summonedNpc->GetVendorEntries());
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage("Failed to summon vendor. Please try again.");
}
}
rektbyfaith
01-31-2025, 05:00 PM #5

Archived author: Whomadeit • Posted: 2025-01-31T17:00:09.811000+00:00
Original source

#include "Player.h"
#include "ScriptMgr.h"
#include "Creature.h"
#include "ObjectAccessor.h"
#include "Chat.h"

uint64 vendorNpcGuid = 0; // Global variable to track spawned vendor

void SendMenu_show_vendor(Player* player, Item* item)
{
uint32 vendor_id = 1234; // Replace with actual vendor NPC entry

uint32 distance = 2;

// Get player's current position
float playerX = player->GetPositionX();
float playerY = player->GetPositionY();
float playerZ = player->GetPositionZ();
float playerO = player->GetOrientation();

// Calculate summon position a few feet in front of the player
float summonX = playerX + distance * cos(playerO);
float summonY = playerY + distance * sin(playerO);
float summonZ = playerZ;

// Adjust summonZ if terrain height differs
summonZ = player->GetMap()->GetHeight(summonX, summonY, summonZ);

// Face NPC toward player
float npcOrientation = playerO + M_PI;

if (vendorNpcGuid)
{
// Find and despawn existing vendor
if (Creature* existingNpc = ObjectAccessor::GetCreature(*player, vendorNpcGuid))
{
if (existingNpc->IsInWorld())
existingNpc->DespawnOrUnsummon();
}
vendorNpcGuid = 0;
}

// Summon the vendor
if (Creature* summonedNpc = player->SummonCreature(vendor_id, summonX, summonY, summonZ, npcOrientation, TEMPSUMMON_MANUAL_DESPAWN, 300))
{
vendorNpcGuid = summonedNpc->GetGUID(); // Store NPC GUID for later reference
player->GetSession()->SendListInventory(summonedNpc->GetGUID(), summonedNpc->GetVendorEntries());
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage("Failed to summon vendor. Please try again.");
}
}

rektbyfaith
Administrator
0
01-31-2025, 05:01 PM
#6
Archived author: Thordekk • Posted: 2025-01-31T17:01:57.657000+00:00
Original source

wiki by hand like always
rektbyfaith
01-31-2025, 05:01 PM #6

Archived author: Thordekk • Posted: 2025-01-31T17:01:57.657000+00:00
Original source

wiki by hand like always

rektbyfaith
Administrator
0
01-31-2025, 05:02 PM
#7
Archived author: Thordekk • Posted: 2025-01-31T17:02:07.265000+00:00
Original source

vendorNpcGuid = 0;
rektbyfaith
01-31-2025, 05:02 PM #7

Archived author: Thordekk • Posted: 2025-01-31T17:02:07.265000+00:00
Original source

vendorNpcGuid = 0;

rektbyfaith
Administrator
0
01-31-2025, 05:02 PM
#8
Archived author: Whomadeit • Posted: 2025-01-31T17:02:18.275000+00:00
Original source

rektbyfaith
01-31-2025, 05:02 PM #8

Archived author: Whomadeit • Posted: 2025-01-31T17:02:18.275000+00:00
Original source

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)