Olá galera IMP,
Estou com um problema no meu DropSystem que não estou conseguindo solucionar, ele está dropando apenas o primeiro item que eu coloco na configuravel mesmo com os outros items com mesmo % de Rate...
Código:
#include "stdafx.h"
DROP DropInfo[255];
int nDropRateCount;
int DropCount;
void LoadDropSystem()
{
FILE *fp;
BOOL bRead = FALSE;
DWORD dwArgv = 0;
char sLineTxt[255] = {0};
DropCount = 0;
fp = fopen("..\\GTeam\\DropSystem.txt","r");
if(DropCount > MAX_DROP_NUMBER)
{
MessageBoxA(NULL, "Maximo de items do DropSystem foi excedido", "[DropSystem]", 0);
::ExitProcess(1);
}
if(!fp)
{
MessageBoxA(NULL, "DropSystem.txt não esta presente!", "Error!", MB_OK);
::ExitProcess(0);
}
rewind(fp);
while(fgets(sLineTxt, 255, fp) != NULL)
{
if(sLineTxt[0] == '/')continue;
if(sLineTxt[0] == ';')continue;
int n[11];
sscanf(sLineTxt, "%d %d %d %d %d %d %d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4], &n[5], &n[6], &n[7], &n[8], &n[9], &n[10]);
DropInfo[DropCount].IGroup = n[0];
DropInfo[DropCount].ID = n[1];
DropInfo[DropCount].MapDrop = n[2];
DropInfo[DropCount].MinLev = n[3];
DropInfo[DropCount].MaxLev = n[4];
DropInfo[DropCount].Skill = n[5];
DropInfo[DropCount].Luck = n[6];
DropInfo[DropCount].Life = n[7];
DropInfo[DropCount].Exc = n[8];
DropInfo[DropCount].Anc = n[9];
DropInfo[DropCount].Perc = n[10];
DropCount++;
nDropRateCount++;
}
rewind(fp);
fclose(fp);
}
bool ExcDropSystem(DWORD aIndex, DWORD MonsterID)
{
for(DropCount=0;DropCount<nDropRateCount;DropCount++)
{
if(rand()%10001 <= DropInfo[DropCount].Perc)
{
srand(static_cast<int>(time(NULL)));
OBJECTSTRUCT *pObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
if(DropInfo[DropCount].MapDrop == pObj->MapNumber || DropInfo[DropCount].MapDrop == -1)
{
int Item = (DropInfo[DropCount].IGroup * 512) + DropInfo[DropCount].ID;
int RDiv = (DropInfo[DropCount].MaxLev - DropInfo[DropCount].MinLev) + 1;
int ItemLevel = rand()%RDiv + DropInfo[DropCount].MinLev;
int ItemSkill,ItemLuck,ItemOpt,ItemExc,ItemAncient;
ItemSkill = rand()%(DropInfo[DropCount].Skill + 1);
ItemLuck = rand()%(DropInfo[DropCount].Luck + 1);
ItemOpt = rand()%(DropInfo[DropCount].Life + 1);
if(ItemOpt >= 1)ItemOpt = rand()%4;
ItemExc = DropInfo[DropCount].Exc;
if(ItemExc > 0)ItemSkill = 1;
else{
ItemSkill = 0;
}
if(ItemExc >= 1)
{
ItemExc = Radom2ExcOptGen();
}
else{
ItemExc = 0;
}
ItemAncient = DropInfo[DropCount].Anc;
if(ItemAncient >= 1)
{
int ADiv = rand()%3;
if(ADiv == 0)ItemAncient = 0;
if(ADiv == 1)ItemAncient = 5;
if(ADiv == 2)ItemAncient = 10;
}
else{
ItemAncient = 0;
}
OBJECTSTRUCT *mObj = (OBJECTSTRUCT*)OBJECT_POINTER(MonsterID);
ItemSerialCreateSend(aIndex,mObj->MapNumber,mObj->X,mObj->Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,ItemAncient);
return false;
}
}
}
return true;
Código:
#include "stdafx.h"
#define MAX_DROP_NUMBER 1000
typedef struct Drop
{
int IGroup;
int ID;
int MapDrop;
int MinLev;
int MaxLev;
int Skill;
int Luck;
int Life;
int Exc;
int Anc;
int Perc;
}DROP;
//Structures
extern DROP DropInfo[255];
extern int DropCount;
void LoadDropSystem();
bool ExcDropSystem(DWORD aIndex, DWORD MonsterID);
Se puderem me dar uma luz eu ficarei muito feliz...
Atenciosamente,
João Neto.