예제 #1
0
Graph::PosPair EffRect::GetOperPos()
{
    Graph::Point p1, p2;
    p1.x = m_pParam->pUser->GetPosX();
    p1.y = m_pParam->pUser->GetPosY();
    p2.x = p2.y = 0.0f;

    CServerRegion *rgn = (CServerRegion*)(m_pParam->pUser->GetFather());
    m_pParam->pMouseShape = dynamic_cast<CMoveShape*>( 
        rgn->FindChildObject( m_pParam->nMouseShapeType, m_pParam->MouseShapeID ) );

    if( m_ePos == ePos_Dest && m_pParam->pMouseShape )
    {
        p2.x = m_pParam->pMouseShape->GetPosX();
        p2.y = m_pParam->pMouseShape->GetPosY();
        if( m_IsWithinObj)
            m_pExcept = m_pParam->pMouseShape;
    }
    else if( m_ePos == ePos_Coord )
    {
        p2.x = (float) m_pParam->nMouseX;
        p2.y = (float) m_pParam->nMouseY;
    }

    return std::make_pair( p1, p2 );
}
예제 #2
0
void Script::CallScriptByGUID(const CGUID& shapeGuid, const char* scriptFilename)
{
	CMoveShape* shape = GetGame()->FindShape(TYPE_PLAYER, shapeGuid);
	if(shape==NULL)
	{
		CServerRegion* region = dynamic_cast<CServerRegion*>(m_RunEnv.region);
		if(region != NULL)
			shape = dynamic_cast<CMoveShape*>(region->FindChildObject(TYPE_MONSTER, shapeGuid));
	}

	if(shape != NULL) // 本地调用脚本
	{
		RunEnv env;
		env.region = dynamic_cast<CRegion*>(shape->GetFather());
		env.srcShape = shape;
		GetInst(ScriptSys).RunScript(env, scriptFilename);
	}
	else // 跨服调用脚本
	{
		CMessage msg(MSG_S2W_QUEST_PlayerRunScript);
		msg.Add(shapeGuid); // call guid
		msg.Add(scriptFilename);	 // called script name
		msg.SendToSocket(GetGame()->GetWSSocket());
	}
}
예제 #3
0
void DoC2SMailGetGolds( CMessage *pMsg )
{
	//取金钱
	CPlayer *pPlayer = pMsg->GetPlayer();
	CGUID NpcGuid = NULL_GUID;
	pMsg->GetGUID(NpcGuid);
	CServerRegion *pRegion = pMsg->GetRegion();

	if (NULL==pRegion)
	{
		return;
	}
	CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid);
	CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape);

	//if (pPlayer && pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0  && pMailNpc->Distance( pPlayer ) < 8)// attention
	//{
		CGUID MailGuid;
		pMsg->GetGUID(MailGuid);
		CMail *pMail = GameManager::GetInstance()->GetMailManager()->GetMail(MailGuid);
		if (NULL!=pPlayer && pMail && pMail->GetReceiverGuid()==pPlayer->GetExID())
		{
			GameManager::GetInstance()->GetMailManager()->SendGetGoldFromMailToWS(MailGuid,pPlayer);
		}
	//}

}
예제 #4
0
void DoC2SMailReject( CMessage *pMsg )
{
	CPlayer *pPlayer = pMsg->GetPlayer();
	CGUID NpcGuid = NULL_GUID;
	pMsg->GetGUID(NpcGuid);

	CServerRegion *pRegion = pMsg->GetRegion();
	if (NULL==pRegion)
	{
		return;
	}
	CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid);
	CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape);

	//if (pPlayer && pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0  && pMailNpc->Distance( pPlayer ) < 8)
	//{

		//! 拒收邮件
		CGUID guid;
		pMsg->GetGUID(guid);				
		CMail *pMail = GameManager::GetInstance()->GetMailManager()->GetMail(guid);
		if (pMail && pMail->GetReceiverGuid()==pPlayer->GetExID())
		{
			pPlayer->DeleteReceiveMailList(guid);
			CMessage msg(MSG_S2W_MAIL_REJECT);
			msg.Add(pPlayer->GetExID());
			msg.Add(guid);
			msg.Send();					
		}
	//}
}
예제 #5
0
void DoC2SMailGetGoods( CMessage *pMsg )
{
	//! 从邮件中取物品到背包
	CPlayer *pPlayer = pMsg->GetPlayer();
	CGUID NpcGuid = NULL_GUID;
	pMsg->GetGUID(NpcGuid);

	CServerRegion *pRegion = pMsg->GetRegion();
	if (NULL==pRegion)
	{
		return;
	}
	CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid);

	CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape);

	//if (pPlayer &&pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0  && pMailNpc->Distance( pPlayer ) < 8)//attention
	//{
		CGUID MailGuid;
		pMsg->GetGUID(MailGuid);
		long lIndex = pMsg->GetLong();			

		GameManager::GetInstance()->GetMailManager()->GetGoodsFromMail(MailGuid,pPlayer,lIndex);		

	//}

}
예제 #6
0
void DoC2SMailDelete( CMessage *pMsg )
{
	//! 删除邮件
	list<CGUID> lGuid;
	CPlayer *pPlayer = pMsg->GetPlayer();	

	CGUID NpcGuid = NULL_GUID;
	pMsg->GetGUID(NpcGuid);

	CServerRegion *pRegion = pMsg->GetRegion();
	if (NULL==pRegion)
	{
		return;
	}
	CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid);
	CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape);

	//if (pPlayer && pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0  && pMailNpc->Distance( pPlayer ) < 8)//tag
	//{
		long lNum = pMsg->GetWord();

		if (lNum<0 || NULL==pPlayer)
		{
			return;
		}	

		for (int i = 0; i < lNum; ++i)
		{
			CGUID guid;
			pMsg->GetGUID(guid);
			lGuid.push_back(guid);
		}

		//if (GameManager::GetInstance()->GetMailManager()->CheckDeleteMail(lGuid,pPlayer))
		//{
		GameManager::GetInstance()->GetMailManager()->DeleteMailToWS(lGuid,pPlayer);			
