void CCommands::AddStats(int aIndex, LPCSTR AddPoints, DWORD Type)
{
char Message[255];
int Points = atoi(AddPoints);
if(Points < 1) return;
LPOBJ lpObj = &gObj[aIndex];
if(g_Configs.AddStatsEnable == 0) return;
if(Points > g_Configs.AddStatsMaxPoints)
{
sprintf(Message,"You can add %d point(s)",g_Configs.AddStatsMaxPoints);
GCServerMsgStringSend(Message,aIndex,1);
return;
}
if(g_Configs.AddStatsLevel > lpObj->Level)
{
sprintf(Message,"You must be %d level to use this command",g_Configs.AddStatsLevel);
GCServerMsgStringSend(Message,aIndex,1);
return;
}
if(g_Configs.AddStatsCost > lpObj->Money)
{
sprintf(Message,"You need %d of Zen to use this command",g_Configs.AddStatsCost);
GCServerMsgStringSend(Message,aIndex,1);
return;
}
if(Type == 4 && lpObj->Class != CLASS_DARKLORD)
{
GCServerMsgStringSend("Command is only to DarkLord",aIndex,1);
return;
}
if(lpObj->LevelUpPoint < Points)
{
GCServerMsgStringSend("Don't have you sufficient points",aIndex,1);
return;
}
int maxStr = Points + lpObj->Strength;
if (Type == 3) {
if (maxStr > g_Configs.MaxStats) {
sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
GCServerMsgStringSend(Message, aIndex, 1);
return;
}
}
int maxAgi = Points + lpObj->Dexterity;
if (Type == 2) {
if (maxAgi > g_Configs.MaxStats) {
sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
GCServerMsgStringSend(Message, aIndex, 1);
return;
}
}
int maxVit = Points + lpObj->Vitality;
if (Type == 1) {
if (maxVit > g_Configs.MaxStats) {
sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
GCServerMsgStringSend(Message, aIndex, 1);
return;
}
}
int maxEne = Points + lpObj->Energy;
if (Type == 0) {
if (maxEne > g_Configs.MaxStats) {
sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
GCServerMsgStringSend(Message, aIndex, 1);
return;
}
}
int maxCmd = Points + lpObj->Leadership;
if (Type == 4) {
if (maxCmd > g_Configs.MaxStatsCmd) {
sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStatsCmd);
GCServerMsgStringSend(Message, aIndex, 1);
return;
}
}
lpObj->Money -= g_Configs.AddStatsCost;
GCMoneySend(aIndex, lpObj->Money);
switch(Type)
{
case 3:
lpObj->Strength += Points;
break;
case 2:
lpObj->Dexterity += Points;
break;
case 1:
lpObj->Vitality += Points;
lpObj->MaxLife += lpObj->VitalityToLife * Points;
GCReFillSend(lpObj->m_Index,lpObj->MaxLife + lpObj->AddLife,0xFE,0,lpObj->iMaxShield+lpObj->iAddShield);
break;
case 0:
lpObj->Energy += Points;
lpObj->MaxMana += lpObj->EnergyToMana * Points;
gObjSetBP(lpObj->m_Index);
GCManaSend(lpObj->m_Index,lpObj->MaxMana + lpObj->AddMana,0xFE,0,lpObj->MaxBP);
break;
case 4:
lpObj->Leadership += Points;
break;
}
// =================================================
// YOU NEED THIS FOR CORRECT SENDING FUNCTION.
// =================================================
BYTE PMSG_USE_STAT_FRUIT[8] = { 0xC1,0x08,0x2C,0x00,0x01,0x00,0x03,0x00 };
PMSG_USE_STAT_FRUIT[4] = LOBYTE(Points);
PMSG_USE_STAT_FRUIT[5] = HIBYTE(Points);
PMSG_USE_STAT_FRUIT[6] = (BYTE)Type;
DataSend(aIndex,(unsigned char*)PMSG_USE_STAT_FRUIT,8);
// =================================================
lpObj->LevelUpPoint -= Points;
GCLevelUpMsgSend(lpObj->m_Index,1);
// ----
gObjCalCharacter(aIndex);
// ----
sprintf(Message,"%d Added points!",Points);
GCServerMsgStringSend(Message,aIndex,1);
sprintf(Message,"Already have you %d Points",lpObj->LevelUpPoint);
GCServerMsgStringSend(Message,aIndex,1);
}