Soly
Member
- Gender
- Male
That's totally right... I haven't had caffeine todayI moved the monster.dead out of the check for character level just in case
Also.. there is a problem with your modification (specifically the part about reducing XP)
1) When you reduce the XP you are reassigning the variable so any successful "not the last who hit" will reduce the XP value more and more.
2) You are checking for each client's packet data for the last client who hit, but this fails because you are checking the first "hey mob is dead" packet... the other clients will have data not relevant to this code because packets are executed as soon as they are received entirely.
To fix 1, easy enough use a new variable inside the scope of the level check
To fix 2, you can ignore any calls to this function if it's not the client who killed the monster.
Only execute when the client who sent the packet was the last one who hit and then give full xp to this client and reduced xp to the rest.
Here is an updated version that accounts for this
Code:
CLIENT *c; // This is the client who's packet is being executed, in teth it will be 'client' iirc
int32_t i1;
// Somewhere at the top of the function
if (mid < 0xB50)
{
if (l->monsterData[mid].dead[c->clientID] == 0 && c->decbuf[0x10] != 0)
{
...
for (i1 = 0; i1 < 4; i1++)
{
// we don't have full parties every time
if (l->client[i1] != NULL)
{
if (l->client[i1]->character.level < 199)
{
// Is this iteration the client who killed it?
if (l->client[i1] == c)
{
ClientAddExp(l->client[i1], xp);
}
else
{
ClientAddExp(l->client[i1], (XP * 77) / 100L);
}
}
}
// Just to be totally sure ;)
l->monsterData[mid].dead[i1] = 1;
}
...
}
}