Пример #1
0
BOOL TMonsterSkillElement::ApplyElementTeleportSkill(int iIndex, int iTargetIndex)
{
	if ( !OBJMAX_RANGE(iIndex))
		return FALSE;

	if ( gObjCheckUsedBuffEffect(&gObj[iIndex],BUFF_STUN) == TRUE )
		return FALSE;

	if ( gObjCheckUsedBuffEffect(&gObj[iIndex],BUFF_SLEEP) == TRUE )
		return FALSE;

	if ( gObjCheckUsedBuffEffect(&gObj[iIndex],BUFF_EARTHBINDS) == TRUE )
		return FALSE;

	LPOBJ lpObj = &gObj[iIndex];

	BYTE x;
	BYTE y;
	int depth = rand()%4 + 3;
	PMSG_MAGICATTACK_RESULT pAttack;

	if ( (rand()%2) == 0 )
		x = lpObj->X + depth;
	else
		x = lpObj->X - depth;

	if ( (rand()%2) == 0 )
		y = lpObj->Y + depth;
	else
		y = lpObj->Y - depth;

	if ( gObjCheckTeleportArea(iIndex, x, y) == FALSE )
	{
		LogAddC(2, "[%s] Try Teleport Not Move Area [%d,%d]", lpObj->Name,	x, y);
		return FALSE;
	}

	PHeadSetBE((LPBYTE)&pAttack, 0x19, sizeof(pAttack));

	pAttack.MagicNumberH = SET_NUMBERH(AT_SKILL_TELEPORT);
	pAttack.MagicNumberL = SET_NUMBERL(AT_SKILL_TELEPORT);

	pAttack.SourceNumberH = SET_NUMBERH(iIndex);
	pAttack.SourceNumberL = SET_NUMBERL(iIndex);
	pAttack.TargetNumberH = SET_NUMBERH(iIndex);
	pAttack.TargetNumberL = SET_NUMBERL(iIndex);

	if ( lpObj->Type == OBJ_USER )
		DataSend(iIndex, (LPBYTE)&pAttack, pAttack.h.size);	

	MsgSendV2(lpObj, (LPBYTE)&pAttack, pAttack.h.size);	

	LogAddC(2, "[%s] Warp [%d,%d] -> [%d,%d]", lpObj->Name, lpObj->X, lpObj->Y, x, y);

	gObjTeleportMagicUse(iIndex, x, y);
	lpObj->TargetNumber = -1;

	return FALSE;
}
BOOL TMonsterSkillElement::ApplyElementTeleportSkill(int iIndex, int iTargetIndex)
{
	if ( !OBJMAX_RANGE(iIndex))
		return FALSE;

	if ( gObj[iIndex].m_iSkillStunTime > 0 )
		return FALSE;

	LPOBJ lpObj = &gObj[iIndex];
	BYTE x;
	BYTE y;
	int depth = rand()%4 + 3;
	PMSG_MAGICATTACK_RESULT pAttack;

	if ( (rand()%2) == 0 )
		x = lpObj->X + depth;
	else
		x = lpObj->X - depth;

	if ( (rand()%2) == 0 )
		y = lpObj->Y + depth;
	else
		y = lpObj->Y - depth;

	if ( gObjCheckTeleportArea(iIndex, x, y) == FALSE )
	{
		CLog.LogAddC(TColor.Red(), "[%s][%s] Try Teleport Not Move Area [%d,%d]",
			lpObj->AccountID, lpObj->Name,	x, y);
		
		return FALSE;
	}

	C3HeadSet((LPBYTE)&pAttack, 0x19, sizeof(pAttack));

	pAttack.MagicNumberH = SET_NUMBERH(6);
	pAttack.MagicNumberL = SET_NUMBERL(6);
	pAttack.SourceNumberH = SET_NUMBERH(iIndex);
	pAttack.SourceNumberL = SET_NUMBERL(iIndex);
	pAttack.TargetNumberH = SET_NUMBERH(iIndex);
	pAttack.TargetNumberL = SET_NUMBERL(iIndex);

	if ( lpObj->Type == OBJ_USER )
		gSendProto.DataSend(iIndex, (LPBYTE)&pAttack, pAttack.h.size);	

	gSendProto.VPMsgSend(lpObj, (LPBYTE)&pAttack, pAttack.h.size);	

	CLog.LogAddC(TColor.Red(), "[%s] Warp [%d,%d] -> [%d,%d]",
		lpObj->Name, lpObj->X, lpObj->Y, x, y);

	gObjTeleportMagicUse(iIndex, x, y);
	lpObj->TargetNumber = -1;

	return FALSE;
}