コード例 #1
0
//[sky] 召唤士兵(每个士兵都是一个独立的个体不同以召唤兽或者宠物)
int SceneArchitecture::summonSoldiers(DWORD id, Cmd::petType type, WORD num, DWORD sid, const char * name, DWORD anpcid,zPos pos,BYTE dir)
{
	zNpcB *base = npcbm.get(id);
	zNpcB *abase = NULL;
	if (anpcid>0) abase = npcbm.get(anpcid);
	if (NULL == base) return false;

	t_NpcDefine define;
	define.id = base->id;
	strncpy(define.name,base->name,MAX_NAMESIZE-1);
	if (pos.x != 0 && pos.y !=0)
		define.pos = pos;
	else
		define.pos = getPos();
	define.num = 1;
	define.interval = 5;
	define.initstate = zSceneEntry::SceneEntry_Normal;
	define.width = 6;
	define.height = 6;
	define.pos -= zPos(define.width/2,define.height/2);
	define.scriptID = sid;
	scene->initRegion(define.region,define.pos,define.width,define.height);

	int NewNum = 0;
	SceneNpc * newPet = NULL;

	for( int i=0; i< num; i++ )
	{
		newPet = scene->summonOneNpc<SceneNpc>(define,pos,base,dupIndex,0,abase,dir,this);

		if (newPet)
		{
			//sky 设置召唤出来的士兵的阵营和召唤者一样
			newPet->BattCampID = this->BattCampID;

			if (name&&(0!=strncmp(name,"",MAX_NAMESIZE)))
				strncpy(newPet->name,name,MAX_NAMESIZE-1);

			SceneNpcManager::getMe().addSpecialNpc(newPet);

			newPet->aif = newPet->aif | AIF_ACTIVE_MODE;
			newPet->setDir(dir);
			newPet->setSpeedRate( 2.0 );
			NewNum++;
		}
	}

	return NewNum;
}
コード例 #2
0
ファイル: Skill.cpp プロジェクト: ifzz/loki
/**
 * \brief 执行一个技能操作(一个操作包含若干个技能状态,操作有不同的目标对象和范围等)[sky]技能操作
 */
