Howdy,
I am looking into some of this coding for C++, which I am not good at... however I want to add this feature that monsters only drop 1 item from the loot table.
TFS 1.3
I wanted to know if this code here
monsters.cpp
Is the correct spot to adjust monster loot?
I tried adjusting what I thought was the area to change this but I am apparently not correct..
I changed
to
thinking that the next lines
Would only generate 1 item instead of pulling from the itemList itself
I think I am close, but like I said this is kind of above me right now...It appears there could be a work around with a .lua script adding "extra loot" and having it pull from a loot list that way.. but I don't want to go in and adjust all my monsters into that 1 script and remove their drops from XML, etc etc..
Thanks for listening!
I am looking into some of this coding for C++, which I am not good at... however I want to add this feature that monsters only drop 1 item from the loot table.
TFS 1.3
I wanted to know if this code here
monsters.cpp
C++:
std::vector<Item*> MonsterType::createLootItem(const LootBlock& lootBlock)
{
int32_t itemCount = 0;
uint32_t randvalue = Monsters::getLootRandom();
if (randvalue < lootBlock.chance) {
if (Item::items[lootBlock.id].stackable) {
itemCount = randvalue % lootBlock.countmax + 1;
} else {
itemCount = 1;
}
}
std::vector<Item*> itemList;
while (itemCount > 0) {
uint16_t n = static_cast<uint16_t>(std::min<int32_t>(itemCount, 100));
Item* tmpItem = Item::CreateItem(lootBlock.id, n);
if (!tmpItem) {
break;
}
itemCount -= n;
if (lootBlock.subType != -1) {
tmpItem->setSubType(lootBlock.subType);
}
if (lootBlock.actionId != -1) {
tmpItem->setActionId(lootBlock.actionId);
}
if (!lootBlock.text.empty()) {
tmpItem->setText(lootBlock.text);
}
itemList.push_back(tmpItem);
}
return itemList;
}
I tried adjusting what I thought was the area to change this but I am apparently not correct..
I changed
C++:
uint16_t n = static_cast<uint16_t>(std::min<int32_t>(itemCount, 100));
C++:
uint16_t n = 1;
C++:
Item* tmpItem = Item::CreateItem(lootBlock.id, n);
if (!tmpItem) {
break;
I think I am close, but like I said this is kind of above me right now...It appears there could be a work around with a .lua script adding "extra loot" and having it pull from a loot list that way.. but I don't want to go in and adjust all my monsters into that 1 script and remove their drops from XML, etc etc..
Thanks for listening!
Last edited: