megaman
16/05/2020, 04:55 PM
Custom feita pelo takumi12 para você poder mixar itens custom na maquina de chaos.
CustomMix.h
// ---
#include "stdafx.h"
#include "RandomManager.h"
// ---
#define MAX_MIX 1000
// ---
struct CUSTOM_MIX
{
int m_Index;
int m_MixMoney;
int m_MixRate_AL0;
int m_MixRate_AL1;
int m_MixRate_AL2;
int m_MixRate_AL3;
int m_CountGroup;
int m_CountItem;
//Index MixMoney MixRate_AL0 MixRate_AL1 MixRate_AL2 MixRate_AL3
};
struct CUSTOM_ITEM_MIX
{
int m_Index;
int m_Group;
int m_Count;
int m_ItemIndex;
int m_ItemLevel;
int m_ItemOption1;
int m_ItemOption2;
int m_ItemOption3;
int m_ItemNewOption;
int m_ItemSetOption;
//Index Group Count ItemIndex ItemLevel ItemOption1 ItemOption2 ItemOption3 ItemNewOption ItemSetOption
};
struct CUSTOM_BAG_MIX
{
int m_Index;
int m_Group;
int m_ItemIndex;
int m_ItemLevel;
int m_ItemOption1;
int m_ItemOption2;
int m_ItemOption3;
int m_ItemNewOption;
int m_ItemSetOption;
};
// ---
class CCustomMix
{
public:
int m_count1;
int m_count2;
int m_count3;
void Load(char* path);
int GetCountItemMix(int IndexMix,int counGroup);
CRandomManager RandomManager(int IndexMix,int counGroup);
CUSTOM_MIX* GetCustomMix(int IndexMix);
CUSTOM_BAG_MIX* GetItemResult(int IndexMix,int group,int ItemIndex);
bool istItemMix(int IndexMix, int group, CItem boxItem);
CUSTOM_MIX m_Data_Mix[MAX_MIX];
CUSTOM_ITEM_MIX m_Data_Item[MAX_MIX];
CUSTOM_BAG_MIX m_Data_Bag[MAX_MIX];
private:
};
extern CCustomMix gCustomMix;
// ---
custommix.cpp
#include "stdafx.h"
#include "Util.h"
#include "ItemManager.h"
#include "Message.h"
#include "User.h"
#include "Path.h"
#include "MemScript.h"
#include "RandomManager.h"
#include "CustomMix.h"
#include "Log.h"
CCustomMix gCustomMix;
void CCustomMix::Load(char* path){
CMemScript* lpMemScript = new CMemScript;
if(lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR,path);
return;
}
if(lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}
this->m_count1 = 0;
this->m_count2 = 0;
this->m_count3 = 0;
for(int n=0;n < MAX_MIX;n++)
{
this->m_Data_Mix[n];
this->m_Data_Item[n];
this->m_Data_Bag[n];
}
try
{
while(true)
{
if(lpMemScript->GetToken() == TOKEN_END)
{
break;
}
int section = lpMemScript->GetNumber();
while(true)
{
if(section == 0)
{
if(strcmp("end",lpMemScript->GetAsString()) == 0)
{
break;
}
this->m_Data_Mix[this->m_count1].m_Index = lpMemScript->GetNumber();
this->m_Data_Mix[this->m_count1].m_MixMoney = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL0 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL1 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL2 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL3 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_CountGroup = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_CountItem = lpMemScript->GetAsNumber();
this->m_count1++;
}
else if(section == 1)
{
if(strcmp("end",lpMemScript->GetAsString()) == 0)
{
break;
}
this->m_Data_Item[this->m_count2].m_Index = lpMemScript->GetNumber();
this->m_Data_Item[this->m_count2].m_Group = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_Count = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemIndex = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemLevel = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemOption1 = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemOption2 = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemOption3 = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemNewOption = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemSetOption = lpMemScript->GetAsNumber();
this->m_count2++;
}
else if(section == 2)
{
if(strcmp("end",lpMemScript->GetAsString()) == 0)
{
break;
}
this->m_Data_Bag[this->m_count3].m_Index = lpMemScript->GetNumber();
this->m_Data_Bag[this->m_count3].m_Group = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemIndex = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemLevel = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemOption1 = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemOption2 = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemOption3 = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemNewOption = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemSetOption = lpMemScript->GetAsNumber();
this->m_count3++;
}
else
{
break;
}
}
}
}
catch(...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}
delete lpMemScript;
}
//---
bool CCustomMix::istItemMix(int IndexMix, int group, CItem boxItem){
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Item[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Item[n].m_Index == IndexMix
&& this->m_Data_Item[n].m_Group == group
&& this->m_Data_Item[n].m_ItemIndex == boxItem.m_Index)
{
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades Level: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemLevel,boxItem.m_Level);
if(this->m_Data_Item[n].m_ItemLevel != -1){
if(boxItem.m_Level < this->m_Data_Item[n].m_ItemLevel){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades Skill: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemOption1,boxItem.m_Option1);
if(this->m_Data_Item[n].m_ItemOption1 != -1){
if(this->m_Data_Item[n].m_ItemOption1 != boxItem.m_Option1){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades Luck: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemOption2,boxItem.m_Option2);
if(this->m_Data_Item[n].m_ItemOption2 != -1){
if(this->m_Data_Item[n].m_ItemOption2 != boxItem.m_Option2){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades OpcionAdicional: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemOption3,boxItem.m_Option3);
if(this->m_Data_Item[n].m_ItemOption3 != -1){
if(this->m_Data_Item[n].m_ItemOption3 > boxItem.m_Option3){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades OpcionExe: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemNewOption,boxItem.m_NewOption);
if(this->m_Data_Item[n].m_ItemNewOption != -1){
if(this->m_Data_Item[n].m_ItemNewOption != boxItem.m_NewOption){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades SetItem: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemSetOption,boxItem.m_SetOption);
if(this->m_Data_Item[n].m_ItemSetOption != -1){
if(this->m_Data_Item[n].m_ItemSetOption != boxItem.m_SetOption){
return false;
}
}
return true;
}
}
return false;
}
int CCustomMix::GetCountItemMix(int IndexMix,int Group){
int itemcount = 0;
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Item[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Item[n].m_Index == IndexMix && this->m_Data_Item[n].m_Group == Group)
{
itemcount+=this->m_Data_Item[n].m_Count;
}
}
return itemcount;
}
//---
CUSTOM_MIX* CCustomMix::GetCustomMix(int IndexMix){
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Mix[n].m_Index == IndexMix)
{
return &this->m_Data_Mix[n];
}
}
return 0;
}
CRandomManager CCustomMix::RandomManager(int IndexMix,int group)
{
CRandomManager RandomManager;
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Bag[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Bag[n].m_Index == IndexMix && this->m_Data_Bag[n].m_Group == group)
{
RandomManager.AddElement(this->m_Data_Bag[n].m_ItemIndex,1);
}
}
return RandomManager;
}
//---
CUSTOM_BAG_MIX* CCustomMix::GetItemResult(int IndexMix,int group,int ItemIndex)
{
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Item[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Bag[n].m_Index == IndexMix
&& this->m_Data_Bag[n].m_Group == group
&& this->m_Data_Bag[n].m_ItemIndex == ItemIndex)
{
return &this->m_Data_Bag[n];
}
}
return 0;
}
ChaosBox.cpp
void CChaosBox::CustomItemMix(LPOBJ lpObj, int type) // OK
{
CUSTOM_MIX* CustomMix = gCustomMix.GetCustomMix(type);
int mixAceptable = false;
int groupMix = -1;
for(int Group = 0 ; Group < CustomMix->m_CountGroup ; Group++){
int item = 0;
gLog.Output(LOG_CHAOS_MIX,"================================================== ====");
gLog.Output(LOG_CHAOS_MIX,"Validando Mix: %d Grupo: %d",CustomMix->m_Index,Group);
for(int slot = 0;slot < CHAOS_BOX_SIZE;slot++)
{
if(lpObj->ChaosBox[slot].IsItem() == 0)
{
continue;
}
if(gCustomMix.istItemMix(CustomMix->m_Index, Group,lpObj->ChaosBox[slot])) // validación si existe el item
{
item++;
gLog.Output(LOG_CHAOS_MIX,"Item Valido: %d ItemCount: [%d/%d]",lpObj->ChaosBox[slot].m_Index,item,CustomMix->m_CountItem);
}
}
if(item == gCustomMix.GetCountItemMix(CustomMix->m_Index,Group)){
mixAceptable = true;
groupMix = Group;
gLog.Output(LOG_CHAOS_MIX,"MixAceptado: [%d -> %d]",CustomMix->m_Index,groupMix);
Group = CustomMix->m_CountGroup;
}
}
if(!mixAceptable) // falló la combinación
{
this->GCChaosMixSend(lpObj->Index,7,0);
return;
}
if(this->GetTalismanOfLuckRate(lpObj,&lpObj->ChaosSuccessRate) == 0)
{
this->GCChaosMixSend(lpObj->Index,240,0);
return;
}
switch(lpObj->AccountLevel){
case 1:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL1 < 0 || CustomMix->m_MixRate_AL1 > 100)?90:CustomMix->m_MixRate_AL1);
break;
case 2:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL2 < 0 || CustomMix->m_MixRate_AL2 > 100)?90:CustomMix->m_MixRate_AL2);
break;
case 3:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL3 < 0 || CustomMix->m_MixRate_AL3 > 100)?90:CustomMix->m_MixRate_AL3);
break;
default:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL0 < 0 || CustomMix->m_MixRate_AL0 > 100)?90:CustomMix->m_MixRate_AL0);
break;
}
lpObj->ChaosMoney = lpObj->ChaosSuccessRate * ((CustomMix->m_MixMoney < 0)?1000:CustomMix->m_MixMoney);
int TaxMoney = (lpObj->ChaosMoney*gCastleSiegeSync.GetTaxRateChaos(lpObj->Index))/100;
lpObj->ChaosMoney += TaxMoney;
if(lpObj->Money < ((DWORD)lpObj->ChaosMoney))
{
this->GCChaosMixSend(lpObj->Index,2,0);
return;
}
lpObj->Money -= lpObj->ChaosMoney;
GCMoneySend(lpObj->Index,lpObj->Money);
gCastleSiegeSync.AddTributeMoney(TaxMoney);
if((GetLargeRand()%100) < lpObj->ChaosSuccessRate)
{
WORD ItemIndex = 0;
BYTE ItemOption1 = 0;
BYTE ItemOption2 = 0;
BYTE ItemOption3 = 0;
BYTE ItemNewOption = 0;
BYTE ItemSetOption = 0;
CRandomManager RandomManager = gCustomMix.RandomManager(CustomMix->m_Index,groupMix);
RandomManager.GetRandomElement(&ItemIndex);
CUSTOM_BAG_MIX* ItemCreate = gCustomMix.GetItemResult(CustomMix->m_Index,groupMix,ItemIndex);
if(ItemCreate->m_ItemOption1 == -1){
gItemOptionRate.GetItemOption1(6,&ItemOption1);
}else{
ItemOption1 = ItemCreate->m_ItemOption1;
}
if(ItemCreate->m_ItemOption2 == -1){
gItemOptionRate.GetItemOption2(6,&ItemOption2);
}else{
ItemOption2 = ItemCreate->m_ItemOption1;
}
if(ItemCreate->m_ItemOption3 == -1){
gItemOptionRate.GetItemOption3(6,&ItemOption3);
}else{
ItemOption3 = ItemCreate->m_ItemOption3;
}
if(ItemCreate->m_ItemNewOption == -1){
gItemOptionRate.GetItemOption4(6,&ItemNewOption);
gItemOptionRate.MakeNewOption(ItemIndex,ItemNewOpt ion,&ItemNewOption);
}else{
ItemNewOption = ItemCreate->m_ItemNewOption;
}
if(ItemCreate->m_ItemSetOption == -1){
gItemOptionRate.GetItemOption5(6,&ItemSetOption);
gItemOptionRate.MakeSetOption(ItemIndex,ItemSetOpt ion,&ItemSetOption);
}else{
ItemSetOption = ItemCreate->m_ItemSetOption;
}
GDCreateItemSend(lpObj->Index,0xFF,0,0,ItemIndex,0,0,0,ItemOption2,ItemOpt ion3,-1,(ItemNewOption+(16*(GetLargeRand()%3))),ItemSetO ption,0,0,0,0xFF,0);
gLog.Output(LOG_CHAOS_MIX,"[CustomMix][Success][%s][%s] - (ChaosSuccessRate: %d, ChaosMoney: %d)",lpObj->Account,lpObj->Name,100,lpObj->ChaosMoney);
}
else
{
this->ChaosBoxInit(lpObj);
this->GCChaosBoxSend(lpObj,0);
this->GCChaosMixSend(lpObj->Index,0,0);
gLog.Output(LOG_CHAOS_MIX,"[CustomMix][Failure][%s][%s] - (ChaosSuccessRate: %d, ChaosMoney: %d)",lpObj->Account,lpObj->Name,lpObj->ChaosSuccessRate,lpObj->ChaosMoney);
}
}
ChaosBox.h
adicione essa linha dentro de class CChaosBox
{
public:
void CustomItemMix(LPOBJ lpObj, int type);
ServerInfo.cpp
gCustomMix.Load(gPath.GetFullPath("Custom\\CustomMix.txt"));
CustomMix.txt
//================================================== ================================================== ======
//Index Disponible : 100 -> 150
//================================================== ================================================== ======
// para ItemLevel Skill Luck MinAdicional Exe ItemSetOption
// -1 = ramdom :: 0 = sin opciones no aplica para ItemLevel
//================================================== ================================================== ======
//--> MinAdicional
// 0 = Sin Opcion; 1 = Adicional +4; 2 = Adicional +8; 3 = Adicional +12
// 4 = Adicional +16; 5 = Adicional +20; 6 = Adicional +24; 7 = Adicional +28
//--> ItemSetOption
// SetAcc1 = 5 ; SetAcc2 = 10;
//================================================== ================================================== ======
0
//Index MixMoney MixRate_AL0 MixRate_AL1 MixRate_AL2 MixRate_AL3 CountGroup CountItem
151 1000 100 100 100 100 3 6
end
//================================================== ================================================== ======
// ITEMS MIX PARA LA COMBINACIÓN
//================================================== ================================================== ======
1
//Index Group Count ItemIndex MinItemLevel Skill Luck MinAdicional Exe ItemSetOption
//-- BlueEyes BM
151 0 1 6159 0 0 0 0 0 0
151 0 1 6174 2 0 0 0 0 0
151 0 1 6175 2 0 0 0 0 0
151 0 1 6829 0 0 0 0 0 0
151 0 1 7190 0 0 0 0 0 0
151 0 1 3690 11 0 -1 4 -1 5
//-- BlueEyes SM
151 1 1 6159 0 0 0 0 0 0
151 1 1 6174 2 0 0 0 0 0
151 1 1 6175 2 0 0 0 0 0
151 1 1 6829 0 0 0 0 0 0
151 1 1 7190 0 0 0 0 0 0
151 1 1 3691 11 0 -1 4 -1 5
//-- BlueEyes ELF
151 2 1 6159 0 0 0 0 0 0
151 2 1 6174 2 0 0 0 0 0
151 2 1 6175 2 0 0 0 0 0
151 2 1 6829 0 0 0 0 0 0
151 2 1 7190 0 0 0 0 0 0
151 2 1 3692 11 0 -1 4 -1 5
end
//================================================== ================================================== ======
// ITEMS RESULTANTE DE LA COMBINACIÓN
//================================================== ================================================== ======
2
//Index Group ItemIndex ItemLevel Skill Luck MinAdicional Exe ItemSetOption
151 0 3748 0 0 0 0 0 5
151 1 3749 0 0 -1 -1 0 5
151 2 3750 0 0 -1 -1 0 5
end
Créditos:
takumi12
CustomMix.h
// ---
#include "stdafx.h"
#include "RandomManager.h"
// ---
#define MAX_MIX 1000
// ---
struct CUSTOM_MIX
{
int m_Index;
int m_MixMoney;
int m_MixRate_AL0;
int m_MixRate_AL1;
int m_MixRate_AL2;
int m_MixRate_AL3;
int m_CountGroup;
int m_CountItem;
//Index MixMoney MixRate_AL0 MixRate_AL1 MixRate_AL2 MixRate_AL3
};
struct CUSTOM_ITEM_MIX
{
int m_Index;
int m_Group;
int m_Count;
int m_ItemIndex;
int m_ItemLevel;
int m_ItemOption1;
int m_ItemOption2;
int m_ItemOption3;
int m_ItemNewOption;
int m_ItemSetOption;
//Index Group Count ItemIndex ItemLevel ItemOption1 ItemOption2 ItemOption3 ItemNewOption ItemSetOption
};
struct CUSTOM_BAG_MIX
{
int m_Index;
int m_Group;
int m_ItemIndex;
int m_ItemLevel;
int m_ItemOption1;
int m_ItemOption2;
int m_ItemOption3;
int m_ItemNewOption;
int m_ItemSetOption;
};
// ---
class CCustomMix
{
public:
int m_count1;
int m_count2;
int m_count3;
void Load(char* path);
int GetCountItemMix(int IndexMix,int counGroup);
CRandomManager RandomManager(int IndexMix,int counGroup);
CUSTOM_MIX* GetCustomMix(int IndexMix);
CUSTOM_BAG_MIX* GetItemResult(int IndexMix,int group,int ItemIndex);
bool istItemMix(int IndexMix, int group, CItem boxItem);
CUSTOM_MIX m_Data_Mix[MAX_MIX];
CUSTOM_ITEM_MIX m_Data_Item[MAX_MIX];
CUSTOM_BAG_MIX m_Data_Bag[MAX_MIX];
private:
};
extern CCustomMix gCustomMix;
// ---
custommix.cpp
#include "stdafx.h"
#include "Util.h"
#include "ItemManager.h"
#include "Message.h"
#include "User.h"
#include "Path.h"
#include "MemScript.h"
#include "RandomManager.h"
#include "CustomMix.h"
#include "Log.h"
CCustomMix gCustomMix;
void CCustomMix::Load(char* path){
CMemScript* lpMemScript = new CMemScript;
if(lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR,path);
return;
}
if(lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}
this->m_count1 = 0;
this->m_count2 = 0;
this->m_count3 = 0;
for(int n=0;n < MAX_MIX;n++)
{
this->m_Data_Mix[n];
this->m_Data_Item[n];
this->m_Data_Bag[n];
}
try
{
while(true)
{
if(lpMemScript->GetToken() == TOKEN_END)
{
break;
}
int section = lpMemScript->GetNumber();
while(true)
{
if(section == 0)
{
if(strcmp("end",lpMemScript->GetAsString()) == 0)
{
break;
}
this->m_Data_Mix[this->m_count1].m_Index = lpMemScript->GetNumber();
this->m_Data_Mix[this->m_count1].m_MixMoney = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL0 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL1 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL2 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_MixRate_AL3 = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_CountGroup = lpMemScript->GetAsNumber();
this->m_Data_Mix[this->m_count1].m_CountItem = lpMemScript->GetAsNumber();
this->m_count1++;
}
else if(section == 1)
{
if(strcmp("end",lpMemScript->GetAsString()) == 0)
{
break;
}
this->m_Data_Item[this->m_count2].m_Index = lpMemScript->GetNumber();
this->m_Data_Item[this->m_count2].m_Group = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_Count = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemIndex = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemLevel = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemOption1 = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemOption2 = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemOption3 = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemNewOption = lpMemScript->GetAsNumber();
this->m_Data_Item[this->m_count2].m_ItemSetOption = lpMemScript->GetAsNumber();
this->m_count2++;
}
else if(section == 2)
{
if(strcmp("end",lpMemScript->GetAsString()) == 0)
{
break;
}
this->m_Data_Bag[this->m_count3].m_Index = lpMemScript->GetNumber();
this->m_Data_Bag[this->m_count3].m_Group = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemIndex = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemLevel = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemOption1 = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemOption2 = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemOption3 = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemNewOption = lpMemScript->GetAsNumber();
this->m_Data_Bag[this->m_count3].m_ItemSetOption = lpMemScript->GetAsNumber();
this->m_count3++;
}
else
{
break;
}
}
}
}
catch(...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}
delete lpMemScript;
}
//---
bool CCustomMix::istItemMix(int IndexMix, int group, CItem boxItem){
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Item[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Item[n].m_Index == IndexMix
&& this->m_Data_Item[n].m_Group == group
&& this->m_Data_Item[n].m_ItemIndex == boxItem.m_Index)
{
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades Level: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemLevel,boxItem.m_Level);
if(this->m_Data_Item[n].m_ItemLevel != -1){
if(boxItem.m_Level < this->m_Data_Item[n].m_ItemLevel){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades Skill: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemOption1,boxItem.m_Option1);
if(this->m_Data_Item[n].m_ItemOption1 != -1){
if(this->m_Data_Item[n].m_ItemOption1 != boxItem.m_Option1){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades Luck: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemOption2,boxItem.m_Option2);
if(this->m_Data_Item[n].m_ItemOption2 != -1){
if(this->m_Data_Item[n].m_ItemOption2 != boxItem.m_Option2){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades OpcionAdicional: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemOption3,boxItem.m_Option3);
if(this->m_Data_Item[n].m_ItemOption3 != -1){
if(this->m_Data_Item[n].m_ItemOption3 > boxItem.m_Option3){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades OpcionExe: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemNewOption,boxItem.m_NewOption);
if(this->m_Data_Item[n].m_ItemNewOption != -1){
if(this->m_Data_Item[n].m_ItemNewOption != boxItem.m_NewOption){
return false;
}
}
gLog.Output(LOG_CHAOS_MIX,"Validando Propiedades SetItem: ItemMix: %d == ItemValidar: %d",this->m_Data_Item[n].m_ItemSetOption,boxItem.m_SetOption);
if(this->m_Data_Item[n].m_ItemSetOption != -1){
if(this->m_Data_Item[n].m_ItemSetOption != boxItem.m_SetOption){
return false;
}
}
return true;
}
}
return false;
}
int CCustomMix::GetCountItemMix(int IndexMix,int Group){
int itemcount = 0;
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Item[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Item[n].m_Index == IndexMix && this->m_Data_Item[n].m_Group == Group)
{
itemcount+=this->m_Data_Item[n].m_Count;
}
}
return itemcount;
}
//---
CUSTOM_MIX* CCustomMix::GetCustomMix(int IndexMix){
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Mix[n].m_Index == IndexMix)
{
return &this->m_Data_Mix[n];
}
}
return 0;
}
CRandomManager CCustomMix::RandomManager(int IndexMix,int group)
{
CRandomManager RandomManager;
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Bag[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Bag[n].m_Index == IndexMix && this->m_Data_Bag[n].m_Group == group)
{
RandomManager.AddElement(this->m_Data_Bag[n].m_ItemIndex,1);
}
}
return RandomManager;
}
//---
CUSTOM_BAG_MIX* CCustomMix::GetItemResult(int IndexMix,int group,int ItemIndex)
{
for(int n=0;n < MAX_MIX;n++)
{
if(this->m_Data_Item[n].m_Index != IndexMix)
{
continue;
}
if(this->m_Data_Bag[n].m_Index == IndexMix
&& this->m_Data_Bag[n].m_Group == group
&& this->m_Data_Bag[n].m_ItemIndex == ItemIndex)
{
return &this->m_Data_Bag[n];
}
}
return 0;
}
ChaosBox.cpp
void CChaosBox::CustomItemMix(LPOBJ lpObj, int type) // OK
{
CUSTOM_MIX* CustomMix = gCustomMix.GetCustomMix(type);
int mixAceptable = false;
int groupMix = -1;
for(int Group = 0 ; Group < CustomMix->m_CountGroup ; Group++){
int item = 0;
gLog.Output(LOG_CHAOS_MIX,"================================================== ====");
gLog.Output(LOG_CHAOS_MIX,"Validando Mix: %d Grupo: %d",CustomMix->m_Index,Group);
for(int slot = 0;slot < CHAOS_BOX_SIZE;slot++)
{
if(lpObj->ChaosBox[slot].IsItem() == 0)
{
continue;
}
if(gCustomMix.istItemMix(CustomMix->m_Index, Group,lpObj->ChaosBox[slot])) // validación si existe el item
{
item++;
gLog.Output(LOG_CHAOS_MIX,"Item Valido: %d ItemCount: [%d/%d]",lpObj->ChaosBox[slot].m_Index,item,CustomMix->m_CountItem);
}
}
if(item == gCustomMix.GetCountItemMix(CustomMix->m_Index,Group)){
mixAceptable = true;
groupMix = Group;
gLog.Output(LOG_CHAOS_MIX,"MixAceptado: [%d -> %d]",CustomMix->m_Index,groupMix);
Group = CustomMix->m_CountGroup;
}
}
if(!mixAceptable) // falló la combinación
{
this->GCChaosMixSend(lpObj->Index,7,0);
return;
}
if(this->GetTalismanOfLuckRate(lpObj,&lpObj->ChaosSuccessRate) == 0)
{
this->GCChaosMixSend(lpObj->Index,240,0);
return;
}
switch(lpObj->AccountLevel){
case 1:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL1 < 0 || CustomMix->m_MixRate_AL1 > 100)?90:CustomMix->m_MixRate_AL1);
break;
case 2:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL2 < 0 || CustomMix->m_MixRate_AL2 > 100)?90:CustomMix->m_MixRate_AL2);
break;
case 3:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL3 < 0 || CustomMix->m_MixRate_AL3 > 100)?90:CustomMix->m_MixRate_AL3);
break;
default:
lpObj->ChaosSuccessRate = ((CustomMix->m_MixRate_AL0 < 0 || CustomMix->m_MixRate_AL0 > 100)?90:CustomMix->m_MixRate_AL0);
break;
}
lpObj->ChaosMoney = lpObj->ChaosSuccessRate * ((CustomMix->m_MixMoney < 0)?1000:CustomMix->m_MixMoney);
int TaxMoney = (lpObj->ChaosMoney*gCastleSiegeSync.GetTaxRateChaos(lpObj->Index))/100;
lpObj->ChaosMoney += TaxMoney;
if(lpObj->Money < ((DWORD)lpObj->ChaosMoney))
{
this->GCChaosMixSend(lpObj->Index,2,0);
return;
}
lpObj->Money -= lpObj->ChaosMoney;
GCMoneySend(lpObj->Index,lpObj->Money);
gCastleSiegeSync.AddTributeMoney(TaxMoney);
if((GetLargeRand()%100) < lpObj->ChaosSuccessRate)
{
WORD ItemIndex = 0;
BYTE ItemOption1 = 0;
BYTE ItemOption2 = 0;
BYTE ItemOption3 = 0;
BYTE ItemNewOption = 0;
BYTE ItemSetOption = 0;
CRandomManager RandomManager = gCustomMix.RandomManager(CustomMix->m_Index,groupMix);
RandomManager.GetRandomElement(&ItemIndex);
CUSTOM_BAG_MIX* ItemCreate = gCustomMix.GetItemResult(CustomMix->m_Index,groupMix,ItemIndex);
if(ItemCreate->m_ItemOption1 == -1){
gItemOptionRate.GetItemOption1(6,&ItemOption1);
}else{
ItemOption1 = ItemCreate->m_ItemOption1;
}
if(ItemCreate->m_ItemOption2 == -1){
gItemOptionRate.GetItemOption2(6,&ItemOption2);
}else{
ItemOption2 = ItemCreate->m_ItemOption1;
}
if(ItemCreate->m_ItemOption3 == -1){
gItemOptionRate.GetItemOption3(6,&ItemOption3);
}else{
ItemOption3 = ItemCreate->m_ItemOption3;
}
if(ItemCreate->m_ItemNewOption == -1){
gItemOptionRate.GetItemOption4(6,&ItemNewOption);
gItemOptionRate.MakeNewOption(ItemIndex,ItemNewOpt ion,&ItemNewOption);
}else{
ItemNewOption = ItemCreate->m_ItemNewOption;
}
if(ItemCreate->m_ItemSetOption == -1){
gItemOptionRate.GetItemOption5(6,&ItemSetOption);
gItemOptionRate.MakeSetOption(ItemIndex,ItemSetOpt ion,&ItemSetOption);
}else{
ItemSetOption = ItemCreate->m_ItemSetOption;
}
GDCreateItemSend(lpObj->Index,0xFF,0,0,ItemIndex,0,0,0,ItemOption2,ItemOpt ion3,-1,(ItemNewOption+(16*(GetLargeRand()%3))),ItemSetO ption,0,0,0,0xFF,0);
gLog.Output(LOG_CHAOS_MIX,"[CustomMix][Success][%s][%s] - (ChaosSuccessRate: %d, ChaosMoney: %d)",lpObj->Account,lpObj->Name,100,lpObj->ChaosMoney);
}
else
{
this->ChaosBoxInit(lpObj);
this->GCChaosBoxSend(lpObj,0);
this->GCChaosMixSend(lpObj->Index,0,0);
gLog.Output(LOG_CHAOS_MIX,"[CustomMix][Failure][%s][%s] - (ChaosSuccessRate: %d, ChaosMoney: %d)",lpObj->Account,lpObj->Name,lpObj->ChaosSuccessRate,lpObj->ChaosMoney);
}
}
ChaosBox.h
adicione essa linha dentro de class CChaosBox
{
public:
void CustomItemMix(LPOBJ lpObj, int type);
ServerInfo.cpp
gCustomMix.Load(gPath.GetFullPath("Custom\\CustomMix.txt"));
CustomMix.txt
//================================================== ================================================== ======
//Index Disponible : 100 -> 150
//================================================== ================================================== ======
// para ItemLevel Skill Luck MinAdicional Exe ItemSetOption
// -1 = ramdom :: 0 = sin opciones no aplica para ItemLevel
//================================================== ================================================== ======
//--> MinAdicional
// 0 = Sin Opcion; 1 = Adicional +4; 2 = Adicional +8; 3 = Adicional +12
// 4 = Adicional +16; 5 = Adicional +20; 6 = Adicional +24; 7 = Adicional +28
//--> ItemSetOption
// SetAcc1 = 5 ; SetAcc2 = 10;
//================================================== ================================================== ======
0
//Index MixMoney MixRate_AL0 MixRate_AL1 MixRate_AL2 MixRate_AL3 CountGroup CountItem
151 1000 100 100 100 100 3 6
end
//================================================== ================================================== ======
// ITEMS MIX PARA LA COMBINACIÓN
//================================================== ================================================== ======
1
//Index Group Count ItemIndex MinItemLevel Skill Luck MinAdicional Exe ItemSetOption
//-- BlueEyes BM
151 0 1 6159 0 0 0 0 0 0
151 0 1 6174 2 0 0 0 0 0
151 0 1 6175 2 0 0 0 0 0
151 0 1 6829 0 0 0 0 0 0
151 0 1 7190 0 0 0 0 0 0
151 0 1 3690 11 0 -1 4 -1 5
//-- BlueEyes SM
151 1 1 6159 0 0 0 0 0 0
151 1 1 6174 2 0 0 0 0 0
151 1 1 6175 2 0 0 0 0 0
151 1 1 6829 0 0 0 0 0 0
151 1 1 7190 0 0 0 0 0 0
151 1 1 3691 11 0 -1 4 -1 5
//-- BlueEyes ELF
151 2 1 6159 0 0 0 0 0 0
151 2 1 6174 2 0 0 0 0 0
151 2 1 6175 2 0 0 0 0 0
151 2 1 6829 0 0 0 0 0 0
151 2 1 7190 0 0 0 0 0 0
151 2 1 3692 11 0 -1 4 -1 5
end
//================================================== ================================================== ======
// ITEMS RESULTANTE DE LA COMBINACIÓN
//================================================== ================================================== ======
2
//Index Group ItemIndex ItemLevel Skill Luck MinAdicional Exe ItemSetOption
151 0 3748 0 0 0 0 0 5
151 1 3749 0 0 -1 -1 0 5
151 2 3750 0 0 -1 -1 0 5
end
Créditos:
takumi12