• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Add loot to GO via C++

Status
Not open for further replies.

Kaev

Super Moderator
[SOLVED] Add loot to GO via C++

Hiho,
i have a chest-GO, where i want to add new loot via C++.

My script looks like this:
Code:
class startChestItemSets : public GameObjectScript
{
public:

	startChestItemSets()
		: GameObjectScript("startChestItemSets")
	{
	}

	void OnLootStateChanged(GameObject* go, uint32 state, Unit* player)
	{
		if (go->getLootState() == GO_ACTIVATED)
		{
			LootStoreItem* item;
			item->itemid = 100;
			item->maxcount = 1;
			item->mincountOrRef = 1;
                        item->chance = 100;
 			go->loot.AddItem(*item);
		}
	}
};

void AddSC_startChestItemSets()
{
	new startChestItemSets();
}

I get a servercrash instead my item, when i open this chest. I think my use of LootStoreItem is wrong.
Can you figure out what's wrong or give me a working example?

~Kaev
 
Last edited:

Reloac

BETA Tester
I don't see why you would do the loot via C++, if you want to change it you'd need to re-build the core, when you can just do it via the database and a reload/restart would fix the loot or change it.
 

Kaev

Super Moderator
I want the loottable in the database + one random hardcoded "itemset".
For example:

Banana (Loottable)
Sword1 + Shield1 (Hardcoded as a itemset)
Or
Banana (Loottable)
Sword2+Boots1 (Also hardcoded as a itemset)
Or
Water+Banana (Loottable)
Sword2+Boots1 (Hardcoded)
 

Jameyboor

Retired Staff
Either create an object of the struct or call the constructor of the struct before working with the pointer.
 
Status
Not open for further replies.
Top