void zSkill::doOperation(const SkillStatus *pSkillStatus)
{
  _entry->carrier.status  = pSkillStatus;      // 一个技能操作
  //_entry->carrier.skilltype = base->usetype;  // 技能使用类型
  //_entry->carrier.skillID  = id;        // 技能ID
  _entry->carrier.skillbase = actionbase;        // 技能字典
  _entry->carrier.revCmd  = *curRevCmd;      // 保存本次收到的攻击消息
  _entry->carrier.attacker  = _entry;      // 攻击者的指针


  WORD wdTarget = pSkillStatus->target;
  if (wdTarget& TARGET_SELF)
  {
    if (_entry->skillStatusM.putOperationToMe(_entry->carrier,true))
    {
      //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
    }
    wdTarget&=(0xff & (~(1))); // 清除表示自己的位,如果只对自己施法那么wdTarget将为0
  }

  _entry->pkValue.damagebonus = actionbase->damnum;
  Scene *pScene = NULL;
  pScene = _entry->scene;
  if (wdTarget)
  {
    if (1 == pSkillStatus->range) // 1据说表示单格,所以做为单攻的判断标志
    {
      switch(curRevCmd->byAttackType)
      {
        case Cmd::ATTACKTYPE_N2U:  /// Npc攻击用户
          {
            //if (!_entry->isPkZone()) return;
            /*if (_entry->tempid == curRevCmd->dwDefenceTempID)
            {
              ScenePk::attackUserCmdToNine(curRevCmd,_entry);
              return;
            }*/
            SceneUser *pDef = pScene->getUserByTempID(curRevCmd->dwDefenceTempID);
            if (pDef)
            {
              if (wdTarget&TARGET_FRIEND)
              {
                if (!_entry->isEnemy(pDef,false,true)&&_entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              if (wdTarget&TARGET_ENEMY)
              {
                if (pDef->getTopMaster()&&pDef->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
                {
                  if (!(pDef->isPkZone(_entry) && _entry->isPkZone(pDef))) // 新加&&this->isPkZone(pDef)
                  {
                    ScenePk::attackFailToMe(curRevCmd,_entry);
                    return;
                  }
                }

                if (_entry->isEnemy(pDef,_entry->getType() == zSceneEntry::SceneEntry_Player)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  _entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_U2U:  /// 用户攻击用户
          {
            //if (!_entry->isPkZone()) return;
            /*if (_entry->tempid == curRevCmd->dwDefenceTempID)
            {
              ScenePk::attackUserCmdToNine(curRevCmd,_entry);
              return;
            }*/
            SceneUser *pDef = pScene->getUserByTempID(curRevCmd->dwDefenceTempID);
            if (pDef)
            {
              if (wdTarget&TARGET_FRIEND)
              {
                if (!_entry->isEnemy(pDef,false,true)&&_entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              if (wdTarget&TARGET_ENEMY)
              {
                if (_entry->isEnemy(pDef,_entry->getType() == zSceneEntry::SceneEntry_Player)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  pDef->isPkZone(_entry)&&_entry->isPkZone(pDef)&&//新加 _entry->isPkZone(pDef)
                  _entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
                else
                {
                  ScenePk::attackFailToMe(curRevCmd,_entry);
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_U2N:  /// 用户攻击Npc
          {
            SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(curRevCmd->dwDefenceTempID);
            if (pNpc)
            {
              if (wdTarget&TARGET_PET)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_PET)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              else if (wdTarget&TARGET_SUMMON)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_SUMMON)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              else if (wdTarget&TARGET_NPC)
              {
                if (pNpc->getTopMaster()&&pNpc->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
                {
                  if (!(pNpc->isPkZone(_entry) && _entry->isPkZone(pNpc))) // 新加&&this->isPkZone(pDef)
                  {
                    ScenePk::attackFailToMe(curRevCmd,_entry);
                    return;
                  }
                }

                if (_entry->isEnemy(pNpc)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  _entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode))
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
                else
                {
                  ScenePk::attackFailToMe(curRevCmd,_entry);
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_N2N:  /// Npc攻击Npc
          {
            SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(curRevCmd->dwDefenceTempID);
            if (pNpc)
            {
              if (wdTarget&TARGET_PET)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_PET)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              else if (wdTarget&TARGET_SUMMON)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_SUMMON)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                    return;
                  }
                  else
                  {
                    return;
                  }
                }
              }
              else if (wdTarget&TARGET_NPC)
              {
                if (_entry->getTopMaster() &&
                  _entry->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player &&
                  pNpc->getTopMaster() &&
                  pNpc->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
                {
                  if (!(pNpc->isPkZone(_entry) && _entry->isPkZone(pNpc))) // 新加&&this->isPkZone(pDef)
                  {
                    ScenePk::attackFailToMe(curRevCmd,_entry);
                    return;
                  }
                }

                if (_entry->isEnemy(pNpc)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  _entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode))
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_U2P:  /// 用户攻击点
          {
            zPos pd;
            DWORD num =0;
            pd.x = (DWORD)curRevCmd->xDes;
            pd.y = (DWORD)curRevCmd->yDes;
            if (findAttackTarget(pSkillStatus,pd,num))
            {
              //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
            }
            return;
          }
          break;
        case Cmd::ATTACKTYPE_U2B:  /// 用户攻击建筑
        default:
          {
            //if (!ScenePk::attackUserCmdToNine(curRevCmd,_entry))
            //{
            //  return;
            //}
            return;
          }
          break;
      }
//      ScenePk::attackFailToMe(curRevCmd,_entry);
    }
    else
    {
      zPos center,pd;
      BYTE byDir=0;
      if (curRevCmd->dwDefenceTempID!=0)
      {
        switch(curRevCmd->byAttackType)
        {
          case Cmd::ATTACKTYPE_N2U:  /// Npc攻击用户
          case Cmd::ATTACKTYPE_U2U:  /// Npc攻击用户
            {
              SceneUser *pDef = pScene->getUserByTempID(curRevCmd->dwDefenceTempID);
              if (pDef)
              {
                center = pDef->getPos();
              }
              else
              {
                center.x = (DWORD)curRevCmd->xDes;
                center.y = (DWORD)curRevCmd->yDes;
              }
            }
            break;
          case Cmd::ATTACKTYPE_N2N:  /// Npc攻击用户
          case Cmd::ATTACKTYPE_U2N:  /// Npc攻击用户
            {
              SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(curRevCmd->dwDefenceTempID);
              if (pNpc)
              {
                center = pNpc->getPos();
              }
              else
              {
                center.x = (DWORD)curRevCmd->xDes;
                center.y = (DWORD)curRevCmd->yDes;
              }
            }
            break;
          default:
            {
              center.x = (DWORD)curRevCmd->xDes;
              center.y = (DWORD)curRevCmd->yDes;
            }
            break;
        }
      }
      else
      {
        center.x = (DWORD)curRevCmd->xDes;
        center.y = (DWORD)curRevCmd->yDes;
      }

      switch(pSkillStatus->center)
      {
        case SKILL_CENTER_TYPE_MOUSE:
          {
//            center.x = (DWORD)curRevCmd->xDes;
//            center.y = (DWORD)curRevCmd->yDes;
            byDir = curRevCmd->byDirect;
            _entry->setDir(byDir);
#ifdef _DEBUG 
            Channel::sendSys(_entry->tempid,Cmd::INFO_TYPE_GAME,"中心点类型:鼠标(%u,%u) 方向:%u",center.x,center.y,byDir);
#endif
            // debug提示
          }
          break;
        case SKILL_CENTER_TYPE_SELF:
          {
            center.x = _entry->getPos().x;
            center.y = _entry->getPos().y;
            byDir = curRevCmd->byDirect;//_entry->getDir();
            _entry->setDir(byDir);
#ifdef  _DEBUG 
            Channel::sendSys(_entry->tempid,Cmd::INFO_TYPE_GAME,"中心点类型:自身(%u,%u) 方向:%u",center.x,center.y,byDir);
#endif
          }
          break;
        default:
#ifdef _DEBUG 
          Channel::sendSys(_entry->tempid,Cmd::INFO_TYPE_GAME,"中心点类型:填写错误请查证");
#endif
          break;
      }

      switch(pSkillStatus->range)
      {
        case 20:
          {
            DWORD tempLen = sizeof(struct Cmd::stAttackMagicUserCmd);
            DWORD itemNum = 0;
#ifdef _DEBUG
            Zebra::logger->error("!!!---客户端发过来的攻击指令原始长度[%u] 当前长度[%u]",tempLen,curRevCmdLen);
#endif
            if (curRevCmdLen>tempLen)
            {
              itemNum = (curRevCmdLen-tempLen)/sizeof(DWORD);
#ifdef _DEBUG
              Zebra::logger->error("!!!---客户端发过来的攻击列表数目[%u]",itemNum);
#endif
              if (itemNum >5) itemNum=5;
              for (DWORD i=0; i<itemNum; i++)
              {
                SceneNpc *pNpc=NULL;
                SceneUser *pUser=NULL;
#ifdef _DEBUG
                Zebra::logger->error("!!!---客户端发过来的被攻击临时坐标[%u]",curRevCmd->dwTempIDList[i]);
#endif
                if ((pNpc=_entry->scene->getNpcByTempID(curRevCmd->dwTempIDList[i]))!=NULL)
                {
                  pd = pNpc->getPos();
                }
                else if ((pUser=_entry->scene->getUserByTempID(curRevCmd->dwTempIDList[i]))!=NULL)
                {
                  pd = pUser->getPos();
                }
                else continue;
/*
                pd.x= (curRevCmd->dwTempIDList[i]>>16) &0xffff;
                pd.y= (curRevCmd->dwTempIDList[i]&0xff);
*/    
#ifdef _DEBUG
                Zebra::logger->error("!!!---客户端发过来的攻击坐标[%u][x=%u,y=%u]",curRevCmd->dwTempIDList[i],pd.x,pd.y);
#endif

//-技能范围测试
#ifdef _DEBUG
                zObjectB *base = objectbm.get(501);
                if (base)
                {
                  zObject *o=zObject::create(base,1);
                  _entry->scene->addObject(o,pd);
                }
#endif
                DWORD num=0;
                if (!findAttackTarget(pSkillStatus,pd,num)) break;
              }
            }
          }
          break;
        case 21:
          {
            zPosVector range;
            pScene->findEntryPosInNine(_entry->getPos(),_entry->getPosI(),range);
            for(zPosVector::iterator iter = range.begin(); iter != range.end() ; iter ++)
            {
              pd = *iter;
//-技能范围测试
#ifdef _DEBUG
              zObjectB *base = objectbm.get(585);
              if (base)
              {
                zObject *o=zObject::create(base,randBetween(1,10));
                _entry->scene->addObject(o,pd);
              }
#endif
              DWORD num=0;
              if (!findAttackTarget(pSkillStatus,pd,num)) break;
            }
          }
          break;
        case 22:
          {
            if (_entry->getType() == zSceneEntry::SceneEntry_Player)
            {
              SceneUser *pUser = (SceneUser *)_entry;

			  TeamManager * team = SceneManager::getInstance().GetMapTeam(pUser->TeamThisID);

              if (team)
              {
				  SendStatusToTeamExec exec(pUser,pSkillStatus);
				  team->execEveryOne(exec);
              }
            }
          }
          break;
        case 50:
          {
            zPosVector range;
            int count=0;
            pScene->findEntryPosInOne(_entry->getPos(),_entry->getPosI(),range);
            for(zPosVector::iterator iter = range.begin(); iter != range.end() ; iter ++)
            {
              count++;
              if (count>20) break;
              pd = *iter;
//-技能范围测试
#ifdef _DEBUG
              zObjectB *base = objectbm.get(585);
              if (base)
              {
                zObject *o=zObject::create(base,randBetween(1,10));
                _entry->scene->addObject(o,pd);
              }
#endif
              DWORD num=0;
              if (!findAttackTarget(pSkillStatus,pd,num)) break;
            }
          }
          break;
        default:
          {
            SMagicRange range;
            DWORD maxCount =0;
            DWORD count=0;
            MagicRangeInit::getInstance().get(pSkillStatus->range,byDir % 2,range);
            maxCount = range.num;
            if (0==maxCount) maxCount = 65535;
            for(std::vector<RelativePos>::iterator iter = range.lib.begin(); iter != range.lib.end() ; iter ++)
            {
              SWORD rangDamageBonus=0;
              pd = iter->getAbsolutePos(center,byDir);
              rangDamageBonus = (*iter).w;
//-技能范围测试
#ifdef _DEBUG
              zObjectB *base = objectbm.get(585);
              if (base)
              {
                zObject *o=zObject::create(base,randBetween(1,10));
                _entry->scene->addObject(o,pd);
              }
#endif
              DWORD num=0;
              if (!findAttackTarget(pSkillStatus,pd,num,rangDamageBonus)) break;
              if (num>0)
              {
                count++;
                if (count>= maxCount) break;
              }
            }
          }
      }
      return;
    }
  }
}
コード例 #3
0
ファイル: Skill.cpp プロジェクト: ifzz/loki
/**
 * \brief  触发一个技能[SKY技能触发]
 * \param  rev 本次收到的客户端消息
 * \param cmdLen 消息长度
 * \return true 技能使用成功 false 技能使用失败
 */
bool zSkill::action(const Cmd::stAttackMagicUserCmd *rev,const DWORD cmdLen)
{
  if (_entry)
  {
    actionbase = getNewBase();
    curRevCmd = rev;
    curRevCmdLen = cmdLen;

	//sky SKILLID_IMMOLATE 献祭技能的ID
	if(rev->wdMagicType == SKILLID_IMMOLATE && _entry->Immolate)
	{
		_entry->skillStatusM.clearSkill(rev->wdMagicType);
		return true;
	}

    // 消耗
    if (this->istemp||_entry->needWeapon(curRevCmd->wdMagicType)) // 检查施放技能是否需要武器
    {
      if (actionbase->ride==0) 
      {
        if (_entry->checkMountHorse()) return false;
      }
      if (_entry->checkSkillCost(actionbase))  // 计算自身各种消耗
      {
        if (_entry->checkPercent())  // 判断技能施放成功的几率
        {
          std::vector<SkillStatus>::const_iterator iter;
          if (_entry->checkReduce(actionbase->objcost,actionbase->objnum))
          {
            showMagicToAll();
            switch(rev->wdMagicType)
            {
              case 226: // 食尸术
              case 319: // 尸暴术
                {
                  SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(rev->dwDefenceTempID);
                  if (pNpc)
                  {
                    if (pNpc->getState() == zSceneEntry::SceneEntry_Death && !pNpc->isUse) 
                    {
                      pNpc->isUse = true;
                      Cmd::stRemoveMapNpcMapScreenUserCmd removeNpc;
                      removeNpc.dwMapNpcDataPosition = rev->dwDefenceTempID;
                      pNpc->scene->sendCmdToNine(pNpc->getPosI(),&removeNpc,sizeof(removeNpc),pNpc->dupIndex);
                    }
                    else
                    {
                      return false;
                    }
                  }
                  else
                  {
                    return false;
                  }
                }
                break;
              default:
                break;
            }
            _entry->doSkillCost(actionbase);
            for(iter  = actionbase->skillStatus.begin(); iter != actionbase->skillStatus.end(); iter ++)
            {
              // 处理依赖消耗物品型技能对物品的消耗,目前此接口未启用,两个参数分别是物品ID和消耗数量
              {
                SkillStatus *pSkillStatus = (SkillStatus *)&*iter;
                doOperation(pSkillStatus);
              }
            }
            _entry->reduce(actionbase->objcost,actionbase->objnum);
            return true;
          }
        }
      }
    }
  }
  else
  {
    Zebra::logger->error("学习的技能中_entry指针为空");
  }
  return false;
}
コード例 #4
0
ファイル: Skill.cpp プロジェクト: ifzz/loki
/**
 * \brief 投送操作到目标对象身上
 * \param pSkillStatus 操作
 * \param pd 坐标点
 * \return 如果是返回true表示可以继续处理攻击攻击过程否则false表示返回
 */
bool zSkill::findAttackTarget(const SkillStatus *pSkillStatus,zPos &pd,DWORD &count,SWORD rangDamageBonus)
{
  WORD wdTarget = pSkillStatus->target;
  Scene *pScene = _entry->scene;

  //检查范围有效
  if (!pScene->zPosValidate(pd))
  {
    return true;
  }
  SceneUser *pFindUser = NULL;
  SceneNpc  *pFindNpc = NULL;
  if (wdTarget&TARGET_FRIEND)
  {
    pFindUser = pScene->getSceneUserByPos(pd);
    if (pFindUser/* && pFindUser!=_entry*/)
    {
      if (!_entry->isEnemy(pFindUser,false,true)&&_entry->checkMagicFlyRoute(pFindUser,pSkillStatus->mode))
      {
        count=1;
        if (pFindUser->skillStatusM.putOperationToMe(_entry->carrier,true,rangDamageBonus))
        {
          //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
          return true;
        }
        else
        {
          return false;
        }
      }
    }
  }
  if (wdTarget&TARGET_ENEMY)
  {
    if (!pFindUser) pFindUser = pScene->getSceneUserByPos(pd);
    if (pFindUser && pFindUser!=_entry)
    {
      if (_entry->getTopMaster()&&_entry->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
      {
        if (!(pFindUser->isPkZone(_entry) && _entry->isPkZone(pFindUser))) // 新加&&this->isPkZone(pDef)
        {
          return true;
        }
      }

      if (_entry->isEnemy(pFindUser)&&
         _entry->checkMagicFlyRoute(pFindUser,pSkillStatus->mode))
      {
        count=1;
        if (pFindUser->skillStatusM.putOperationToMe(_entry->carrier,false,rangDamageBonus))
        {
          //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
          return true;
        }
        else
        {
          return false;
        }
      }
    }
  }

  if (!pFindUser)
  {
    if (wdTarget&TARGET_PET)
    {
      pFindNpc = pScene->getSceneNpcByPos(pd);
      if (pFindNpc/* && pFindNpc!=_entry*/)
      {
        if (!_entry->isEnemy(pFindNpc,false,true)&&_entry->checkMagicFlyRoute(pFindNpc,pSkillStatus->mode)&&pFindNpc->getPetType()==Cmd::PET_TYPE_PET)
        {
          count=1;
          if (pFindNpc->skillStatusM.putOperationToMe(_entry->carrier,true,rangDamageBonus))
          {
            //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
            return true;
          }
          else
          {
            return false;
          }
        }
      }
    }

    if (wdTarget&TARGET_SUMMON)
    {
      pFindNpc = pScene->getSceneNpcByPos(pd);
      if (pFindNpc/* && pFindNpc!=_entry*/)
      {
        if (!_entry->isEnemy(pFindNpc,false,true)&&_entry->checkMagicFlyRoute(pFindNpc,pSkillStatus->mode)&&pFindNpc->getPetType()==Cmd::PET_TYPE_SUMMON)
        {
          count=1;
          if (pFindNpc->skillStatusM.putOperationToMe(_entry->carrier,true,rangDamageBonus))
          {
            //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
            return true;
          }
          else
          {
            return false;
          }
        }
      }
    }

    if (wdTarget&TARGET_NPC)
    {
      if (!pFindNpc) pFindNpc = pScene->getSceneNpcByPos(pd);
      if (pFindNpc && pFindNpc!=_entry)
      {
        if (_entry->getTopMaster() &&
          _entry->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player &&
          pFindNpc->getTopMaster() &&
          pFindNpc->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
        {
          if (!(pFindNpc->isPkZone(_entry) && _entry->isPkZone(pFindNpc))) // 新加&&this->isPkZone(pDef)
          {
            return true;
          }
        }
        if (_entry->isEnemy(pFindNpc)&&
           _entry->checkMagicFlyRoute(pFindNpc,pSkillStatus->mode))
        {
          count=1;
          if (pFindNpc->skillStatusM.putOperationToMe(_entry->carrier,false,rangDamageBonus))
          {
            //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
            return true;
          }
          else
          {
            return false;
          }
        }
      }
    }
  }
  return true;
}
コード例 #5
0
ファイル: ScenePet.cpp プロジェクト: edolphin-ydf/hydzhengtu
/**
 * \brief 当主人是玩家时,以主人的身份进行敌我判断
 * \param entry 判断的对象
 * \return 0:友方 1:敌人 -1:中立
 */
int ScenePet::isUserMasterEnemy(SceneEntryPk * entry)
{
	SceneEntryPk * temp = getTopMaster();
	SceneUser * tm = 0;//top master
	if (temp && temp->getType()==zSceneEntry::SceneEntry_Player)
		tm = (SceneUser*)temp;
	else return -1;

	// TODO 判断传入角色与主人是否为朋友关系
	if (tm==entry) return 0;

	SceneEntryPk * entryMaster = entry->getTopMaster();

	using namespace Cmd;
	//if (PKMODE_ENTIRE==pkMode) return 1;

	switch (entryMaster->getType())
	{
	case zSceneEntry::SceneEntry_Player:
		{
			SceneUser *pUser = (SceneUser *)entryMaster;
			if (pUser == tm) return 0;

			bool def_gem = false;
			bool my_gem = false;

			if (tm->issetUState(Cmd::USTATE_TOGETHER_WITH_TIGER)
				|| tm->issetUState(Cmd::USTATE_TOGETHER_WITH_DRAGON))
			{
				my_gem = true;
			}

			if (pUser->issetUState(Cmd::USTATE_TOGETHER_WITH_TIGER)
				|| pUser->issetUState(Cmd::USTATE_TOGETHER_WITH_DRAGON))
			{
				def_gem = true;
			}

			if ((pUser->charbase.level<20)  && (!pUser->isWarRecord(Cmd::COUNTRY_FORMAL_DARE,tm->charbase.country)) && (!def_gem))
				return 0;
			if ((tm->charbase.level<20)  && (!tm->isWarRecord(Cmd::COUNTRY_FORMAL_DARE,pUser->charbase.country)) && (!my_gem))
				return 0;

			if (tm->scene == pUser->scene && !(my_gem || def_gem))
			{
				//if (tm->charbase.country == pUser->charbase.country)
				//{
				if (tm->charbase.level <= tm->scene->getPkLevel() && pUser->charbase.level >tm->scene->getPkLevel() 
					&& (!tm->isWarRecord(Cmd::SEPT_NPC_DARE,pUser->charbase.septid)))
				{
					return 0;
				}

				if (tm->charbase.level > tm->scene->getPkLevel() && pUser->charbase.level <= tm->scene->getPkLevel() 
					&& (!tm->isWarRecord(Cmd::SEPT_NPC_DARE,pUser->charbase.septid)))
				{
					return 0;
				}
				//}
				//else
				//{
				//  if (tm->charbase.level <= tm->scene->getPkLevel()-10 && pUser->charbase.level >tm->scene->getPkLevel()-10 
				//    && (!tm->isWarRecord(Cmd::SEPT_NPC_DARE,pUser->charbase.septid)))
				//  {
				//    return 0;
				//  }

				//  if (tm->charbase.level > tm->scene->getPkLevel()-10 && pUser->charbase.level <= tm->scene->getPkLevel()-10 
				//    && (!tm->isWarRecord(Cmd::SEPT_NPC_DARE,pUser->charbase.septid)))
				//  {
				//    return 0;
				//  }
				//}
			}

			if (tm->isDiplomatState() ==0 || pUser->isDiplomatState() == 0)
			{
				return 0;
			}

			switch (tm->pkMode)
			{
			case PKMODE_NORMAL:
				{
					return 0;
				}
				break;
			case PKMODE_TEAM:
				{
					//是同一组队或者是增益类魔法
					if ((tm->TeamThisID != 0) && (pUser->TeamThisID == tm->TeamThisID))
						return 0;
					else
						return 1;
				}
				break;
			case PKMODE_TONG:
				{
					if (tm->charbase.unionid != 0 && tm->charbase.unionid == pUser->charbase.unionid)
						return 0;
					else
						return 1;
				}
				break;
			case PKMODE_SEPT:
				{
					if (tm->charbase.septid != 0 && tm->charbase.septid == pUser->charbase.septid)
						return 0;
					else
						return 1;
				}
				break;
			case PKMODE_COUNTRY:
				{
					if (tm->charbase.country != 0 
						&& ((tm->charbase.country == pUser->charbase.country)
						|| (CountryAllyM::getMe().getFriendLevel(tm->charbase.country,
						pUser->charbase.country)>0
						&& (pUser->isSpecWar(Cmd::COUNTRY_FORMAL_DARE) 
						|| tm->isSpecWar(Cmd::COUNTRY_FORMAL_DARE)))))
						return 0;
					else
						return 1;
				}
				break;
			case PKMODE_GOODNESS:
				{
					if (pUser->isRedNamed(false)||pUser->charbase.country!=tm->charbase.country)
						return 1;
					else
						return 0;
				}
				break;
			case PKMODE_ALLY:
				{
					if ((CountryAllyM::getMe().getFriendLevel(pUser->charbase.country,tm->charbase.country)>0)||
						(pUser->charbase.country==tm->charbase.country))
						return 0;
					else
						return 1;
				}
				break;
			case PKMODE_ENTIRE:
				{
					if (pUser->isPkZone(tm)&&tm->isPkZone(pUser))
						return 1;
					else
						return 0;
				}
			default:
				break;
			}
			return 0;
		}
		break;
	case zSceneEntry::SceneEntry_NPC:
		{
			SceneNpc * n = (SceneNpc *)entry;

			if (n->id==COUNTRY_MAIN_FLAG  //这几个不在这里判断
				|| n->id==COUNTRY_SEC_FLAG
				|| n->isMainGeneral()
				|| n->id==COUNTRY_KING_MAIN_FLAG
				|| n->id==COUNTRY_KING_SEC_FLAG
				|| n->id==COUNTRY_SEC_GEN
				|| n->id==COUNTRY_EMPEROR_MAIN_GEN
				|| n->id==COUNTRY_EMPEROR_SEC_GEN)
				return 1;

			//国外npc
			if (!n->isBugbear())
			{
				if (n->npc->flags==1 && tm->charbase.country!=n->scene->getCountryID())
					return 1;
				else
					return -1;
			}

			SceneEntryPk * m = n->getMaster();
			if (m)
			{
				//Zebra::logger->debug("isPetEnemy 183 %s->%s",tm->name,n->getMaster()->name);
				if (!scene->zPosShortRange(n->getPos(),m->getPos(),20) && n->getPetType()==Cmd::PET_TYPE_GUARDNPC)
					return 1;
				else
					return tm->isEnemy(m);
			}

			if ((n->aif&AIF_ATK_REDNAME)||(n->npc->kind==NPC_TYPE_GUARD))
			{
				if (tm->isRedNamed()) return 1;
				if (tm->charbase.country!=tm->scene->getCountryID())
					return 1;
				if (tm->charbase.goodness&Cmd::GOODNESS_ATT)
					return 1;
			}
			switch (n->npc->kind)
			{
			case NPC_TYPE_HUMAN:                    ///人型
			case NPC_TYPE_NORMAL:                   /// 普通类型
			case NPC_TYPE_BBOSS:                    /// 大Boss类型
			case NPC_TYPE_LBOSS:                    /// 小Boss类型
			case NPC_TYPE_PBOSS:                    /// 紫Boss类型
			case NPC_TYPE_BACKBONE:                 /// 精英类型
			case NPC_TYPE_GOLD:                             /// 黄金类型
			case NPC_TYPE_SUMMONS:                  /// 召唤类型
			case NPC_TYPE_AGGRANDIZEMENT:   /// 强化类型
			case NPC_TYPE_ABERRANCE:                /// 变异类型
			case NPC_TYPE_BACKBONEBUG:              /// 精怪类型
			case NPC_TYPE_PET:      /// 宠物类型
			case NPC_TYPE_TOTEM:                    /// 图腾类型
			case NPC_TYPE_GHOST:		///元神类
			case NPC_TYPE_TURRET:			/// 炮塔
			case NPC_TYPE_BARRACKS:
			case NPC_TYPE_CAMP:
			case NPC_TYPE_ANIMON: /// 动物类
				//case NPC_TYPE_DUCKHIT:    /// 花草
				return 1;
			case NPC_TYPE_GUARD:    /// 士兵类型
			case NPC_TYPE_SOLDIER:    /// 士兵类型
				{
					if (tm->charbase.country!=scene->getCountryID())
						return 1;
					if (tm->pkMode==PKMODE_ENTIRE)
						return 1;
					return 0;
				}
			case NPC_TYPE_UNIONGUARD:
				if (tm->isAtt(Cmd::UNION_CITY_DARE))
					return 1;
				else
					if (tm->scene->getUnionDare() && !tm->isSpecWar(Cmd::UNION_CITY_DARE)
						&& !n->isMainGeneral())//大将军第三方不能打
						return 1;//中立方
					else                                                    
						return 0;//城战期间打城战而且不是攻方,就是守方
				break;
			case NPC_TYPE_UNIONATTACKER:
				if (tm->isAtt(Cmd::UNION_CITY_DARE))
					return 0;
				else
					if (tm->scene->getUnionDare() && !tm->isSpecWar(Cmd::UNION_CITY_DARE))
						return 1;//中立方
					else
						return 1;//城战期间打城战而且不是攻方,就是守方
				break;
			default:
				return -1;
			}
			return -1;
		}
		break;
	default:
		return -1;
		break;
	}

}
コード例 #6
0
ファイル: Property.cpp プロジェクト: adan830/gameserver-2
/**     
 * \brief  处理stPropertyUserCmd指令
 *
 *
 * 处理stPropertyUserCmd指令
 *      
 * \param rev: 接受到的指令内容
 * \param cmdLen: 接受到的指令长度
 * \return 处理指令成功返回真,否则返回false
 */       
bool SceneUser::doPropertyCmd(const Cmd::stPropertyUserCmd *rev,DWORD cmdLen)
{
  switch(rev->byParam)
  {
  case SWAPUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stSwapObjectPropertyUserCmd *swap=(Cmd::stSwapObjectPropertyUserCmd *)rev;
        //得到原物品
        zObject *srcobj=packs.uom.getObjectByThisID(swap->qwThisID);
        if (srcobj)
        {
          //交易处理
          if (tradeorder.hasBegin() && tradeorder.in_trade(srcobj))
          {
            return true;
          }
        
          if (mask.is_use(srcobj)) {
            return Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"请先解除该蒙面巾!");
          }
          stObjectLocation org=srcobj->data.pos;
          Xlogger->info("[移动物品]%s移动物品%s(%d,%d,%d,%d)->(%d,%u,%d,%d)",name,srcobj->data.strName,
              org.loc(),org.tab(),org.xpos(),org.ypos(),
              swap->dst.loc(),swap->dst.tab(),swap->dst.xpos(),swap->dst.ypos());
          if (org != swap->dst && packs.moveObject(this,srcobj,swap->dst))
          {
            //向客户端发送指令指明新的两个地方的物品
            if (swap->dst.loc()!=Cmd::OBJECTCELLTYPE_NONE)
              sendCmdToMe(swap,sizeof(Cmd::stSwapObjectPropertyUserCmd));

            if (packs.equip.needRecalc/* || recalcBySword(false)*/)
            {
              notifyEquipChange();
              setupCharBase();
              Cmd::stMainUserDataUserCmd  userinfo;
              full_t_MainUserData(userinfo.data);
              sendCmdToMe(&userinfo,sizeof(userinfo));

              sendMeToNine();
              this->reSendData = false;
#ifdef _DEBUG
              Xlogger->info("[移动物品]完毕......");
#endif
            }
          }
          else
            Xlogger->info("[移动物品]%s移动物品%s(%d,%d,%d,%d)->(%d,%u,%d,%d)失败",name,srcobj->data.strName,
                org.loc(),org.tab(),org.xpos(),org.ypos(),
                swap->dst.loc(),swap->dst.tab(),swap->dst.xpos(),swap->dst.ypos());
        }
        else
          Xlogger->warn("[移动物品]%s未找到移动物品 %ld",name,swap->qwThisID);
        return true;
      }
      break;
    case SPLITUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stSplitObjectPropertyUserCmd *split=(Cmd::stSplitObjectPropertyUserCmd *)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(split->qwThisID);

        if (!srcobj) return true;


        //fix objects which have num can be equiped via this,it's ugly and should be checked at client too
        //NOTICE: this will lead to theses objects can not be equiped,client shouldn't send this cmd,use 
        //stSwapObjectPropertyUserCmd instead when needed.
        if (split->dst.loc() == Cmd::OBJECTCELLTYPE_EQUIP
            || split->dst.loc() == Cmd::OBJECTCELLTYPE_PET) return true;
        
        //交易处理
        if (tradeorder.hasBegin() && tradeorder.in_trade(srcobj))
        {
          return true;
        }

        if (split->dwNum > srcobj->data.dwNum) {
          return true;
        }

        bool notify = false;

        //其他物品 
        Package *destpack=packs.getPackage(split->dst.loc(),split->dst.tab());
        zObject *destobj=NULL;
        if (destpack && 
          destpack->getObjectByZone(&destobj,split->dst.xpos(),split->dst.ypos()) )
        {          
          if (!destobj) { //split
            destobj = zObject::create(srcobj);
            if (destobj)   {
              destobj->data.dwNum = split->dwNum;
              destobj->data.pos = split->dst;

              if (packs.addObject(destobj,false)) {
                srcobj->data.dwNum -= split->dwNum;

                //通知客户端
                Cmd::stSplitObjectPropertyUserCmd ret;
                bcopy(split,&ret,sizeof(ret),sizeof(ret));
                ret.qwNewThisID=destobj->data.qwThisID;
                sendCmdToMe(&ret,sizeof(ret));
                notify = true;
                zObject::logger(destobj->createid,destobj->data.qwThisID,destobj->data.strName,destobj->data.dwNum,destobj->data.dwNum,1,0,NULL,this->id,this->name,"拆分新增",destobj->base,destobj->data.kind,destobj->data.upgrade);
              }
              else {
                zObject::destroy(destobj);
                return true;
              }
              
            }
          } else if (destobj->data.dwObjectID == srcobj->data.dwObjectID && 
            srcobj->base->maxnum>1 &&
            srcobj->data.dwObjectID==destobj->data.dwObjectID &&
            srcobj->data.upgrade==destobj->data.upgrade ) {

            srcobj->data.dwNum -= split->dwNum;
            destobj->data.dwNum += split->dwNum;

            if (destobj->data.dwNum>destobj->base->maxnum)
            {
              destobj->data.dwNum=destobj->base->maxnum;
            }

            notify = true;
            
            //通知客户端
          
            Cmd::stSplitObjectPropertyUserCmd ret;
            bcopy(split,&ret,sizeof(ret),sizeof(ret));
            ret.qwNewThisID=destobj->data.qwThisID;
            sendCmdToMe(&ret,sizeof(ret));


          }
           else {
          }


          if (srcobj->data.dwNum==0)
          {
            zObject::logger(srcobj->createid,srcobj->data.qwThisID,srcobj->data.strName,srcobj->data.dwNum,destobj->data.dwNum,0,0,NULL,this->id,this->name,"拆分删除",srcobj->base,srcobj->data.kind,srcobj->data.upgrade);
            packs.removeObject(srcobj,false,true);
          }
          else
          {
            zObject::logger(srcobj->createid,srcobj->data.qwThisID,srcobj->data.strName,srcobj->data.dwNum,destobj->data.dwNum,0,0,NULL,this->id,this->name,"被拆分",srcobj->base,srcobj->data.kind,srcobj->data.upgrade);
          }

        }

        return true;
      }
      break;
#if 0
    case UNIONUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stUnionObjectPropertyUserCmd *uobj=(Cmd::stUnionObjectPropertyUserCmd *)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(uobj->qwSrcThisID);
        zObject *destobj=packs.uom.getObjectByThisID(uobj->qwDstThisID);
        if (srcobj && destobj && srcobj->base->maxnum>1 &&
            srcobj->data.dwObjectID==destobj->data.dwObjectID &&
            srcobj->data.upgrade==destobj->data.upgrade /*&&
            srcobj->data.pos.dwLocation==Cmd::OBJECTCELLTYPE_MOUSE*/)
        {
          if (srcobj->data.dwNum+destobj->data.dwNum>srcobj->base->maxnum)
          {
            srcobj->data.dwNum=srcobj->data.dwNum+destobj->data.dwNum-srcobj->base->maxnum;
            destobj->data.dwNum=srcobj->base->maxnum;
          }
          else
          {
            destobj->data.dwNum+=srcobj->data.dwNum;
            srcobj->data.dwNum=0;
          }
          //交易处理
          if (destobj->data.pos.dwLocation==Cmd::OBJECTCELLTYPE_TRADE && tradeorder.hasBegin())
          {
            tradeorder.rollback();
            SceneUser *an=tradeorder.getAnother();
            if (an)
            {
              an->lock();
              an->tradeorder.rollback();
              Cmd::stRefCountObjectPropertyUserCmd ret;
              ret.qwThisID=destobj->data.qwThisID;
              ret.dwNum=destobj->data.dwNum;
              an->sendCmdToMe(&ret,sizeof(ret));
              an->unlock();
            }
          }

          //通知客户端
          Cmd::stRefCountObjectPropertyUserCmd ret;
          ret.qwThisID=destobj->data.qwThisID;
          ret.dwNum=destobj->data.dwNum;
          sendCmdToMe(&ret,sizeof(ret));
          if (srcobj->data.dwNum==0)
          {
            packs.rmObject(srcobj);
            Cmd::stRemoveObjectPropertyUserCmd rm;
            rm.qwThisID=srcobj->data.qwThisID;
            sendCmdToMe(&rm,sizeof(rm));
            SAFE_DELETE(srcobj);
          }
          else
          {
            ret.qwThisID=srcobj->data.qwThisID;
            ret.dwNum=srcobj->data.dwNum;
            sendCmdToMe(&ret,sizeof(ret));
          }
        }
        return true;
      }
      break;
#endif
    case USEUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stUseObjectPropertyUserCmd *use=(Cmd::stUseObjectPropertyUserCmd *)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(use->qwThisID);
        if (srcobj && srcobj->data.pos.loc() ==Cmd::OBJECTCELLTYPE_COMMON)
        {
          useObject(srcobj, use->preUseUserID);
        }
        return true;
      }
      break;
	case SET_COWBOX_KEY_PARAMETER:
	{
		//fprintf(stderr,"用户使用钥匙\n");
		Cmd::stSetCowBoxKeyCmd *use = (Cmd::stSetCowBoxKeyCmd*)rev;
		zObject *srcobj=packs.uom.getObjectByThisID(use->qwThisID);


			//if(use->qwThisID)

			Xlogger->error("key id = %u\n",use->qwThisID);
			fprintf(stderr,"key id = %u\n",use->qwThisID);


			if(srcobj == NULL)
			{
				return false;
				Xlogger->error("%s用户在使用钥匙的时候包裹中没有钥匙\n", this->name);
			}

			zObject* ob;
			if(use->Key_id == 964)
			{
				//寻找包裹中是否有金箱
				
				if(!packs.main.getObjectByID(&ob,962))
				{
					ob = packs.uom.getObjectByID(962,0,true);
					if(NULL == ob)
					{
						//fprintf(stderr,"包裹中找不到金箱\n");
						return false;
					}
				}
				//
			}
			else
			{
				if(!packs.main.getObjectByID(&ob,961))
				{
					ob = packs.uom.getObjectByID(961,0,true);
					if(NULL == ob)
					{
						//fprintf(stderr,"包裹中找不到银箱\n");
						return false;
					}
				}
			}

            
			if(NULL == ob)
				return false;
	
			if(--srcobj->data.dwNum)
				{
					Cmd::stRefCountObjectPropertyUserCmd send;
					send.qwThisID=srcobj->data.qwThisID;
					send.dwNum=srcobj->data.dwNum;
					sendCmdToMe(&send,sizeof(send));
				}
				else
				{
					packs.removeObject(srcobj);
				}

				if(--ob->data.dwNum)
				{
					Cmd::stRefCountObjectPropertyUserCmd send;
					send.qwThisID=ob->data.qwThisID;
					send.dwNum=ob->data.dwNum;
					sendCmdToMe(&send,sizeof(send));
					//fprintf(stderr,"钥匙count=%d\n",send.dwNum);
					//return true;
				}
				else
				{
					packs.removeObject(ob);
				}

				//fprintf(stderr,"钥匙,宝盒删除\n");
				return true;
			} 
		break;

    case Cmd::SCROLL_MAP_PROPERTY_USERCMD_PARA:
      {
        Cmd::stScrollMapPropertyUserCmd * smp = (Cmd::stScrollMapPropertyUserCmd*)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(smp->qwThisID);
        if (srcobj && (srcobj->base->id==675 || srcobj->base->id==676) && srcobj->data.pos.loc()==Cmd::OBJECTCELLTYPE_COMMON)
        {
          strncpy(srcobj->data.maker,smp->mapname[0].strMapName,MAX_NAMESIZE);
          useObject(srcobj);
        }
        else if (srcobj && srcobj->data.pos.loc()==Cmd::OBJECTCELLTYPE_EQUIP&&srcobj->base->kind == ItemType_Amulet)
        {
          strncpy(srcobj->data.maker,smp->mapname[0].strMapName,MAX_NAMESIZE);
          useAmulet(srcobj);
        }
        return true;
      }
      break;
      //请求增值地宫列表
    case Cmd::REQUEST_INC_MAP_PROPERTY_USERCMD_PARA:
      {
        zObject *obj = this->packs.equip.getObjectByEquipPos(Cmd::EQUIPCELLTYPE_ADORN);
        if (obj && obj->base->kind == ItemType_Amulet)
        {
          char buf[1024];
          bzero(buf,sizeof(buf));
          Cmd::stScrollMapPropertyUserCmd *smp = (Cmd::stScrollMapPropertyUserCmd*)buf;
          smp->qwThisID = obj->data.qwThisID;
          constructInPlace(smp);
          smp->size = this->scene->getIncCity((const char*)smp->mapname);
          sendCmdToMe(smp,sizeof(Cmd::stScrollMapPropertyUserCmd) + MAX_NAMESIZE * smp->size);        
        }
        return true;
      }
      break;
    case PICKUPITEM_PROPERTY_USERCMD_PARA:
      {
		  Cmd::stPickUpItemPropertyUserCmd *pick=(Cmd::stPickUpItemPropertyUserCmd *)rev;

		  TeamManager * teamMan = SceneManager::getInstance().GetMapTeam(TeamThisID);

		  zPos p;
		  zSceneObject *ret = NULL;
		  p.x=pick->x;
		  p.y=pick->y;
		  ret = scene->getSceneObjectByPos(p);
		  if (ret)
		  {
			  //int ok = 0;
			  zObject *o=ret->getObject();
			  if (!o)
			  {
				  return false;
			  }
			  //无主物品或者在没有组队情况下的物品
			  if ((o->base->id!=673 || o->base->id!=674) && (!ret->getOwner() || ret->getOwner() == this->id || (teamMan && teamMan->IsOurTeam(ret->getOwner()))))
			  {
				  //bool bret = false;
				  if (o->base->id==673)//玄天符
				  {
					  if (guard)
					  {
						  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你正在运镖,保护好你的镖车!");
						  return true;
					  }
					  if (o->data.maker[0]=='\0')
					  {
						  zPos newPos;
						  if (!this->scene->backtoCityMap())
						  {
							  //随机重生区坐标
							  if (!this->scene->randzPosByZoneType(ZoneTypeDef::ZONE_RELIVE,newPos)) return true;
							  if (!this->goTo(newPos)) return true;
						  }
						  else
						  {
							  //在其它地图中寻找城市
							  this->scene->changeMap(this,false);
						  }
					  }
					  else
					  {
						  zPos newPos;
						  newPos.x=o->data.durpoint;
						  newPos.y=o->data.dursecond;


						  SceneManager::CountryMap_iter country_iter = SceneManager::getInstance().country_info.find(scene->getCountryID());
						  if (country_iter == SceneManager::getInstance().country_info.end()) {
							  //unknow country
							  return true;
						  }


						  std::ostringstream os;
						  os << "name=" << o->data.maker;
						  os << " pos=" << o->data.durpoint << "," << o->data.dursecond;
						  Gm::gomap(this,os.str().c_str());
					  }
					  return true;
				  }
				  else if (o->base->id==674)//轩辕符
				  {
					  if (ret->getOwner() == this->id)
					  {
						  if (guard)
						  {
							  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你正在运镖,保护好你的镖车!");
							  return true;
						  }
						  if (o->data.maker[0]=='\0')
						  {
							  zPos newPos;
							  if (!this->scene->backtoCityMap())
							  {
								  //随机重生区坐标
								  if (!this->scene->randzPosByZoneType(ZoneTypeDef::ZONE_RELIVE,newPos)) return true;
								  if (!this->goTo(newPos)) return true;
							  }
							  else
							  {
								  //在其它地图中寻找城市
								  this->scene->changeMap(this,false);
							  }
						  }
						  else
						  {
							  zPos newPos;
							  newPos.x=o->data.durpoint;
							  newPos.y=o->data.dursecond;


							  SceneManager::CountryMap_iter country_iter = SceneManager::getInstance().country_info.find(scene->getCountryID());
							  if (country_iter == SceneManager::getInstance().country_info.end()) {
								  //unknow country
								  return true;
							  }


							  std::ostringstream os;
							  os << "name=" << o->data.maker;
							  os << " pos=" << o->data.durpoint << "," << o->data.dursecond;
							  Gm::gomap(this,os.str().c_str());
						  }
					  }
					  return true;
				  }
			  }

			  if (!ret->getOwner() || ret->getOwner() == this->id ||(teamMan->IsOurTeam(ret->getOwner()) && (teamMan && teamMan->isNormalObj())))
			  {
				  Combination callback(this,o);
				  packs.main.execEvery(callback);
				  if (packs.equip.pack(EquipPack::L_PACK) && packs.equip.pack(EquipPack::L_PACK)->can_input()) packs.equip.pack(EquipPack::L_PACK)->execEvery(callback);
				  if (packs.equip.pack(EquipPack::R_PACK) && packs.equip.pack(EquipPack::R_PACK)->can_input()) packs.equip.pack(EquipPack::R_PACK)->execEvery(callback);

				  bool added = false;
				  if (o->data.dwNum) {

					  if (this->packs.uom.space(this) >= 1 && packs.addObject(o,true,AUTO_PACK)) {
						  //如果是双倍经验道具和荣誉道具需要绑定
						  if (o->base->kind == ItemType_DoubleExp || o->base->kind == ItemType_Honor || o->base->kind == ItemType_ClearProperty)
						  {
							  o->data.bind=1;
						  }
						  added = true;
						  Cmd::stAddObjectPropertyUserCmd status;
						  status.byActionType = Cmd::EQUIPACTION_OBTAIN;
						  bcopy(&o->data,&status.object,sizeof(t_Object),sizeof(status.object));
						  sendCmdToMe(&status,sizeof(status));
					  }
					  else
					  {
						  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你的包裹已满");
						  Cmd::stAddMapObjectMapScreenUserCmd status;
						  status.action = Cmd::OBJECTACTION_DROP;
						  status.data.dwMapObjectTempID = o->data.qwThisID;
						  status.data.dwObjectID = o->data.dwObjectID;
						  strncpy(status.data.pstrName,o->data.strName,MAX_NAMESIZE);
						  status.data.x = p.x;
						  status.data.y = p.y;
						  status.data.wdNumber = o->data.dwNum;
						  status.data.wdLevel = o->base->level;
						  status.data.upgrade = o->data.upgrade;
						  status.data.kind = o->data.kind;
						  scene->sendCmdToNine(ret->getPosI(),&status,sizeof(status),this->dupIndex);  
					  }
				  }

				  if (callback.num() || added) {
					  OnGet event(o->data.dwObjectID);
					  EventTable::instance().execute(*this,event);
					  zObject::logger(o->createid,o->data.qwThisID,o->data.strName,o->data.dwNum,o->data.dwNum,1,this->scene->id,this->scene->name,this->id,this->name,"拣东西",o->base,o->data.kind,o->data.upgrade);
					  if (ScriptQuest::get_instance().has(ScriptQuest::OBJ_GET,o->data.dwObjectID)) { 
						  char func_name[32];
						  sprintf(func_name,"%s_%d","get",o->data.dwObjectID);
						  execute_script_event(this,func_name,o);
					  }                
					  /*
					  Xlogger->debug("%s(%u)捡到%s(%u)在(%u,%u)",
					  name,id,o->name,o->id,ret->getPos().x,ret->getPos().y);
					  // */
				  }

				  if (added) {
					  ret->clear();
				  }
				  if (!o->data.dwNum || added) {
					  scene->removeObject(ret);

					  Cmd::stRemoveMapObjectMapScreenUserCmd re;
					  re.dwMapObjectTempID=ret->id;
					  scene->sendCmdToNine(getPosI(),&re,sizeof(re),this->dupIndex);

					  SAFE_DELETE(ret);
				  }

				  return true;
				  // }
			  }
			  else
			  {
				  zObject *o=ret->getObject();
				  if (o && o->base->id!=673 && o->base->id!=674)//轩辕符
				  {
					  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"对不起,该物品不属于你");
				  }
			  }
		  }
	  }
	  break;

	  //sky 老的打造消息不在处理拉
    /*case FOUNDITEM_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().make(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::MAKE);
      }
      break;*/
    case UPGRADEITEM_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().upgrade(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::UPGRADE);
      }
      break;
    case COMPOSEITEM_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().compose(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::COMPOSE);
      }
      break;
    case COMPOSE_SOUL_STONE_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().compose_soul_stone(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::COMPOSE);
      }
      break;
    case HOLE_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().hole(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::HOLE);
      }
      break;
    case ENCHASEL_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().enchance(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::ENCHANCE);
      }
      break;
    case DECOMPOSE_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().decompose(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::DECOMPOSE);
      }
      break;


    //更新用户快捷键  
    case Cmd::ACCELKEY_PROPERTY_USERCMD_PARA:
      {
        Cmd::stAccekKeyPropertyUserCmd *acc = (Cmd::stAccekKeyPropertyUserCmd *)rev;
        int len = sizeof(Cmd::stAccekKeyPropertyUserCmd) + acc->accelNum * sizeof(Cmd::stGameAccelKey);
        if (acc->accelNum > 0 && len < 1024)
        {
          memcpy(accelData,rev,len,sizeof(accelData),sizeof(accelData));
        }
        else
        {
          bzero(accelData,sizeof(accelData));
        }
        //Xlogger->debug("(%s,%ld)更新用户快捷键成功",this->name,this->tempid);
        return true;
      }
      break;

    //添加用户技能数据
    case ADDUSERSKILL_PROPERTY_USERCMD_PARA:
      {
        if (!addSkillData((Cmd::stAddUserSkillPropertyUserCmd *)rev))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"不能再次学习已经学习到技能");
        }
        return true;
      }
      break;
    
    //删除用户技能
    case REMOVEUSERSKILL_PROPERTY_USERCMD_PARAMETER:
      {
        if (removeSkill((Cmd::stRemoveUserSkillPropertyUserCmd *)rev))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"删除技能失败");
        }
        return true;
      }
      break;

    //技能升级  
    case ADDSKILLPOINT_PROPERTY_USERCMD:
      {
        if (!upgradeSkill(((Cmd::stAddSkillPointPropertyUserCmd *)rev)->dwSkillID))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"不能升级该技能");
        }
        return true;
      }
      break;
    case SYSTEMSETTINGS_PROPERTY_USERCMD_PARA:
      {
		  Cmd::stSystemSettingsUserCmd *st = (Cmd::stSystemSettingsUserCmd *)rev;


		  //允许组队
		  if (isset_state(st->data.bySettings,Cmd::USER_SETTING_TEAM))
		  {
			  set_state(sysSetting,Cmd::USER_SETTING_TEAM);
			  setOpen(true);
		  }
		  else
		  {
			  clear_state(sysSetting,Cmd::USER_SETTING_TEAM);
			  setOpen(false);
		  }

		  bcopy(&st->data.bySettings[1],setting,sizeof(setting),sizeof(setting));
		  bcopy(st->data.dwChatColor,chatColor,sizeof(chatColor),sizeof(chatColor));


#ifdef _DEBUG
		  Xlogger->debug("收到系统设置消息:%x %x %x %x,%u %u %u %u %u %u %u %u",st->data.bySettings[0],st->data.bySettings[1],st->data.bySettings[2],st->data.bySettings[3],st->data.dwChatColor[0],st->data.dwChatColor[1],st->data.dwChatColor[2],st->data.dwChatColor[3],st->data.dwChatColor[4],st->data.dwChatColor[5],st->data.dwChatColor[6],st->data.dwChatColor[7]);
#endif

		  //通知session
		  Cmd::Session::t_sysSetting_SceneSession send;
		  bcopy(sysSetting,send.sysSetting,sizeof(send.sysSetting),sizeof(send.sysSetting));
		  strncpy((char *)send.name,name,MAX_NAMESIZE-1);
		  sessionClient->sendCmd(&send,sizeof(send));

		  //通知网关
		  Cmd::Scene::t_sysSetting_GateScene gate_send;
		  bcopy(sysSetting,gate_send.sysSetting,sizeof(gate_send.sysSetting),sizeof(gate_send.sysSetting));
		  gate_send.id=this->id;
		  this->gatetask->sendCmd(&gate_send,sizeof(gate_send));


		  return true;
	  }
	  break;
