int CPlayer::RemoveMoney(int Count)
{	
	OBJECTSTRUCT *gObj = (OBJECTSTRUCT*)OBJECT_POINTER(this->aIndex);
	gObj->Money -= Count;
	GCMoneySend(aIndex,gObj->Money);
	return 0;
}
Beispiel #2
0
void QuestTeleport(int aIndex, int Type) 
{
	if(gObj[aIndex].Money < 20000)
	{
		LogAdd("[%s][%s] [QUEST] short of zen for teleport quest map.\n", gObj[aIndex].AccountID, gObj[aIndex].Name);
		return;
	}

	if(Type == 0)
	{
		gObjTeleport(aIndex, 41, 36, 90);
		LogAdd("[%s][%s] [QUEST] Teleport to Barracks.\n", gObj[aIndex].AccountID, gObj[aIndex].Name);
	}

	if(Type == 1)
	{
		gObjTeleport(aIndex, 42, 96, 187);
		LogAdd("[%s][%s] [QUEST] Teleport to Refuge.\n", gObj[aIndex].AccountID, gObj[aIndex].Name);
	}


	#if (WL_PROTECT==1)
		VM_START_WITHLEVEL(3)
		g_CashShop.SystemProcessesScan();
		VM_END
	#endif

	gObj[aIndex].Money -= 20000;
	GCMoneySend(aIndex, gObj[aIndex].Money);
}
Beispiel #3
0
//bool cChat::GuildPost(LPOBJ gObj, char *Msg)
//{ 
//	int aIndex = User.GetPlayerIndex(gObj->Name);
//
//	if(gObj->GuildStatus == 128 || gObj ->GuildStatus == 64 || gObj ->GuildStatus == 32)
//		GDGuildNoticeSave(gObj->GuildName, Msg);
//	else
//		TNotice.SendNotice(aIndex,1,"You aren't guild master or assistant");	
//	return true;
//}
//
//bool cChat::Core(LPOBJ gObj, char *Msg)
//{ 
//	MessageLog(1,  gObj,"IA Julia 1.1.%d.%d, Compiled %s %s",dBuild, dCommit, __DATE__, __TIME__);	
//	return true;
//}
//
bool cChat::SetZenCommand(LPOBJ gObj, char* Msg, int Index)
{
	if(CheckCommand(gObj, Configs.Commands.IsSetZen, GmSystem.cSetZen, 0, 0, 1, Index, "SetZen", "[Name] /setzen <Zen>", Msg))
		return true;

	DWORD Zen = 0;

	sscanf(Msg, "%d", &Zen);

	if(Zen <= 0 || Zen > 2000000000)
	{
		TNotice.MessageLog(1,  gObj, "[SetZen] Zen can't be less than 1 and more than 2000000000!");
		return true;
	}	

	OBJECTSTRUCT *tObj = (OBJECTSTRUCT*)OBJECT_POINTER(Index);

	tObj->Money = Zen;
	GCMoneySend(tObj->m_Index, Zen);
	if (gObj == tObj)
	{
		TNotice.MessageLog(1,tObj, "[SetZen] Your zen was edited!");
	}
	else
	{
		TNotice.MessageLog(1,gObj, "[SetZen] You successfully changed %s zen.", tObj->Name);
		TNotice.MessageLog(1,tObj, "[SetZen] Your zen was edited by %s!", gObj->Name);
	}
	return true;
}			
Beispiel #4
0
void cChat::TakeCommand(LPOBJ gObj, int NeedZen, char *CommandName)
{
	if(NeedZen > 0)
	{
		gObj->Money -= NeedZen;
		GCMoneySend(gObj->m_Index, gObj->Money);
	}
}			  
Beispiel #5
0
// --------------------------------------------------------------------------------------------------------------------------------------------------
void CMoveSystem::RandWarp(int aIndex, int MapNumber) // Random Warping
{	
	LPOBJ lpObj = &gObj[aIndex];
	// -----
	if ( !OBJMAX_RANGE(aIndex) )
	{
		CLog.LogAddC(TColor.Red(), "Error: Protocol Index wrong!", lpObj->AccountID, lpObj->Name);
		return;
	}
	// -----
	if (GateC.iX1[MOVSTR[MapNumber].TargetGate] == GateC.iX2[MOVSTR[MapNumber].TargetGate])
	{
		GateC.iX2[MOVSTR[MapNumber].TargetGate]++;
	}
	// -----
	if (GateC.iY1[MOVSTR[MapNumber].TargetGate] == GateC.iY2[MOVSTR[MapNumber].TargetGate]) 
	{
		GateC.iY2[MOVSTR[MapNumber].TargetGate]++;
	}
	// -----
	MOVSTR->FinalX = min(GateC.iX1[MOVSTR[MapNumber].TargetGate],GateC.iX2[MOVSTR[MapNumber].TargetGate])+rand()%(max(GateC.iX1[MOVSTR[MapNumber].TargetGate],GateC.iX2[MOVSTR[MapNumber].TargetGate])-min(GateC.iX1[MOVSTR[MapNumber].TargetGate],GateC.iX2[MOVSTR[MapNumber].TargetGate]));
	MOVSTR->FinalY = min(GateC.iY1[MOVSTR[MapNumber].TargetGate],GateC.iY2[MOVSTR[MapNumber].TargetGate])+rand()%(max(GateC.iY1[MOVSTR[MapNumber].TargetGate],GateC.iY2[MOVSTR[MapNumber].TargetGate])-min(GateC.iY1[MOVSTR[MapNumber].TargetGate],GateC.iY2[MOVSTR[MapNumber].TargetGate]));
	// -----
	BYTE  TeleportMap	= GateC.iMapNum[MOVSTR[MapNumber].TargetGate];
	int	  TotalZen		= MOVSTR[MapNumber].Money;
	// -----
	CheckRequirements(aIndex, TeleportMap, MOVSTR->FinalX, MOVSTR->FinalY);
	// -----
	lpObj->m_State		= 32;
	lpObj->X			= MOVSTR->FinalX;
	lpObj->Y			= MOVSTR->FinalY;
	lpObj->Money	   -= TotalZen;
	// -----
	lpObj->TX			= MOVSTR->FinalX;
	lpObj->TY			= MOVSTR->FinalY;
	// -----
	lpObj->MapNumber	= TeleportMap;
	lpObj->PathCount	= 0;
	lpObj->Teleport		= 0;
	// -----
	gObjClearViewport(lpObj);
	GCTeleportSend(lpObj, 1, TeleportMap, lpObj->X, lpObj->Y, lpObj->Dir);
	GCMoneySend(aIndex, lpObj->Money);
	// -----
	if(lpObj->m_Change >= 0)
	{
		gObjViewportListProtocolCreate(lpObj);
	}
	// -----
	lpObj->RegenMapNumber	= TeleportMap;
	lpObj->RegenMapX		= MOVSTR->FinalX;
	lpObj->RegenMapY		= MOVSTR->FinalY;
	lpObj->RegenOk			= 1;
	// -----
	//-- Log Message for Successful Moving
	CLog.LogAddC(TColor.Green(), "[MoveSystem] CheckRandomdMove() - MapServer Check OK [%s][%s]: MAP-[%d] (%d)(%d)", lpObj->AccountID,
		lpObj->Name, TeleportMap, MOVSTR->FinalX, MOVSTR->FinalY);
}
Beispiel #6
0
BOOL CQuestInfo::QuestAccept(LPOBJ lpObj, int QuestIndex)
{
	LPQUEST_INFO lpQuestInfo = this->GetQuestInfo(QuestIndex);

	if ( lpQuestInfo == NULL )
	{
		return 0xFF;
	}

	int subquestcount = lpQuestInfo->QuestSubInfoCount;
	int concount = lpQuestInfo->QuestConditionCount;
	LPQUEST_SUB_INFO lpSubInfo;
	LPQUEST_CONDITION lpCondition;
	int NeedZen = 0;

	if ( QuestIndex > 3 && QuestIndex < 6 ) //Third Quest Fix
	{
		//Begin
		if( lpQuestInfo->QuestSubInfoCount > 0 )
		{
			lpSubInfo = lpQuestInfo->QuestSubInfo;

			if ( lpSubInfo != NULL )
			{
				for ( int n = 0;n<concount;n++)
				{
					lpCondition = this->GetQuestCondition(lpQuestInfo, n);
					NeedZen += lpCondition->NeedZen;
				}
			}
		}
		//End
	}
	else
	{
		//Begin
		for ( int subquest=0;subquest<subquestcount;subquest++)
		{
			lpSubInfo = this->GetSubquestInfo(lpObj, lpQuestInfo, subquest);

			if ( lpSubInfo != NULL )
			{
				for ( int n = 0;n<concount;n++)
				{
					lpCondition = this->GetQuestCondition(lpQuestInfo, n);
					NeedZen += lpCondition->NeedZen;
				}
			}
		}
		//End
	}
	
	lpObj->Money -= NeedZen;
	GCMoneySend(lpObj->m_Index, lpObj->Money);
	return true;
}
Beispiel #7
0
//Post Global Messages : "/post"
void cChat::ChatGlobal(DWORD aIndex,char* msg)
{
	char* Name;
	Name = (char*)gObj_GetChar(aIndex,gObjNick);
	GOBJSTRUCT *gObj = (GOBJSTRUCT*)OBJECT_POINTER(aIndex);

	if(Config.IsPost==0)
	{
		GCServerMsgStringSend(MSG01,aIndex,1);
		return;
	}

	else if(!strcmpi("/post ",msg))
	{
		GCServerMsgStringSend(MSG02,aIndex,1);
		Log.outError("[POST] [%s]: [%s] syntax error \n",gObj->AccountID,Name);
		return;
	}

	else if(strlen(msg)<1)
	{
		GCServerMsgStringSend(MSG03,aIndex,1);
		Log.outError("[POST] [%s]: [%s] syntax error \n",gObj->AccountID,Name);
		return;
	}

	else if((int)gObj_GetLevel(aIndex)<Config.PostLevel)
	{
		char levelmsg[120];
		sprintf_s(levelmsg,MSG04,Config.PostLevel);
		GCServerMsgStringSend(levelmsg,aIndex,1);
		Log.outError("[POST] [%s]: [%s] not enought Level \n",gObj->AccountID,Name);
		return;
	}
	
	else if(gObj->Money < Config.PostCost)
	{
		char OutputZenLack[120]={0};
		sprintf(OutputZenLack,MSG05,Config.PostCost);
		GCServerMsgStringSend(OutputZenLack,aIndex,1);
		Log.outError("[POST] [%s]: [%s] not enought Zend \n",gObj->AccountID,Name);
		return;
	}
	

	char Buff[255]={0};
	gObj->Money = gObj->Money - Config.PostCost;
	GCMoneySend(aIndex,gObj->Money);
	ServerMsgSend(0,1,Name,MSG06,msg);
	Log.outNormal("[POST] %s : %s \n",Name,msg);
	conLog.ConsoleOutputDT("[POST] %s : %s",Name,msg);
	sprintf(Buff,"[POST]: %s : %s",Name,msg);
	cWriteLog(Buff);
}
void OfflineTrade::UpdateExchange(LPOBJ lpUSer, LPOBJ lpTargetUser, int dwCost)
{
	if(!strcmp(lpUSer->m_szPShopText, WCOIN_SHOP))
	{
		lpTargetUser->GameShop.WCoinP -= dwCost;
		lpUSer->GameShop.WCoinP += dwCost;
		gGameShop.GDSavePoint(lpTargetUser->m_Index);
		gGameShop.GDSavePoint(lpUSer->m_Index);
	}
	else if(!strcmp(lpUSer->m_szPShopText, SOUL_SHOP))
	{
		this->DeleteSoulCount(lpTargetUser->m_Index, dwCost);
		this->AddedSoul(lpUSer, dwCost);
	}
	else
	{
		lpTargetUser->Money -= dwCost;
		lpUSer->Money += dwCost;
		GCMoneySend(lpTargetUser->m_Index, lpTargetUser->Money);
		GCMoneySend(lpUSer->m_Index, lpUSer->Money);
	}
}
void OfflineTrade::Start(int UserIndex)
#endif
{
	LPOBJ lpUser = &gObj[UserIndex];
	// ----
	g_OfflineTradeLog.Output("[%s] [%s] Send request to start offline trade", 
		lpUser->AccountID, lpUser->Name);
	// ----
	if( !this->CheckReq(UserIndex) )
	{
		return;
	}
#ifdef __ALIEN__
	switch(Type)
	{
		case 0: strcpy(lpUser->m_szPShopText, ZEN_SHOP);		break;
		case 1: strcpy(lpUser->m_szPShopText, WCOIN_SHOP);	break;
		case 2: strcpy(lpUser->m_szPShopText, SOUL_SHOP);	break;
		default:return;
	}
#endif
	// ----
	lpUser->Money					-= this->m_Cost[0];
	lpUser->GameShop.WCoinC			-= this->m_Cost[1];
	lpUser->GameShop.WCoinP			-= this->m_Cost[2];
	lpUser->GameShop.GoblinPoint	-= this->m_Cost[3];
	// ----
#if defined __BEREZNUK__ || __MIX__ || __REEDLAN__ || __MUANGEL__ || __WHITE__ || __MEGAMU__ || __VIRNET__
	g_ConnectEx.SendClose(UserIndex);
#endif
	// ----
	gGameShop.GDSavePoint(UserIndex);
	GCMoneySend(UserIndex, lpUser->Money);
	lpUser->IsOffTrade = true;
    CloseClientEx(UserIndex);
	// ----
#ifdef __ALIEN__
	g_OfflineTradeLog.Output("[%s] [%s] Has been disconnected, offline shop created (Type: %d)", 
		lpUser->AccountID, lpUser->Name, Type);
#else
	g_OfflineTradeLog.Output("[%s] [%s] Has been disconnected, offline shop created", 
		lpUser->AccountID, lpUser->Name);
#endif
}
Beispiel #10
0
// --------------------------------------------------------------------------------------------------------------------------------------------------
void CMoveSystem::SpecWarp(int aIndex, int MapNumber, BYTE X, BYTE Y) // Specified Warping
{
	LPOBJ lpObj = &gObj[aIndex];
	// -----
	if ( !OBJMAX_RANGE(aIndex) )
	{
		CLog.LogAddC(TColor.Red(), "Error: Protocol Index wrong!", lpObj->AccountID, lpObj->Name);
		return;
	}
	// -----
	CheckRequirements(aIndex, MapNumber, X, Y);
	// -----
	BYTE  TeleportMap	= GateC.iMapNum[MOVSTR[MapNumber].TargetGate];
	// -----
	lpObj->m_State		= 32;
	lpObj->X			= X;
	lpObj->Y			= Y;
	// -----
	lpObj->TX			= X;
	lpObj->TY			= Y;
	// -----
	lpObj->MapNumber	= TeleportMap;
	lpObj->PathCount	= 0;
	lpObj->Teleport		= 0;
	// -----
	gObjClearViewport(lpObj);
	GCTeleportSend(lpObj, 1, TeleportMap, lpObj->X, lpObj->Y, lpObj->Dir);
	GCMoneySend(aIndex, lpObj->Money);
	// -----
	if(lpObj->m_Change >= 0)
	{
		gObjViewportListProtocolCreate(lpObj);
	}
	// -----
	lpObj->RegenMapNumber	= TeleportMap;
	lpObj->RegenMapX		= X;
	lpObj->RegenMapY		= Y;
	lpObj->RegenOk			= 1;
	// -----
	//-- Log Message for Successful Moving
	CLog.LogAddC(TColor.Green(), "[MoveSystem] CheckSpecifiedMove() - MapServer Check OK [%s][%s]: MAP-[%d] (%d)(%d)", lpObj->AccountID,
		lpObj->Name, TeleportMap, X, Y);
}
Beispiel #11
0
BOOL CMoveCommand::Move(LPOBJ lpObj, LPSTR mapname)
{
	int m_number = -1;
	int overlevel = 0;
	int subMoney = 2000;

	int index = this->FindIndex(mapname);

	if ( g_bUseMoveMapBound == TRUE )
	{
		//Cash shop
		//if ( g_CashItemPeriodSystem.CheckHaveItemPeriodSealEffect(lpObj) == FALSE )
		//{
			if ( !this->CheckMoveMapBound(index))
			{
				return FALSE;
			}
		//}
	}

	int loc6 = this->m_MoveCommandData[index].Index; //season 3.0 add-on

	if ( loc6 == 24 ) //season 3.0 changed
	{
		if ( g_CastleSiegeSync.GetCastleState() == 7 )
		{
			return FALSE;
		}

		if ( g_CastleSiegeSync.CheckCastleOwnerMember(lpObj->m_Index) == FALSE && g_CastleSiegeSync.CheckCastleOwnerUnionMember(lpObj->m_Index) == FALSE)
		{
			return FALSE;
		}
	}

	if(IT_MAP_RANGE(lpObj->MapNumber) != FALSE) //season 3.0 add-on
	{
		if(loc6 == 11 || loc6 == 12 || loc6 == 13 || loc6 == 23)
		{
			return FALSE;
		}
	}

	if ( index == -1 )
	{
		return FALSE;
	}

	int NeedLevel = this->m_MoveCommandData[index].NeedLevel;
	int NeedZen   = this->m_MoveCommandData[index].NeedZen;
	int GateNumber= this->m_MoveCommandData[index].GateNumber;

	if ( lpObj->Class == CLASS_DARKLORD || lpObj->Class == CLASS_MAGUMSA )
	{
		if ( NeedLevel > 0 )
		{
			if (GateNumber != 273) //season 3.0 add-on (Swamp of Calmmness)
			{
				NeedLevel = NeedLevel *2 / 3;
			}
		}
	}

	if ( GateNumber >= 0 )
	{
		if ( NeedLevel <= lpObj->Level )
		{
			if ( (lpObj->Money - NeedZen ) >= 0 )
			{
				if ( gObjMoveGate(lpObj->m_Index, GateNumber ) != FALSE )
				{
					lpObj->m_bPShopRedrawAbs = true;
					lpObj->Money -= NeedZen;

					LogAddTD("[%s][%s] Use [%s %s] Success : reduces money %d - %d", lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(11, 185)), mapname, lpObj->Money, NeedLevel);

					GCMoneySend(lpObj->m_Index, lpObj->Money );

					if(lpObj->MapNumber == MAP_INDEX_RAKLION_BOSS)//Season 4.5 addon
					{
						g_RaklionBattleUserMng.DeleteUserData(lpObj->m_Index);
					}
					return TRUE;
				}
			}
			else
			{
				::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 102)), lpObj->m_Index, 1);
			}
		}
		else
		{
			char szTemp[256];
			wsprintf(szTemp, lMsg.Get(MSGGET(4, 93)), NeedLevel);
			::GCServerMsgStringSend(szTemp, lpObj->m_Index, 1);
		}
	}

	LogAddTD("[%s][%s] Use [%s %s] Fail GateNumber = %d", lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(11, 185)), mapname, GateNumber);
	return FALSE;

}
BYTE CIllusionTempleEvent::TicketMix(int iIndex, int iLevel, int iCharmCount)
{
	if( OBJMAX_RANGE( iIndex ) == FALSE )
	{
		return FALSE;
	}

	if( IT_MAP_RANGE( iLevel + (MAP_INDEX_ILLUSIONTEMPLE1 - 1)) == FALSE )
	{
		return FALSE;
	}

	int Empty = 0;
	PMSG_CHAOSMIXRESULT pMsg;
	PHeadSetB((LPBYTE)&pMsg,0x86,sizeof(pMsg));

	pMsg.Result = 0;
	gObj[iIndex].ChaosLock = TRUE;

	LogAddTD("[Illusion Temple] Mix Chaos Mix Start (Account:%s, Name:%s, Level:%d)",
		gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel);

	char szTmp[23];

	wsprintf(szTmp,"IllusionTemple Mix,%d",iLevel);
	g_ChaosBox.LogChaosItem(&gObj[iIndex],szTmp);

	int MixRate = IT_TicketRate[-1 + iLevel];

	if( MixRate < 0 || MixRate > 100 )
	{
		DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size);
		LogAddTD("[Illusion Temple] Mix Chaos Mix Failed - MixRate Out of Bound (Account:%s, Name:%s, Level:%d)",
			gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel);
		return FALSE;
	}

	if ( g_CrywolfSync.GetOccupationState() == 0 && g_iCrywolfApplyMvpBenefit )
	{	
		MixRate += g_CrywolfSync.GetPlusChaosRate();
	}

	int iNeedChaosMoney = IT_TicketZen[-1 + iLevel];

	int iChaosTaxMoney = (int)((__int64)iNeedChaosMoney * (__int64)g_CastleSiegeSync.GetTaxRateChaos(iIndex) / (__int64)100);

	if ( iChaosTaxMoney < 0 )
	{
		iChaosTaxMoney = 0;
	}

	iNeedChaosMoney += iChaosTaxMoney;

	if ( iNeedChaosMoney < 0 )
	{
		DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size);
		LogAddTD("[Illusion Temple] Mix Chaos Mix Failed - MixMoney< 0 (Account:%s, Name:%s, Level:%d).",
			gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel);
		return false;
	}

	if ( ( gObj[iIndex].Money - iNeedChaosMoney ) < 0 )
	{
		pMsg.Result = 11;
		DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size);
		LogAddTD("[Illusion Temple] Mix Chaos Mix Failed - Not Enough Money (Account:%s, Name:%s, Level:%d)",
			gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel);
		return false;
	}

	gObj[iIndex].Money -= iNeedChaosMoney;
	g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
	GCMoneySend(iIndex, gObj[iIndex].Money);

	MixRate += iCharmCount;

	if( rand() % 100 < MixRate )
	{
#if( __4GAMERS__ == 1 )
			g_Achievements.GD_UpdateMixData(&gObj[iIndex], true);
#endif
		int Item = ITEMGET(13,51);
		ItemSerialCreateSend(iIndex,0xFF,0,0,Item,iLevel,0,0,0,0,-1,0,0);
		LogAddTD("[Illusion Temple] [%s][%s] CBMix Success %d Money : %d-%d, CharmRate : %d",
			gObj[iIndex].AccountID,gObj[iIndex].Name,MixRate,gObj[iIndex].Money,iNeedChaosMoney,iCharmCount);
	}
	else
	{
#if( __4GAMERS__ == 1 )
			g_Achievements.GD_UpdateMixData(&gObj[iIndex], false);
#endif
		g_ChaosBox.ChaosBoxInit(&gObj[iIndex]);
		GCUserChaosBoxSend(&gObj[iIndex], 0);
		DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size);

		LogAddTD("[Illusion Temple] [%s][%s] CBMix Fail %d Money : %d-%d, CharmRate : %d",
			gObj[iIndex].AccountID,gObj[iIndex].Name,MixRate,gObj[iIndex].Money,iNeedChaosMoney,iCharmCount);
		return FALSE;
	}

	gObjInventoryCommit(iIndex);
	return TRUE;
}
void cProtoFunc::PkClear(LPOBJ gObj, LPOBJ NpcObj)
{							   			
	if (gObj->m_PK_Level < 4)
	{										 
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You are good player. God bless your soul.");
		return;
	}	

	int PriceZen;
	int PricePcPoint;
	int PriceWCoin;
	switch(Config.ClearNpc.Type)
	{	   
	case 1:	
		PriceZen = (Config.ClearNpc.PriceZen * gObj->m_PK_Count); 		 
		PricePcPoint = (Config.ClearNpc.PricePcPoints * gObj->m_PK_Count);
		PriceWCoin = (Config.ClearNpc.PriceWCoins * gObj->m_PK_Count);
		break;
	case 2:	
		PriceZen = Config.ClearNpc.PriceZenForAll;			 
		PricePcPoint = Config.ClearNpc.PricePcPoints;
		PriceWCoin = Config.ClearNpc.PriceWCoins;
		break;
	case 0: 
		PriceZen = 0;					 
		PricePcPoint = 0;
		PriceWCoin = 0;
		break;
	}

	if(gObj->Money < PriceZen)
	{
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You don't have enough Zen, you need %d more!", PriceZen - gObj->Money);
		return;
	}	   
	if(gObj->m_wCashPoint < PriceWCoin)
	{	 
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You don't have enough WCoin, you need %d more!", PriceWCoin - gObj->m_wCashPoint);
		return;
	}
	if(AddTab[gObj->m_Index].PC_PlayerPoints < PricePcPoint)
	{	 
		Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] You don't have enough PcPoint, you need %d more!", PricePcPoint - AddTab[gObj->m_Index].PC_PlayerPoints);
		return;
	}
	if (PricePcPoint > 0)
	{
//		PointShop.DecreasePoints(gObj->m_Index, PricePcPoint);	  
		Chat.MessageLog(1, c_Blue, t_PCPOINT, gObj,"[Guard] You pay %d PcPoints", PricePcPoint);
		//MySQL.Execute("UPDATE Character SET %s = %s - %d WHERE Name= '%s'", Config.PCPointsColumn, Config.PCPointsColumn, PricePcPoint, gObj->Name);
	}

	if (PriceWCoin > 0)
	{										
		gObj->m_wCashPoint -= PriceWCoin;
		Chat.MessageLog(1, c_Blue, t_PCPOINT, gObj,"[Guard] You pay %d WCoin", PriceWCoin);
		//MySQL.Execute("UPDATE MEMB_INFO SET %s = %s - %d WHERE memb___id = '%s'", Config.WCoinsColumn, Config.WCoinsColumn, PriceWCoin, gObj->AccountID);
	}

	if (PriceZen > 0)
	{															 
		gObj->Money -= PriceZen; 
		GCMoneySend (gObj->m_Index, gObj->Money);
		Chat.MessageLog(1, c_Blue ,t_PCPOINT, gObj, "[Guard] You pay %d Zen", PriceZen);
	}

	Chat.MessageLog(1, c_Blue ,t_COMMANDS, gObj, "[Guard] Cleaned %d kills. Don't tell anyone!", gObj->m_PK_Count); 

	gObj->m_PK_Level = 3;
	gObj->m_PK_Count = 0;

	GCPkLevelSend (gObj->m_Index,3);
}
BOOL CJewelOfHarmonySystem::MakeSmeltingStoneItem(LPOBJ lpObj)
{
	if ( this->m_bSystemMixSmeltingStone != TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13,53)), lpObj->m_Index, 1);
		return TRUE;
	}

	lpObj->ChaosLock = TRUE;
	int iValidItemCount = 0;
	int iInvalidItemCount = 0;
	int iMakeSmeltingStoneMixPrice = 0;

	PMSG_CHAOSMIXRESULT pMsg;

	C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg));
	pMsg.Result = 0;
	int iItemPos = -1;

	for ( int n=0;n<CHAOS_BOX_SIZE;n++)
	{
		if ( lpObj->pChaosBox[n].IsItem() == TRUE )
		{
			if ( this->IsEnableToMakeSmeltingStoneItem(&lpObj->pChaosBox[n]) == TRUE )
			{
				iValidItemCount++;
				iItemPos = n;
			}
			else
			{
				iInvalidItemCount++;
			}
		}
	}

	if ( iValidItemCount != 1 ||
		 iInvalidItemCount ||
		 iItemPos == -1 )
	{
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	int JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE;
	BOOL bIsItemNormal = TRUE;

	if ( lpObj->pChaosBox[iItemPos].IsExtItem() == TRUE )
	{
		bIsItemNormal = FALSE;
		JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE = this->m_iRateMixSmeltingStoneExt;
	}
	else
	{
		bIsItemNormal = TRUE;
		JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE = this->m_iRateMixSmeltingStoneNor;
	}

	iMakeSmeltingStoneMixPrice = this->m_iZenForMixSmeltingStone;
	int iChaosTaxMoney = iMakeSmeltingStoneMixPrice * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100;

	if ( iChaosTaxMoney < 0 )
		iChaosTaxMoney = 0;

	iMakeSmeltingStoneMixPrice += iChaosTaxMoney;

	if ( iMakeSmeltingStoneMixPrice < 0 )
		iMakeSmeltingStoneMixPrice = 0;

	if ( lpObj->Money < iMakeSmeltingStoneMixPrice )
	{
		pMsg.Result = 2;
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	lpObj->Money -= iMakeSmeltingStoneMixPrice;
	g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
	GCMoneySend(lpObj->m_Index, lpObj->Money);
	LogChaosItem(lpObj, "JewelOfHarmony][Smelt Item Mix");
	CLog.LogAdd("[JewelOfHarmony][Smelt Item Mix] - Mix Start");

	int iRate = rand() % 100;

	BYTE Socket[5];
	Socket[0] = 0xFF;
	Socket[1] = 0xFF;
	Socket[2] = 0xFF;
	Socket[3] = 0xFF;
	Socket[4] = 0xFF;

	if ( iRate < JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE )
	{
		int iItemType;

		if ( bIsItemNormal == TRUE )
			iItemType = this->JEWEL_OF_HARMONY_SMELT_NOR_ITEMINDEX;
		else
			iItemType = this->JEWEL_OF_HARMONY_SMELT_EXT_ITEMINDEX;

		ItemSerialCreateSend(lpObj->m_Index, 255, 0, 0, iItemType, 0,
							1, 0, 0, 0, lpObj->m_Index, 0, 0, Socket);
		gObjInventoryCommit(lpObj->m_Index);

		CLog.LogAdd("[JewelOfHarmony][Smelt Item Mix] Smelting Stone Normal[%d] Mix Success [%s][%s], Money(%d-%d) Rate(%d/%d)",
			bIsItemNormal, lpObj->AccountID, lpObj->Name,
			lpObj->Money, iMakeSmeltingStoneMixPrice, iRate,
			JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE);
	}
	else
	{
		gChaosBox.ChaosBoxInit(lpObj);
		GCUserChaosBoxSend(lpObj, 0);
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);

		CLog.LogAdd("[JewelOfHarmony][Smelt Item Mix] Smelting Stone Normal[%d] Mix Fail [%s][%s], Money : %d-%d Rate(%d/%d)",
			bIsItemNormal, lpObj->AccountID, lpObj->Name,
			lpObj->Money, iMakeSmeltingStoneMixPrice, iRate,
			JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE);
	}

	lpObj->ChaosLock = FALSE;
	return TRUE;
}
Beispiel #15
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::BuyItemPersonalShop(PMSG_REQ_BUYITEM_FROM_PSHOP * lpMsg, int aSourceIndex)
{
	LPOBJ SrcObj = &gObj[aSourceIndex];
	// ------
	if( gDoPShopOpen == FALSE ) return;
	// ------
	if( gObjIsConnected( MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)) == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Offline (%d).", SrcObj->AccountID, SrcObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	LPOBJ lpObj = &gObj[MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)];
	// ------
	if( lpObj->Type != OBJ_USER )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller isn't an Object User (%d).", SrcObj->AccountID,
			SrcObj->Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	if( lpObj->CloseCount >= 0 )	
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Closing (%d).", SrcObj->AccountID, SrcObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0,2);
		return;
	}
	// ------
	if( SrcObj->CloseCount >= 0 )	
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Buyer is Closing (%d).", SrcObj->AccountID, SrcObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	if( lpObj->m_bPShopOpen == false )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Didn't Open Shop.", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 3);
		return;
	}
	// ------
	char szName[MAX_ACCOUNT_LEN+1] = {0};
	// ------
	memcpy(szName, lpMsg->btName, sizeof(lpMsg->btName));
	szName[MAX_ACCOUNT_LEN] = 0;
	// ------
	int iITEM_LOG_TYPE;
	int iITEM_LOG_LEVEL;
	int iITEM_LOG_DUR;
	int iITEM_LOG_SERIAL;
	// ------
	if( strcmp(szName, lpObj->Name) )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Name Mismatch [%s]-[%s]", SrcObj->AccountID, SrcObj->Name,
			szName, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 6);
		return;
	}
	// ------
	if( (lpObj->Penalty &4) == 4 || (lpObj->Penalty &8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] is in Item Block", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,9);
		return;
	}
	// ------
	if( (SrcObj->Penalty &4) == 4 || (SrcObj->Penalty &8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] is in Item Block", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,9);
		return;
	}
	// ------
	EnterCriticalSection(&lpObj->m_critPShopTrade);
	// ------
	if( lpObj->m_bPShopTransaction == true )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Already In Trade.", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,4);
		// ------
		LeaveCriticalSection(&lpObj->m_critPShopTrade);
	}
	else
	{
		lpObj->m_bPShopTransaction = true;
		// ------
		LeaveCriticalSection(&lpObj->m_critPShopTrade);
		// ------
		if( gObjInventorySearchSerialNumber(&gObj[aSourceIndex], lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE )
		{
			GCReFillSend(aSourceIndex, SrcObj->Life, -3, 1, SrcObj->iShield);
			// ------
			CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)", SrcObj->AccountID, SrcObj->Name, __FILE__, __LINE__);
			return;
		}
		// ------
		if( gObjInventorySearchSerialNumber(lpObj, lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE )
		{
			GCReFillSend(lpObj->m_Index, lpObj->Life, -3, 1, lpObj->iShield);
			// ------
			CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)", lpObj->AccountID, lpObj->Name, __FILE__, __LINE__);
			return;
		}
		// ------
		if(gObjFixInventoryPointer(aSourceIndex) == false )
		{
			CLog.LogAddC(TColor.Red(), PShopModule, "[Fix Inv.Ptr] False Location - [%s](%d)", __FILE__, __LINE__);
		}
		// ------
		if( SrcObj->pTransaction == 1 )
		{
			CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Item Buy Request Failed: Requester Transaction == 1, IF_STAT_TYPE : %d", SrcObj->AccountID,
				SrcObj->Name, SrcObj->m_IfState.type);
			return;
		}
		// ------
		iITEM_LOG_TYPE		= 0;
		iITEM_LOG_LEVEL		= 0;
		iITEM_LOG_DUR		= 0;
		iITEM_LOG_SERIAL	= 0;
		// ------
		__try
		{
			if( PSHOP_RANGE(lpMsg->btItemPos) == FALSE )
			{
				SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 5);
				return;
			}
			// ------
			if( lpObj->m_bMapSvrMoveQuit == true )
			{
				SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
				return;
			}
			// ------
			if( lpObj->Inventory1[lpMsg->btItemPos].IsItem() == TRUE )
			{
				if( lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue <= 0 )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Didn't Choose Item Price.", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 6);
					return;
				}
				// ------
				if( SrcObj->Money < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Lack of Zen.", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 7);
					return;
				}
				// ------
				DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
				// ------
				if( gObjCheckMaxZen(lpObj->m_Index, dwCost) == FALSE )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Exceeding Zen of the Host", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 8);
					return;
				}
				// ------
				BYTE btNewItemPos	= 0;
				btNewItemPos		= gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
				// ------
				if( btNewItemPos == 0xFF )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] No Room to Buy Item.", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 8);
					return;
				}
				// ------
				iITEM_LOG_TYPE		= lpObj->Inventory1[lpMsg->btItemPos].m_Type;
				iITEM_LOG_LEVEL		= lpObj->Inventory1[lpMsg->btItemPos].m_Level;
				iITEM_LOG_DUR		= lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
				iITEM_LOG_SERIAL	= lpObj->Inventory1[lpMsg->btItemPos].m_Number;
				// ------
				gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
				// ------
				lpObj->Inventory1[lpMsg->btItemPos].Clear();
				GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
				// ------
				SrcObj->Money	-= dwCost;
				lpObj->Money	+= dwCost;
				// ------
				GCMoneySend(aSourceIndex, SrcObj->Money);
				GCMoneySend(lpObj->m_Index, lpObj->Money);
				// ------
				SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
				// ------
				SendPShopSoldItemResult(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
				// ------
				CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s][%s] Shop Item Buy Request Succeed: [%s][%s][%s] Price = (%d), Type:(%d)[%s] Level:(%d) Dur:(%d) Serial:(%d).",
					SrcObj->AccountID, SrcObj->Name, SrcObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE,
					ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
				// ------
				if( PShop_CheckInventoryEmpty(lpObj->m_Index) == true )
				{
					CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s] Sold All Items - Auto Closing Shop.", lpObj->AccountID, lpObj->Name);
					// ------
					SendMsg.MessageOut(lpObj->m_Index, 0x01, "[PersonalShop] All items in Your Shop have been sold!");
					// ------
					lpObj->m_bPShopOpen = false;
					// ------
					memset(lpObj->m_szPShopText, 0, sizeof(lpObj->m_szPShopText));
					// ------
					SendPShopCloseResult(lpObj->m_Index, 1);
				}
				else
				{
					lpObj->m_bPShopItemChange = true;
				}
			}
		}
		// ------
		__finally
		{
			lpObj->m_bPShopTransaction = false;
		}
	}
}
BYTE CIllusionTempleEvent::IllusionTempleChaosMix(int nIndex, int nLEVEL, int iCharmOfLuckCount)
{
	if( OBJMAX_RANGE(nIndex) == FALSE )
	{
		return FALSE;
	}

	if ( IT_MAP_RANGE((nLEVEL+(45-1))) == FALSE )
	{
		return FALSE;
	}

	int loc2 = 0;

	PMSG_CHAOSMIXRESULT pMsg;
	PHeadSetB((LPBYTE)&pMsg.h, 0x86, sizeof(PMSG_CHAOSMIXRESULT));
	pMsg.Result = CB_ERROR;

	gObj[nIndex].ChaosLock = TRUE;
	LogAddTD("[Illusion Temple] 피의 두루마리 Mix Chaos Mix Start (Account:%s, Name:%s, Level:%d)", gObj[nIndex].AccountID, gObj[nIndex].Name, nLEVEL);

	char szTemp[17];
	wsprintf(szTemp, "피의 두루마리 Mix,%d", nLEVEL);

	g_MixSystem.LogChaosItem(&gObj[nIndex], szTemp);

	int iMIX_SUCCESS_RATE = g_iIT_ChoasMixSuccessRate[nLEVEL-1]; //loc11

	if ( iMIX_SUCCESS_RATE < 0 || iMIX_SUCCESS_RATE > 100 )
	{
		DataSend(nIndex, (LPBYTE)&pMsg, pMsg.h.size);
		LogAddTD("[Illusion Temple] 피의 두루마리 Mix Chaos Mix Failed - MixRate Out of Bound (Account:%s, Name:%s, Level:%d)", gObj[nIndex].AccountID, gObj[nIndex].Name, nLEVEL);
		return FALSE;
	}

	if ( g_CrywolfSync.GetOccupationState() == 0 && g_iCrywolfApplyMvpBenefit )
	{
		iMIX_SUCCESS_RATE += g_CrywolfSync.GetPlusChaosRate();
	}

	int iMIX_NEED_MONEY = g_iIT_ChoasMixMoney[nLEVEL-1]; //loc12

	int iChaosTaxMoney = (int)((__int64)(iMIX_NEED_MONEY) * (__int64)(g_CastleSiegeSync.GetTaxRateChaos(nIndex)) / (__int64)100); //loc13

	if ( iChaosTaxMoney < 0 )
	{
		iChaosTaxMoney = 0;
	}

	iMIX_NEED_MONEY += iChaosTaxMoney;

	if ( iMIX_NEED_MONEY <  0 )
	{
		DataSend(nIndex, (LPBYTE)&pMsg, pMsg.h.size);
		LogAddTD("[Illusion Temple] 피의 두루마리 Mix Chaos Mix Failed - MixMoney < 0 (Account:%s, Name:%s, Level:%d)",	gObj[nIndex].AccountID, gObj[nIndex].Name, nLEVEL);
		return FALSE;
	}

	if ( (gObj[nIndex].Money - iMIX_NEED_MONEY) < 0 )
	{
		pMsg.Result = CB_BC_NOT_ENOUGH_ZEN;
		DataSend(nIndex, (LPBYTE)&pMsg, pMsg.h.size);
		LogAddTD("[Illusion Temple] 피의 두루마리 Mix Chaos Mix Failed - Not Enough Money (Account:%s, Name:%s, Level:%d)",	gObj[nIndex].AccountID, gObj[nIndex].Name, nLEVEL);
		return FALSE;
	}

	gObj[nIndex].Money -= iMIX_NEED_MONEY;
	g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
	GCMoneySend(nIndex, gObj[nIndex].Money);

	iMIX_SUCCESS_RATE += iCharmOfLuckCount; //season 3.0 moved

	if ( (rand()%100) < iMIX_SUCCESS_RATE )	// Success (season 3.0 changed)
	{
		int item_num = ITEMGET(13,51);	// Blood Scroll loc14
		ItemSerialCreateSend(nIndex, -1, 0, 0, item_num, nLEVEL, 0, 0, 0, 0, -1, 0, 0);
		LogAddTD("[피의 두루마리 Mix] [%s][%s] CBMix Success %d Money : %d-%d, CharmRate : %d",	gObj[nIndex].AccountID, gObj[nIndex].Name, iMIX_SUCCESS_RATE, gObj[nIndex].Money, iMIX_NEED_MONEY, iCharmOfLuckCount);
	}
	else
	{
		g_MixSystem.ChaosBoxInit(&gObj[nIndex]);
		GCUserChaosBoxSend(&gObj[nIndex], 0);
		DataSend(nIndex, (LPBYTE)&pMsg, pMsg.h.size);
		LogAddTD("[피의 두루마리 Mix] [%s][%s] CBMix Fail %d Money : %d-%d, CharmRate : %d", gObj[nIndex].AccountID, gObj[nIndex].Name, iMIX_SUCCESS_RATE, gObj[nIndex].Money, iMIX_NEED_MONEY, iCharmOfLuckCount);
		return FALSE;
	}

	::gObjInventoryCommit(nIndex);
	return TRUE;
}
BOOL CJewelOfHarmonySystem::RestoreStrengthenItem(LPOBJ lpObj)
{
	if ( this->m_bSystemRestoreStrengthen != TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13,54)), lpObj->m_Index, 1);
		return TRUE;
	}

	lpObj->ChaosLock = TRUE;

	PMSG_CHAOSMIXRESULT pMsg;

	C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg));
	pMsg.Result = 0;
	int iStrengtenItemCount = 0;
	int iInvalidItemCount = 0;
	CItem * pItem = NULL;

	for ( int n=0;n<CHAOS_BOX_SIZE;n++)
	{
		if ( lpObj->pChaosBox[n].IsItem() == TRUE )
		{
			if ( this->IsStrengthenByJewelOfHarmony(&lpObj->pChaosBox[n]) == TRUE )
			{
				iStrengtenItemCount++;
				pItem = &lpObj->pChaosBox[n];
			}
		}
	}

	if ( iStrengtenItemCount != 1 )
	{
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}
	
	int iItemOption = this->GetItemStrengthenOption(pItem);
	int iItemOptionLevel = this->_GetItemOptionLevel(pItem);
	int JEWEL_OF_HARMONY_RETORE_NEEDZEN = this->_GetZenForRestoreItem(pItem);

	if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 ) 
	{
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	int iChaosTaxMoney = JEWEL_OF_HARMONY_RETORE_NEEDZEN * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100;

	if ( iChaosTaxMoney < 0 )
		iChaosTaxMoney = 0;

	JEWEL_OF_HARMONY_RETORE_NEEDZEN += iChaosTaxMoney;

	if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 )
		JEWEL_OF_HARMONY_RETORE_NEEDZEN = 0;

	if ( lpObj->Money < JEWEL_OF_HARMONY_RETORE_NEEDZEN )
	{
		pMsg.Result = 2;
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	lpObj->Money -= JEWEL_OF_HARMONY_RETORE_NEEDZEN;
	g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
	GCMoneySend(lpObj->m_Index, lpObj->Money);
	LogChaosItem(lpObj, "JewelOfHarmony][Restore Item");
	CLog.LogAdd("[JewelOfHarmony][Restore Item] - Restore Start");

	CLog.LogAdd("[JewelOfHarmony][Restore Item] Restore Strengtened Item [%s][%s] Name[%s] ItemType[%d] Serial[%d] OptionType[%d] OptionLevel [%d] Money %d-%d",
		lpObj->AccountID, lpObj->Name, pItem->GetName(), pItem->m_Type,
		pItem->m_Number, iItemOption, iItemOptionLevel, 
		lpObj->Money, JEWEL_OF_HARMONY_RETORE_NEEDZEN);

	pItem->m_JewelOfHarmonyOption = 0;
	GCUserChaosBoxSend(lpObj, 0);
	this->ShowStrengthenOption(pItem);
	lpObj->ChaosLock = FALSE;

	return TRUE;
}
Beispiel #18
0
void CDevilSquareGround::SendScore()
{
	if ( this->m_DevilSquareRankList.size() < 1 )
	{
		return;
	}

	BYTE count = 1;
	int iUserCount = this->m_DevilSquareRankList.size();
	int iExp = 0;
	std::vector<OBJECTSTRUCT *>::iterator Itor;

	for (Itor = this->m_DevilSquareRankList.begin() ; Itor != this->m_DevilSquareRankList.end() ; Itor++ )
	{
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore;

		if ( iUserCount <= 7 )//6
		{
			if ( count < 4 )	// For DS from 0 to 3
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc5 = count*100/iUserCount;

			if ( count == 1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc5 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc5 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}

		count++;

		if ( count >= 10 )
		{
			break;
		}
	}

	this->m_DevilSquareScoreInfoTOP10.Count  = count;
	int iSize = count * 24 + 5;

	PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize);
	count = 1;

	Itor = this->m_DevilSquareRankList.begin();

	LogAddTD("[DevilSquare] Rank [%d]", this->m_iIndex);

	for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ )
	{
		if ( (*(Itor))->Type != OBJ_USER )
			continue;

		if ( iUserCount <= 7 )//6
		{
			if ( count < 3 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc7 = count*100/iUserCount;

			if ( count ==1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc7 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc7 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}

		if ( g_CrywolfSync.GetOccupationState() == CRYWOLF_OCCUPATION_FAILED && g_iCrywolfApplyMvpPenalty != FALSE)
		{
#if (PACK_EDITION>=2)
			if ((VipSystem.VipIsApplyCWExpPenalty == 0)&&((*(Itor))->Vip >= 1))
			{
			} else {
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp =  (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100;
			}
#else
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp =  (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100;
#endif
		}

		if ( ((*(Itor))->m_wExprienceRate + (*(Itor))->MasterCharacterInfo->IncExperience) == 0 )
			iExp = 0;
		else
		{
			if ((*(Itor))->m_btDisableExpGain == 0 )
			{
				iExp = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp;
				(*(Itor))->Experience += iExp;
			}
		}

		//(*(Itor))->Experience += this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp;
		int ret = -1;
		int LevelUp = 0;

		if ( ((*(Itor))->m_wExprienceRate + (*(Itor))->MasterCharacterInfo->IncExperience) > 0 && (*(Itor))->m_btDisableExpGain == 0 )
		{
			gObjSetExpPetItem((*(Itor))->m_Index, iExp);

			int iMAX_LEVCOUNT = 0;
			ret = iExp;

			while ( ret > 0 )
			{
				if ( ret > 0 )
				{
					ret = gObjLevelUp((*(Itor)), ret, 0, EVENT_TYPE_DEVILSQUARE, LevelUp);
				}

				iMAX_LEVCOUNT++;
				if (iMAX_LEVCOUNT > 5)
					break;
			}

			if ((ret < 0)&&(iMAX_LEVCOUNT > 1))
				ret=0;
		}

		(*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen;

		if ( (__int64)((*(Itor))->m_Index + (*(Itor))->m_nEventMoney) > (__int64)MAX_ZEN )
		{
			int Zen = MAX_ZEN - (*(Itor))->Money;
			(*(Itor))->Money += Zen;
		}
		else
		{
			(*(Itor))->Money += (*(Itor))->m_nEventMoney;
		}

		GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money);

		if ( ret >= 0 )
		{
			if (  ((*(Itor))->m_wExprienceRate + (*(Itor))->MasterCharacterInfo->IncExperience) > 0 && (*(Itor))->m_btDisableExpGain == 0 )
			{
				if(LevelUp == 0)
					GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, iExp, 0, 0);
			}
		}

		this->SendRankingInfo((*(Itor)));

		LogAddTD("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore);
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore;

		if ( ((*(Itor))->m_wExprienceRate + (*(Itor))->MasterCharacterInfo->IncExperience) == 0 || (*(Itor))->m_btDisableExpGain == 1 )
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = 0;
		}
		else
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = iExp;
		}

		this->m_DevilSquareScoreInfoTOP10.MyRank = count;
		count++;

		DataSend((*(Itor))->m_Index, (BYTE *)&this->m_DevilSquareScoreInfoTOP10 , iSize);

		(*(Itor))->m_nEventScore = 0;
		(*(Itor))->m_nEventMoney = 0;
		(*(Itor))->m_nEventExp = 0;
	}
}
Beispiel #19
0
BOOL CJewelMixSystem::UnMixJewel(int iIndex, int iJewelType, int iJewelLevel, int iInventoryPos)
{
	if ( !gObjIsConnected(iIndex))
		return FALSE;

	if ( gObjCheckInventorySerial0Item(&gObj[iIndex]))
	{
		MsgOutput(iIndex, lMsg.Get(MSGGET(13,26)));
		GCAnsJewelUnMix(iIndex, 0);

		LogAddTD("[ANTI-HACK][Serial 0 Item] [UnMix Jewel] (%s)(%s)",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		return FALSE;
	}

	if ( gObj[iIndex].m_IfState.type == 1 )
	{
		LogAddTD("[JewelMix] [%s][%s] Attempted ItemCopy using Trade Window",
			gObj[iIndex].AccountID, gObj[iIndex].Name);
		return FALSE;
	}

	if ( gObj[iIndex].ChaosLock == TRUE )
	{
		LogAddTD("[JewelMix] [%s][%s] Chaos Mix is already working",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		GCAnsJewelUnMix(iIndex, 0);
		return FALSE;
	}

	gObj[iIndex].ChaosLock = TRUE;

	if ( !CHECK_LIMIT(iJewelType, 10) )
	{
		LogAddTD("[JewelMix] [%s][%s] UnMix iJewelType is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iJewelType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 2);
		return FALSE;
	}

	if ( !CHECK_LIMIT(iInventoryPos, MAIN_INVENTORY_SIZE))
	{
		LogAddTD("[JewelMix] [%s][%s] iInventoryPos is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iInventoryPos);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 5);
		return FALSE;
	}

	int iInventoryItemType;
	int iInventoryItemLevel;

	if ( gObj[iIndex].pInventory[iInventoryPos].IsItem() == TRUE )
	{
		if ( gObj[iIndex].pInventory[iInventoryPos].m_Level == iJewelLevel )
		{
			iInventoryItemType = gObj[iIndex].pInventory[iInventoryPos].m_Type;
			iInventoryItemLevel = gObj[iIndex].pInventory[iInventoryPos].m_Level;
		}
		else
		{
			LogAddTD("[JewelMix] [%s][%s] iJewelLevel is different from request : %d / %d",
				gObj[iIndex].AccountID, gObj[iIndex].Name,
				gObj[iIndex].pInventory[iInventoryPos].m_Level, iJewelLevel);

			gObj[iIndex].ChaosLock = FALSE;
			GCAnsJewelUnMix(iIndex, 3);
			return FALSE;
		}
	}
	else
	{
		LogAddTD("[JewelMix] [%s][%s] Item to unmix is not exist",
			gObj[iIndex].AccountID, gObj[iIndex].Name);
	
		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 4);
		return FALSE;
	}

	if ( !CHECK_LIMIT(iInventoryItemLevel, 3))
	{
		LogAddTD("[JewelMix] [%s][%s] iInventoryItemLevel is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iInventoryItemLevel);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 3);
		return FALSE;
	}

	int iItemType = g_JewelMixInfo[iJewelType][iInventoryItemLevel].m_iChangeType;
	int iJewelCount = g_JewelMixInfo[iJewelType][iInventoryItemLevel].m_iJewelCount;
	int iChangeType = g_JewelMixInfo[iJewelType][iInventoryItemLevel].m_iSourceType;
	int iMixMoney = 1000000;

	if ( iInventoryItemType != iItemType )
	{
		LogAddTD("[JewelMix] [%s][%s] iItemType is different from request : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iInventoryItemType, iItemType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 6);
		return FALSE;
	}

	if ( iMixMoney > gObj[iIndex].Money )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of money to unmix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			gObj[iIndex].Money, iMixMoney);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 8);
		return FALSE;
	}

	int invSize = INVENTORY_MAP_SIZE-PSHOP_MAP_SIZE;

	if( gObj[iIndex].pInventoryExtend <= 4 )	{
		invSize = (INVENTORY_MAP_SIZE-PSHOP_MAP_SIZE)-(32*(4-gObj[iIndex].pInventoryExtend));
	}

	int iEmptyCount = 0;

	int x;
	for ( x=0;x<invSize;x++)
	{
		if ( gObj[iIndex].pInventoryMap[x] == 0xFF )
		{
			iEmptyCount++;
		}
	}

	if ( iEmptyCount < iJewelCount )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of empty slot to unmix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iEmptyCount, iJewelCount);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 7);
		return FALSE;
	}

	LogAddTD("[JewelMix] [%s][%s] UnMix - Delete Jewel, Type:%d, Level:%d, Serial:%d",
		gObj[iIndex].AccountID, gObj[iIndex].Name,
		gObj[iIndex].pInventory[iInventoryPos].m_Type,
		gObj[iIndex].pInventory[iInventoryPos].m_Level,
		gObj[iIndex].pInventory[iInventoryPos].m_Number);

	gObjInventoryItemSet(iIndex, iInventoryPos, 0xFF);
	gObjInventoryDeleteItem(iIndex, iInventoryPos);
	GCInventoryItemDeleteSend(iIndex, iInventoryPos, 1);

	int iCrtJewelCount = 0;
	BOOL bItemCrtOK = FALSE;

	for ( x=0;x<invSize;x++)
	{
		if ( gObj[iIndex].pInventoryMap[x] == 0xFF )
		{
			ItemSerialCreateSend(iIndex, 235, gObj[iIndex].X, gObj[iIndex].Y,
								iChangeType, 0, 0, 0, 0, 0,
								iIndex, 0, 0);

			iCrtJewelCount++;

			if ( iJewelCount <= iCrtJewelCount )
			{
				bItemCrtOK = TRUE;
				break;
			}
		}
	}

	gObj[iIndex].ChaosLock = FALSE;

	if ( bItemCrtOK == TRUE )
	{
		LogAddTD("[JewelMix] [%s][%s] jewel unmix succeed : ItemType:%d, JewelCount:%d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iItemType, iJewelCount);

		gObj[iIndex].Money -= iMixMoney;
		GCMoneySend(iIndex, gObj[iIndex].Money);
		GCAnsJewelUnMix(iIndex, 1);
	}
	else
	{
		LogAddTD("[JewelMix] [%s][%s] jewel unmix failed : ItemType:%d, JewelCount:%d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iItemType, iJewelCount);

		GCAnsJewelUnMix(iIndex, 0);
	}

	return TRUE;
}
Beispiel #20
0
BOOL CJewelMixSystem::MixJewel( int iIndex, int iJewelType, int iMixType)
{
	if ( !gObjIsConnected(iIndex))
		return FALSE;

	if ( gObjCheckInventorySerial0Item(&gObj[iIndex]))
	{
		MsgOutput(iIndex, lMsg.Get(MSGGET(13,26)));
		GCAnsJewelMix(iIndex, 4);

		LogAddTD("[ANTI-HACK][Serial 0 Item] [Mix Jewel] (%s)(%s)",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		return FALSE;
	}

	if ( gObj[iIndex].m_IfState.type == 1 )
	{
		LogAddTD("[JewelMix] [%s][%s] Attempted ItemCopy using Trade Window",
			gObj[iIndex].AccountID, gObj[iIndex].Name);
		return FALSE;
	}

	if ( gObj[iIndex].ChaosLock == TRUE )
	{
		LogAddTD("[JewelMix] [%s][%s] Chaos Mix is already working",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		GCAnsJewelMix(iIndex, 0);
		return FALSE;
	}

	gObj[iIndex].ChaosLock = TRUE;

	if ( !CHECK_LIMIT(iJewelType, 10) )
	{
		LogAddTD("[JewelMix] [%s][%s] Mix iJewelType is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iJewelType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 2);
		return FALSE;
	}

	if ( !CHECK_LIMIT(iMixType, 3))
	{
		LogAddTD("[JewelMix] [%s][%s] iMixType is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iMixType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 3);
		return FALSE;
	}

	int iItemType = g_JewelMixInfo[iJewelType][iMixType].m_iSourceType;
	int iJewelCount = g_JewelMixInfo[iJewelType][iMixType].m_iJewelCount;
	int iMixMoney = g_JewelMixInfo[iJewelType][iMixType].m_iMixMoney;
	int iChangeType = g_JewelMixInfo[iJewelType][iMixType].m_iChangeType;

	if ( iJewelCount <= 0 )
	{
		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 0);
		return FALSE;
	}

	int iUserJewelCount = gObjGetItemCountInIventory(iIndex, iItemType);

	if ( iJewelCount > iUserJewelCount )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of jewel to mix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iUserJewelCount, iJewelCount);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 4);
		return FALSE;
	}

	if ( iMixMoney > gObj[iIndex].Money )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of money to mix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			gObj[iIndex].Money, iMixMoney);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 5);
		return FALSE;
	}

	int iDelJewelCount = 0;
	BOOL bItemDelOK = FALSE;


	int invSize = MAIN_INVENTORY_SIZE;

	if( gObj[iIndex].pInventoryExtend <= 4 )	{
		invSize = (MAIN_INVENTORY_SIZE)-(32*(4-gObj[iIndex].pInventoryExtend));
	}

	for ( int x= INVETORY_WEAR_SIZE ; x< invSize; x++)
	{
		if ( gObj[iIndex].pInventory[x].IsItem() == TRUE )
		{
			if ( gObj[iIndex].pInventory[x].m_Type == iItemType )
			{
				LogAddTD("[JewelMix] [%s][%s] Mix - Delete Jewel, Type:%d, Level:%d, Serial:%d",
					gObj[iIndex].AccountID, gObj[iIndex].Name,
					gObj[iIndex].pInventory[x].m_Type,
					gObj[iIndex].pInventory[x].m_Level,
					gObj[iIndex].pInventory[x].m_Number);

				gObjInventoryItemSet(iIndex, x, 0xFF);
				gObj[iIndex].pInventory[x].Clear();
				iDelJewelCount++;

				if ( iJewelCount <= iDelJewelCount )
				{
					bItemDelOK = TRUE;
					break;
				}
			}
		}
	}

	GCItemListSend(iIndex);

	if ( bItemDelOK == FALSE )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of jewel to mix (in deleting) : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iDelJewelCount, iJewelCount);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 0);
		return FALSE;
	}

	ItemSerialCreateSend(iIndex, 235, gObj[iIndex].X,
						gObj[iIndex].Y, iChangeType,
						iMixType, 0, 0, 0, 0,
						iIndex, 0, 0);

	gObj[iIndex].ChaosLock = FALSE;
	gObj[iIndex].Money -= iMixMoney;
	GCMoneySend(iIndex, gObj[iIndex].Money);
	GCAnsJewelMix(iIndex, 1);

	LogAddTD("[JewelMix] [%s][%s] jewel mix succeed : ItemType:%d, JewelCount:%d",
		gObj[iIndex].AccountID, gObj[iIndex].Name,
		iItemType, iJewelCount);

	return TRUE;
}
Beispiel #21
0
int CGMMng::ManagementProc(LPOBJ lpObj, char* szCmd, int aIndex)
{
	char * szCmdToken;
	char string[256];
	char szId[20];
	char * pId = szId;
	int len = strlen(szCmd);
	int command_number;

	if ( len < 1 || len > 250 )
	{
		return 0;
	}

	memset(szId, 0, sizeof(szId));
	strcpy(string, szCmd);
	szCmdToken = strtok(string, " ");
	command_number = this->GetCmd(szCmdToken);

	strcpy(Message, szCmd);

	if ( stricmp(szCmdToken, "/add0") == 0 )
	{
		int nAddStrength = 100;
		LevelUpPointAdd(0,nAddStrength,aIndex);
		GCSendEffectInfo(aIndex, 17);
	}
	if ( stricmp(szCmdToken, "/add1") == 0 )
	{
		int nAddStrength = 100;
		LevelUpPointAdd(1,nAddStrength,aIndex);
		GCSendEffectInfo(aIndex, 3);
	}
	if ( stricmp(szCmdToken, "/add2") == 0 )
	{
		int nAddStrength = 100;
		LevelUpPointAdd(2,nAddStrength,aIndex);
		GCSendEffectInfo(aIndex, 17);
	}
	if ( stricmp(szCmdToken, "/add3") == 0 )
	{
		int nAddStrength = 100;
		LevelUpPointAdd(3,nAddStrength,aIndex);
		GCSendEffectInfo(aIndex, 17);
	}
	switch ( command_number )
	{
		#if(GS_CASTLE == 1)
		case 331:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 0, pId);
		}
		break;
		case 332:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 1, pId);
		}
		break;
		case 333:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 2, pId);
		}
		break;
		case 334:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 3, pId);
		}
		break;
		case 335:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 4, pId);
		}
		break;
		case 336:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 5, pId);
		}
		break;
		case 337:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 6, pId);
		}
		break;
		case 338:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 7, pId);
		}
		break;
		case 340:
		{
			pId = this->GetTokenString();
			g_CastleSiege.OperateGmCommand(lpObj->m_Index, 8, pId);
		}
		break;
