• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Need Help editing a function

kird

New Member
Joined
Jul 3, 2010
Messages
78
Reaction score
1
Well this is the dropLoot() function located inside Player.cpp file
Code:
void Player::dropLoot(Container* corpse)
{
	if(!corpse || lootDrop != LOOT_DROP_FULL)
		return;

	uint32_t start = g_config.getNumber(ConfigManager::BLESS_REDUCTION_BASE), loss = lossPercent[LOSS_CONTAINERS], bless = getBlessings();
	while(bless > 0 && loss > 0)
	{
		loss -= start;
		start -= g_config.getNumber(ConfigManager::BLESS_REDUCTION_DECREAMENT);
		bless--;
	}

	uint32_t itemLoss = (uint32_t)std::floor((5. + loss) * lossPercent[LOSS_ITEMS] / 1000.);
	for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
	{
		Item* item = inventory[i];
		if(!item)
			continue;

		uint32_t rand = random_range(1, 100);
		if(skull > SKULL_WHITE || (item->getContainer() && rand < loss) || (!item->getContainer() && rand < itemLoss))
		{
			g_game.internalMoveItem(NULL, this, corpse, INDEX_WHEREEVER, item, item->getItemCount(), 0);
			sendRemoveInventoryItem((slots_t)i, inventory[(slots_t)i]);
		}
	}
}
I need to fix it so it only drops the backpacks 100% of the time but never drop equipment.

I'd do it myself but as i suck at c++ im afraid of fucking the script up.

Thnx in advance

Kird~
 
Code:
void Player::dropLoot(Container* corpse)
{
	if(!corpse || lootDrop != LOOT_DROP_FULL)
		return;

	uint32_t start = g_config.getNumber(ConfigManager::BLESS_REDUCTION_BASE), loss = lossPercent[LOSS_CONTAINERS], bless = getBlessings();
	while(bless > 0 && loss > 0)
	{
		loss -= start;
		start -= g_config.getNumber(ConfigManager::BLESS_REDUCTION_DECREAMENT);
		bless--;
	}

	uint32_t itemLoss = (uint32_t)std::floor((5. + loss) * lossPercent[LOSS_ITEMS] / 1000.);
	for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
	{
		Item* item = inventory[i];
		if(!item)
			continue;

		uint32_t rand = random_range(1, 100);
		if(skull > SKULL_WHITE || (item->getContainer() && rand < loss) || (!item->getContainer() && rand < itemLoss))
		{
			g_game.internalMoveItem(NULL, this, corpse, INDEX_WHEREEVER, item, item->getItemCount(), 0);
			sendRemoveInventoryItem((slots_t)i, inventory[(slots_t)i]);
		}
	}
}
Kird~

Code:
void Player::dropLoot(Container* corpse)
{
	if(!corpse || lootDrop != LOOT_DROP_FULL)
		return;

	for(int32_t i = SLOT_BACKPACK; i < SLOT_ARMOR; ++i)
	{
		Item* item = inventory[i];
		if(!item)
			continue;

	if(item->getContainer() || (!item->getContainer() )
		{
			g_game.internalMoveItem(NULL, this, corpse, INDEX_WHEREEVER, item, item->getItemCount(), 0);
			sendRemoveInventoryItem((slots_t)i, inventory[(slots_t)i]);
		}
	}
}

If you have red or black skull you loss only bp, bless system & aol not working... anjoy:peace:
 
It guives me the folowing error while compiling:

Code:
769 -- expected ')' before '{' token 
773 -- expected primary-expression before '}' token 
773  expected ';' before '}' token 
773 -- *** [obj//player.o] Error 1

It seems that u missed a '}' but i can't fix it, i've ever made c++
Help please

Yours~
Kird

btw: Thnx for the replies
 
Last edited:
It guives me the folowing error while compiling:

Code:
769 -- expected ')' before '{' token 
773 -- expected primary-expression before '}' token 
773  expected ';' before '}' token 
773 -- *** [obj//player.o] Error 1

It seems that u missed a '}' but i can't fix it, i've ever made c++
Help please

Yours~
Kird

btw: Thnx for the replies


hmmm it works for me...
Code:
void Player::dropLoot(Container* corpse)
{
	if(!corpse || lootDrop != LOOT_DROP_FULL)
		return;

	for(int32_t i = SLOT_BACKPACK; i < SLOT_ARMOR; ++i)
	{
		Item* item = inventory[i];
			if(!item)
				continue;

		if(item->getContainer() || (!item->getContainer())
			{
				g_game.internalMoveItem(NULL, this, corpse, INDEX_WHEREEVER, item, item->getItemCount(), 0);
				sendRemoveInventoryItem((slots_t)i, inventory[(slots_t)i]);
			}
	}
}
 
I'm useing 0.3.6pl1 server, did u test it on this server too?


Hmm ok i try to compile it on this version... wait moment...;)

edit...

This MUST be good...
Code:
void Player::dropLoot(Container* corpse)
{
	if(!corpse || lootDrop != LOOT_DROP_FULL)
		return;

	for(int32_t i = SLOT_BACKPACK; i < SLOT_ARMOR; ++i)
	{
		Item* item = inventory[i];
			if(!item)
				continue;

		if(item->getContainer() || !item->getContainer())
			{
				g_game.internalMoveItem(NULL, this, corpse, INDEX_WHEREEVER, item, item->getItemCount(), 0);
				sendRemoveInventoryItem((slots_t)i, inventory[(slots_t)i]);
			}
	}
}
 
Last edited:
Back
Top