Ejemplo n.º 1
0
void GCEquipmentSendHook(int aIndex)
{							
	OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);

	GCEquipmentSend(aIndex);
	
	//Fix Double Pets on trade cancel/ok/success
	if(gObj->pInventory[8].m_Type != SLOT_EMPTY)
	{
		if(gObj->pInventory[8].m_Type == 0x1A50 || gObj->pInventory[8].m_Type == 0x1A7B)
		{	
			CItem OldItem;
			OldItem = gObj->pInventory[8];
			gObj->pInventory[8].m_Type = -1;

			gObjMakePreviewCharSet(aIndex);
			GCItemListSend(aIndex);
			gObjViewportListProtocolCreate(gObj);

			gObj->pInventory[8] = OldItem;

			gObjMakePreviewCharSet(aIndex);
			GCItemListSend(aIndex);
			gObjViewportListProtocolCreate(gObj);
		}
	}
	
	if(gObj->pInventory[RING_01].m_Type == 0x1A7A 
		|| gObj->pInventory[RING_02].m_Type == 0x1A7A) //Skeleton Ring
		_beginthread( TradeSystem__Cancel, 0, NULL  );
}
Ejemplo n.º 2
0
//006bbab0
bool CPeriodItemEx::RemovePeriodItemData(LPOBJ lpObj, BYTE btItemType, WORD wItemCode, unsigned long dwSerial)	//OK
{
	if( !lpObj )
		return false;

	if( lpObj->Type != OBJ_USER || lpObj->Connected < 2 )
		return false;

	if( btItemType == 1 )
	{
		BUFF_EFFECT_DATE* lpBuffData = 0;
		lpBuffData = g_BuffEffectSlot.GetEffectDataFromItemCode(wItemCode);

		if( !lpBuffData )
			return false;

		gObjRemoveBuffEffect(lpObj,lpBuffData->btIndex);
	}
	else if( btItemType == 2 )
	{
		if( dwSerial == 0 )
			return false;

		int iInventoryPosition = 0;
		iInventoryPosition = this->GetItemFromInventory(lpObj,wItemCode,dwSerial);

		if( iInventoryPosition == -1 )
			return false;

		SetDisableItemToExpire(lpObj,iInventoryPosition);
		//auto-deleting
		gObjInventoryDeleteItem(lpObj->m_Index, iInventoryPosition);
		GCInventoryItemDeleteSend(lpObj->m_Index, iInventoryPosition, 1);
		gObjCalCharacter(lpObj->m_Index);
		// ----
		if( iInventoryPosition < 12 )
		{
			if( iInventoryPosition == 10 || iInventoryPosition == 11 )
			{
				gObjUseSkill.SkillChangeUse(lpObj->m_Index);
			}
			// ----
			gObjMakePreviewCharSet(lpObj->m_Index);
			PMSG_USEREQUIPMENTCHANGED pChange;
			PHeadSetB((LPBYTE)&pChange, 0x25, sizeof(pChange));
			pChange.NumberH = SET_NUMBERH(lpObj->m_Index);
			pChange.NumberL = SET_NUMBERL(lpObj->m_Index);
			ItemByteConvert(pChange.ItemInfo, lpObj->pInventory[iInventoryPosition]);
			pChange.ItemInfo[1] = iInventoryPosition <<  4;
			pChange.ItemInfo[1] |= LevelSmallConvert(lpObj->m_Index, iInventoryPosition) & 0x0F;
			DataSend(lpObj->m_Index, (LPBYTE)&pChange, pChange.h.size);
			MsgSendV2(lpObj, (LPBYTE)&pChange, pChange.h.size);
		}
	}
	else
	{
		return false;
	}


	ITEMDATA ItemData;
	ItemData.btType = btItemType;
	ItemData.wItemCode = wItemCode;
	ItemData.dwSerial = dwSerial;

	RequestPeriodItemDelete(lpObj,&ItemData);
	return true;
}
BOOL CJewelOfHarmonySystem::StrengthenItemByJewelOfHarmony(LPOBJ lpObj, int source, int target)
{
	if ( this->m_bSystemStrengthenItem == FALSE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 52)), lpObj->m_Index, 1);
		return FALSE;
	}

	if ( source < 0 || source > MAIN_INVENTORY_SIZE-1 )
		return FALSE;

	if ( target < 0 || target > MAIN_INVENTORY_SIZE-1 )
		return FALSE;

	if ( lpObj->pInventory[source].IsItem() == FALSE )
		return FALSE;

	if ( lpObj->pInventory[target].IsItem() == FALSE )
		return FALSE;

	CItem * pSource = &lpObj->pInventory[source];
	CItem * pTarget = &lpObj->pInventory[target];

	if ( this->IsStrengthenByJewelOfHarmony(pTarget) == TRUE )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Already Strengtened [%s][%s]",
			lpObj->AccountID, lpObj->Name);

		return FALSE;
	}

	if (pTarget->IsSetItem() == TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 44)), lpObj->m_Index, 1);
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] SetItem not enable to Strengtened [%s][%s]",
			lpObj->AccountID, lpObj->Name);

		return FALSE;
	}

	int iItemType = this->_GetItemType(pTarget);

	if ( iItemType == JEWELOFHARMONY_ITEM_TYPE_NULL )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Invalid ItemType[%d]",
			lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iItemType);
		
		return FALSE;
	}

	int iItemOption = this->_GetSelectRandomOption(pTarget, iItemType);

	if ( iItemOption == AT_JEWELOFHARMONY_NOT_STRENGTHEN_ITEM )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail - NOT OPTION [%s][%s] Name[%s] Type[%d] Serial[%d] ItemType[%d]",
			lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iItemType);
		
		return FALSE;
	}

	int iItemOptionLevel = this->m_itemOption[iItemType][iItemOption].iRequireLevel;
	int iSuccessRate = rand() % 100;

	if ( iSuccessRate >= this->m_iRateStrengthenSuccess )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d]  Rate (%d/%d)",
			lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess);
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 45)), lpObj->m_Index, 1);
		return TRUE;
	}


	this->_MakeOption(pTarget, iItemOption, iItemOptionLevel);

	CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Success [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d) Option %d OptionLevel %d",
		lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
		pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess,
		iItemOption, iItemOptionLevel);

	GCServerMsgStringSend(lMsg.Get(MSGGET(13, 46)), lpObj->m_Index, 1);

	gObjMakePreviewCharSet(lpObj->m_Index);

	float levelitemdur = (float)ItemGetDurability(lpObj->pInventory[target].m_Type,
		lpObj->pInventory[target].m_Level, lpObj->pInventory[target].IsExtItem(),
		lpObj->pInventory[target].IsSetItem());

	lpObj->pInventory[target].m_Durability = levelitemdur * lpObj->pInventory[target].m_Durability / lpObj->pInventory[target].m_BaseDurability;

	lpObj->pInventory[target].Convert(lpObj->pInventory[target].m_Type,
		lpObj->pInventory[target].m_Option1, lpObj->pInventory[target].m_Option2,
		lpObj->pInventory[target].m_Option3, lpObj->pInventory[target].m_NewOption,
		lpObj->pInventory[target].m_SetOption, lpObj->pInventory[target].m_ItemOptionEx,lpObj->pInventory[target].m_ItemSocket);


	return TRUE;
}
Ejemplo n.º 4
0
BOOL CQuestInfo::QuestClear(LPOBJ lpObj, int QuestIndex)
{
	LPQUEST_INFO lpQuestInfo = this->GetQuestInfo(QuestIndex);

#if (FOREIGN_GAMESERVER==1)
	if ( szAuthKey[18] != AUTHKEY18 )
	{
		DestroyGIocp();
	}
#endif

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

	int subquestcount = lpQuestInfo->QuestSubInfoCount;
	int concount = lpQuestInfo->QuestConditionCount;
	LPQUEST_SUB_INFO lpSubInfo;

	for ( int subquest=0;subquest<subquestcount;subquest++)
	{
		lpSubInfo = this->GetSubquestInfo(lpObj, lpQuestInfo, subquest);

		if ( lpSubInfo != NULL )
		{
			if ( lpSubInfo->RewardType == QUEST_COMPENSATION_CHANGEUP )
			{
				lpObj->LevelUpPoint += lpSubInfo->RewardCount;
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_STATUP, lpSubInfo->RewardCount );
				lpObj->ChangeUP = true;
				lpObj->DbClass |= 1;
				gObjMakePreviewCharSet(lpObj->m_Index);
				BYTE btClass = (lpObj->Class * 32) & 224 ;
				btClass |= (lpObj->ChangeUP * 16) & 16;
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_CHANGEUP, btClass);
				LogAddTD("[Quest] Quest Clear (%s) : [%s][%s] Stat(%d,%d), ChangeUp",
					lpQuestInfo->Name, lpObj->AccountID, lpObj->Name, lpObj->LevelUpPoint,
					lpSubInfo->RewardCount );
			}
			else if ( lpSubInfo->RewardType == QUEST_COMPENSATION_STATUP )
			{
				lpObj->LevelUpPoint += lpSubInfo->RewardCount;
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_STATUP, lpSubInfo->RewardCount );
				LogAddTD("[Quest] Quest Clear (%s) : [%s][%s] Stat(%d,%d)",
					lpQuestInfo->Name, lpObj->AccountID, lpObj->Name, lpObj->LevelUpPoint,
					lpSubInfo->RewardCount );
			}
			else if ( lpSubInfo->RewardType == QUEST_COMPENSATION_PLUSSSTAT )
			{
				int level = lpObj->Level - QUEST_MINLEVEL_PLUSSTAT;

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

				lpObj->LevelUpPoint += level;
				lpObj->PlusStatQuestClear = true;
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_PLUSSSTAT, level );
				LogAddTD("[Quest] Quest Clear (%s) : [%s][%s] Stat(%d,%d), PlusStat",
					lpQuestInfo->Name, lpObj->AccountID, lpObj->Name, lpObj->LevelUpPoint,
					level );
			}
			else if ( lpSubInfo->RewardType == QUEST_COMPENSATION_COMBOSKILL )
			{
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_COMBOSKILL, 0 );
				lpObj->ComboSkillquestClear = true;
				LogAddTD("[Quest] Quest Clear (%s) : [%s][%s] ComboSkill",
					lpQuestInfo->Name, lpObj->AccountID, lpObj->Name);
			}
			else if ( lpSubInfo->RewardType == QUEST_COMPENSATION_CHANGEUP2 )
			{
				lpObj->LevelUpPoint += lpSubInfo->RewardCount;
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_STATUP, lpSubInfo->RewardCount);
				lpObj->ChangeUP = 2;
				BYTE btClass;
				btClass = (lpObj->Class * 32) + 24;

				if (lpObj->DbClass != 2 || lpObj->DbClass != 18 || lpObj->DbClass != 34 || lpObj->DbClass != 50 || lpObj->DbClass != 66 ) //HermeX Great Anti-Hack :P
				{
					if (lpObj->DbClass == 48 || lpObj->DbClass == 64)
					{
						lpObj->DbClass += 2;
					}
					else
					{
						lpObj->DbClass += 1;
					}
				}
				gObjMakePreviewCharSet(lpObj->m_Index);
				GCSendQuestPrize(lpObj->m_Index, QUEST_COMPENSATION_CHANGEUP2, btClass);
				LogAddTD("[Quest] Quest Clear (%s) : [%s][%s] Stat(%d,%d), ChangeUp2",
					lpQuestInfo->Name, lpObj->AccountID, lpObj->Name, lpObj->LevelUpPoint,
					lpSubInfo->RewardCount );
			}

			if ( lpSubInfo->QuestType == 1 )
			{
				gObjDelteItemCountInInventory(lpObj->m_Index, lpSubInfo->NeedType, lpSubInfo->NeedSubType,
					lpSubInfo->NeedNumber);
			}
		}
	}
	return true;
}
Ejemplo n.º 5
0
void ObjBotWarper::MakeBot()
{
	if(this->Enabled == true)
	{
		for(int botNum=0;botNum<MAX_BOTWARPER;botNum++)
		{
			if(this->bot[botNum].Enabled == true)
			{
				int result = gObjAddCallMon();

				if(result >= 0)
				{
					this->bot[botNum].index = result;
					gObj[result].m_PosNum = (WORD)-1;
					gObj[result].X = this->bot[botNum].X;
					gObj[result].Y = this->bot[botNum].Y;
					gObj[result].m_OldX = this->bot[botNum].X;
					gObj[result].m_OldY = this->bot[botNum].Y;
					gObj[result].TX = this->bot[botNum].X;
					gObj[result].TY = this->bot[botNum].Y;
					gObj[result].MTX = this->bot[botNum].X;
					gObj[result].MTY = this->bot[botNum].Y;
					gObj[result].Dir = this->bot[botNum].Dir;
					gObj[result].MapNumber = this->bot[botNum].Map;
					gObj[result].Live = TRUE;
					gObj[result].PathCount = 0;
					gObj[result].IsBot = 10;
					gObjSetMonster(result,this->bot[botNum].Class,"PetBot");

					gObj[result].ChangeUP = this->bot[botNum].Class & 0x07;	// Set Second Type of Character
					gObj[result].Class = this->bot[botNum].Class;
					gObj[result].Level = 400;
					gObj[result].Life = 1;
					gObj[result].MaxLife = 2;
					gObj[result].Mana = 1;
					gObj[result].MaxMana = 2;
					gObj[result].Experience = 0;
					gObj[result].DbClass = this->bot[botNum].Class;
					
					gObj[result].pInventory = new CItem[INVENTORY_NORMAL_SIZE];	
					gObj[result].Inventory1 = new CItem[INVENTORY_NORMAL_SIZE];
					gObj[result].InventoryMap1 = new BYTE[INVENTORY_NORMAL_SIZE];
					gObj[result].pInventoryMap = new BYTE[INVENTORY_NORMAL_SIZE];

					for (int i=0;i<INVENTORY_NORMAL_SIZE;i++)
					{
						gObj[result].pInventory[i].Clear();
						gObj[result].Inventory1[i].Clear();
					}

					memset(&gObj[result].pInventoryMap[0], (BYTE)-1, INVENTORY_NORMAL_SIZE);
					memset(&gObj[result].InventoryMap1[0], (BYTE)-1, INVENTORY_NORMAL_SIZE);

					strncpy(gObj[result].Name,this->bot[botNum].Name,sizeof(gObj[result].Name));


					for(int i=0;i<9;i++)
					{
						if(this->bot[botNum].body[i].num >= 0 && this->bot[botNum].body[i].Enabled == true)
						{
							CItem item;
							item.m_Level = this->bot[botNum].body[i].level;
							item.m_SkillOption = 0;
							item.m_LuckOption = 1;
							item.m_Z28Option = this->bot[botNum].body[i].opt;
							item.m_Durability = 255.0f;
							item.m_JewelOfHarmonyOption = 0;
							item.m_ItemOptionEx = 0;
							item.m_ItemSlot1 = 0;
							item.m_ItemSlot2 = 0;
							item.m_ItemSlot3 = 0;
							item.m_ItemSlot4 = 0;
							item.m_ItemSlot5 = 0;
							item.Convert(this->bot[botNum].body[i].num,item.m_SkillOption,item.m_LuckOption,item.m_Z28Option,0,0,item.m_ItemOptionEx,3);

							gObj[result].pInventory[i].m_SkillOption = item.m_SkillOption;
							gObj[result].pInventory[i].m_LuckOption = item.m_LuckOption;
							gObj[result].pInventory[i].m_Z28Option = item.m_Z28Option;
							gObj[result].pInventory[i].m_JewelOfHarmonyOption = item.m_JewelOfHarmonyOption;
							gObj[result].pInventory[i].m_ItemOptionEx = item.m_ItemOptionEx;

							item.m_Number = 0;
							
							gObjInventoryInsertItemPos(gObj[result].m_Index,item,i,0);
						}
					}
					
					gObj[result].Inventory1 = gObj[result].pInventory;
					gObj[result].InventoryMap1 = gObj[result].pInventoryMap;
					gObjMakePreviewCharSet(result);

					gObj[result].m_AttackType = 0;
					gObj[result].BotSkillAttack = 0;					

					gObj[result].m_Attribute = 100;
					gObj[result].TargetNumber = (WORD)-1;
					gObj[result].m_ActState.Emotion = 0;
					gObj[result].m_ActState.Attack = 0;
					gObj[result].m_ActState.EmotionCount = 0;
					gObj[result].PathCount = 0;
					gObj[result].BotPower = 0;
					gObj[result].BotDefense = this->bot[botNum].OnlyVip;
					gObj[result].BotLife = 1;
					gObj[result].BotMaxLife = 1;
					
					gObj[result].BotLvlUpDefense = 1;
					gObj[result].BotLvlUpPower = 1;
					gObj[result].BotLvlUpLife = 1;
					gObj[result].BotLvlUpMana = 1;
					gObj[result].BotLvlUpExp = 1;
					gObj[result].BotLvlUpMaxLevel = 1;

					gObj[result].m_MoveRange = 1;
					gObj[result].BotFollowMe = 0;
					gObj[result].NextExp = gLevelExperience[gObj[result].Level];

					GCRecallMonLife(gObj[result].m_RecallMon,gObj[result].MaxLife,gObj[result].Life);

					ChatSend(&gObj[result],"I'll Warp you!");
					GCActionSend(&gObj[result],AT_SALUTE1,result,result);
				}
			}
		}
	}
}
Ejemplo n.º 6
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;
}