//		}
	//}

}
예제 #7
0
void DoC2SMailAgreedPay( CMessage *pMsg )
{
	//! 同意付费
	CPlayer *pPlayer = pMsg->GetPlayer();
	CGUID NpcGuid = NULL_GUID;
	pMsg->GetGUID(NpcGuid);

	CServerRegion *pRegion = pMsg->GetRegion();
	if (NULL==pRegion)
	{
		return;
	}
	if (NULL==pPlayer)
	{
		return;
	}

	//玩家在交易或摆摊中不能付款
	if (pPlayer->GetCurrentProgress()==CPlayer::PROGRESS_OPEN_STALL 
		|| pPlayer->GetCurrentProgress()==CPlayer::PROGRESS_TRADING )
	{
		return;
	}

	CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid);
	CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape);

	//if (pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0  && pMailNpc->Distance( pPlayer ) < 8)//--attention
	//{			
		CGUID MailGuid;
		pMsg->GetGUID(MailGuid);
		CMail *pMail = GameManager::GetInstance()->GetMailManager()->GetMail(MailGuid);
		if (pMail && pMail->GetReceiverGuid()==pPlayer->GetExID() && pMail->GetType()==PAYGOLD_MAIL)
		{
			GameManager::GetInstance()->GetMailManager()->PayMoneyMail(pMail,pPlayer);
		}
	//}
}
예제 #8
0
// 响应其他消息
void CMoveShape::OnShapeMessage(CMessage* pMsg)
{
	switch(pMsg->GetType())
	{
	case MSG_C2S_SHAPE_CHANGELINEDRGN:
		{
			long linedID = pMsg->GetLong();
			long templateID = pMsg->GetLong();
			CGUID rgnID;
			pMsg->GetGUID(rgnID);
			CGUID playerID;
			pMsg->GetGUID(playerID);
			long lX = pMsg->GetLong();
			long lY = pMsg->GetLong();
			CPlayer* player = GetGame()->FindPlayer(playerID);
			if(player)
			{
				// 判断是否是分线场景的TemplateID
				map<long, vector<long>>::iterator linedId = GameManager::GetInstance()->GetRgnManager()->GetLinedRgnIdByLinedIdMap().find(linedID);
				if(linedId != GameManager::GetInstance()->GetRgnManager()->GetLinedRgnIdByLinedIdMap().end())
				{
					vector<long>::iterator templateIdItr;
					// 判断玩家当前场景ID跟消息是否一致
					templateIdItr = std::find(linedId->second.begin(), linedId->second.end(), player->GetRegionID());
					if(templateIdItr == linedId->second.end()) // 未找到该场景ID
					{
						char szGuid[128];
						playerID.tostring(szGuid);
						AddLogText("切换分线场景时:在场景%d上的玩家%s想切换到场景%d非法!", player->GetRegionID(), szGuid, templateID);
						return;
					}

					templateIdItr = std::find(linedId->second.begin(), linedId->second.end(), templateID);
					if(templateIdItr != linedId->second.end())
						player->ChangeRegion(RGN_NORMAL, rgnID, lX, lY, -1, templateID);
				}
			}
		}
		break;
	// 改变玩家方向
	case MSG_C2S_SHAPE_CHANGEDIR:
		{
			BYTE lDir = pMsg->GetByte();
			float fDir = pMsg->GetFloat();
			pMsg->GetPlayer()->SetDirEx(fDir);

			pMsg->SetType(MSG_S2C_SHAPE_CHANGEDIR);
			pMsg->Add(pMsg->GetPlayer()->GetType());
			pMsg->Add(pMsg->GetPlayer()->GetExID());
			pMsg->SendToNearestPlayer(this,true,pMsg->GetPlayer());
		}
		break;

	case MSG_C2S_SHAPE_SETPOS:	// 瞬移
		{
			if (CGlobeSetup::GetSetup()->bAllowClientChangePos == false)
				break;;

			long lType = pMsg->GetLong();
			CGUID guid; pMsg -> GetGUID(guid);
			CShape* pShape = (CShape*)pMsg->GetRegion()->FindChildObject(lType, guid);
			if( pShape )
			{
				long x = pMsg->GetLong();
				long y = pMsg->GetLong();
				
				pMsg->SetType(MSG_S2C_SHAPE_SETPOS);
				pShape->SetPosXY( x+0.5f, y+0.5f );
				pMsg->SendToAround(pShape);
			}
		}
		break;
	case MSG_C2S_SHAPE_MOVE:
		{			
#ifdef _RUNSTACKINFO1_
			CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_MOVE) Start.");
#endif
			float fCurX = pMsg->GetFloat();
			float fCurY = pMsg->GetFloat();
			float fDestX = pMsg->GetFloat();
			float fDestY = pMsg->GetFloat();
#ifdef _RUNSTACKINFO1_
			char pszStatckInfo[1024]="";
			_snprintf(pszStatckInfo,1024,"CurX:%f,CurY:%f,DestX:%f,DestY:%f",fCurX,fCurY,fDestX,fDestY);
			CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),pszStatckInfo);