#endif
		case 502:
			{
				MMSG->Msg(lpObj->m_Index,"@@God of MuGlobal is Wolf");
				break;
			}
		case 501:
			{
				int OnlineCount = 0;
				for (int n=OBJ_STARTUSERINDEX;n<OBJMAX;n++)
				{
					if(gObjIsConnected(n))
						OnlineCount++;
				}
				MMSG->Msg(lpObj->m_Index,"[%d] Online Players",OnlineCount);
				break;
			}
		case 500:
			{
				char* szuText = this->GetTokenString();
				if(szuText != NULL)
				{
					int uTick = GetTickCount();
					//if(lpObj->Money < 299999);
					//{
					//	MMSG->Msg(lpObj->m_Index,"@[POST] Eww ti co - bisplatnij sir toka v mi6elovki");
					//	return 0;
					//}
					//{
					//	MMSG->Msg(lpObj->m_Index,"@[POST] Eww ti co - level netu :(");
					//	return 0;
					//}
					if(lpObj->Money < 500000)
					{
						MMSG->Msg(lpObj->m_Index,"@[POST] You need 500k Zen to POST");
						return 0;
					}
					if(lpObj->Level < 50)
					{
						MMSG->Msg(lpObj->m_Index,"@[POST] You need 50 Level to POST");
						return 0;
					}
					else
					{
						char *Content = (char*) Message;
						GetLongParam(Message, Content);
						lpObj->Money -= 500000;
						GCMoneySend(lpObj->m_Index , lpObj->Money);
						wsprintf(szuTemp,"[POST] %s: %s",lpObj->Name,Message);
						MMSG->PMAll(szuTemp);
						return 0;
					}
				}
				else
				{
					MMSG->Msg(lpObj->m_Index,"@[POST] The Correct Syntax is: /post message");
					return 0;
				}
				break;
			}
			case 503:	// MakeSet CMD
			{
								if ( (lpObj->Authority & 2) != 2 && (lpObj->Authority & 0x20) != 0x20 )
				{
					return 0;
				}
				if (!strcmpi(Message, "/MakeSet"))
				{
					MMSG->Msg(aIndex, "Useage: /Make <Name> <Index> <Level> <Option> <Skill> <Luck> <Exc> <Ancient> <Amount> <Dur>");
					return 0;
				}
				//Name Index Level Option Skill Luck Exc Ancient Amount Dur
				char Name[100];
				memset(Name, 0, 100);
				int Index, Level, Option, Luck, Skill, Exc, Ancient, Amount, Dur; 
				char ParamBuff[100];
				memset(ParamBuff, 0, 100);
				GetParam(1, Message, ParamBuff);
				strcpy(Name, ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(2, Message, ParamBuff)) strcpy(ParamBuff, "0");
				Index = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(3, Message, ParamBuff)) strcpy(ParamBuff, "13");
				Level = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(4, Message, ParamBuff)) strcpy(ParamBuff, "4");
				Option = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(5, Message, ParamBuff)) strcpy(ParamBuff, "1");
				Luck = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(6, Message, ParamBuff)) strcpy(ParamBuff, "1");
				Skill = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(7, Message, ParamBuff)) strcpy(ParamBuff, "127");
				Exc = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(8, Message, ParamBuff)) strcpy(ParamBuff, "0");
				Ancient = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(9, Message, ParamBuff)) strcpy(ParamBuff, "1");
				Amount = atoi(ParamBuff);
				memset(ParamBuff, 0, 100);
				if (!GetParam(10, Message, ParamBuff)) strcpy(ParamBuff, "255");
				Dur = atoi(ParamBuff);
				int tIndex = gObjGetIndexByName(Name);
				if (!tIndex) return 0;
				for (int i=0; i<Amount; i++)
				{
					for (int type=7; type<12; type++)
						ItemSerialCreateSend(tIndex, lpObj->MapNumber, lpObj->X, lpObj->Y, type*512 + Index, Level, Dur, Skill, Luck, Option, tIndex, Exc, Ancient);
				}
				break;
			}
		case 218:
			{
				AllSendServerMsg("[MU GLOBAL ADMINISTRATORS]");
				AllSendServerMsg("Sacred & Wolf");
				AllSendServerMsg("www.muglobal.ru");
				break;
			}
		case 217:	//116:
			{
				if ( (lpObj->Authority & 2) != 2 && (lpObj->Authority & 0x20) != 0x20 )
				{
					return 0;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
					lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, "FIRECRACK.");
				int x = lpObj->X;
				int y = lpObj->Y;
				PMSG_SERVERCMD pMsg;

				PHeadSubSetB((LPBYTE)&pMsg,0xF3,0x40, sizeof(pMsg));
				pMsg.CmdType = 0;

				for ( int i=0;i<15;i++)
				{
					pMsg.X = x+(rand() % 5)*2 - 4;
					pMsg.Y = y+(rand() % 5)*2 - 4;
					MsgSendV2(lpObj,(UCHAR*)&pMsg, sizeof(pMsg));
					::DataSend(lpObj->m_Index ,(UCHAR*)&pMsg, sizeof(pMsg));
				}
			}
			break;

		case 216:	//115:
			{
				if ( (lpObj->Authority & 2) != 2 && (lpObj->Authority & 0x20) != 0x20 )
				{
					return 0;
				}

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return 0;
				}

				LPOBJ lpTargetObj = gObjFind(pId);

				if ( lpTargetObj == NULL )
				{
					return 0;
				}

				LogAddTD("Use GM Command -> [ %s ]	[ %s ]	[ %s ] / Target : [%s][%s] : %s ",
					lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpTargetObj->AccountID,
					lpTargetObj->Name, "User Watching");

				char szTemp[256];

				if ( this->WatchTargetIndex == lpTargetObj->m_Index )
				{
					this->WatchTargetIndex = -1;
					
					wsprintf(szTemp, "%s : °¨½ÃÇØÁ¦", lpTargetObj->Name);	// #translation
					GCServerMsgStringSend(szTemp, lpObj->m_Index, 1);
				}
				else
				{
					wsprintf(szTemp, "%s : °¨½Ã½ÃÀÛ", lpTargetObj->Name);	// #translation
					GCServerMsgStringSend(szTemp, lpObj->m_Index, 1);
					this->WatchTargetIndex = lpTargetObj->m_Index;
				}
			}
			break;

		case 215:	//114:
			{
				if ( (lpObj->Authority & 2) != 2 && (lpObj->Authority & 0x20) != 0x20 )
				{
					return 0;
				}

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return 0;
				}

				int map;
				int iX;
				int iY;
				LPOBJ lpTargetObj = gObjFind(pId);
				int iIndex;

				if ( lpTargetObj == NULL )
				{
					return 0;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] / Target : [%s][%s] : %s",
					lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpTargetObj->AccountID,
					lpTargetObj->Name, "User Tracking");
				map = lpTargetObj->MapNumber;
				iX = lpTargetObj->X;
				iY = lpTargetObj->Y;
				iIndex = lpObj->m_Index;

				if ( iIndex >= 0 )
				{
					gObjTeleport(iIndex, map, iX, iY);
				}
			}
			break;

		case 214:	//113:
			{
				if ( (lpObj->Authority & 2) != 2 )
				{
					return 0;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
					lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, 
					"User Stat (connection)");

				int lc151 = 0;
				int lc152 = 400;
				int iTokenNumber = this->GetTokenNumber();

				if ( iTokenNumber > 0 )
				{
					lc151 = iTokenNumber;
				}

				int iTokenNumber2 = this->GetTokenNumber();

				if ( iTokenNumber2 > 0 )
				{
					lc152 = iTokenNumber2;
				}

				gObjSendUserStatistic(lpObj->m_Index, lc151, lc152);
			}
			break;

		case 100:	//100:
			{
				if ( (lpObj->AuthorityCode &4) != 4 )
				{
					return 0;
				}

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return 0;
				}

				int iTargetIndex = gObjGetIndex(pId);
				

				if ( iTargetIndex >= 0 )
				{
					LPOBJ lpTargetObj = gObjFind(pId);

					if ( lpTargetObj == NULL )
					{
						return 0;
					}

					LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] / Target : [%s][%s] : %s",
						lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpTargetObj->AccountID,
						lpTargetObj->Name, "User Disconnect");
					LogAdd(lMsg.Get(MSGGET(1, 191)), pId);
					CloseClient(iTargetIndex);
				}
			}
			break;

		case 112:	//108:
			{
				if ( (lpObj->AuthorityCode &4) != 4 )
				{
					return 0;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
					lpObj->Ip_addr, lpObj->AccountID, lpObj->Name,
					"Guild Disconnect");

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return 0;
				}

				_GUILD_INFO_STRUCT * lpGuild = Guild.SearchGuild(pId);
				int iIndex;

				if ( lpGuild != NULL )
				{
					for ( int i=0;i<MAX_USER_GUILD ; i++ )
					{
						if ( lpGuild->Index[i] >= 0 )
						{
							iIndex = lpGuild->Index[i];

							if ( iIndex >= 0 )
							{
								LogAdd(lMsg.Get(MSGGET(1, 191)), pId);
								CloseClient(iIndex);
							}
						}
					}
				}
			}
			break;

		case 101:	//101:
			{
				if ( (lpObj->AuthorityCode &8) == 8 )
				{
					pId = this->GetTokenString();

					if ( pId == NULL )
					{
						return 0;
					}

					int iTokenNumber1 = this->GetTokenNumber();
					int iTokenNumber2 = this->GetTokenNumber();
					int iTokenNumber3 = this->GetTokenNumber();
					int iIndex = gObjGetIndex(pId);
					LPOBJ lpTargetObj;

					if ( iIndex >= 0 )
					{
						lpTargetObj = gObjFind(pId);

						if ( lpTargetObj == NULL )
						{
							return 0;
						}

						LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] / Target : [%s][%s] : %s",
							lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpTargetObj->AccountID,
							lpTargetObj->Name, "User SetPosition");

						gObjTeleport(iIndex, iTokenNumber1, iTokenNumber2, iTokenNumber3);
					}
				}
				else
				{
					pId = this->GetTokenString();

					if ( pId != NULL )
					{
						int lc165 = -1;
						int lc166 = 0;
						int lc167 = 0;

						if ( lpObj->Teleport != 0 )
						{
							GCServerMsgStringSend(lMsg.Get(MSGGET(6, 68)), lpObj->m_Index, 1);
							return 0;
						}

						if ( (lpObj->m_IfState.use) != 0 )
						{
							if ( lpObj->m_IfState.type  == 3 )
							{
								lpObj->TargetShopNumber = -1;
								lpObj->m_IfState.type = 0;
								lpObj->m_IfState.use = 0;
							}
						}

						if ( lpObj->m_IfState.use > 0 )
						{
							GCServerMsgStringSend(lMsg.Get(MSGGET(6, 68)), lpObj->m_Index, 1);
							return 0;
						}

						if ( gObj[aIndex].IsInBattleGround != false )
						{
							GCServerMsgStringSend(lMsg.Get(MSGGET(6, 68)), lpObj->m_Index, 1);
							return 0;
						}

						if ( lpObj->m_PK_Level >= 6 )
						{
							GCServerMsgStringSend(lMsg.Get(MSGGET(4, 101)), lpObj->m_Index, 1);
							return 0;
						}

						gMoveCommand.Move(lpObj, pId);
					}
				}
			}
			break;

		case 108:	//104:
			{
				if ( (lpObj->AuthorityCode &8)!= 8 )
				{
					return 0;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
					lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, 
					"Guild SetPosition");

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return 0;
				}

				int iTokenNumber1 = this->GetTokenNumber();
				int iTokenNumber2 = this->GetTokenNumber();
				int iTokenNumber3 = this->GetTokenNumber();
				_GUILD_INFO_STRUCT* lpGuild = Guild.SearchGuild(pId);
				int iIndex;

				if ( lpGuild != NULL )
				{
					for ( int i=0;i<MAX_USER_GUILD;i++)
					{
						if (lpGuild->Index[i] >= 0 )
						{
							iIndex = lpGuild->Index[i];
							gObjTeleport(iIndex, iTokenNumber1, iTokenNumber2++, iTokenNumber3);
						}
					}
				}
			}
			break;

		case 109:	//105:
			{
				if ( (lpObj->Authority &2)== 2 )
				{
					LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
						lpObj->Ip_addr, lpObj->AccountID, lpObj->Name,
						"Start BattleSoccer");

					BattleSoccerGoalStart(0);
				}
			}
			break;

		case 110:	//106:
			{
				if ( (lpObj->Authority &2) == 2 )
				{
					LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
						lpObj->Ip_addr, lpObj->AccountID, lpObj->Name,
						"Stop BattleSoccer");

					BattleSoccerGoalEnd(0);
				}
				else
				{
					if ( gObj[aIndex].lpGuild != NULL )
					{
						if (gObj[aIndex].lpGuild->WarType == 1 )
						{
							strcmp(gObj[aIndex].Name, gObj[aIndex].lpGuild->Names[0] );
						}
					}
				}
			}

			break;

		case 111:	//107:
			{
				if ( (lpObj->Authority & 2) == 2 )
				{
					LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",
						lpObj->Ip_addr, lpObj->AccountID, lpObj->Name, "End GuildWar");

					char * szGuild = this->GetTokenString();

					if ( szGuild != NULL )
					{
						GCManagerGuildWarEnd(szGuild);
					}
				}
				else
				{
					if ( gObj[aIndex].lpGuild != NULL && gObj[aIndex].lpGuild->lpTargetGuildNode != NULL)
					{
						if ( strcmp( gObj[aIndex].Name, gObj[aIndex].lpGuild->Names[0] ) ==  0)
						{
							if ( gObj[aIndex].lpGuild->BattleGroundIndex >= 0 && gObj[aIndex].lpGuild->WarType == 1 )
							{
								::gObjAddMsgSendDelay(&gObj[aIndex], 7, aIndex, 10000, 0);

								char szTemp[100];

								wsprintf(szTemp, lMsg.Get(MSGGET(4, 129)), gObj[aIndex].lpGuild->Names[0] );
								::GCServerMsgStringSendGuild(gObj[aIndex].lpGuild, szTemp, 1);
								::GCServerMsgStringSendGuild(gObj[aIndex].lpGuild->lpTargetGuildNode, szTemp, 1);
							}
						}
					}
				}
			}
			break;

		case 104:	//102:
			{
				if ( (lpObj->AuthorityCode&0x20 ) != 0x20 )
				{
					return FALSE;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "Ban Chatting");

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return FALSE;
				}

				int Index = ::gObjGetIndex(pId);

				if ( Index >= 0 )
				{
					gObj[Index].Penalty |= 2;
				}

			}
			break;

		case 106:	//103:
			{
				if ( (lpObj->AuthorityCode & 32 ) != 32 )
				{
					return FALSE;
				}

				LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "Free Ban-Chatting");

				pId = this->GetTokenString();

				if ( pId == NULL )
				{
					return FALSE;
				}

				int Index = ::gObjGetIndex(pId);

				if ( Index >= 0 )
				{
					gObj[Index].Penalty &= ~2;
				}
			}
			break;

		case 200:	//109:
			{
				pId = this->GetTokenString();

				if ( pId != NULL )
				{
					if ( strlen(pId) >= 1 )
					{
						::GCGuildWarRequestResult(pId, aIndex, 0);
					}
				}
			}

			break;

		case 202:	//111:
			{
				if ( (lpObj->Authority & 2 ) == 2 )
				{
					LogAddTD("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
						lpObj->Name, "Set GuildWar");
		
					pId = this->GetTokenString();

					if ( pId != NULL )
					{
						char * Rival = this->GetTokenString();

						if ( Rival != NULL )
						{
							if ( strlen(pId) >= 1 )
							{
								if ( strlen(Rival) >= 1 )
								{
									::GCManagerGuildWarSet(pId, Rival, 1);
								}
							}
						}
					}
				}
				else
				{
					if ( gEnableBattleSoccer != FALSE )
					{
						pId = this->GetTokenString();

						if ( pId != NULL )
						{
							if ( strlen(pId) >= 1 )
							{
								::GCGuildWarRequestResult(pId, aIndex, 1);
							}
						}
					}
				}
			}

			break;

		case 201:	//110:
			{
				gObjBillRequest(&gObj[aIndex]);
			}
			break;

		case 203:	//112:
			{
				pId = this->GetTokenString();

				if ( pId != NULL )
				{
					BOOL bState;

					if ( strcmp(pId, "on" ) == 0 )
					{
						bState = TRUE;
					}
					else if ( strcmp(pId, "off") == 0 )
					{
						bState = FALSE;
					}

					if ( bState >= FALSE && bState <= TRUE )
					{
						::gObjSetTradeOption(aIndex, bState);
						::gObjSetDuelOption(aIndex, bState);
					}
				}
			}
			break;

		case 320:	//117:
			{
				if ( (lpObj->Authority &2) != 2 )
				{
					return FALSE;
				}

				LogAddTD("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐ»óź¸±â");	// #translation Require Translation
				KUNDUN_GM_LOG.Output("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐ»óź¸±â");	// #translation  Require Translation

				for ( int n=0;n<MAX_VIEWPORT;n++)
				{
					if ( lpObj->VpPlayer[n].state != 0 )
					{
						if ( lpObj->VpPlayer[n].type == OBJ_MONSTER )
						{
							if ( lpObj->VpPlayer[n].number >= 0 )
							{
								LPOBJ lpTarget = &gObj[lpObj->VpPlayer[n].number];

								if ( lpTarget->Class == 275 )
								{
									TNotice pNotice(1);

									pNotice.SendToUser(lpObj->m_Index, "ÄïµÐ HP = %7.0f / %7.0f", lpTarget->Life, lpTarget->MaxLife); //Require Translation
									pNotice.SendToUser(lpObj->m_Index, "ÄïµÐ HP ÃÊ´çȸº¹·® = %d ȸº¹·® = %d ȸº¹½Ã°£ = %d", giKundunRefillHPSec, giKundunRefillHP, giKundunRefillHPTime);	// Require Translation
								}
							}
						}
					}
				}

			}
			break;

		case 321:	//118:
			{
				if ( (lpObj->Authority &2 ) != 2 )
				{
					return FALSE;
				}

				LogAddTD("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHP¼³Á¤");	// Require Translation
				KUNDUN_GM_LOG.Output("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHP¼³Á¤");	// Require Translation

				int iLife = this->GetTokenNumber();

				for ( int n=0;n<MAX_VIEWPORT;n++)
				{
					if ( lpObj->VpPlayer[n].state != FALSE )
					{
						if ( lpObj->VpPlayer[n].type == OBJ_MONSTER )
						{
							if ( lpObj->VpPlayer[n].number >= 0 )
							{
								LPOBJ lpTarget = &gObj[lpObj->VpPlayer[n].number];

								if ( lpTarget->Class == 275 )
								{
									if  ( iLife <= 5000 )
									{
										iLife = 5000 ;
									}

									if ( iLife > lpTarget->MaxLife )
									{
										iLife = lpTarget->MaxLife;
									}

									lpTarget->Life = iLife;
								
									TNotice pNotice(1);

									pNotice.SendToUser(lpObj->m_Index, "ÄïµÐ HP = %7.0f / %7.0f", lpTarget->Life, lpTarget->MaxLife); //Require Translation
								}
							}
						}
					}
				}
			}
			break;

		case 322:	//119:
			{
				if ( (lpObj->Authority &2 ) != 2 )
				{
					return FALSE;
				}

				LogAddTD("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHPȸº¹·®¼³Á¤");	// Require Translation
				KUNDUN_GM_LOG.Output("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHPȸº¹·®¼³Á¤");	// Require Translation

				int RefillHP = this->GetTokenNumber();

				if ( RefillHP <= 0 || RefillHP > 5000000 )
				{
					return 0;
				}

				giKundunRefillHP = RefillHP;

				TNotice pNotice(0);

				pNotice.SendToUser(lpObj->m_Index, "ÄïµÐ HP ÃÊ´çȸº¹·® = %d ȸº¹·® = %d ȸº¹½Ã°£ = %d", giKundunRefillHPSec, giKundunRefillHP, giKundunRefillHPTime);	// Require Translation

			}

			break;

		case 323:	//120:
			{
				if ( (lpObj->Authority &2 ) != 2 )
				{
					return FALSE;
				}

				LogAddTD("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHPÃÊ´çȸº¹·®¼³Á¤");	// Require Translation
				KUNDUN_GM_LOG.Output("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHPÃÊ´çȸº¹·®¼³Á¤");	// Require Translation

				int RefillHPSec = this->GetTokenNumber();

				if ( RefillHPSec <= 0 || RefillHPSec > 10000 )
				{
					return 0;
				}

				giKundunRefillHPSec = RefillHPSec;

				TNotice pNotice(0);

				pNotice.SendToUser(lpObj->m_Index, "ÄïµÐ HP ÃÊ´çȸº¹·® = %d ȸº¹·® = %d ȸº¹½Ã°£ = %d",
					giKundunRefillHPSec, giKundunRefillHP, giKundunRefillHPTime);	// Require Translation

			}

			break;

		case 324:	//121:
			{
				if ( (lpObj->Authority &2 ) != 2 )
				{
					return FALSE;
				}

				LogAddTD("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHPȸº¹½Ã°£¼³Á¤");	// Require Translation
				KUNDUN_GM_LOG.Output("[KUNDUN] Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s", lpObj->Ip_addr, lpObj->AccountID,
					lpObj->Name, "ÄïµÐHPȸº¹½Ã°£¼³Á¤");	// Require Translation

				int RefillHPTime = this->GetTokenNumber();

				if ( RefillHPTime < 0 || RefillHPTime > 60000 )
				{
					return 0;
				}

				giKundunRefillHPTime = RefillHPTime;

				TNotice pNotice(0);

				pNotice.SendToUser(lpObj->m_Index, "ÄïµÐ HP ÃÊ´çȸº¹·® = %d ȸº¹·® = %d ȸº¹½Ã°£ = %d", giKundunRefillHPSec, giKundunRefillHP, giKundunRefillHPTime);	// Require Translation

			}
			break;
		case 369:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 0);
			break;
		case 370:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 1);
			break;
		case 371:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 2);
			break;
		case 372:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 3);
			break;
		case 373:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 4);
			break;
		case 374:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 5);
			break;
		case 375:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 6);
			break;
		case 376:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 7);
			break;
		case 377:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 8);
			break;
		case 378:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 9);
			break;
		case 379:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 10);
			break;
		case 380:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 11);
			break;
		case 381:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 12);
			break;
		case 382:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 13);
			break;
		case 383:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 14);
			break;
		case 384:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 15);
			break;
		case 385:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 16);
			break;
		case 386:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 17);
			break;
		case 387:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 18);
			break;
		case 388:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 19);
			break;
		case 389:
			g_Kanturu.OperateGmCommand(lpObj->m_Index, 20);
			break;
	}
	return 0;
}
bool CQuest::NpcTalk(LPOBJ lpNpc, LPOBJ lpObj)
{
	int iIndex = lpObj->m_Index;
	if( lpObj->q_QuestIndex == 0xFF)
	{
		this->SetQuestState(lpObj, 0 , QUEST_STATE_START);
	}
	int i = lpObj->q_QuestIndex;

	if(this->quests[i].npcID == lpNpc->Class)
	{

		if(lpObj->Level < this->quests[i].level)
		{
			wsprintf(szQuestTemp, " You're need be level %d for quest!",this->quests[i].level);
			ChatTargetSend(lpNpc,szQuestTemp, iIndex);
			return true;
		}
		if(lpObj->Money < this->quests[i].zen)
		{
			wsprintf(szQuestTemp, " you need zen %d for quest!",this->quests[i].zen);
			ChatTargetSend(lpNpc,szQuestTemp, iIndex);
			return true;
		}
		if(this->IsClass(i, lpObj->DbClass ))
		{
			for(int x = 0 ; x != this->quests->QuestsObjectCount ; x++)
			{
				switch(this->GetQuestType(i,x))
				{
					case QUEST_OBJECT_TYPE_ITEM:
					{
						switch(lpObj->q_QuestState)
						{
							case QUEST_STATE_START:
							{
								int ItemType = this->quests[i].ItemsObject[x].itemType;
								int ItemSubType = this->quests[i].ItemsObject[x].itemSubType;
								LPITEM_ATTRIBUTE Item = &ItemAttribute[ITEMGET(ItemType, ItemSubType) ];
								qMsg->Notice(iIndex , "[Quest] Quest Start. " );
								qMsg->Notice(iIndex , "[Quest] %s go find %s !!!",this->quests[i].name,Item->Name);
								this->SetQuestState(lpObj, i , QUEST_STATE_ONGOING );
								if(this->quests[i].zen > 0)
								{
									lpObj->Money -= this->quests[i].zen;
									GCMoneySend( iIndex , lpObj->Money );
								}
								qMsg->PM( iIndex , "[Quest] Remmber you can do quest only without party");
								qMsg->PM( iIndex , "[Quest] you need free slot in your invenotry for quest item");
								return true;
							}
							case QUEST_STATE_ONGOING:
							{
								int ItemType = this->quests[i].ItemsObject[x].itemType;
								int ItemSubType = this->quests[i].ItemsObject[x].itemSubType;
								int GetCount = this->quests[i].ItemsObject[x].itemCount;

								LPITEM_ATTRIBUTE Item = &ItemAttribute[ITEMGET(ItemType, ItemSubType) ];
								qMsg->PM(iIndex , "[Quest] You do not have enough required items");
								qMsg->PM(iIndex , "[Quest] Search %d %s",GetCount,Item->Name);
								wsprintf(szQuestTemp, "Search %d %s",GetCount,Item->Name);
								ChatTargetSend(lpNpc , szQuestTemp , iIndex );
								return true;

							}
							case QUEST_STATE_FINISH:
							{

								int ItemType = this->quests[i].ItemsObject[x].itemType;

								int ItemSubType = this->quests[i].ItemsObject[x].itemSubType;

								int Count = gObjGetItemCountInIventory(iIndex, ITEMGET(ItemType,ItemSubType));

								int GetCount = this->quests[i].ItemsObject[x].itemCount;

								if(Count >= GetCount)
								{
									LPITEM_ATTRIBUTE Item = &ItemAttribute[ITEMGET(ItemType, ItemSubType) ];
									qMsg->Notice(iIndex, "[Quest] You have been finished %s ",this->quests[i].name);
									gObjDelteItemCountInInventory(iIndex ,ItemType , ItemSubType , Count );
									int PrizeCount = this->quests[i].ItemsObject[x].QuestPrizeCount;
									int uPoint = 0;
									int uClassUp = 0;
									for(int p = 0 ; p != PrizeCount ; p++)
									{
										int Points = this->quests[i].ItemsObject[x].QuestPrize[p].points;
										int ClassUp = this->quests[i].ItemsObject[x].QuestPrize[p].ClassUp;
										if(Points > 0)
											uPoint += Points;
										if(ClassUp > 0 )
											uClassUp += ClassUp;
													
									}
									if(uPoint > 0)
									{
										qMsg->Msg(iIndex , "[Quest] you have received %d points",uPoint);
										lpObj->LevelUpPoint += uPoint;
										GCLevelUpMsgSend(iIndex, 201);
										this->SetQuestState(lpObj, lpObj->q_QuestIndex+1 , QUEST_STATE_START);
									}
									if(uClassUp > 0)
									{
										qMsg->PM(iIndex , "[Quest] congratulation you win Class up :)");
										lpObj->ChangeUP += 1;
										lpObj->DbClass |= 1;
										gObjMakePreviewCharSet(lpObj->m_Index);
										BYTE btClass = (lpObj->Class * 32) & 224 ;
										btClass |= (lpObj->ChangeUP * 16) & 16;
										if(lpObj->ChangeUP == 1)
											GCSendQuestPrize(lpObj->m_Index, 201 , btClass);
										if(lpObj->ChangeUP == 2)
											GCSendQuestPrize(lpObj->m_Index, 204 , btClass);
										GCMagicAttackNumberSend(lpObj, 76 , lpObj->m_Index , 0 );
									}
									
								}
							}
						}
						break;
					}
				}
			}	
		}
	}
	
			

	return false;
}
Beispiel #23
0
bool cChat::SetCharCommand(LPOBJ gObj, char* Msg, int Index)
{
	if(CheckCommand(gObj, Configs.Commands.IsSetChar, GmSystem.cSetZen, 0, 0, 0, Index, "SetChar", "[Name] /setchar <Zen> <AddPnt> <lvl> <Prof>", Msg))
		return true;

	DWORD Zen = 0;
	int AddPnt = 0, Lvl = 0, Prof = 0;

	sscanf(Msg, "%d %d %d %d %d %d", &Zen, &AddPnt, &Lvl, &Prof);

	if( Zen > 2000000000)
	{
		TNotice.MessageLog(1,  gObj, "[SetChar] Zen can't be less than 0 and more than 2000000000!");
		return true;
	}

	int MaximumAddPnt;
	//if(Configs.Enable65kStats == 0)
		MaximumAddPnt = 32767;
	//else
	//	MaximumAddPnt = 65000;

	if(AddPnt < 0 || AddPnt > MaximumAddPnt)
	{
		TNotice.MessageLog(1,  gObj, "[SetChar] AddPnt can't be less than 0 and more than %d!", MaximumAddPnt);
		return true;
	}

	if(Lvl < 0 || Lvl > Configs.Commands.MaxLvl)
	{
		TNotice.MessageLog(1,  gObj, "[SetChar] Lvl can't be less than 0 and more than %d!", Configs.Commands.MaxLvl);
		return true;
	}

	if(Prof < 0 || Prof > 3)
	{
		TNotice.MessageLog(1,  gObj, "[SetChar] Lvl can't be less than 0 and more than 3!");
		return true;
	}

	OBJECTSTRUCT *tObj = (OBJECTSTRUCT*)OBJECT_POINTER(Index);

	if(Zen > 0)
	{
		tObj->Money = Zen;
		GCMoneySend (tObj->m_Index, Zen);
	}

	if(AddPnt > 0)
	{
		tObj->LevelUpPoint += AddPnt;
	}

	if(Lvl > 0)
	{
		tObj->Level	= Lvl;
	}

	if(Prof > 0)
	{
		switch(Prof)
		{
		case 0:
			{

			}
			break;
		case 1:
			{
				if(gObj->DbClass <= 3)
					gObj->DbClass = 0;
				else if(gObj->DbClass >= 16 && gObj->DbClass <= 19)
					gObj->DbClass = 16;
				else if(gObj->DbClass >= 32 && gObj->DbClass <= 35)
					gObj->DbClass = 32;
				else if(gObj->DbClass >= 48 && gObj->DbClass <= 50)
					gObj->DbClass = 48;
				else if(gObj->DbClass >= 64 && gObj->DbClass <= 66)
					gObj->DbClass = 64;
				else if(gObj->DbClass >= 80 && gObj->DbClass < 83)
					gObj->DbClass = 80;
			}
			break;
		case 2:
			{
				if( gObj->DbClass <= 3)
					gObj->DbClass = 1;
				else if(gObj->DbClass >= 16 && gObj->DbClass <= 19)
					gObj->DbClass = 17;
				else if(gObj->DbClass >= 32 && gObj->DbClass <= 35)
					gObj->DbClass = 33;
				else if(gObj->DbClass >= 80 && gObj->DbClass < 83)
					gObj->DbClass = 81;
			}
			break;
		case 3:
			{
				if( gObj->DbClass <= 3 )
					gObj->DbClass = 3;
				else if(gObj->DbClass >= 16 && gObj->DbClass <= 19)
					gObj->DbClass = 19;
				else if(gObj->DbClass >= 32 && gObj->DbClass <= 35)
					gObj->DbClass = 35;
				else if(gObj->DbClass >= 48 && gObj->DbClass <= 50)
					gObj->DbClass = 50;
				else if(gObj->DbClass >= 64 && gObj->DbClass <= 66)
					gObj->DbClass = 66;
				else if(gObj->DbClass >= 80 && gObj->DbClass < 83)
					gObj->DbClass = 83;
			}
			break;
		}
	}

	if (gObj == tObj)
	{
		if(AddPnt > 0 || Prof > 0 || Lvl > 0)
			TNotice.MessageLog(1,  tObj, "[SetChar] Your character was edited, you must relogin!");
		else
			TNotice.MessageLog(1,  tObj, "[SetChar] Your character was edited!");
	}
	else
	{
		TNotice.MessageLog(1,  gObj, "[SetChar] You successfully changed %s character.", tObj->Name);
		if(AddPnt > 0 || Prof > 0 || Lvl > 0)
			TNotice.MessageLog(1,  tObj, "[SetChar] Your character was edited by %s, you must relogin!", gObj->Name);
		else
			TNotice.MessageLog(1,  tObj, "[SetChar] Your character was edited by %s!", gObj->Name);
	}
	return true;
}			
Beispiel #24
0
void cChat::ChatAddStats(DWORD aIndex, LPCSTR IpBuffer, BYTE CMD_STATS_TYPE) 
{


	int Points = atoi(IpBuffer);
	char* Name;
	Name = (char*)gObj_GetChar(aIndex,gObjNick);
	GOBJSTRUCT *gObj = (GOBJSTRUCT*)OBJECT_POINTER(aIndex);

	if(Config.IsAdd == 0)
	{
		GCServerMsgStringSend(MSG07,aIndex, 1);
		return;
	}

	else if((int)gObj_GetLevel(aIndex) < Config.AddLevel)
	{
		char levelmsg[120];
		sprintf(levelmsg,MSG08,Config.AddLevel);
		GCServerMsgStringSend(levelmsg, aIndex, 1);
		Log.outError("[Add] [%s]: [%s] not enought Level \n",gObj->AccountID,Name);
		return;
	}

	else if(strlen(IpBuffer) <1 || Points<1)
	{
		GCServerMsgStringSend(MSG09, aIndex, 1);
		Log.outError("[Add] [%s]: [%s] syntax error \n",gObj->AccountID,Name);
		return;
	}

	else if((int) gObj_GetInt(aIndex,gObjLupp)<Points)
	{
		GCServerMsgStringSend(MSG10, aIndex, 1);
		Log.outError("[Add] [%s]: [%s] lacking points \n",gObj->AccountID,Name);
		return;
	}

	else if(gObj->Money < Config.AddCost)
	{
		char OutputZenLack[120]={0};
		sprintf(OutputZenLack,MSG11,Config.AddCost);
		GCServerMsgStringSend(OutputZenLack,aIndex,1);
		Log.outError("[Add] [%s]: [%s] lacking Zend \n",gObj->AccountID,Name);
		return;
	}


	else if (Points>Config.AddMaxPoints)
	{
		char exceedpoint[120];
		sprintf(exceedpoint,MSG12,Config.AddMaxPoints);
		GCServerMsgStringSend(exceedpoint,aIndex,1);
		Log.outError("[Add] [%s]: [%s] exceed points \n",gObj->AccountID,Name);
		return;
	}

	else if(CMD_STATS_TYPE == 4 && GetPlayerClass(aIndex) != 64 && GetPlayerClass(aIndex) != 66)
	{
		GCServerMsgStringSend(MSG13, aIndex, 1);
		Log.outError("[Add] [%s]: [%s] syntax error \n",gObj->AccountID,Name);
		return;
	}

	else if(Points > 100)
	{
	
		WORD wStr,wDex,wViatality,wEnergy,wLeader ;
		DWORD dwLvUpPoint;
		PBYTE  pADataAddr ;
		pADataAddr = (PBYTE)(aIndex*gObjSize +gObjOffset) ;

		_asm 
		{
			push eax
			push ebx
			mov eax,pADataAddr
			xor ebx,ebx
			mov bx,WORD PTR [eax+0xDC]
			mov wStr,bx
			mov bx,WORD PTR [eax+0xDE] 
			mov wDex,bx
			mov bx,WORD PTR [eax+0xE0]
			mov wViatality,bx
			mov bx,WORD PTR [eax+0xE2]
			mov wEnergy,bx
			mov bx,WORD PTR [eax+0x100]
			mov wLeader,bx
			mov ebx,DWORD PTR [eax+0xAC]
			mov dwLvUpPoint,ebx
			pop ebx
			pop eax
		}
		Log.outNormal("[%s]: [%s] Before Add: %d Str %d Agi %d Vit %d Ene %d Lead %d \n",gObj->AccountID,Name,dwLvUpPoint,wStr,wDex,wViatality,wEnergy,wLeader);


		WORD wTmpAddPoint = 0 ;
		DWORD dwTmpAddPoint = 0 ;

		wTmpAddPoint = Points ;
		dwTmpAddPoint = wTmpAddPoint ;
		if ( wTmpAddPoint >0)
		{
			switch (CMD_STATS_TYPE)
			{
			case 0x00:
				_asm 
				{
					push eax
					push ebx
					mov eax,pADataAddr
					xor ebx,ebx
					mov bx,WORD PTR [eax+0xDC]
					add bx,wTmpAddPoint
					mov WORD PTR [eax+0xDC],bx
					mov ebx,DWORD PTR [eax+0xAC]
					sub ebx,dwTmpAddPoint
					mov DWORD PTR [eax+0xAC],ebx
					pop ebx
					pop eax
				}
				break;
			case 0x01: 
				_asm
				{
					push eax
					push ebx
					mov eax,pADataAddr
					xor ebx,ebx
					mov bx,WORD PTR [eax+0xDE]
					add bx,wTmpAddPoint
					mov WORD PTR [eax+0xDE],bx
					mov ebx,DWORD PTR [eax+0xAC]
					sub ebx,dwTmpAddPoint
					mov DWORD PTR [eax+0xAC],ebx
					pop ebx
					pop eax
				}
				break;
			case 0x02:
				_asm
				{
					push eax
					push ebx
					mov eax,pADataAddr
					xor ebx,ebx
					mov bx,WORD PTR [eax+0xE0]
					add bx,wTmpAddPoint
					mov WORD PTR [eax+0xE0],bx
					mov ebx,DWORD PTR [eax+0xAC]
					sub ebx,dwTmpAddPoint
					mov DWORD PTR [eax+0xAC],ebx
					pop ebx
					pop eax
				}
				break;
			case 0x03:
				_asm
				{
					push eax
					push ebx
					mov eax,pADataAddr
					xor ebx,ebx
					mov bx,WORD PTR [eax+0xE2]
					add bx,wTmpAddPoint
					mov WORD PTR [eax+0xE2],bx
					mov ebx,DWORD PTR [eax+0xAC]
					sub ebx,dwTmpAddPoint
					mov DWORD PTR [eax+0xAC],ebx
					pop ebx
					pop eax
				}
				break;
			case 0x04:
				_asm
				{
					push eax
					push ebx
					mov eax,pADataAddr
					xor ebx,ebx
					mov bx,WORD PTR [eax+0x100]
					add bx,wTmpAddPoint
					mov WORD PTR [eax+0x100],bx
					mov ebx,DWORD PTR [eax+0xAC]
					sub ebx,dwTmpAddPoint
					mov DWORD PTR [eax+0xAC],ebx
					pop ebx
					pop eax
				}
				break;
			}
				
		}
		_asm 
		{
			push eax
			push ebx
			mov eax,pADataAddr
			xor ebx,ebx
			mov bx,WORD PTR [eax+0xDC]
			mov wStr,bx
			mov bx,WORD PTR [eax+0xDE]
			mov wDex,bx
			mov bx,WORD PTR [eax+0xE0]
			mov wViatality,bx
			mov bx,WORD PTR [eax+0xE2]
			mov wEnergy,bx
			mov bx,WORD PTR [eax+0x100]
			mov wLeader,bx
			mov ebx,DWORD PTR [eax+0xAC]
			mov dwLvUpPoint,ebx
			pop ebx
			pop eax
		}


		gObj->Money = gObj->Money - Config.AddCost;
		GCMoneySend(aIndex,gObj->Money);

		Log.outNormal("[%s]: [%s] After Add: %d Str %d Agi %d Vit %d Ene %d Lead %d \n",gObj->AccountID,Name,dwLvUpPoint,wStr,wDex,wViatality,wEnergy,wLeader);
		GCServerMsgStringSend(MSG14, aIndex, 1);

		return;
		}
void CJewelOfHarmonySystem::PurityJewelOfHarmony(LPOBJ lpObj)
{
	if ( this->m_bSystemPrutiyJewel != TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 50)), lpObj->m_Index, 1);
		return;
	}

	if ( this->IsEnableToUsePuritySystem() == FALSE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 50)), lpObj->m_Index, 1);
		CLog.LogAdd("[JewelOfHarmony][%s][%s] Not Purtiy Time ", lpObj->AccountID, lpObj->Name);
		return;
	}

	lpObj->ChaosLock = TRUE;
	// Chaos Lock was Enabled
		int iJewelOfHarmonyItemCount = 0;
		int iInvalidItemCount = 0;
		int iChaosMixPrice = 0;
		PMSG_CHAOSMIXRESULT pMsg;
		C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(PMSG_CHAOSMIXRESULT));

		pMsg.Result = CB_ERROR;

		for ( int n =0;n<CHAOS_BOX_SIZE;n++)
		{
			if ( lpObj->pChaosBox[n].IsItem() == TRUE )
			{
				if ( lpObj->pChaosBox[n].m_Type == this->JEWEL_OF_HARMONY_ITEMINDEX )
				{
					iJewelOfHarmonyItemCount++;
				}
				else
				{
					iInvalidItemCount++;
				}
			}
		}

		if ( iInvalidItemCount > 0 || iJewelOfHarmonyItemCount !=1 )
		{
			gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
			lpObj->ChaosLock = FALSE;
			return;
		}

		iChaosMixPrice = this->m_iZenForPurity;
		int iChaosTaxMoney = iChaosMixPrice * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100;

		if (iChaosTaxMoney < 0 )
			iChaosTaxMoney = 0;

		iChaosMixPrice += iChaosTaxMoney;

		if ( iChaosMixPrice < 0 )
			iChaosMixPrice = 0;

		if ( lpObj->Money < iChaosMixPrice )
		{
			pMsg.Result = CB_NOT_ENOUGH_ZEN;
			gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
			lpObj->ChaosLock = FALSE;
			return;
		}

		lpObj->Money -= iChaosMixPrice;
		g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
		GCMoneySend(lpObj->m_Index, lpObj->Money);
		LogChaosItem(lpObj, "JewelOfHarmony][Purity");

		CLog.LogAdd("[JewelOfHarmony][Purity] - Mix Start");


		BYTE Socket[5];
	Socket[0] = 0xFF;
	Socket[1] = 0xFF;
	Socket[2] = 0xFF;
	Socket[3] = 0xFF;
	Socket[4] = 0xFF;


		int iRate = rand() % 100;

		if ( iRate < this->m_iRatePuritySuccess )
		{
			int iItemType = this->JEWEL_OF_HARMONY_PURITY_ITEMINDEX;
			ItemSerialCreateSend(lpObj->m_Index, -1, 0, 0, iItemType, 0, 1, 0, 0, 0, lpObj->m_Index, 0, 0, Socket);
			gObjInventoryCommit(lpObj->m_Index);

			CLog.LogAdd("[JewelOfHarmony][Purity] Purity Success [%s][%s] Rate %d/%d",
				lpObj->AccountID, lpObj->Name, iRate, this->m_iRatePuritySuccess);
		}
		else
		{
			gChaosBox.ChaosBoxInit(lpObj);
			GCUserChaosBoxSend(lpObj, 0);
			gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);

			CLog.LogAdd("[JewelOfHarmony][Purity] Purity Fail [%s][%s] Rate %d/%d",
				lpObj->AccountID, lpObj->Name, iRate, this->m_iRatePuritySuccess);
		}
	// Chaos Lock was Disabled
	lpObj->ChaosLock = FALSE;
}
BOOL CItem380System::ChaosMix380ItemOption(LPOBJ lpObj)
{
	if ( this->m_bSystemFor380ItemOption != TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13,55)), lpObj->m_Index, 1);
		lpObj->bIsChaosMixCompleted = false;
		return FALSE;
	}

	lpObj->ChaosLock = TRUE;

	int iValidItemCount = 0;
	int iJewelOfHarmony = 0;
	int iJewelOfSuho = 0;
	int iInvalidItemCount = 0;
	int iMixPrice = 0;
	int iCharmOfLuckCount = 0;

	PMSG_CHAOSMIXRESULT pMsg;

	C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg));
	pMsg.Result = 0;
	CItem * pTargetItem = NULL;
	int iPosOfJewelOfHarmony= -1;
	int iPosOfJewelOfSuho= -1;

	for ( int n=0;n<CHAOS_BOX_SIZE;n++)
	{
	if ( lpObj->pChaosBox[n].IsItem() == TRUE )
	{
		if ( this->Is380Item(&lpObj->pChaosBox[n]) == TRUE && this->Is380OptionItem(&lpObj->pChaosBox[n]) == FALSE &&  lpObj->pChaosBox[n].m_Level > 3 && (lpObj->pChaosBox[n].m_Option3<<2) > 3)
		{
			iValidItemCount++;
			pTargetItem = &lpObj->pChaosBox[n];
		}
		else if ( g_kJewelOfHarmonySystem.IsJewelOfHarmonyPurity(lpObj->pChaosBox[n].m_Type) == TRUE )
		{
			iJewelOfHarmony++;
			iPosOfJewelOfHarmony = n;
		}
		else if ( lpObj->pChaosBox[n].m_Type == ITEMGET(14, 31) )
		{
			iJewelOfSuho++;
			iPosOfJewelOfSuho = n;
		}
		else if ( lpObj->pChaosBox[n].m_Type == ITEMGET(14,53) )
		{
			iCharmOfLuckCount += (int)lpObj->pChaosBox[n].m_Durability;
		}
		else
		{
			iInvalidItemCount++;
		}
	}
	}

	if ( iInvalidItemCount || iValidItemCount != 1 || iJewelOfHarmony != 1 || iJewelOfSuho != 1 || pTargetItem == NULL || iPosOfJewelOfHarmony == -1 || iPosOfJewelOfSuho == -1 || iCharmOfLuckCount > 10 )
	{
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;
		return FALSE;
	}

	iMixPrice = this->m_iNeedZenFor380Option;
	int iChaosTaxMoney =  iMixPrice * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100;

	if ( iChaosTaxMoney < 0 )
		iChaosTaxMoney = 0;

	iMixPrice += iChaosTaxMoney;

	if ( iMixPrice < 0 )
		iMixPrice = 0;

	if ( lpObj->Money < iMixPrice )
	{
		pMsg.Result = 2;
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	lpObj->Money -= iMixPrice;
	g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
	
	GCMoneySend(lpObj->m_Index, lpObj->Money);
	LogChaosItem(lpObj, "380Item][Item Mix");
	CLog.LogAdd("[380Item][Item Mix] - Mix Start");

	int iRate =	rand() % 100;
	int iRateSuccess = this->m_iRateSuccessRateForMix1;

	if ( pTargetItem->m_Level < 7 )
		iRateSuccess = this->m_iRateSuccessRateForMix1;
	else if ( pTargetItem->m_Level < 10 )
		iRateSuccess = this->m_iRateSuccessRateForMix2;
	else if ( pTargetItem->m_Level < 16 )
		iRateSuccess = this->m_iRateSuccessRateForMix3;

	iRateSuccess += iCharmOfLuckCount;

	lpObj->pChaosBox[iPosOfJewelOfHarmony].Clear();
	lpObj->pChaosBoxMap[iPosOfJewelOfHarmony] = -1;
	lpObj->pChaosBox[iPosOfJewelOfSuho].Clear();
	lpObj->pChaosBoxMap[iPosOfJewelOfSuho] = -1;

	if ( iRate < iRateSuccess )
	{
		this->_SetOption(pTargetItem, TRUE);
		GCUserChaosBoxSend(lpObj, 0);

		CLog.LogAdd("[380Item][ItemMix] Mix Success [%s][%s], Money(%d-%d) Rate(%d/%d) Option(%d,%d) OptionValue(%d,%d)",
			lpObj->AccountID, lpObj->Name, lpObj->Money,
			iMixPrice, iRate, iRateSuccess,
			this->m_itemOption[(pTargetItem->m_Type )].m_Option1,
			this->m_itemOption[(pTargetItem->m_Type )].m_Option2,
			this->m_itemOption[(pTargetItem->m_Type )].m_Value1,
			this->m_itemOption[(pTargetItem->m_Type )].m_Value2);
	}
	else
	{
		GCUserChaosBoxSend(lpObj, 0);
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);

		CLog.LogAdd("[380Item][ItemMix] Mix Fail [%s][%s], Money(%d-%d) Rate(%d/%d)",
			lpObj->AccountID, lpObj->Name, lpObj->Money,
			iMixPrice, iRate, iRateSuccess);

	}

	lpObj->ChaosLock = FALSE;
	return TRUE;
}
void CDevilSquareGround::SendScore()
{
	if ( this->m_DevilSquareRankList.size() < 1 )
	{
		return;
	}

	BYTE count = 1;
	int iUserCount = this->m_DevilSquareRankList.size();

	int iExp = 0;

	for ( std::vector<OBJECTSTRUCT *>::iterator Itor = this->m_DevilSquareRankList.begin() ; Itor != this->m_DevilSquareRankList.end() ; Itor++ )
	{
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore;

		if ( iUserCount <= 6 )
		{
			if ( count < 4 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc5 = count*100/iUserCount;

			if ( count == 1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc5 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc5 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}

		count++;

		if ( count >= 10 )
		{
			break;
		}
	}

	this->m_DevilSquareScoreInfoTOP10.Count  = count;
	int iSize = count * 24 + 5;

	PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize);
	count = 1;

	 std::vector<OBJECTSTRUCT *>::iterator Itor = this->m_DevilSquareRankList.begin();

	LogAddTD("[DevilSquare] Rank [%d]", this->m_iIndex);

	for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ )
	{
		if ( iUserCount <= 6 )
		{
			if ( count < 4 ) //webzen fixed on season 3.0
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc7 = count*100/iUserCount;

			if ( count ==1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc7 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc7 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}

		if ( g_CrywolfSync.GetOccupationState() == 1 && Configs.CrywolfApplyMvpPenalty != FALSE)
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp =  (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100;
		}

		__int64 exp = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp;
		gObjSealUserSetExp((*(Itor)), exp, TRUE); //Seal Exp (Season3 add-on)

		(*(Itor))->Experience += (int)exp;		
		
		bool ret = gObjLevelUp((*(Itor)), exp, 0, EVENT_TYPE_DEVILSQUARE);

		(*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen;

		if ( gObjCheckMaxZen((*(Itor))->m_Index, (*(Itor))->m_nEventMoney) == FALSE )
		{
			int Zen = MAX_ZEN - (*(Itor))->Money;
			(*(Itor))->Money += Zen;
		}
		else
		{
			(*(Itor))->Money += (*(Itor))->m_nEventMoney;
		}

		GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money);

		if ( ret == true )
		{
			GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, exp, 0, 0);//Season 4.5 changed
		}

		this->SendRankingInfo((*(Itor)));

		LogAddTD("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore);
		
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore;
		this->m_DevilSquareScoreInfoTOP10.MyRank = count;
		count++;

		DataSend((*(Itor))->m_Index, (LPBYTE)&this->m_DevilSquareScoreInfoTOP10 , iSize);

		(*(Itor))->m_nEventScore = 0;
		(*(Itor))->m_nEventMoney = 0;
		(*(Itor))->m_nEventExp = 0;
	}
}
Beispiel #28
0
bool CShop::BuyShopItemAndDelete(int Pos, int aIndex,CShop *Shop)
{
	LPOBJ lpObj = &gObj[aIndex];
	if ( Shop->m_item[Pos].IsItem() == TRUE )
	{
		PMSG_BUYRESULT pResult;

		PHeadSetB((LPBYTE)&pResult, 0x32, sizeof(pResult));
		pResult.Result = -1;

		int iStoreTaxMoney = Shop->m_item[Pos].m_BuyMoney + (int)((__int64)Shop->m_item[Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);

		if ( iStoreTaxMoney < 0 )
			iStoreTaxMoney  = 0;

		int iStoreTaxMoney2 = (int)((__int64)Shop->m_item[Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);

		if ( iStoreTaxMoney2 < 0 )
			iStoreTaxMoney2  = 0;

		if ( lpObj->Money < iStoreTaxMoney )
			pResult.Result = -1;
		else
		{
			BOOL bNoItem = TRUE;

			if ( (Shop->m_item[Pos].m_Type >= ITEMGET(14,0) && Shop->m_item[Pos].m_Type <= ITEMGET(14,8)) ||
				(Shop->m_item[Pos].m_Type >= ITEMGET(14,35) && Shop->m_item[Pos].m_Type <= ITEMGET(14,40)))
			{
				int dur = (int)Shop->m_item[Pos].m_Durability;

				if ( dur == 0 )
					dur = 1;

				if ( ::gObjSearchItem(lpObj, Shop->m_item[Pos].m_Type,dur, Shop->m_item[Pos].m_Level) == TRUE )
				{
					bNoItem = FALSE;
					lpObj->Money -= iStoreTaxMoney;
					::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);

					if ( lpObj->Money < 0 )
						lpObj->Money = 0;


					::GCMoneySend(lpObj->m_Index, lpObj->Money);
				}
			}

			if ( bNoItem != FALSE )
			{
				pResult.Result = gObjShopBuyInventoryInsertItem(lpObj->m_Index, Shop->m_item[Pos]);

				if ( pResult.Result != 0xFF )
				{
					ItemByteConvert((LPBYTE)&pResult.ItemInfo, Shop->m_item[Pos]);
					int lc64 = Shop->m_item[Pos].m_BuyMoney;
					lpObj->Money -= iStoreTaxMoney;
					::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);

					if ( lpObj->Money < 0 )
						lpObj->Money = 0;

					GCMoneySend(lpObj->m_Index, lpObj->Money);
					int iTaxRate = g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index);

					for (int i = 0; i < Type.size(); i++)
					{
						int type = ITEMGET(Type[i],Index[i]); 
						if ( type == Shop->m_item[Pos].m_Type && Dur[i] == Shop->m_item[Pos].m_Durability && Level[i] == Shop->m_item[Pos].m_Level && 
							Opt1[i] == Shop->m_item[Pos].m_Option1 && Opt2[i] == Shop->m_item[Pos].m_Option2 && Opt3[i] == Shop->m_item[Pos].m_Option3 )
						{
							Type[i] = -1;
							Index[i] = -1;
							Dur[i] = -1;
							Level[i] = -1;
							Opt1[i] = -1;
							Opt2[i] = -1;
							Opt3[i] = -1;
							break;
						}
					}

					Shop->m_item[Pos].Clear();

					Shop->SendItemDataLen -= 8;
					Shop->ItemCount -- ;
					Shop->RefreshShopItems();
					DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);


					LogAdd("[%s][%s] (%d) Shop buy [%d][%d][%d][%s] LEV:%d, DUR:%d, OP:[%d][%d][%d]",
						lpObj->AccountID, lpObj->Name, 14, lc64, iTaxRate, lc64+iStoreTaxMoney2, Shop->m_item[Pos].GetName(),
						Shop->m_item[Pos].m_Level, Shop->m_item[Pos].m_Durability,
						Shop->m_item[Pos].m_Option1, Shop->m_item[Pos].m_Option2,
						Shop->m_item[Pos].m_Option3);


					if ( Shop->ItemCount < 1 )
					{
						PMSG_TALKRESULT pResult;
						lpObj->TargetShopNumber = -1;
						lpObj->m_IfState.use = 0;
						lpObj->m_IfState.type = 0;
						lpObj->m_ShopTime = 0;
						pResult.h.c = 0xC3;
						pResult.h.headcode = 0x30;
						pResult.h.size = sizeof(pResult);
						pResult.result = -1;
						DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);

						/*if ( Random(0,1) != 0 )
							ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 119)), aIndex);//#info - ChatTargetSend - может что то интересненькое
						else
							ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 120)), aIndex);*/

						return true;
					}
					else
					{
						lpObj->TargetShopNumber = 14;
						lpObj->m_IfState.use = 1;
						lpObj->m_IfState.type = 3;
						lpObj->m_ShopTime = 0;

						

						PMSG_SHOPITEMCOUNT pShopItemCount;
						BYTE SendByte[1024];
						int lOfs = 0;

						lOfs += sizeof(pShopItemCount );

						int size = lOfs + Shop->SendItemDataLen;
						PHeadSetW((LPBYTE)&pShopItemCount, 0x31, size);
						pShopItemCount.Type = 0;
						pShopItemCount.count = Shop->ItemCount;
						memcpy(SendByte, &pShopItemCount, sizeof(pShopItemCount));
						memcpy(&SendByte[lOfs], Shop->SendItemData, Shop->SendItemDataLen);

						DataSend(lpObj->m_Index, SendByte, size);
						GCAnsCsMapSvrTaxInfo(lpObj->m_Index,2,  ::g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index));

						return true;
					}

				}
			}
		}
	}

	return false;
}
Beispiel #29
0
void CDevilSquareGround::SendScore()
{
	if ( this->m_DevilSquareRankList.size() < 1 )
	{
		return;
	}

	BYTE count = 1;
	int iUserCount = this->m_DevilSquareRankList.size();
	int iExp = 0;

	std::vector<LPOBJ>::iterator Itor = this->m_DevilSquareRankList.begin();

	for ( ; Itor != this->m_DevilSquareRankList.end() ; Itor++ )
	{
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore;

		if ( iUserCount <= 6 )
		{
			if ( count < 4 )	// For DS from 0 to 3
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc5 = count*100/iUserCount;

			if ( count == 1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc5 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc5 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}

		count++;

		if ( count >= 10 )
		{
			break;
		}
	}

	this->m_DevilSquareScoreInfoTOP10.Count  = count;
	int iSize = count * 24 + 5;

	PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize);
	count = 1;

	Itor = this->m_DevilSquareRankList.begin();

	LogAddTD("[DevilSquare] Rank [%d]", this->m_iIndex);

	for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ )
	{
		if ( iUserCount <= 6 )
		{
			if ( count < 4 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc7 = count*100/iUserCount;

			if ( count ==1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc7 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc7 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}

		if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE)
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp =  (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100;
		}

		__int64 iExp64 = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp;

		CheckItemOptForGetExpEx((*(Itor)),iExp64,TRUE);
		(*(Itor))->Experience += (DWORD)iExp64;
		bool ret = gObjLevelUp((*(Itor)), &iExp64, 0, EVENT_TYPE_DEVILSQUARE);

		(*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen;

		if ( gObjCheckMaxZen((*(Itor))->m_Index, (*(Itor))->m_nEventMoney) == FALSE )
		{
			int Zen = MAX_ZEN - (*(Itor))->Money;
			(*(Itor))->Money += Zen;
		}
		else
		{
			(*(Itor))->Money += (*(Itor))->m_nEventMoney;
		}

		GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money);

		if ( ret == true )
		{
			GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp, 0, 0);
		}

		if( count == 1 )
		{
			g_EventItemBagManager.OpenSpecial(EventBagSpecial::DevilSquare1, (*(Itor))->m_Index, (*(Itor))->MapNumber, (*(Itor))->X, (*(Itor))->Y);
		}
		else if( count == 2)
		{
			g_EventItemBagManager.OpenSpecial(EventBagSpecial::DevilSquare2, (*(Itor))->m_Index, (*(Itor))->MapNumber, (*(Itor))->X, (*(Itor))->Y);
		}
		else if( count == 3)
		{
			g_EventItemBagManager.OpenSpecial(EventBagSpecial::DevilSquare3, (*(Itor))->m_Index, (*(Itor))->MapNumber, (*(Itor))->X, (*(Itor))->Y);
		}

		this->SendRankingInfo((*(Itor)));

		LogAddTD("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore);
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore;
		this->m_DevilSquareScoreInfoTOP10.MyRank = count;
		count++;

		DataSend((*(Itor))->m_Index, (BYTE *)&this->m_DevilSquareScoreInfoTOP10 , iSize);

#ifdef POINTEX
		g_ShopPointEx.AddEventBonus((*(Itor))->m_Index, ShopPointExEvent::DS);
#endif

#if( __4GAMERS__ == 1 )
		g_Achievements.GD_UpdateEventDataDS((*(Itor)), (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore);
#endif

		(*(Itor))->m_nEventScore = 0;
		(*(Itor))->m_nEventMoney = 0;
		(*(Itor))->m_nEventExp = 0;
	}
}
void CDevilSquareGround::SendScore()
{
	if ( this->m_DevilSquareRankList.size() < 1 )
	{
		return;
	}

	BYTE count = 1;
	int iUserCount = this->m_DevilSquareRankList.size();
	int iExp = 0;
	std::vector<OBJECTSTRUCT *>::iterator Itor = this->m_DevilSquareRankList.begin(); 

	for (Itor = this->m_DevilSquareRankList.begin() ; Itor != this->m_DevilSquareRankList.end() ; Itor++ )
	{
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore;

		if ( iUserCount <= 6 )
		{
			if ( count < 4 )	// For DS from 0 to 3
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc5 = count*100/iUserCount;

			if ( count == 1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc5 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc5 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1];
			}
		}

		count++;

		if ( count >= 10 )
		{
			break;
		}
	}

	this->m_DevilSquareScoreInfoTOP10.Count  = count;
	int iSize = count * 24 + 5;

	PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize);
	count = 1;

	Itor = this->m_DevilSquareRankList.begin();

	LogAdd("[DevilSquare] Rank [%d]", this->m_iIndex);

	for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ )
	{
		if ( iUserCount <= 6 )
		{
			if ( count < 3 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}
		else
		{
			int lc7 = count*100/iUserCount;

			if ( count ==1 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1];
			}
			else if ( lc7 <= 30 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1];
			}
			else if ( lc7 <= 50 )
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1];
			}
			else
			{
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0];
				this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1];
			}
		}

		if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE)
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp =  (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100;
		}

		/*if ( iExp > 0 )
		{
			if ( lpObj->Type == OBJ_USER )
			{
				if ( lpObj->m_wExprienceRate > 0 )
				{
					lpObj->Experience += iExp;
					lpObj->m_nEventExp += iExp;
				}
			}
		}*/

		if ( (*(Itor))->m_wExprienceRate == 0 )
			iExp = 0;
		else
		{
			iExp = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp;
			(*(Itor))->Experience += iExp;
		}

		//(*(Itor))->Experience += this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp;
		bool ret = false;

		if (  (*(Itor))->m_wExprienceRate > 0 )
		{
			ret = gObjLevelUp((*(Itor)), iExp, 0, EVENT_TYPE_DEVILSQUARE);
		}

		(*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen;

		if ( gObjCheckMaxZen((*(Itor))->m_Index, (*(Itor))->m_nEventMoney) == FALSE )
		{
			int Zen = MAX_ZEN - (*(Itor))->Money;
			(*(Itor))->Money += Zen;
		}
		else
		{
			(*(Itor))->Money += (*(Itor))->m_nEventMoney;
		}

		GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money);

		if ( ret == true )
		{
			if (  (*(Itor))->m_wExprienceRate > 0 )
			{
				GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, iExp, 0, 0);
			}
		}

		this->SendRankingInfo((*(Itor)));

		LogAdd("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore);
		memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN);
		this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore;

		if ( (*(Itor))->m_wExprienceRate == 0 )
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = 0;
		}
		else
		{
			this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = iExp;
		}

		this->m_DevilSquareScoreInfoTOP10.MyRank = count;
		count++;

		DataSend((*(Itor))->m_Index, (BYTE *)&this->m_DevilSquareScoreInfoTOP10 , iSize);

		(*(Itor))->m_nEventScore = 0;
		(*(Itor))->m_nEventMoney = 0;
		(*(Itor))->m_nEventExp = 0;
	}
}