/*
    //分配五行点数
    case DISTRIBUTEUFIVEPOINT_PROPERTY_USERCMD_PARA:
      {
        Xlogger->debug("(%s,%ld)分配五行点数指令",this->name,this->tempid);
        Cmd::stDistributeFivePointPropertyUserCmd *dis = (Cmd::stDistributeFivePointPropertyUserCmd *)rev;
        if (IsJoin(dis->fiveType) && charbase.points > 0 || (charbase.five == dis->fiveType && charbase.points > 0))
        {
          charbase.fivevalue[dis->fiveType] ++;
          charstate.fivevalue[dis->fiveType] ++;
          int type = dis->fiveType;
        charstate.fivedefence[(type + 1) % 5] = 
          (WORD)sqrt(sqrt((charbase.fivevalue[type] * charbase.fivevalue[type] * charbase.fivevalue[type])));
          if (charbase.fivevalue[type] % 4 == 0)
          {
            type =(type + 3) % 5;
            if (charbase.fivevalue[type] > 0)
            {
              charbase.fivevalue[type] ++;
              charstate.fivevalue[type] ++;
              charstate.fivedefence[(type + 1) % 5] = 
                (WORD)sqrt(sqrt((charbase.fivevalue[type] * charbase.fivevalue[type] * charbase.fivevalue[type])));
              if (charbase.fivevalue[type] % 4 == 0)
              {
                type =(type + 3) % 5;
                charbase.fivevalue[type] ++;
                charstate.fivevalue[type] ++;
                charstate.fivedefence[(type + 1) % 5] = 
                  (WORD)sqrt(sqrt((charbase.fivevalue[type] * charbase.fivevalue[type] * charbase.fivevalue[type])));
              }
            }
          }
          charbase.points --;

          //装备改变攻击力预处理
          calPreValue();

          //刷新用户数据
          Cmd::stMainUserDataUserCmd  userinfo;
          full_t_MainUserData(userinfo.data);
          sendCmdToMe(&userinfo,sizeof(userinfo));
          break;
*/
    //分配属性点数
    case DISTRIBUTEUPOINT_PROPERTY_USERCMD_PARA:
      {
        if (charbase.points>0)
        {
          Cmd::stDistributePointPropertyUserCmd *dis = (Cmd::stDistributePointPropertyUserCmd *)rev;
          switch(dis->type)
          {
            case Cmd::PROPERTY_CON:  //体质
            case Cmd::PROPERTY_STR:  //体力
            case Cmd::PROPERTY_DEX:  //敏捷
            case Cmd::PROPERTY_INT:  //智力
            case Cmd::PROPERTY_MEN:  //精神
              {
                charbase.wdProperty[dis->type]++;
                charbase.points--;
                this->setupCharBase();
                //刷新用户数据
                Cmd::stMainUserDataUserCmd  userinfo;
                full_t_MainUserData(userinfo.data);
                sendCmdToMe(&userinfo,sizeof(userinfo));
              }
              break;
            default:
              {
              }
              break;
          }
        }
        return true;
      }
      break;
    case CLEARPOINT_PROPERTY_USERCMD_PARA:
      {
        Cmd::stClearPointPropertyUserCmd *cmd = (Cmd::stClearPointPropertyUserCmd*)rev;
        switch (cmd->dwItemID)
        {
          case 752:
            if (this->charbase.level<40)
            {
              if (this->reduceObjectNum(752,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
          case 760:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(760,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
          case 756:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(756,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
          default:
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
        }
        charbase.points =charbase.points
            +charbase.wdProperty[0]
            +charbase.wdProperty[1]
            +charbase.wdProperty[2]
            +charbase.wdProperty[3]
            +charbase.wdProperty[4];
        charbase.wdProperty[0]=0;
        charbase.wdProperty[1]=0;
        charbase.wdProperty[2]=0;
        charbase.wdProperty[3]=0;
        charbase.wdProperty[4]=0;
        this->setupCharBase();
        //刷新用户数据
        Cmd::stMainUserDataUserCmd  userinfo;
        full_t_MainUserData(userinfo.data);
        sendCmdToMe(&userinfo,sizeof(userinfo));
        Xlogger->info("角色[%s]使用洗属性点功能成功",this->name);
        return true;
      }
      break;
    case CLEARPOINT_LIMIT_PROPERTY_USERCMD_PARA:
      {
        Cmd::stClearPointLimitPropertyUserCmd *cmd = (Cmd::stClearPointLimitPropertyUserCmd*)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(cmd->qwThisID);
        if (srcobj && srcobj->data.pos.loc() ==Cmd::OBJECTCELLTYPE_COMMON)
        {
          if (srcobj->base->kind == ItemType_ClearProperty && srcobj->base->id == 755)
          {
            BYTE num = cmd->byProperty%5;
            if (charbase.wdProperty[num]>5)
            {
              charbase.points +=5;
              charbase.wdProperty[num]=charbase.wdProperty[num]-5;
            }
            else
            {
              charbase.points += charbase.wdProperty[num];
              charbase.wdProperty[num]=0;
            }
            this->setupCharBase();
            //刷新用户数据
            Cmd::stMainUserDataUserCmd  userinfo;
            full_t_MainUserData(userinfo.data);
            sendCmdToMe(&userinfo,sizeof(userinfo));

            zObject::logger(srcobj->createid,srcobj->data.qwThisID,srcobj->data.strName,srcobj->data.dwNum,srcobj->data.dwNum,0,this->id,this->name,0,NULL,"用洗5点属性宝石",NULL,0,0);
            Xlogger->info("角色[%s]使用洗5点属性功能成功",this->name);
            packs.removeObject(srcobj); //notify and delete
          }
        }
        return true;
      }
      break;
    case CLEARUSERSKILLPOINT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stClearUserSkillPointPropertyUserCmd *cmd = (Cmd::stClearUserSkillPointPropertyUserCmd*)rev;
        switch (cmd->dwItemID)
        {
          case 753:
            if (this->charbase.level<40)
            {
              if (this->reduceObjectNum(753,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
          case 761:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(761,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
          case 757:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(757,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
          default:
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
        }
        charbase.skillpoint = charbase.level;
        usm.clear();
        Cmd::stClearSkillUserCmd send;
        sendCmdToMe(&send,sizeof(send));
        skillValue.init();
        this->setupCharBase();
        //刷新用户数据
        Cmd::stMainUserDataUserCmd  userinfo;
        full_t_MainUserData(userinfo.data);
        sendCmdToMe(&userinfo,sizeof(userinfo));
        Xlogger->info("角色[%s]使用洗技能点功能成功",this->name);
        return true;
      }
      break;
    case BODYCOLOR_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stBodyColorPropertyUserCmd *bcp = (stBodyColorPropertyUserCmd*)rev;
        if ((bcp->dwBodyColorCustom != charbase.bodyColor) && packs.equip.canChangeColor())
        {
          DWORD cost = 1000;
/*
          zObject *gold=packs.getGold();          
          if (!gold)
          {
            Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
            return true;
          }

          if (cost > gold->data.dwNum)
          {
            Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
            return true;
          }
          gold->data.dwNum -= cost;
          if (gold->data.dwNum==0)
          {
            stRemoveObjectPropertyUserCmd rmgold;
            rmgold.qwThisID=gold->data.qwThisID;
            sendCmdToMe(&rmgold,sizeof(rmgold));
            packs.rmObject(gold);
            SAFE_DELETE(gold);
          }
          else
          {
            stRefCountObjectPropertyUserCmd setgold;
            setgold.qwThisID=gold->data.qwThisID;
            setgold.dwNum=gold->data.dwNum;
            sendCmdToMe(&setgold,sizeof(setgold));
          }
*/
          if (!packs.checkMoney(cost) || !packs.removeMoney(cost,"服装染色")) {
            Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
            return true;
          }
          Channel::sendMoney(this,Cmd::INFO_TYPE_GAME,cost,"服装染色成功,花费银子");
          if (packs.equip.equip(EquipPack::OTHERS3)  && ( packs.equip.equip(EquipPack::OTHERS3)->base->kind == ItemType_FashionBody || packs.equip.equip(EquipPack::OTHERS3)->base->kind == ItemType_HighFashionBody) )
          {
            packs.equip.equip(EquipPack::OTHERS3)->data.color = bcp->dwBodyColorCustom;
          }
          else if (packs.equip.equip(EquipPack::OTHERS2)  && ( packs.equip.equip(EquipPack::OTHERS2)->base->kind == ItemType_FashionBody || packs.equip.equip(EquipPack::OTHERS2)->base->kind == ItemType_HighFashionBody) )
          {
            packs.equip.equip(EquipPack::OTHERS2)->data.color = bcp->dwBodyColorCustom;
          }
          else if (packs.equip.equip(EquipPack::BODY)) 
          {
            packs.equip.equip(EquipPack::BODY)->data.color = bcp->dwBodyColorCustom;
          }
          else
          {
            charbase.bodyColor = bcp->dwBodyColorCustom;
          }
          //Cmd::stAddUserMapScreenUserCmd cmd;
          //full_t_MapUserData(cmd.data);
          //scene->sendCmdToNine(getPosI(),&cmd,sizeof(cmd),false);
          reSendMyMapData();
        }
        else
        {
          Xlogger->warn("用户(%u,%s,%u)更换不可更换颜色的衣服",id,name,tempid);
        }
        return true;
      }
      break;
    case FACE_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stFacePropertyUserCmd *fp = (stFacePropertyUserCmd*)rev;
        if (fp->dwFace == charbase.face)
        {
          return true;
        }
        DWORD cost=0;
        zHeadListB *base=headlistbm.get(fp->dwFace);
        if (base)
        {
          cost = base->cost;
        }
        else
        {
          return true;
        }
        if (!packs.checkMoney(cost) || !packs.removeMoney(cost,"更换头像")) {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        
        charbase.face = fp->dwFace;
        Channel::sendMoney(this,Cmd::INFO_TYPE_GAME,cost,"头像更换成功,花费银子");
        //Cmd::stAddUserMapScreenUserCmd cmd;
        //full_t_MapUserData(cmd.data);
        //scene->sendCmdToNine(getPosI(),&cmd,sizeof(cmd),false);
        reSendMyMapData();
        return true;
      }
      break;
    case HAIR_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stHairPropertyUserCmd *hp = (stHairPropertyUserCmd*)rev;
        if (hp->dwHairColor == charbase.hair && hp->byHairType == getHairType())
        {
          return true;
        }
        DWORD cost = 0;
        int isChange = 0;
        if (hp->byHairType != getHairType())
        {
          zHairStyleB *base=hairstylebm.get(hp->byHairType);
          if (base)
          {
            cost = base->cost;
            isChange = 1;
          }
          /*
          switch(hp->byHairType)
          {
            case HairStype_1:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_2:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_3:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_4:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_5:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_6:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            default:
              break;
          }
          // */
        }
        if ((hp->dwHairColor & 0X00FFFFFF) != getHairColor())
        {
          zHairColourB *base=haircolourbm.get(hp->dwHairColor & 0X00FFFFFF);
          if (base)
          {
            /// 如果不是光头换发色才需要银子
            if (hp->byHairType != 1)
            {
              cost += base->cost;
            }
            isChange = 2;
          }
          /*
          switch(hp->dwHairColor)
          {
            case HairColor_black:
              {
                isChange = 2;
                cost += 1000;
              }
              break;
            case HairColor_drink:
              {
                isChange = 2;
                cost += 2000;
              }
              break;
            case HairColor_purple:
              {
                isChange = 2;
                cost += 3000;
              }
              break;
          }
          // */
        }
/*
        zObject *gold=packs.getGold();
        if (!gold)
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        if (cost > gold->data.dwNum)
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        gold->data.dwNum -= cost;
        if (gold->data.dwNum==0)
        {
          stRemoveObjectPropertyUserCmd rmgold;
          rmgold.qwThisID=gold->data.qwThisID;
          sendCmdToMe(&rmgold,sizeof(rmgold));
          packs.rmObject(gold);
          SAFE_DELETE(gold);
        }
        else
        {
          stRefCountObjectPropertyUserCmd setgold;
          setgold.qwThisID=gold->data.qwThisID;
          setgold.dwNum=gold->data.dwNum;
          sendCmdToMe(&setgold,sizeof(setgold));
        }
*/
        if (!packs.checkMoney(cost) || !packs.removeMoney(cost,"美发")) {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        
        if (isChange)
        {
          Channel::sendMoney(this,Cmd::INFO_TYPE_GAME,cost,"美发成功,花费银子");
        }
        else
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"所选服务雷同,请选择其他服务");
        }
        setHairType(hp->byHairType);
        setHairColor(hp->dwHairColor);
        //Cmd::stAddUserMapScreenUserCmd cmd;
        //full_t_MapUserData(cmd.data);
        //scene->sendCmdToNine(getPosI(),&cmd,sizeof(cmd),false);
        reSendMyMapData();
        return true;
      }
      break;
	case SELECT_PROPERTY_USERCMD_PARA:
		{
			using namespace Cmd;
			stSelectPropertyUserCmd * spu = (stSelectPropertyUserCmd*)rev;
			//Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"收到选择指令");
			if (spu->dwOldTempID)
			{
				if (spu->byOldType == MAPDATATYPE_USER)
				{
					SceneUser *pDel = SceneUserManager::getMe().getUserByTempID(spu->dwOldTempID);
					if (pDel)
					{
						//pDel->selected_lock.lock();
						pDel->selected.erase(this->tempid);
						//pDel->selected_lock.unlock();
					}
				}
				else
				{
					SceneNpc *pDel = SceneNpcManager::getMe().getNpcByTempID(spu->dwOldTempID);
					if (pDel)
					{
						//pDel->selected_lock.lock();
						pDel->selected.erase(this->tempid);
						//pDel->selected_lock.unlock();
					}
				}
			}
			//如果目标为-1则表示不再选中别的对象
			if (spu->dwTempID == (DWORD)-1)
			{
				break;
			}
			switch(spu->byType)
			{
			case MAPDATATYPE_NPC:
				{
					SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(spu->dwTempID);
					if (pNpc)
					{
						//pNpc->selected_lock.lock();
						pNpc->selected.insert(SelectedSet_value_type(this->tempid));
						Cmd::stRTSelectedHpMpPropertyUserCmd ret;
						ret.byType = Cmd::MAPDATATYPE_NPC;
						ret.dwTempID = pNpc->tempid;//临时编号
						ret.dwHP = pNpc->hp;//当前血
						ret.dwMaxHp = pNpc->getMaxHP();//最大hp
						ret.dwMP = 0;//this->charbase.mp;//当前mp
						ret.dwMaxMp = 0;//this->charstate.maxmp;//最大mp
						//pNpc->selected_lock.unlock();
						this->sendCmdToMe(&ret,sizeof(ret));
						char Buf[200]; 
						bzero(Buf,sizeof(Buf));
						stSelectReturnStatesPropertyUserCmd *srs=(stSelectReturnStatesPropertyUserCmd*)Buf;
						constructInPlace(srs);
						srs->byType = MAPDATATYPE_NPC;
						srs->dwTempID = spu->dwTempID;
						pNpc->skillStatusM.getSelectStates(srs,sizeof(Buf));
						if (srs->size > 0)
						{
							this->sendCmdToMe(srs,sizeof(stSelectReturnStatesPropertyUserCmd) + 
								sizeof(srs->states[0]) * srs->size);
						}
					}
				}
				break;
			case MAPDATATYPE_USER:
				{
					using namespace Cmd;
					SceneUser *pUser = SceneUserManager::getMe().getUserByTempID(spu->dwTempID);
					if (pUser)
					{
						//Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"%s收到选择%s指令",this->name,pUser->name);
						//pUser->selected_lock.lock();
						pUser->selected.insert(SelectedSet_value_type(this->tempid));
						Cmd::stRTSelectedHpMpPropertyUserCmd ret;
						ret.byType = Cmd::MAPDATATYPE_USER;
						ret.dwTempID = pUser->tempid;//临时编号
						ret.dwHP = pUser->charbase.hp;//当前血
						ret.dwMaxHp = pUser->charstate.maxhp;//最大hp
						ret.dwMP = pUser->charbase.mp;//当前mp
						ret.dwMaxMp = pUser->charstate.maxmp;//最大mp
						//pUser->selected_lock.unlock();
						this->sendCmdToMe(&ret,sizeof(ret));
						char Buf[200]; 
						bzero(Buf,sizeof(Buf));
						stSelectReturnStatesPropertyUserCmd *srs=(stSelectReturnStatesPropertyUserCmd*)Buf;
						constructInPlace(srs);
						srs->byType = MAPDATATYPE_USER;
						srs->dwTempID = spu->dwTempID;
						pUser->skillStatusM.getSelectStates(srs,sizeof(Buf));
						if (srs->size > 0)
						{
							this->sendCmdToMe(srs,sizeof(stSelectReturnStatesPropertyUserCmd) + 
								sizeof(srs->states[0]) * srs->size);
						}
						//临时发送pk附加状态,等待以后策划修改^_^处理
						pUser->sendtoSelectedPkAdditionStateToUser(this);
						pUser->sendtoSelectedReliveWeakStateToUser(this);
						pUser->sendtoSelectedTrainStateToUser(this);
					}
				}
				break;
			default:
				break;
			}
		}
      break;
      //请求观察某个用户
    case SELECT_MAINUSER_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stSelectMainUserPropertyUserCmd *smu = (stSelectMainUserPropertyUserCmd*)rev;
        switch(smu->byType)
        {
          case MAPDATATYPE_USER:
            {
              SceneUser *pUser = SceneUserManager::getMe().getUserByTempID(smu->dwTempID);
              if (pUser)
              {
                if (!pUser->mask.is_masking())
                {
                  char Buf[sizeof(stSelectReturnMainUserPropertyUserCmd) + sizeof(EquipedObject) * 16];
                  bzero(Buf,sizeof(Buf));
                  stSelectReturnMainUserPropertyUserCmd *srm = (stSelectReturnMainUserPropertyUserCmd*)Buf;
                  constructInPlace(srm);
                  srm->dwTempID = pUser->tempid;
                  pUser->full_t_MainUserData(srm->mainuser_data);
                  pUser->full_t_MapUserData(srm->mapuser_data);
                
                  srm->dwSize = pUser->packs.equip.fullAllEquiped((char*)srm->object_data);
                  this->sendCmdToMe(srm,sizeof(stSelectReturnMainUserPropertyUserCmd) 
                      + sizeof(EquipedObject) * srm->dwSize);

                  if (pUser->horse.horse())
                  {
                      stSelectReturnHorsePropertyUserCmd send;
                      pUser->horse.full_HorseDataStruct(&send.data);
                      sendCmdToMe(&send,sizeof(send));
                  }
                }
                else
                {
                  Channel::sendSys(this,Cmd::INFO_TYPE_MSG,"他是蒙面人无法观察");
                }
              }
            }
            break;
          case MAPDATATYPE_NPC:
            {
            }
            break;
          default:
            break;
        }
      }
      break;
    case HONOR_TO_PKVALUE_PROPERTY_USERCMD_PARA:
      {
        short good = this->charbase.goodness & 0x0000FFFF;
        short old_good = good;
        DWORD old_honor = this->charbase.honor;
        if (good > 0 && good < (short)Cmd::GOODNESS_7 && this->charbase.honor > 0)
        {
          if (good <= (short)(this->charbase.honor / 5))
          {
            this->charbase.honor -= good * 5;
            good = 0;
          }
          else
          {
            good -= (short)(this->charbase.honor / 5);
            this->charbase.honor = this->charbase.honor % 5;
          }
          this->charbase.goodness = this->charbase.goodness & 0XFFFF0000 + good;
          Cmd::stMainUserDataUserCmd  userinfo;
          full_t_MainUserData(userinfo.data);
          sendCmdToMe(&userinfo,sizeof(userinfo));
          reSendMyMapData();
          zObject::logger(0,0,"荣誉值",this->charbase.honor,old_honor - this->charbase.honor,0,this->id,this->name,0,NULL,"洗PK值扣除荣誉值",NULL,0,0);
          return Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"你用%u荣誉点缩短了%u分钟的罪恶时间",old_honor - this->charbase.honor,old_good - good);
        }
        return true;
      }
      break;
    case GO_TRAIN_PROPERTY_USERCMD_PARA:
      {
        if ((privatestore.step() != PrivateStore::NONE) || tradeorder.hasBegin())//正在交易
          return true;

        Cmd::stGoTrainPropertyUserCmd * cmd = (Cmd::stGoTrainPropertyUserCmd *)rev;

        char mname[MAX_NAMESIZE];
        bzero(mname,MAX_NAMESIZE);
        DWORD mid = 192+cmd->level;
        SceneManager::getInstance().buildMapName(6,mid,mname);
        zPos p;
        switch (cmd->level)
        {
          case 1:
            p = zPos(172,265);
            break;
          case 2:
            p = zPos(257,144);
            break;
          case 3:
            p = zPos(34,188);
            break;
          case 4:
            p = zPos(139,270);
            break;
          case 5:
            p = zPos(69,192);
            break;
          case 6:
            p = zPos(217,208);
            break;
          case 7:
            p = zPos(245,200);
            break;
          case 8:
            p = zPos(78,187);
            break;
          case 9:
            p = zPos(107,204);
            break;
          default:
            Xlogger->error("%s 进入修炼地图层数不对 level=%u",name,cmd->level);
            return true;
            break;
        }

        zObject * o = 0;
        if (!packs.main.getObjectByID(&o,798))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你缺少一件必要的道具");
          return true;
        }

        packs.removeObject(o,true,true);
        charbase.trainTime = 86399;
        sendtoSelectedTrainState();

        Scene * s=SceneManager::getInstance().getSceneByName(mname);
        if (s)
        {
          if (changeMap(s,p))
            Xlogger->info("%s 进入练级地图 %s(%u,%u)",name,s->name,getPos().x,getPos().y);
          else
            Xlogger->info("%s 进入练级地图失败 %s(%u,%u)",name,s->name,p.x,p.y);
        }
        else
        {       
          Cmd::Session::t_changeScene_SceneSession cmd;
          cmd.id = id;
          cmd.temp_id = tempid;
          cmd.x = p.x;
          cmd.y = p.y;
          cmd.map_id = 0; 
          cmd.map_file[0] = '\0';
          strncpy((char *)cmd.map_name,mname,MAX_NAMESIZE);
          sessionClient->sendCmd(&cmd,sizeof(cmd));
        }
      }
      break;
    default:
      break;
  }
//  Xlogger->debug("SceneUser::doPropertyCmd\tparam:%d",rev->byParam);
  return false;
}
コード例 #7
0
ファイル: Rush.cpp プロジェクト: adan830/gameserver-2
/**
 * \brief 处理进入阶段的事件
 * 恢复、召唤、开关、说话等动作在阶段开始时发生
 * 这些动作是瞬间的,如果阶段持续时间不为0,则在余下的时间内boss做普通攻击
 *
 */
void Rush::enterNextPhase()
{
  if (!end && curPhase<phaseVector.size()-1)
  {
    curPhase++;
    Xlogger->debug("%s : 阶段%d",rushName,curPhase);
    setPhaseTime(phaseVector[curPhase].lasttime*1000);
    if (strcmp(phaseVector[curPhase].say,""))
      Channel::sendNine(boss,phaseVector[curPhase].say);

    //按照脚本来动作
    if (boss->AIC->isActive()
        && phaseVector[curPhase].action!=RUSH_SUMMON_PET
        && phaseVector[curPhase].action!=RUSH_SUMMON_RUSH
        && phaseVector[curPhase].action!=RUSH_END)
      return;

    switch (phaseVector[curPhase].action)
    {
      case RUSH_RELIVE:
        break;
      case RUSH_MOVETO:
        {
          t_NpcAIDefine d(NPC_AI_PATROL,phaseVector[curPhase].pos,phaseVector[curPhase].region,phaseVector[curPhase].region,phaseVector[curPhase].lasttime);
          boss->AIC->setAI(d);
        }
        break;
      case RUSH_ATTACK:
        {
          t_NpcAIDefine d(NPC_AI_ATTACK,phaseVector[curPhase].pos,phaseVector[curPhase].region,phaseVector[curPhase].region,phaseVector[curPhase].lasttime);
          boss->AIC->setAI(d);
        }
        break;
      case RUSH_RECOVER:
        {
          boss->hp = boss->getMaxHP();
          //boss->AIC->setNormalAI();
        }
        break;
      case RUSH_SUMMON:
        {
          summonServant();
          //boss->AIC->setNormalAI();
        }
        break;
      case RUSH_BROADCAST:
        {
          Channel::sendCountryInfo(countryID,Cmd::CHAT_TYPE_GM,phaseVector[curPhase].say);
        }
        break;
      case RUSH_SUMMON_RUSH:
        {
          zNpcB *base = npcbm.get(phaseVector[curPhase].x);

          if (base)
          {
            t_NpcDefine define;
            zPos pos = phaseVector[curPhase].pos;
            define.id = base->id;
            strncpy(define.name,base->name,MAX_NAMESIZE-1);
            define.pos = phaseVector[curPhase].pos;
            define.num = 1;
            define.interval = 0x0fffffff;
            define.initstate = zSceneEntry::SceneEntry_Normal;
            define.width = phaseVector[curPhase].region;
            define.height = phaseVector[curPhase].region;
            define.pos -= zPos(phaseVector[curPhase].region/2,phaseVector[curPhase].region/2);
            define.scriptID = phaseVector[curPhase].z;

            Scene * scene = SceneManager::getInstance().getSceneByName(mapName);
            if (!scene)
            {
              Xlogger->debug("召唤攻城servant时,未找到该地图 name=%s",mapName);
              return;
            }
            scene->initRegion(define.region,define.pos,define.width,define.height);

            for (DWORD i=0; i<phaseVector[curPhase].y; i++)
            {
              SceneNpc * servant = scene->summonOneNpc<SceneNpc>(define,zPos(0,0),base,0,0,0);
              //summonCount++;
              if (servant)
              {
                servant->aif |= AIF_ACTIVE_MODE;
                servant->isRushNpc = true;
                servants.push_back(servant);
#ifdef _DEBUG
                Xlogger->debug("[怪物攻城]%s (%u,%u)",servant->name,servant->getPos().x,servant->getPos().y);
#endif
              }
            }
          }
          //boss->AIC->setNormalAI();
        }
        break;
      case RUSH_SUMMON_PET:
        {
          summonPet();
        }
        break;
      case RUSH_SUMMON_ON:
        {
          canSummon = true;
          //boss->AIC->setNormalAI();
        }
        break;
      case RUSH_SUMMON_OFF:
        {
          canSummon = false;
          //boss->AIC->setNormalAI();
        }
        break;
      case RUSH_CLEAR:
        {
          //boss->AIC->setNormalAI();
        }
        break;
      case RUSH_END:
        {
          setPhaseTime(clearDelay*1000);
          //boss->AIC->setNormalAI();
        }
        break;
      default:
        break;
    }
  }
#if 0
  else
    Xlogger->debug("%s : 攻城结束",rushName);
#endif
}
コード例 #8
0
/**
 * \brief 执行挑战指令
 *
 *
 * \param rev 挑战指令
 * \param cmdLen 消息长度
 * \return 是否成功
 */
bool SceneUser::doNpcDareCmd(const Cmd::stDareUserCmd *rev,DWORD cmdLen)
{
#ifdef _DEBUG
       Zebra::logger->debug("doNpcDareCmd处理[%d]号消息",rev->byParam);
#endif 
  switch (rev->byParam)
  {
    case Cmd::QUESTION_NPCDARE_INFO_PARA:
      {
        Cmd::Session::t_questionNpcDare_SceneSession send;
        Cmd::stQuestionNpcDareInfo* ptCmd = (Cmd::stQuestionNpcDareInfo*)rev;
          
        send.dwUserID = this->id;
        send.dwCountryID = this->scene->getCountryID();
        send.dwMapID = this->scene->getRealMapID();
        send.dwNpcID = ptCmd->dwNpcID;
        send.byType = ptCmd->byType;
        sessionClient->sendCmd(&send,sizeof(send));
        return true;
      }
      break;
    case Cmd::NPCDARE_DARE_PARA:
      {
        Cmd::stDareNpcDare * pCmd = (Cmd::stDareNpcDare *) rev;
        SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(pCmd->dwNpcID);
        if (pNpc)
        {
          if (scene->checkTwoPosIInNine(getPosI(),pNpc->getPosI()))
          {
            if (scene->getCountryID() == this->charbase.country)
            {
              if (this->charbase.septid !=0)
              {
                /*
                NpcDareObjectCompare found;
                found.dwObjectID = CREATE_NPCDARE_NEED_ITEM;
                zObject *itemobj = packs.uom.getObject(found);// 查找道具
                if (itemobj)
                {
                  packs.removeObject(itemobj); //notify and delete
                  Cmd::Session::t_NpcDare_Dare_SceneSession send;

                  send.dwCountryID = scene->getCountryID();
                  send.dwMapID = scene->getRealMapID();
                  send.dwNpcID = pNpc->npc->id;
                  send.dwUserID = this->id;
                  sessionClient->sendCmd(&send,sizeof(send));
                  return true;
                }
                else
                {
                  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"缺少挑战发起道具!");
                }
                */
                if (this->packs.checkMoney(4000))
                {
                  Cmd::Session::t_NpcDare_Dare_SceneSession send;

                  send.dwCountryID = scene->getCountryID();
                  send.dwMapID = scene->getRealMapID();
                  send.dwNpcID = pNpc->npc->id;
                  send.dwUserID = this->id;
                  sessionClient->sendCmd(&send,sizeof(send));
                  return true;
                }
                else
                {
                  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"缺少足够的钱来发起挑战!");
                }
              }
              else
              {
                Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你还没有家族不能发起挑战!");
              }
            }
            else
            {
              Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"不在自己国家无法发起挑战!");
            }
          }
          else
          {
            Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"距离太远,无法对话!");
          }
        }
        return true;
      }
      break;
    case Cmd::NPCDARE_GETGOLD_PARA:
      {
        Cmd::stDareNpcDare * pCmd = (Cmd::stDareNpcDare *) rev;
        Cmd::Session::t_NpcDare_GetGold_SceneSession send;
        send.dwUserID = this->id;
        send.dwNpcID = pCmd->dwNpcID;
        send.dwCountryID = this->scene->getCountryID();
        send.dwMapID = this->scene->getRealMapID();
        sessionClient->sendCmd(&send,sizeof(send));

        return true;
      }
      break;
    default:
      break;
  }
  return false;
}