#endif
			CSMClient::GetSM()->SendWatchResult(GetName(),eGGC_Move);
			// 处理行走请求
			OnQuestMoveStep(fCurX,fCurY,fDestX,fDestY);
#ifdef _RUNSTACKINFO1_
			CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_MOVE) End.");
#endif
		}
		break;
	case MSG_C2S_SHAPE_STOPMOVE:
		{
#ifdef _RUNSTACKINFO1_
			CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_STOPMOVE) Start.");
#endif
			float fCurX = pMsg->GetFloat();
			float fCurY = pMsg->GetFloat();
			short nDir = pMsg->GetByte();
			OnQuestStopMove(fCurX,fCurY,nDir);
#ifdef _RUNSTACKINFO1_
			CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_STOPMOVE) End.");
#endif
		}
		break;
		//改变移动模式
	case MSG_C2S_SHAPE_CHANGEMOVEMODE:
		{
			bool bRun = pMsg->GetChar()==0?false:true;
			pMsg -> GetPlayer()->SetIsRun(bRun);

			if (pMsg->GetPlayer()->GetIsRide())
			{
				if(!GetIsRun())
					pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fPlayerWalkSpeed);
				else
					pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fPlayerRunSpeed);

			}
			else
			{
				if(!GetIsRun())
					pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fRidePlayerWalkSpeed);
				else
					pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fRidePlayerRunSpeed);
			}


			pMsg -> GetPlayer()->SendChangedSpeedToClients();
		}
		break;
	// 客户端主动请求shape数据
	case MSG_C2S_SHAPE_QUESTINFO:
		{
		}
		break;
	case MSG_C2S_SHAPE_EMOTION:
		{
			LONG lType		= pMsg -> GetLong();
			CGUID guid; pMsg -> GetGUID(guid);
			DWORD dwEmotion	= pMsg -> GetDWord();

			CPlayer* pPlayer = pMsg -> GetPlayer();
			if( pPlayer -> GetType() == lType &&
				pPlayer -> GetExID() == guid )
			{
				pPlayer -> PerformEmotion( dwEmotion );
			}
		}
		break;
	case MSG_C2S_SHAPE_SETSELECTEDSHAPE:
		{
			//设定当前选择的目标
			long lType = pMsg->GetLong();
			CGUID guid = NULL_GUID;
			pMsg->GetGUID(guid);
			CPlayer *pPlayer = pMsg ->GetPlayer();
			if (pPlayer)
			{
				CServerRegion *pRegion = dynamic_cast<CServerRegion*>(pPlayer->GetFather());
				if(pRegion)
				{
					long lOldType = 0;
					CGUID OldGuid;
					pPlayer->GetTarget(OldGuid,lOldType);
					if(OldGuid != guid)
					{
						CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(pRegion->FindChildObject(lOldType,OldGuid));
						if(pMoveShape)
							pMoveShape->RemoveSelectSelfPlayer(pPlayer->GetExID());
						pPlayer->SetTarget(guid,lType);	
						if(guid != NULL_GUID)
						{
							pMoveShape = dynamic_cast<CMoveShape*>(pRegion->FindChildObject(lType,guid));
							if(pMoveShape)
							{
								pMoveShape->AddSelectSelfPlayer(pPlayer->GetExID());
								set<string>	setDirtyAttr;
								setDirtyAttr.insert("C_MaxHp");
								setDirtyAttr.insert("Hp");
								//更新属性
								pMoveShape->UpdateHPMPToClient(setDirtyAttr);
							}
						}
					}
				}
			}
		}
		break;
	case MSG_C2S_SHAPE_GETTSELECTEDSHAPE:
		{
			// 获得当前选择的目标
			CPlayer *pPlayer = pMsg->GetPlayer();
			if (pPlayer)
			{
				long lType = 0;
				CGUID guid = NULL_GUID;
				pPlayer->GetTarget(guid,lType);


				CServerRegion* pServerRegion = (CServerRegion*)(pPlayer->GetFather());
				if(NULL == pServerRegion || guid == NULL_GUID)	
					return ;			

					CBaseObject *pObj = pServerRegion->FindChildObject(lType,guid);		
					CMoveShape *pMoveShape = dynamic_cast<CMoveShape*>(pObj);
					if (pMoveShape)
					{	
						long lTargetType = 0;
						CGUID guidTarget = NULL_GUID;
						pMoveShape->GetTarget(guidTarget,lTargetType);
						
						if (guid != NULL_GUID)
						{
							CMessage msg(MSG_S2C_SHAPE_GETTSELECTEDSHAPE);
							msg.Add(lTargetType);
							msg.Add(guidTarget);
							msg.SendToPlayer(pPlayer->GetExID());
						}		
					}		
			}
		}
		break;

	}
}
예제 #9
0
//得到所用的作用对象
unsigned int CEffPoint::GetEffectObjs(list<CMoveShape*>& listObjs)
{
    listObjs.clear();
    CMoveShape* pShape = NULL;
    if(m_ePos==ePos_Self)
    {
        pShape= m_pParam->pUser;
    }
    else if(m_ePos==ePos_Dest )
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nMouseShapeType,m_pParam->MouseShapeID);
            m_pParam->pMouseShape = dynamic_cast<CMoveShape*>(pObj);
            pShape = m_pParam->pMouseShape;
        }
    }
    else if(m_ePos == ePos_Mouse)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            pShape = dynamic_cast<CMoveShape*>(pServerRegion->GetShape(m_pParam->nMouseX,m_pParam->nMouseY));
            m_pParam->pMouseShape = pShape;
        }
    }
    else if (m_ePos == ePos_Firer)
    {
        if (m_pParam->pFirer)
        {
            pShape = m_pParam->pFirer;
        }
        else
        {
            CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
            if(pServerRegion)
            {
                CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nFirerType,m_pParam->FirerID);
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }
    }
    else if (m_ePos == ePos_Attacker)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->pUser->GetAttackerType(),m_pParam->pUser->GetAttackerGuid());
            if (pObj)
            {
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }
    }
    else if (m_ePos == ePos_Target)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CGUID TargetGuid =NULL_GUID;
            long  lTargetType = 0;
            m_pParam->pUser->GetTarget(TargetGuid,lTargetType);
            CBaseObject *pObj = pServerRegion->FindChildObject(lTargetType,TargetGuid);
            if (pObj)
            {
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }
    }
    else if (m_ePos==ePos_AttackTarget)
    {
        CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
        if(pServerRegion)
        {
            CGUID AttackTargetGuid =NULL_GUID;
            long  lAttackTargetType = 0;
            m_pParam->pUser->GetAttacktarget(AttackTargetGuid,lAttackTargetType);
            CBaseObject *pObj = pServerRegion->FindChildObject(lAttackTargetType,AttackTargetGuid);
            if (pObj)
            {
                pShape = dynamic_cast<CMoveShape*>(pObj);
            }
        }

    }
    else if (m_ePos == ePos_Host)
    {
        pShape = m_pParam->pUser->GetHost();
    }


    //加入shape
    if(pShape)
    {
        if(m_pCondiGroup )
        {   //有条件且为真
            if( m_pCondiGroup->Result(pShape,m_pParam) )
                listObjs.push_back(pShape);
        }
        else
        {
            //没有条件对象
            listObjs.push_back(pShape);
        }
    }
    return listObjs.size();
}
예제 #10
0
//得到所用的作用对象
unsigned int CEffCirc::GetEffectObjs(list<CMoveShape*>& listObjs)
{
	listObjs.clear();
	int nNum = 0;
	list<POINT> listPos;
	m_pParam->nPosition = m_eCenter;
	
    if ( m_strNum!="" )
    {
          /// by:expter 2010/08/31 技能增加一个参数
          m_nNum = m_pParam->pFirer->GetSkillValue(m_pParam->nID,m_pParam->nLvl,m_strNum);
    }
    if( m_nNum < 0 )
        m_nNum = 0;

	CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
	if(NULL == pServerRegion)	return 0;

	CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nMouseShapeType,m_pParam->MouseShapeID);
	m_pParam->pMouseShape = dynamic_cast<CMoveShape*>(pObj);	

    CMoveShape *pExcept = NULL;
	if(m_eCenter == ePos_Self && m_pParam->pUser)
	{
		m_pParam->lDestX = m_pParam->pUser->GetTileX();
		m_pParam->lDestY = m_pParam->pUser->GetTileY();
	}
	else if (m_eCenter == ePos_Mouse)
	{
		m_pParam->lDestX = m_pParam->nMouseX;
		m_pParam->lDestY = m_pParam->nMouseY;
	}
	else if (m_eCenter == ePos_Dest && m_pParam->pMouseShape)
	{
		m_pParam->lDestX = m_pParam->pMouseShape->GetTileX();
		m_pParam->lDestY = m_pParam->pMouseShape->GetTileY();
        if( m_IsWithinObj)
            pExcept = m_pParam->pMouseShape;
	}
	else if(m_eCenter==ePos_DestCoord && m_pParam->lDestX==0 && m_pParam->lDestY==0 && m_pParam->pMouseShape)
	{
		m_pParam->lDestX = m_pParam->pMouseShape->GetTileX();
		m_pParam->lDestY = m_pParam->pMouseShape->GetTileY();
        if( m_IsWithinObj)
            pExcept = m_pParam->pMouseShape;
	}
	else if (m_eCenter == ePos_Coord)
	{
		m_pParam->lDestX = m_pParam->nMouseX;
		m_pParam->lDestY = m_pParam->nMouseY;
	}

	vector<CShape*> vOut;

	pServerRegion->FindAroundObject(m_pParam->pUser,TYPE_MONSTER,vOut);
	pServerRegion->FindAroundObject(m_pParam->pUser,TYPE_PLAYER,vOut);
	for (vector<CShape*>::iterator it=vOut.begin(); it!=vOut.end();++it)
	{
		if(m_eCenter == ePos_Self && (*it)!=m_pParam->pUser)
		{
			//使用者
			long lDistance = m_pParam->pUser->RealDistance((*it));
			if (lDistance<0)			
				lDistance = 0;
			
			if (lDistance>m_nRadius)
			{
				continue;
			}		
		}
		else if(m_eCenter == ePos_Mouse)
		{
			//鼠标
			if(Distance((*it)->GetTileX(),(*it)->GetTileY(),m_pParam->nMouseX,m_pParam->nMouseY)>m_nRadius)
			{
				continue;
			}			
		}
		else if(m_eCenter == ePos_Dest && m_pParam->pMouseShape && m_pParam->pMouseShape!=(*it))
		{
			//目标
			long lDistance = m_pParam->pMouseShape->RealDistance((*it));
			if (lDistance<0)
				lDistance = 0;
			if (lDistance>m_nRadius)
			{
				continue;			
			}		
		}
		else if(m_eCenter==ePos_DestCoord && m_pParam->lDestX!=0 && m_pParam->lDestY!=0)
		{
			//坐标
			if (Distance(m_pParam->lDestX,m_pParam->lDestY,(*it)->GetTileX(),(*it)->GetTileY())>m_nRadius)
			{
				continue;			
			}
		}
		else if (m_eCenter==ePos_Coord)
		{
			if (Distance(m_pParam->lDestX,m_pParam->lDestY,(*it)->GetTileX(),(*it)->GetTileY())>m_nRadius)
			{
				continue;			
			}
		}

        if ( pExcept )
        {
#ifdef _SKILL_INFO_D_      
            Log4c::Trace(SKILL_MODULE, "EffCirc:作用于对象外的玩家判断!\n");    
#endif
        }
		CMoveShape *pMoveShape = dynamic_cast<CMoveShape*>(*it);
		if(pMoveShape &&(NULL==m_pCondiGroup || m_pCondiGroup->Result(pMoveShape,m_pParam)))
		{
			++nNum;		
			if (m_nNum>0)
			{      
				if (m_nNum<nNum)
				{
					break;
				}
			}
            /// 除去范围内对象
            if( pExcept && pExcept == pMoveShape )
            {
                continue;                       
            }
			listObjs.push_back(pMoveShape);
		}		
	}	
	
	return nNum;
}
예제 #11
0
//得到所用的作用对象
unsigned int CEffLine::GetEffectObjs(list<CMoveShape*>& listObjs)
{
	listObjs.clear();
	int nNum = 0;

    if ( m_strNum!="" )
    {
        /// by:expter 2010/08/31 技能增加一个参数
        m_nNum = m_pParam->pFirer->GetSkillValue(m_pParam->nID,m_pParam->nLvl,m_strNum);
    }
    if( m_nNum < 0 )
        m_nNum = 0;

	list<POINT> listPos;
	CServerRegion* pServerRegion = (CServerRegion*)(m_pParam->pUser->GetFather());
	if(NULL == pServerRegion)	return 0;

	CBaseObject *pObj = pServerRegion->FindChildObject(m_pParam->nMouseShapeType,m_pParam->MouseShapeID);
	m_pParam->pMouseShape = dynamic_cast<CMoveShape*>(pObj);

    CMoveShape *pExcept = NULL;

	if(m_ePos == ePos_Self)
		return 0;
	//目标
	else if(m_ePos == ePos_Dest && m_pParam->pMouseShape)
	{
		GetLinePointToDest(listPos,
			m_pParam->pUser->GetTileX(),m_pParam->pUser->GetTileY(),
			m_pParam->pMouseShape->GetTileX(),m_pParam->pMouseShape->GetTileY(),m_nDistance);
        if( m_IsWithinObj)
            pExcept = m_pParam->pMouseShape;
	}
	//目标坐标点位置
	else if(m_ePos == ePos_Coord)
	{
		GetLinePointToDest(listPos,
			m_pParam->pUser->GetTileX(),m_pParam->pUser->GetTileY(),
			m_pParam->nMouseX,m_pParam->nMouseY,m_nDistance);
	}	
	//鼠标位置
	else if(m_ePos == ePos_Mouse)
	{		
		long lDir = m_pParam->pUser->GetDestDir(m_pParam->pUser->GetTileX(),
							m_pParam->pUser->GetTileY(),
							m_pParam->nMouseX,m_pParam->nMouseY);
		//得到与目标之间的格子
		//得到与目标之间的格子
		GetLinePointByDir(listPos,m_pParam->pUser->GetTileX(),
									m_pParam->pUser->GetTileY(),lDir,m_nDistance);
	}

    if ( pExcept )
    {
#ifdef _SKILL_INFO_D_      
        Log4c::Trace(SKILL_MODULE, "CEffLine:作用于对象外的玩家");    
#endif
    }

	//计算出moveshape
	list<POINT>::iterator it = listPos.begin();
	for(;it != listPos.end();it++)
	{
		POINT& pos = (*it);		
		CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(pServerRegion->GetShape(pos.x,pos.y));
		if(pMoveShape &&(NULL==m_pCondiGroup || m_pCondiGroup->Result(pMoveShape,m_pParam)))
		{
			nNum++;
            if (m_nNum>0)
            {      
                if (m_nNum<nNum)
                {
                    break;
                }
            }
            /// 除去范围内对象
            if( pExcept && pExcept == pMoveShape )
            {
#ifdef _SKILL_INFO_D_       
               Log4c::Trace(SKILL_MODULE, "CEffLine:作用于对象外的玩家");    
#endif
                continue;                       
            }
			listObjs.push_back(pMoveShape);
		}

	}
	return nNum;
}
예제 #12
0
void DoC2SMailSend( CMessage *pMsg )
{
	CPlayer *pPlayer = pMsg->GetPlayer();
	if (NULL == pPlayer)
	{
		return;
	}
	//玩家在交易或摆摊中不能交易
	if (pPlayer->GetCurrentProgress()==CPlayer::PROGRESS_OPEN_STALL || pPlayer->GetCurrentProgress()==CPlayer::PROGRESS_TRADING )
	{
		return;
	}

	CGUID NpcGuid = NULL_GUID;
	pMsg->GetGUID(NpcGuid);

	CServerRegion *pRegion = pMsg->GetRegion();
	if (NULL==pRegion)
	{
		return;
	}
	CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid);

	CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape);

	//if (pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0  && pMailNpc->Distance( pPlayer ) < 8)//  --attention
	//{


	tagMailParam *pMailParam = OBJ_CREATE(tagMailParam);

	long lReceiver	= pMsg->GetLong();						//收信人个数
	if (lReceiver > 100)
	{
		return;
	}

	for (int i=0; i<lReceiver; ++i)
	{
		char strReceiver[128];
		pMsg->GetStr(strReceiver,GlobalSetup::GetSetup()->lMaxName+1);

		if (lstrlen(strReceiver)>=GlobalSetup::GetSetup()->lMaxName)
		{
			GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(pPlayer->GetExID(),MAIL_SENDING_FAILED_INVALID_MAXNAME);
			continue;
		}
		list<string>::iterator it= find((pMailParam->strReceiverList).begin(),(pMailParam->strReceiverList).end(),strReceiver);//           (pMailParam->strReceiverList).f
		if (it==(pMailParam->strReceiverList).end())
		{
			(pMailParam->strReceiverList).push_back(strReceiver);
		}				
	}
	char strTemp[2048];
	pMsg->GetStr(strTemp,GlobalSetup::GetSetup()->lMaxSubject+1);								//主题
	if (lstrlen(strTemp)>=GlobalSetup::GetSetup()->lMaxSubject)
	{
		GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(pPlayer->GetExID(),MAIL_SENDING_FAILED_INVALID_MAXSUBJECT);
		return;
	}
	pMailParam->strSubject	= strTemp;


	pMsg->GetStr(strTemp,GlobalSetup::GetSetup()->lMaxText+1);							//内容
	if (lstrlen(strTemp)>=GlobalSetup::GetSetup()->lMaxText)
	{
		GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(pPlayer->GetExID(),MAIL_SENDING_FAILED_INVALID_MAXTEXT);
		return;
	}

	pMailParam->strText			= strTemp;

	pMailParam->lGold			= pMsg->GetLong();			//金币
	pMailParam->lType			= pMsg->GetByte();			//类型


	////普通物品
	long lCGoodNum	= pMsg->GetLong();	

	if (lCGoodNum>MAXGOODNUM)
	{
		char pszGuid[50]="";
		pPlayer->GetExID().tostring(pszGuid);
		Log4c::Warn(ROOT_MODULE,FormatText("GS_GOODS_91",pPlayer->GetName(),pszGuid,lCGoodNum));//%s(ID:%s) 玩家发送物品的数量:%d超过限制(此玩家利用非常规方式发送消息)

		OBJ_RELEASE(tagMailParam, pMailParam);
		return;
	}
	for (int i=0; i<lCGoodNum; ++i)
	{		
		listGoods *ptgGoods = OBJ_CREATE(listGoods);
		pMsg->GetGUID(ptgGoods->goodsguid);
		ptgGoods->lNum = pMsg->GetLong();
		ptgGoods->lContainerID = pMsg->GetDWord();
		ptgGoods->lPos	= pMsg->GetDWord();
		pMailParam->Goodslist.push_back(ptgGoods);
	}
	//}
	pMailParam->strWriter = pPlayer->GetName();
	pMailParam->WriterGuid = pPlayer->GetExID();
	pMailParam->bReject = 1;


	//! 发信			
	CMail *pMail = OBJ_CREATE_PVOID(CMail, (void*)pMailParam);

	if (pMail->GetType()==SYSTEM_MAIL || pMail->GetGold()<0 || pMail->GetType()>=SENDGOLD_MAIL)
	{
		pMail->DeleteMailGoods();
		OBJ_RELEASE(CMail, pMail);
		return;
	}			

	GameManager::GetInstance()->GetMailManager()->AddMail(pMail,pPlayer);//“在这里发送 MSG_S2W_MAIL_SEND 消息给 worldserver
	//	}
}