// TMSrv 7.56 004C1FC0 | TMSrv 7.57 00573A30
void ProcessRanking()
{
if (RankingTime > 0)
{
--RankingTime / 5;
if (!(RankingTime % 5))
{
int kRank1 = 0;
int kRank2 = 0;
for (int i = 1; i < MAX_USER; ++i)
{
if (pUser[i].Mode == USER_PLAY && pMob[i].MOB.CurrentScore.Hp > 0)
{
int TargetX = pMob[i].TargetX;
int TargetY = pMob[i].TargetY;
if (TargetX >= kRanking1X && TargetX <= kRanking2X &&
TargetY >= kRanking1X && TargetY <= kRanking2Y)
{
if (RankingProcess == 1)
{
if (i == Ranking1)
++kRank1;
if (i == Ranking2)
++kRank2;
}
else
{
if (pMob[i].MOB.Guild == Ranking1)
kRank1 += pMob[i].MOB.CurrentScore.Level;
if (pMob[i].MOB.Guild == Ranking2)
kRank2 += pMob[i].MOB.CurrentScore.Level;
}
}
}
}
if (!kRank1 || !kRank2)
RankingTime = 0;
}
if (RankingTime < 60)
{
SendDamage(142, 4007, 195, 4042);
SendDamage(142, 4046, 195, 4082);
SendEnvEffect(142, 4007, 168, 4018, 32, 0);
SendEnvEffect(142, 4071, 168, 4082, 32, 0);
SendEnvEffect(142, 4019, 168, 4030, 32, 0);
SendEnvEffect(142, 4059, 168, 4070, 32, 0);
SendEnvEffect(142, 4031, 168, 4042, 32, 0);
SendEnvEffect(142, 4047, 168, 4058, 32, 0);
SendEnvEffect(168, 4007, 195, 4018, 32, 0);
SendEnvEffect(168, 4071, 195, 4082, 32, 0);
SendEnvEffect(168, 4019, 195, 4030, 32, 0);
SendEnvEffect(168, 4059, 195, 4070, 32, 0);
SendEnvEffect(168, 4031, 195, 4042, 32, 0);
SendEnvEffect(168, 4047, 195, 4058, 32, 0);
}
else if (RankingTime < 120)
{
SendDamage(142, 4007, 195, 4034);
SendDamage(142, 4055, 195, 4082);
SendEnvEffect(142, 4007, 168, 4018, 32, 0);
SendEnvEffect(142, 4071, 168, 4082, 32, 0);
SendEnvEffect(142, 4019, 168, 4030, 32, 0);
SendEnvEffect(142, 4059, 168, 4070, 32, 0);
SendEnvEffect(168, 4007, 195, 4018, 32, 0);
SendEnvEffect(168, 4071, 195, 4082, 32, 0);
SendEnvEffect(168, 4019, 195, 4030, 32, 0);
SendEnvEffect(168, 4059, 195, 4070, 32, 0);
}
else if (RankingTime < 180)
{
SendDamage(142, 4007, 195, 4019);
SendDamage(142, 4070, 195, 4082);
SendEnvEffect(142, 4007, 168, 4018, 32, 0);
SendEnvEffect(142, 4071, 168, 4082, 32, 0);
SendEnvEffect(169, 4007, 195, 4018, 32, 0);
SendEnvEffect(169, 4071, 195, 4082, 32, 0);
}
}
if (RankingTime <= 0)
{
int nRank1 = 0;
int nRank2 = 0;
int mScore1 = 0;
int mScore2 = 0;
int TotalScore1 = 0;
int TotalScore2 = 0;
for (int j = 1; j < MAX_USER; ++j)
{
if (pUser[j].Mode == USER_PLAY && pMob[j].MOB.CurrentScore.Hp > 0)
{
int TargetX = pMob[j].TargetX;
int TargetY = pMob[j].TargetY;
if (TargetX >= kRanking1X && TargetX <= kRanking2X &&
TargetY >= kRanking1X && TargetY <= kRanking2Y)
{
if (RankingProcess == 1)
{
if (j == Ranking1)
++nRank1;
if (j == Ranking2)
++nRank2;
}
else
{
if (pMob[j].MOB.Guild == Ranking1)
nRank1 += pMob[j].MOB.CurrentScore.Level;
if (pMob[j].MOB.Guild == Ranking2)
nRank2 += pMob[j].MOB.CurrentScore.Level;
}
if (pMob[j].MOB.Equip[13].sIndex == 769)
{
if (j == Ranking1)
mScore1 += pMob[j].MOB.Equip[13].stEffect[0].cValue;
if (j == Ranking2)
mScore2 += pMob[j].MOB.Equip[13].stEffect[0].cValue;
}
}
}
}
nRanking1[NAME_LENGTH - 1] = 0;
nRanking1[NAME_LENGTH - 2] = 0;
nRanking2[NAME_LENGTH - 1] = 0;
nRanking2[NAME_LENGTH - 2] = 0;
TotalScore1 = nRank1 + mScore1;
TotalScore2 = nRank2 + mScore2;
for (int k = 1; k < MAX_USER; ++k)
{
if (pUser[k].Mode == USER_PLAY)
{
int isRank = false;
if (RankingProcess == 1)
{
if (k == Ranking1 || k == Ranking2)
isRank = true;
}
else
{
if (pMob[k].MOB.Guild == Ranking1 || pMob[k].MOB.Guild == Ranking2)
isRank = false;
}
if (isRank)
{
if (TotalScore1 == TotalScore2)
{
SendClientSignalParm(k, ESCENE_FIELD, _MSG_StartTime, 0);
snprintf(Buffer, 0x80u, g_pMessageStringTable[_SS_S_S_Draw], nRanking1, nRanking2, TotalScore1, TotalScore2);
SendClientMessage(k, Buffer);
}
else
{
SendClientSignalParm(k, ESCENE_FIELD, _MSG_StartTime, 0);
if (TotalScore1 > TotalScore2)
snprintf(Buffer, 0x80u, g_pMessageStringTable[_SS_S_WinBy_S], nRanking1, nRanking2, TotalScore1, TotalScore2);
else
snprintf(Buffer, 0x80u, g_pMessageStringTable[_SS_S_WinBy_S], nRanking2, nRanking1, TotalScore1, TotalScore2);
SendClientMessage(k, Buffer);
}
}
}
}
MSG_MessageDBRecord stDBRecord;
memset(&stDBRecord, 0, sizeof(MSG_MessageDBRecord));
stDBRecord.Type = _MSG_MessageDBRecord;
stDBRecord.ID = 0;
stDBRecord.Size = sizeof(MSG_MessageDBRecord);
ClearPocessRanking();
}
}
// TMSrv 7.56 004C3A90 | TMSrv 7.57 00575300
void ClearPocessRanking()
{
RankingProcess = 0;
RankingTime = 0;
Ranking1 = 0;
Ranking2 = 0;
nRanking1[0] = 0;
nRanking2[0] = 0;
ClearAreaTeleport(kRanking1X, kRanking1Y, kRanking2X, kRanking2Y, 2572, 1752);
}