コード例 #1
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;
}
コード例 #2
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;
}