Hitman94
Member
- Joined
- Feb 9, 2009
- Messages
- 88
- Solutions
- 1
- Reaction score
- 12
Everything works on OTX server: D only had to clean everything I had underneath
Now it looks like this
And I can not connect to my old code, the teeth worked which looks like this
Maybe someone wants to combine it so that there are no mistakes I can not give thanks in advance
I apologize for the translator
C++:
void MonsterType :: createLoot (Container * corpse)
Now it looks like this
C++:
void MonsterType::createLoot(Container* corpse)
{
if (g_config.getNumber(ConfigManager::RATE_LOOT) == 0) {
corpse->startDecaying();
return;
}
Player* owner = g_game.getPlayerByID(corpse->getCorpseOwner());
std::string autolooted = "";
if (!owner || owner->getStaminaMinutes() > 840) {
for (auto it = info.lootItems.rbegin(), end = info.lootItems.rend(); it != end; ++it) {
auto itemList = createLootItem(*it);
if (itemList.empty()) {
continue;
}
for (Item* item : itemList) {
//check containers
if (Container* container = item->getContainer()) {
if (!createLootContainer(container, *it)) {
delete container;
continue;
}
}
if (owner && owner->getAutoLootItem(item->getID())){
g_game.internalPlayerAddItem(owner, item, true, CONST_SLOT_WHEREEVER);
autolooted = autolooted + ", " + item->getNameDescription();
} else if (g_game.internalAddItem(corpse, item) != RETURNVALUE_NOERROR) {
corpse->internalAddThing(item);
}
}
}
if (owner) {
std::ostringstream ss;
std::string lootMsg = corpse->getContentDescription();
//ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription(); -- change for autoloot system
if (autolooted != "" && corpse->getContentDescription() == "nothing"){
lootMsg = autolooted.erase(0,2) + " that was autolooted";
} else if (autolooted != ""){
lootMsg = corpse->getContentDescription() + " and " + autolooted.erase(0,2) + " was auto looted";
}
ss << "Loot of " << nameDescription << ": " << lootMsg;
if (owner->getParty()) {
ss << " by " << owner->getName();
owner->getParty()->broadcastPartyLoot(ss.str());
} else {
owner->sendTextMessage(MESSAGE_LOOT, ss.str());
}
}
} else {
std::ostringstream ss;
ss << "Loot of " << nameDescription << ": nothing (due to low stamina)";
if (owner->getParty()) {
owner->getParty()->broadcastPartyLoot(ss.str());
} else {
owner->sendTextMessage(MESSAGE_LOOT, ss.str());
}
}
corpse->startDecaying();
}
And I can not connect to my old code, the teeth worked which looks like this
C++:
void MonsterType::createLoot(Container* corpse)
{
if (g_config.getNumber(ConfigManager::RATE_LOOT) == 0) {
corpse->startDecaying();
return;
}
if (info.isRewardBoss) {
auto timestamp = time(nullptr);
Item* rewardContainer = Item::CreateItem(ITEM_REWARD_CONTAINER);
rewardContainer->setIntAttr(ITEM_ATTRIBUTE_DATE, timestamp);
corpse->setIntAttr(ITEM_ATTRIBUTE_DATE, timestamp);
corpse->internalAddThing(rewardContainer);
corpse->setRewardCorpse();
corpse->startDecaying();
return;
}
Player* owner = g_game.getPlayerByID(corpse->getCorpseOwner());
if (!owner || owner->getStaminaMinutes() > 840) {
bool canRerollLoot = false;
if (owner) {
for (int i = 0; i < 3; i++) {
if (owner->getPreyType(i) == 3 && name == owner->getPreyName(i)) {
uint32_t rand = uniform_random(0, 100);
if (rand <= owner->getPreyValue(i)) {
canRerollLoot = true;
}
break;
}
}
}
for (auto it = info.lootItems.rbegin(), end = info.lootItems.rend(); it != end; ++it) {
auto itemList = createLootItem(*it, canRerollLoot);
if (itemList.empty()) {
continue;
}
for (Item* item : itemList) {
//check containers
if (Container* container = item->getContainer()) {
if (!createLootContainer(container, *it)) {
delete container;
continue;
}
}
if (g_game.internalAddItem(corpse, item) != RETURNVALUE_NOERROR) {
corpse->internalAddThing(item);
}
}
}
if (owner) {
std::ostringstream ss;
if (canRerollLoot) {
ss << "Loot of " << nameDescription << " [PREY]: " << corpse->getContentDescription();
} else {
ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription();
}
if (owner->getParty()) {
owner->getParty()->broadcastPartyLoot(ss.str());
} else {
owner->sendTextMessage(MESSAGE_LOOT, ss.str());
}
}
} else {
std::ostringstream ss;
ss << "Loot of " << nameDescription << ": nothing (due to low stamina)";
if (owner->getParty()) {
owner->getParty()->broadcastPartyLoot(ss.str());
} else {
owner->sendTextMessage(MESSAGE_LOOT, ss.str());
}
}
corpse->startDecaying();
}
Maybe someone wants to combine it so that there are no mistakes I can not give thanks in advance
I apologize for the translator