All mobs drop gil

Post Reply
Urzah
Posts: 1
Joined: Sat Dec 07, 2013 12:46 pm

All mobs drop gil

Post by Urzah » Thu Dec 12, 2013 12:02 pm

Hello
I've been trying to make all mobs drop gil, i noticed that to do so, you probably have to edit ai/ai_mob_dummy.cpp
By default, i Have this:

//check for gil (beastmen drop gil, some NMs drop gil)
if(m_PMob->CanDropGil())
{
charutils::DistributeGil(PChar, m_PMob); // TODO: REALISATION MUST BE IN TREASUREPOOL
}

How can I get every monster to drop gil?
Ive tried simply commenting the lines, but it doesn't work :/
Can anyone help?

Thanks

User avatar
Signature
Posts: 126
Joined: Fri May 02, 2014 3:44 am

Re: All mobs drop gil

Post by Signature » Tue May 06, 2014 2:02 am

\darkstar\src\map\utils\mobutils.cpp
this will get you started. You can even be more specific with levels. amking each level range drop more and more gil as they get higher in level.

Code: Select all

if (PMob->GetSLevel() < 15)
	{
		PMob->setMobMod(MOBMOD_GIL_MIN, 1000);
		PMob->setMobMod(MOBMOD_GIL_MAX, 10000);
		PMob->setMobMod(MOBMOD_MUG_GIL, 50000);
	}

	if(PMob->GetSLevel() > 15)
	
	{
		PMob->setMobMod(MOBMOD_GIL_MIN, 2000);
		PMob->setMobMod(MOBMOD_GIL_MAX, 25000);
		PMob->setMobMod(MOBMOD_MUG_GIL, 10000);
   }

Dragus
Posts: 11
Joined: Thu Oct 09, 2014 12:54 am

Re: All mobs drop gil

Post by Dragus » Sat Oct 11, 2014 8:46 pm

Hello,

I've tried putting that code to make mobs at certain levels drop certain gil in a couple different places but I can't seem to get it to work. Could anyone point out where I need to put those two iff statements?

Thanks!

User avatar
Vivitaru
Posts: 41
Joined: Wed Apr 30, 2014 6:35 am
Location: Canada

Re: All mobs drop gil

Post by Vivitaru » Sat Oct 11, 2014 11:49 pm

Edit:

Sounds like you might want to have a custom formula based on mob level, try something like this:

charutils.cpp ; void DistributeGil(CCharEntity* PChar, CMobEntity* PMob)

Code: Select all

	uint32 gil = (PMob->GetMLevel() * 10) + rand() % 15, mul = 1.0f;
	int8 LevelDifference = PMob->GetMLevel() - PChar->GetMLevel();   // Get Level Difference

	if (LevelDifference < 0) {
		if (LevelDifference > -10) {
			mul += (PMob->GetMLevel() * 0.020f);
		}
		else{
		      gil = 0;
		}
	}
	else {
		mul += (LevelDifference*1.25);
	}
   gil *= mul;

Dragus
Posts: 11
Joined: Thu Oct 09, 2014 12:54 am

Re: All mobs drop gil

Post by Dragus » Sun Oct 12, 2014 5:50 pm

Thanks for replying!

I tried putting the code in under the distrubutegil thing, but it still didn't work :( I wanted it based on the mobs level, pretty much exactly how Signature had it in his. Is there something else I have to change or something? I've tried everywhere xD I put the entire function that's in my server below.

Code: Select all

void DistributeGil(CCharEntity* PChar, CMobEntity* PMob)
{
    //work out the amount of gil to give (guessed; replace with testing)
    uint32 gil = PMob->GetRandomGil();
	
		//Add gil drops
		if (PMob->GetSLevel() < 15)
		{
			PMob->setMobMod(MOBMOD_GIL_MIN, 100);
			PMob->setMobMod(MOBMOD_GIL_MAX, 1000);
			PMob->setMobMod(MOBMOD_MUG_GIL, 50000);
		}

		if(PMob->GetSLevel() > 15)
   
		{
			PMob->setMobMod(MOBMOD_GIL_MIN, 200);
			PMob->setMobMod(MOBMOD_GIL_MAX, 2500);
			PMob->setMobMod(MOBMOD_MUG_GIL, 1000);
		}

	//distribute to said members (perhaps store pointers to each member in first loop?)
	if (PChar->PParty != NULL)
	{
        // TODO: плохая реализация - два раза проверяем дистанцию, два раза проверяем один и тот же массив
		
		
		
        uint8 count = 0;
        //work out how many pt members should get the gil
        for (uint8 i = 0; i < PChar->PParty->members.size(); i++)
		{
            CBattleEntity* PMember = PChar->PParty->members[i];
            if (PMember->getZone() == PMob->getZone() && distance(PMember->loc.p, PMob->loc.p) < 100)
			{
                count++;
			}
		}

        uint32 gilperperson = count == 0 ? gil : (gil / count);

		for (uint8 i = 0; i < PChar->PParty->members.size(); i++)
		{
            CCharEntity* PMember = (CCharEntity*)PChar->PParty->members[i];
			if (PMember->getZone() == PMob->getZone() && distance(PMember->loc.p, PMob->loc.p) < 100)
			{
                UpdateItem(PMember, LOC_INVENTORY, 0, gilperperson);
                PMember->pushPacket(new CMessageBasicPacket(PMember,PMember,gilperperson,0,565));
            }
        }
    }
    else if (distance(PChar->loc.p, PMob->loc.p) < 100)
    {
        UpdateItem(PChar, LOC_INVENTORY, 0, gil);
        PChar->pushPacket(new CMessageBasicPacket(PChar,PChar,gil,0,565));
	}
}

Post Reply