Results 1 to 2 of 2

Thread: [RESOLVED] Read One ID only

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Resolved [RESOLVED] Read One ID only

    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)

    With RED i had cover the fields that need to be changed so this to work out
    Code:
    iToken = GetToken();
    this->m_DropInfo[m_TotalDrops].m_DropMonsterMinLevel = TokenNumber;
    become:
    iToken = GetToken();
    this->m_DropInfo[m_TotalDrops].m_MonsterID = TokenNumber;
    Code:
    #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;
    
    					iToken = GetToken();
    					this->m_DropInfo[m_TotalDrops].m_DropMonsterMinLevel = TokenNumber;
    
    					iToken = GetToken();
    					this->m_DropInfo[m_TotalDrops].m_DropMonsterMaxLevel = TokenNumber;
    
    					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++)
    		{
    			if((gObj->Level >= this->m_DropInfo[i].m_DropMonsterMinLevel) && (gObj->Level <= this->m_DropInfo[i].m_DropMonsterMaxLevel))
    			{
    				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;
    }

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Read One ID only

    anything?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width