Read Specific ID

I want to make my code to read only MonsterID (specific monster ID, example MonsterID = 50, so if i kill this monster 50 will drop me the item, all other monsters if i kill not drop the same).

My request is to remove this MonsterMinLevel and MonsterMaxLevel and to use only MonsterID number.

With RED i had cover the fields that need to be changed so this to work out
1
2
3
4
5
[COLOR="#FF0000"]iToken = GetToken();
this->m_DropInfo[m_TotalDrops].m_DropMonsterMinLevel = TokenNumber;[/COLOR]
become:
[COLOR="#00FF00"]iToken = GetToken();
this->m_DropInfo[m_TotalDrops].m_MonsterID = TokenNumber;[/COLOR]


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include "StdAfx.h"

// Drop System
CDropSystem DropSystem;

void CDropSystem::Init(char* File)
{
	this->m_Enabled = GetPrivateProfileInt("Server","EnableDropSystem",1,commonsettings);
	this->m_TotalDrops = 0;

	if(this->m_Enabled == 1)
	{
		this->LoadFile(File);
		Log.Add("%s file load!",File);
	}
}

void CDropSystem::LoadFile(char* File)
{
	SMDFile = fopen(File,"r");

	if(SMDFile == 0)
	{
		MessageBoxA(0,"Unable to load ECustomDrop.ini - File not found.","Error",MB_OK);
		this->m_Enabled = 0;
		return;
	}

	int iToken = 0;

	while(true)
	{
		iToken = GetToken();

		if(iToken == 2)
		{
			break;
		}

		if(iToken == 1)
		{
			int SubClass = TokenNumber;

			if(SubClass == 0)
			{
				while (true)
				{
					iToken = GetToken();

					if(iToken == 0)
					{
						if(strcmp("end",TokenString) == 0)
						{
							break;
						}
					}

					this->m_DropInfo[m_TotalDrops].m_DropType = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropIndex = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropLevelMin = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropLevelMax = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropSkill = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropLuck = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropOption = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropExcellent = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropAncient = TokenNumber;

					[COLOR="#FF0000"]iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropMonsterMinLevel = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropMonsterMaxLevel = TokenNumber;[/COLOR]

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropMap = TokenNumber;

					iToken = GetToken();
					this->m_DropInfo[m_TotalDrops].m_DropRate = TokenNumber;

					this->m_TotalDrops++;
				}
			}
		}
	}

	fclose(SMDFile);
}

int CDropSystem::RandomizeItemDrop(OBJECTSTRUCT* gObj,OBJECTSTRUCT* gTargetObj)
{
	if(this->m_Enabled == 1)
	{
		int MaxHitUser = gObjMonsterTopHitDamageUser(gObj);

		if(this->m_TotalDrops == 0)
		{
			return true;
		}

		for(int i = 0; i < this->m_TotalDrops; i++)
		{
			[COLOR="#FF0000"]if((gObj->Level >= this->m_DropInfo[i].m_DropMonsterMinLevel) && (gObj->Level <= this->m_DropInfo[i].m_DropMonsterMaxLevel))[/COLOR]
			{
				if((this->m_DropInfo[i].m_DropMap == -1) || (this->m_DropInfo[i].m_DropMap == gTargetObj->MapNumber))
				{
					if((rand() % 10000) < this->m_DropInfo[i].m_DropRate)
					{
						int iType = ITEMGET(this->m_DropInfo[i].m_DropType,this->m_DropInfo[i].m_DropIndex);

						unsigned int Skill;
						unsigned int Luck;
						unsigned int Opt;
						unsigned int Level;
						unsigned int Dur;
						unsigned int Exc;

						Dur = 0;

						if(this->m_DropInfo[i].m_DropSkill > 0)
						{
							if((rand() % 100) < 50)
							{
								Skill = 1;
							}
							else
							{
								Skill = 0;
							}
						}

						if(this->m_DropInfo[i].m_DropLuck > 0)
						{
							if((rand() % 100) < 50)
							{
								Luck = 1;
							}
							else
							{
								Luck = 0;
							}
						}

						if ((this->m_DropInfo[i].m_DropLevelMin > 0) && (this->m_DropInfo[i].m_DropLevelMax > this->m_DropInfo[i].m_DropLevelMin))
						{
							unsigned char Sub = (this->m_DropInfo[i].m_DropLevelMax - this->m_DropInfo[i].m_DropLevelMin) + 1;
							Level = this->m_DropInfo[i].m_DropLevelMin + (rand() % Sub);
						}
						else
						{
							Level = 0;
						}

						if(this->m_DropInfo[i].m_DropOption > 0)
						{
							if((rand() % 100) < 50)
							{
								Opt = 1;
							}
							else
							{
								Opt = 0;
							}
						}

						if(this->m_DropInfo[i].m_DropExcellent > 0)
						{
							Exc = GetRandomExcOption(this->m_DropInfo[i].m_DropExcellent, false);
						}
						else
						{
							Exc = 0;
						}

						ItemSerialCreateSend(gObj->m_Index, gObj->MapNumber, gObj->X, gObj->Y, iType, Level, Dur, Luck, Skill, Opt, MaxHitUser, Exc, m_DropInfo[i].m_DropAncient);
						Log.Add("[DropSystem] (%s)(%s) Drop %d (%d)!",gTargetObj->AccountID,gTargetObj->Name,iType,gObj->MapNumber);
						return true;
					}
				}
			}
		}
	}

	return false;
}
can we have a class declaration , and how are we supposed to test file , do we need any special configurations ?
.h file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef __DROPSYSTEM_H__
#define __DROPSYSTEM_H__

// Drop System
struct ITEM_DROP_INFO
{
	int m_DropType;
	int m_DropIndex;
	int m_DropLevelMin;
	int m_DropLevelMax;
	int m_DropSkill;
	int m_DropLuck;
	int m_DropOption;
	int m_DropExcellent;
	int m_DropAncient;
	int m_DropMonsterMinLevel;
	int m_DropMonsterMaxLevel;
	int m_DropMap;
	int m_DropRate;
};

class CDropSystem
{
public:

	void Init(char* File);
	void LoadFile(char* File);

	int RandomizeItemDrop(OBJECTSTRUCT* gObj,OBJECTSTRUCT* gTargetObj);

private:

	int m_Enabled;
	int m_TotalDrops;
	ITEM_DROP_INFO m_DropInfo[255];
};

extern CDropSystem DropSystem;

#endif 
could it be more appropriate like this ?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct ITEM_DROP_INFO
{
   struct ITEM
  {
        int m_DropType;
     	int m_DropLevelMin;
	int m_DropLevelMax;
	int m_DropSkill;
	int m_DropLuck;
	int m_DropOption;
	int m_DropExcellent;
	int m_DropAncient;
	int m_DropMonsterMinLevel;
	int m_DropMonsterMaxLevel;
	int m_DropMap;
	int m_DropRate;
  }m_impl[255];
   ITEM& getIndex(unsigned short _index) {return m_impl[_index];}
};


then change
ITEM_DROP_INFO m_DropInfo[255]
by
ITEM_DROP_INFO m_info;
i had recoded everything now i make it work like i wanted.
problem is not in .h file it was on .cpp file
where monstermaxlevel and minlevel were the problems
What was the issue?
Topic archived. No new replies allowed.