int NFCLoginLogicModule::OnLoginEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (3 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } ////////////////////////////////////////////////////////////////////////// const NFIDENTID xIdent = var.Object(0); const std::string& strAccount = var.String(1); const std::string& strPassword = var.String(2); int64_t nState = -1; std::vector<std::string> xFieldVec; std::vector<std::string> xValueVec; xFieldVec.push_back("Password"); if (m_pClusterSqlModule->Query("AccountInfo", strAccount, xFieldVec, xValueVec) && xFieldVec.size() == xValueVec.size() && strPassword == xValueVec[0]) { //µÇ¼³É¹¦ nState = 0; } NFCDataList valEventInfo; valEventInfo << nState << xIdent << strAccount; m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_LOGIN_RESULTS, valEventInfo); return 0; }
int NFCLoginNet_ServerModule::OnSelectWorldResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (7 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } const int nWorldID = var.Int(0); const NFIDENTID xClientIdent = var.Object(1); const int nLoginID = var.Int(2); const std::string& strAccount = var.String(3); const std::string& strWorldAddress = var.String(4); int nPort = var.Int(5); const std::string& strWorldKey = var.String(6); NF_SHARE_PTR<int> xFD = mxClientIdent.GetElement(xClientIdent); if (xFD) { NFMsg::AckConnectWorldResult xMsg; xMsg.set_world_id(nWorldID); xMsg.mutable_sender()->CopyFrom(NFToPB(xClientIdent)); xMsg.set_login_id(nLoginID); xMsg.set_account(strAccount); xMsg.set_world_ip(strWorldAddress); xMsg.set_world_port(nPort); xMsg.set_world_key(strWorldKey); SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_CONNECT_WORLD, xMsg, *xFD); } return 0; }
int NFCWorldToMasterModule::OnSelectServerResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (var.GetCount() != 7 || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } const int nWorldID = var.Int(0); const NFIDENTID xClientIdent = var.Object(1); const int nLoginID = var.Int(2); const std::string& strAccount = var.String(3); const std::string& strWorldAddress = var.String(4); const int nPort = var.Int(5); const std::string& strKey = var.String(6); NFMsg::AckConnectWorldResult xMsg; xMsg.set_world_id(nWorldID); xMsg.set_login_id(nLoginID); xMsg.set_world_port(nPort); xMsg.mutable_sender()->CopyFrom(NFINetModule::NFToPB(xClientIdent)); xMsg.set_account(strAccount); xMsg.set_world_ip(strWorldAddress); xMsg.set_world_key(strKey); SendSuitByPB(NFMsg::EGMI_ACK_CONNECT_WORLD, xMsg); return 0; }
int NFCGameScene::OnPlayerMoveEvent(const int nEventID, const NFIDataList& varDataList) { const NFGUID &self = varDataList.Object(0); Sprite *pPlayer = m_Players.GetElement(self); const NFVector3 &toPos = varDataList.Vector3(2); pPlayer->stopAllActions(); pPlayer->runAction(CCMoveTo::create(1.0f, Vec2(toPos.X(), toPos.Y()))); return 0; }
int NFCGameScene::OnPlayerChatEvent(const int nEventID, const NFIDataList& varDataList) { const NFGUID &self = varDataList.Object(0); Sprite *pPlayer = m_Players.GetElement(self); auto pChat = ui::Text::create(varDataList.String(3), "", 16); pChat->setAnchorPoint(Vec2(0.5, 0)); pChat->setPosition(Vec2(pPlayer->getAnchorPointInPoints().x, pPlayer->getContentSize().height+ pChat->getContentSize().height)); pPlayer->addChild(pChat); pChat->runAction(Sequence::create(FadeIn::create(0.5), DelayTime::create(5.0f), FadeIn::create(0.5), RemoveSelf::create(), NULL)); pChat->runAction(MoveBy::create(0.5, Vec2(0, pChat->getContentSize().height))); return 0; }
int NFCLoginNet_ServerModule::OnLoginResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var) { if (3 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } const int nState = var.Int(0); const NFIDENTID xIdent = var.Object(1); const std::string& strAccount = var.String(2); NF_SHARE_PTR<int> xFD = mxClientIdent.GetElement(xIdent); if (xFD) { if (0 != nState) { //此帐号密码错误或者被封号 //登录失败 NFMsg::AckEventResult xMsg; xMsg.set_event_code(NFMsg::EGEC_ACCOUNTPWD_INVALID); SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_LOGIN, xMsg, *xFD); return 0; } NetObject* pNetObject = GetNet()->GetNetObject(*xFD); if (pNetObject) { //记录他登录过 pNetObject->SetConnectKeyState(1); pNetObject->SetAccount(strAccount); } //把服务器列表广播下去 NFMsg::AckEventResult xData; xData.set_event_code(NFMsg::EGEC_ACCOUNT_SUCCESS); SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_LOGIN, xData, *xFD); //SynWorldToClient(unAddress); m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, *xFD), "Login successed :", strAccount.c_str()); } return 0; }
int NFCItemModule::OnRequireUseItemEvent( const NFGUID& self, const int nEventID, const NFIDataList& var ) { if (var.GetCount() != 2 || !var.TypeEx(TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } //EGameErrorCode errorCode = EGameErrorCode::EGEC_INVALID_ITEM; const std::string& strItemID = var.String(0); const NFGUID xTargetID = var.Object(0); if(!m_pElementInfoModule->ExistElement(strItemID) || !m_pKernelModule->GetObject(xTargetID)) { return 0; } NF_SHARE_PTR<NFIRecord> pRecordPack = m_pKernelModule->FindRecord(self, NFrame::Player::R_BagItemList()); if (nullptr != pRecordPack) { // const bool bRet = m_pPackModule->DeleteItem(self, strItemID, 1); // if (bRet) // { // int nItemType = m_pElementInfoModule->GetPropertyInt(strItemID, "ItemType"); // NFIItemConsumeProcessModule* pConsumeProcessModule = m_pItemConsumeManagerModule->GetConsumeModule(nItemType); // if (pConsumeProcessModule) // { // if (pConsumeProcessModule->ConsumeLegal(self, strItemID, xTargetID) > 0) // { // pConsumeProcessModule->ConsumeProcess(self, strItemID, xTargetID); // // return 0; // } // } // } } return 0; }
int NFCRecord::FindRowByColValue(const int nCol, const NFIDataList& var, NFIDataList& varResult) { if (!ValidCol(nCol)) { return -1; } TDATA_TYPE eType = var.Type(0); if (eType != mVarRecordType->Type(nCol)) { return -1; } switch (eType) { case TDATA_INT: return FindInt(nCol, var.Int(nCol), varResult); break; case TDATA_FLOAT: return FindFloat(nCol, var.Float(nCol), varResult); break; case TDATA_STRING: return FindString(nCol, var.String(nCol).c_str(), varResult); break; case TDATA_OBJECT: return FindObject(nCol, var.Object(nCol), varResult); break; default: break; } return -1; }
int NFCBriefSkillConsumeProcessModule::ConsumeProcess( const NFGUID& self, const std::string& strSkillName, const NFIDataList& other, NFIDataList& damageListValue, NFIDataList& damageResultList ) { NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementModule->GetPropertyManager( strSkillName ); if ( pPropertyManager == NULL ) { return 1; } // NFIProperty* pSkillDamageProperty = pPropertyManager->GetElement( "DamageProperty" ); // NFIProperty* pSkillDamageValue = pPropertyManager->GetElement( "DamageValue" ); // NFIProperty* pSkillDamageType = pPropertyManager->GetElement( "DamageType" ); // NFIProperty* pSkillDamageSubType = pPropertyManager->GetElement( "DamageSubType" ); // if ( pSkillDamageProperty == NULL || pSkillDamageValue == NULL || pSkillDamageType == NULL || pSkillDamageSubType == NULL ) // { // return 1; // } // // int nDamageType = pSkillDamageType->QueryInt(); // int nDamageSubType = pSkillDamageSubType->QueryInt(); // NFCDataList valueEffectProperty( pSkillDamageProperty->QueryString().c_str(), "," ); // NFCDataList valueEffectValue( pSkillDamageValue->QueryString().c_str(), "," ); // // if ( valueEffectProperty.GetCount() != valueEffectValue.GetCount() ) // { // return 1; // } //for ( int i = 0; i < valueEffectProperty.GetCount(); i++ ) { //先测定目标是否有此属性(其实是担心配错了) for ( int j = 0; j < other.GetCount(); j++ ) { NFGUID identOther = other.Object( j ); if ( identOther.IsNull() ) { continue; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( identOther ); if ( pObject == NULL ) { continue; } //短刀伤害,只能是HP,MP之类的有最大上限值的属性 // std::string strCurProperty = valueEffectProperty.StringVal( i ); // std::string strMaxProperty = "MAX" + strCurProperty; // NFIProperty* pOtherCurProperty = pObject->GetPropertyManager()->GetElement( strCurProperty ); // NFIProperty* pOtherMaxProperty = pObject->GetPropertyManager()->GetElement( strMaxProperty ); // if ( pOtherCurProperty == NULL || pOtherMaxProperty == NULL ) // { // continue; // } NF_SHARE_PTR<NFIProperty> pLastProperty = pObject->GetPropertyManager()->GetElement( "LastAttacker" ); if ( pLastProperty ) { pLastProperty->SetObject( self ); } } } //m_pKernelModule->LogErrorItem(strSkillName.c_str(), ""); return 0; }
bool NFCPVPMatchModule::TeamApplyPVP(const NFGUID& xTeam, const NFIDataList& varMemberList, int nPVPMode, const int nScore) { int nMemberCount = varMemberList.GetCount(); std::vector<NFGUID> xPlayerList; for (int i = 0; i < varMemberList.GetCount(); i++) { const NFGUID& xPlayerID = varMemberList.Object(i); if (xPlayerID.IsNull()) { return false; } xPlayerList.push_back(xPlayerID); } int nGrade = GetGradeByScore(nScore); int nPVPModeMaxMember = GetMemberCount(nPVPMode); if (nPVPModeMaxMember < 0) { return false; } if (nMemberCount > nPVPModeMaxMember) { return false; } NFGUID xFindRoomID; int bRed = EPVPREDORBLUE_RED; std::vector<NFGUID> xRoomIDList; if (m_pPVPMatchRedisModule->GetStatusRoomID(nPVPMode, nGrade, EPVPROOMSTATUS_WAIT, xRoomIDList)) { for (int i = 0; i < xRoomIDList.size(); i++) { const NFGUID& xRoomID = xRoomIDList[i]; NFMsg::PVPRoomInfo xRoomInfo; if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo)) { if ((xRoomInfo.xredplayer_size() + nMemberCount) < xRoomInfo.maxpalyer()) { xFindRoomID = xRoomID; bRed = EPVPREDORBLUE_RED; break; } else if ((xRoomInfo.xblueplayer_size() + nMemberCount) < xRoomInfo.maxpalyer()) { xFindRoomID = xRoomID; bRed = EPVPREDORBLUE_BULE; break; } } } } if (xFindRoomID.IsNull()) { xFindRoomID = CreateRoom(NFGUID(), nPVPMode, nGrade); if (xFindRoomID.IsNull()) { return false; } m_pPVPMatchRedisModule->SetStatusRoomID(nPVPMode, nGrade, EPVPROOMSTATUS_WAIT, xFindRoomID); } return PlayerListEnterRoom(xPlayerList, bRed, xFindRoomID); }
int NFCSceneProcessModule::OnEnterSceneEvent( const NFIDENTID& self, const int nEventID, const NFIDataList& var ) { if ( var.GetCount() != 4 || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } NFIDENTID ident = var.Object( 0 ); int nType = var.Int( 1 ); int nTargetScene = var.Int( 2 ); int nTargetGroupID = var.Int( 3 ); int nOldSceneID = m_pKernelModule->GetPropertyInt( self, "SceneID" ); char szSceneID[MAX_PATH] = {0}; sprintf(szSceneID, "%d", nTargetScene); #ifdef NF_USE_ACTOR int nActorID = m_pElementInfoModule->GetPropertyInt(szSceneID, "ActorID"); int nSelfActorID = pPluginManager->GetActorID(); if (nSelfActorID != nActorID) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "target scene not runing in this server", nTargetScene); return 1; #endif if ( self != ident ) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "you are not you self, but you want to entry this scene", nTargetScene); return 1; } const int nNowContainerID = m_pKernelModule->GetPropertyInt(self, "SceneID"); const int nNowGroupID = m_pKernelModule->GetPropertyInt(self, "GroupID"); if (nNowContainerID == nTargetScene && nNowGroupID == nTargetGroupID) { //本来就是这个层这个场景就别切换了 m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "in same scene and group but it not a clone scene", nTargetScene); return 1; } nTargetGroupID = CreateCloneScene( nTargetScene, nTargetGroupID, "File.xml", NFCDataList() ); if ( nTargetGroupID <= 0 ) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "CreateCloneScene failed", nTargetScene); return 0; } //得到坐标 float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; const std::string& strRelivePosList = m_pElementInfoModule->GetPropertyString(szSceneID, "RelivePos"); NFCDataList valueRelivePosList( strRelivePosList.c_str(), ";" ); if ( valueRelivePosList.GetCount() >= 1 ) { NFCDataList valueRelivePos( valueRelivePosList.String( 0 ).c_str(), "," ); if ( valueRelivePos.GetCount() == 3 ) { fX = boost::lexical_cast<float>( valueRelivePos.String( 0 ) ); fY = boost::lexical_cast<float>( valueRelivePos.String( 1 ) ); fZ = boost::lexical_cast<float>( valueRelivePos.String( 2 ) ); } } NFCDataList xSceneResult( var ); xSceneResult.Add( fX ); xSceneResult.Add( fY ); xSceneResult.Add( fZ ); m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_BEFORE, xSceneResult ); if(!m_pKernelModule->SwitchScene( self, nTargetScene, nTargetGroupID, fX, fY, fZ, 0.0f, var )) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "SwitchScene failed", nTargetScene); return 0; } xSceneResult.Set(3, NFINT64(nTargetGroupID));//spicial m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_RESULT, xSceneResult ); return 0; } int NFCSceneProcessModule::OnLeaveSceneEvent( const NFIDENTID& object, const int nEventID, const NFIDataList& var ) { if (1 != var.GetCount() || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN)) { return -1; } NFINT32 nOldGroupID = var.Int(0); NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(object); if (pObject.get() && nOldGroupID > 0) { int nContainerID = pObject->GetPropertyInt("SceneID"); if (GetCloneSceneType(nContainerID) == SCENE_TYPE_MAINLINE_CLONE) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, object, "DestroyCloneSceneGroup", nOldGroupID); DestroyCloneScene(nContainerID, nOldGroupID, var); } } return 0; } int NFCSceneProcessModule::OnObjectClassEvent( const NFIDENTID& self, const std::string& strClassName, const CLASS_OBJECT_EVENT eClassEvent, const NFIDataList& var ) { if ( strClassName == "Player" ) { if ( CLASS_OBJECT_EVENT::COE_DESTROY == eClassEvent ) { //如果在副本中,则删除他的那个副本 int nContainerID = m_pKernelModule->GetPropertyInt(self, "SceneID"); if (GetCloneSceneType(nContainerID) == SCENE_TYPE_MAINLINE_CLONE) { int nGroupID = m_pKernelModule->GetPropertyInt(self, "GroupID"); m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, self, "DestroyCloneSceneGroup", nGroupID); DestroyCloneScene(nContainerID, nGroupID, NFCDataList()); } } else if ( CLASS_OBJECT_EVENT::COE_CREATE_HASDATA == eClassEvent ) { m_pEventProcessModule->AddEventCallBack( self, NFED_ON_CLIENT_ENTER_SCENE, this, &NFCSceneProcessModule::OnEnterSceneEvent ); m_pEventProcessModule->AddEventCallBack( self, NFED_ON_CLIENT_LEAVE_SCENE, this, &NFCSceneProcessModule::OnLeaveSceneEvent ); } } return 0; } E_SCENE_TYPE NFCSceneProcessModule::GetCloneSceneType( const int nContainerID ) { char szSceneIDName[MAX_PATH] = { 0 }; sprintf( szSceneIDName, "%d", nContainerID ); if (m_pElementInfoModule->ExistElement(szSceneIDName)) { return (E_SCENE_TYPE)m_pElementInfoModule->GetPropertyInt(szSceneIDName, "SceneType"); } return SCENE_TYPE_ERROR; }
int NFCPotionItemConsumeProcessModule::ConsumeProcess( const NFIDENTID& self, const std::string& strItemName, const NFIDataList& other ) { //附加效果 NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementInfoModule->GetPropertyManager( strItemName ); if ( pPropertyManager ) { NF_SHARE_PTR<NFIProperty> pItemEffectProperty = pPropertyManager->GetElement( "EffectProperty" ); NF_SHARE_PTR<NFIProperty> pItemEffectValue = pPropertyManager->GetElement( "EffectValue" ); if ( pItemEffectProperty && pItemEffectValue ) { NFCDataList valueEffectProperty( pItemEffectProperty->GetString().c_str(), "," ); NFCDataList valueEffectValue( pItemEffectValue->GetString().c_str(), "," ); if ( valueEffectProperty.GetCount() == valueEffectValue.GetCount() ) { for ( int i = 0; i < valueEffectProperty.GetCount(); i++ ) { //先测定目标是否有此属性(其实是担心配错了) for ( int j = 0; j < other.GetCount(); j++ ) { NFIDENTID identOther = other.Object( j ); if ( !identOther.IsNull() ) { NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( identOther ); if ( pObject ) { std::string strCurProperty = valueEffectProperty.String( i ); std::string strMaxProperty = "MAX" + strCurProperty; NF_SHARE_PTR<NFIProperty> pOtherCurProperty = pObject->GetPropertyManager()->GetElement( strCurProperty ); NF_SHARE_PTR<NFIProperty> pOtherMaxProperty = pObject->GetPropertyManager()->GetElement( strMaxProperty ); if ( pOtherCurProperty && pOtherMaxProperty ) { //药物,只能是绝对值,百分比不要了,百分比让BUFF去做 //而且,只有最大值的那种,才能使用,因此,这里只能有 HP MP CSP 3样属性 //重要的是,不能超过最大值,这几个属性那个都是整型数据 //类似最大HP之类的,不能通过药剂直接修改属性,而是通过BUFF来修改,只要是分层属性都通过BUFF修改 int nAddValue = boost::lexical_cast<int>( valueEffectValue.String( i ) ); if ( "EXP" == strCurProperty ) { m_pLevelModule->AddExp( self, nAddValue ); } else if ( "HP" == strCurProperty ) { m_pPropertyModule->AddHP( self, nAddValue ); } else if ( "MP" == strCurProperty ) { m_pPropertyModule->AddMP( self, nAddValue ); } } else { m_pLogModule->LogProperty(NFILogModule::NLL_ERROR_NORMAL, self, strCurProperty, "", __FUNCTION__, __LINE__); return 0; } } } } } return other.GetCount(); } } } m_pLogModule->LogProperty(NFILogModule::NLL_ERROR_NORMAL, self, strItemName, "", __FUNCTION__, __LINE__); return 0; }
int NFCSkillModule::OnUseSkill(const NFGUID& self, const NFIDataList& var) { if ( var.GetCount() != 2) { return 1; } const std::string& strSkillID = var.String( 0 ); const NFGUID& nTargetID = var.Object(1); NF_SHARE_PTR<NFIObject> pObejct = m_pKernelModule->GetObject(self); if ( pObejct == NULL ) { return 1; } //NF_SHARE_PTR<NFIRecord> pRecordSkill = pObejct->GetRecordManager()->GetElement( mstrSkillTableName ); //if ( pRecordSkill == NULL ) //{ // return 1; //} //NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementInfoModule->GetPropertyManager( var.String( 2 ) ); //if ( pPropertyManager == NULL ) //{ // return 1; //} //NF_SHARE_PTR<NFIProperty> pItemTypeProperty = pPropertyManager->GetElement( "SkillType" ); //if ( pItemTypeProperty == NULL ) //{ // return 1; //} //配置表中真的有这么个技能类别 //EGameSkillType eItemType = ( EGameSkillType )pItemTypeProperty->GetInt(); if (!m_pElementInfoModule->ExistElement(strSkillID)) { return 1; } //NFISkillConsumeProcessModule* pConsumeProcessModule = m_pSkillConsumeManagerModule->GetConsumeModule( EGameSkillType::EGST_JOBSKILL_BRIEF ); //if ( pConsumeProcessModule == NULL ) //{ // return 1; //} //NFCDataList damageValueList; //NFCDataList damageResultList; //int nResult = pConsumeProcessModule->ConsumeProcess( var.Object( 0 ), var.String( 2 ), valueOther, damageValueList, damageResultList ); //for (int i = 0; i < valueOther.GetCount(); i++) //{ // m_pKernelModule->SetPropertyInt(valueOther.Object(i), "HP", 0); // damageValueList.AddInt(0); // damageResultList.AddInt(0); //} int nCurHP = m_pKernelModule->GetPropertyInt(nTargetID, NFrame::NPC::HP()); if (nCurHP <= 0) { return 1; } m_pKernelModule->SetPropertyObject(nTargetID, NFrame::NPC::LastAttacker(), self); m_pKernelModule->SetPropertyInt(nTargetID, NFrame::NPC::HP(), (nCurHP - 10) >= 0 ? (nCurHP - 10) : 0); // 暂时扣10点血 ////结果事件--无论失败或者是成功,都会发下去--当然使用结果只对使用者下发--成果的结果,还得对被施放的人发 //if ( damageValueList.GetCount() == damageResultList.GetCount() // && damageValueList.GetCount() == valueOther.GetCount() ) //{ // NFCDataList valueResult; // valueResult.AddString( var.String( 2 ).c_str() ); // valueResult.AddInt( valueOther.GetCount() ); // valueResult.Append( valueOther, 0, valueOther.GetCount() ); //伤害对象 // valueResult.Append( damageValueList, 0, damageValueList.GetCount() ); //伤害值 // valueResult.Append( damageResultList, 0, damageResultList.GetCount() ); //击打效果 // //现在不需要反馈,杀了就杀了 // //m_pEventProcessModule->DoEvent( pObejct->Self(), NFED_ON_CLIENT_USE_SKILL_RESULT, valueResult ); //} return 0; }
int NFCSkillModule::OnRequireUseSkillEvent( const NFGUID& self, const int nEventID, const NFIDataList& var ) { if ( var.GetCount() < 3) { return 1; } //EGameErrorCode errorCode = EGameErrorCode::EGEC_INVALID_SKILL; NF_SHARE_PTR<NFIObject> pObejct = m_pKernelModule->GetObject( var.Object( 0 ) ); if ( pObejct == NULL ) { return 1; } NF_SHARE_PTR<NFIRecord> pRecordSkill = pObejct->GetRecordManager()->GetElement( NFrame::Player::R_SkillTable() ); if ( pRecordSkill == NULL ) { return 1; } NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementInfoModule->GetPropertyManager( var.String( 2 ) ); if ( pPropertyManager == NULL ) { return 1; } NF_SHARE_PTR<NFIProperty> pItemTypeProperty = pPropertyManager->GetElement(NFrame::Skill::SkillType()); if ( pItemTypeProperty == NULL ) { return 1; } //配置表中真的有这么个技能类别 EGameSkillType eItemType = ( EGameSkillType )pItemTypeProperty->GetInt(); NFISkillConsumeProcessModule* pConsumeProcessModule = m_pSkillConsumeManagerModule->GetConsumeModule( EGameSkillType::EGST_JOBSKILL_BRIEF ); if ( pConsumeProcessModule == NULL ) { return 1; } NFCDataList valueOther; valueOther.Append( var, 3, var.GetCount() - 3 ); // 被攻击玩家数量 3表示从第几个参数开始是被攻击玩家 // if ( pConsumeProcessModule->ConsumeLegal( var.ObjectVal( 0 ), var.StringVal( 2 ), valueOther ) != 0 ) // { // return 1; // } // // if ( pConsumeProcessModule->ConsumeSelf( var.ObjectVal( 0 ), var.StringVal( 2 ) ) != 0 ) // { // return 1; // } // NFCDataList damageValueList; NFCDataList damageResultList; int nResult = pConsumeProcessModule->ConsumeProcess( var.Object( 0 ), var.String( 2 ), valueOther, damageValueList, damageResultList ); for (int i = 0; i < valueOther.GetCount(); i++) { m_pKernelModule->SetPropertyInt(valueOther.Object(i), NFrame::NPC::HP(), 0); damageValueList.AddInt(0); damageResultList.AddInt(0); } //结果事件--无论失败或者是成功,都会发下去--当然使用结果只对使用者下发--成果的结果,还得对被施放的人发 if ( damageValueList.GetCount() == damageResultList.GetCount() && damageValueList.GetCount() == valueOther.GetCount() ) { NFCDataList valueResult; valueResult.AddString( var.String( 2 ).c_str() ); valueResult.AddInt( valueOther.GetCount() ); valueResult.Append( valueOther, 0, valueOther.GetCount() ); //伤害对象 valueResult.Append( damageValueList, 0, damageValueList.GetCount() ); //伤害值 valueResult.Append( damageResultList, 0, damageResultList.GetCount() ); //击打效果 //现在不需要反馈,杀了就杀了 //m_pEventProcessModule->DoEvent( pObejct->Self(), NFED_ON_CLIENT_USE_SKILL_RESULT, valueResult ); } return 0; }
int NFCSceneProcessModule::OnEnterSceneEvent( const NFGUID& self, const int nEventID, const NFIDataList& var ) { if ( var.GetCount() != 4 || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN)) { return 0; } const NFGUID ident = var.Object( 0 ); const int nType = var.Int( 1 ); const int nTargetScene = var.Int( 2 ); const int nTargetGroupID = var.Int( 3 ); const int nNowSceneID = m_pKernelModule->GetPropertyInt( self, NFrame::Player::SceneID()); const int nNowGroupID = m_pKernelModule->GetPropertyInt(self, NFrame::Player::GroupID()); if ( self != ident ) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "you are not you self, but you want to entry this scene", nTargetScene); return 1; } if (nNowSceneID == nTargetScene && nTargetGroupID == nNowGroupID) { //本来就是这个层这个场景就别切换了 m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "in same scene and group but it not a clone scene", nTargetScene); return 1; } //每个玩家,一个副本 NFINT64 nNewGroupID = 0; if (nTargetGroupID <= 0) { nNewGroupID = CreateCloneScene( nTargetScene ); } else { nNewGroupID = nTargetGroupID; } if ( nNewGroupID <= 0 ) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "CreateCloneScene failed", nTargetScene); return 0; } //得到坐标 double fX = 0.0; double fY = 0.0; double fZ = 0.0; const std::string strSceneID = lexical_cast<std::string>(nTargetScene); const std::string& strRelivePosList = m_pElementInfoModule->GetPropertyString(strSceneID, NFrame::Scene::RelivePos()); NFCDataList valueRelivePosList( strRelivePosList.c_str(), ";" ); if ( valueRelivePosList.GetCount() >= 1 ) { NFCDataList valueRelivePos( valueRelivePosList.String( 0 ).c_str(), "," ); if ( valueRelivePos.GetCount() == 3 ) { fX = lexical_cast<double>( valueRelivePos.String( 0 ) ); fY = lexical_cast<double>( valueRelivePos.String( 1 ) ); fZ = lexical_cast<double>( valueRelivePos.String( 2 ) ); } } NFCDataList xSceneResult( var ); xSceneResult.Add( fX ); xSceneResult.Add( fY ); xSceneResult.Add( fZ ); m_pKernelModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_BEFORE, xSceneResult ); if(!m_pKernelModule->SwitchScene( self, nTargetScene, nNewGroupID, fX, fY, fZ, 0.0f, var )) { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "SwitchScene failed", nTargetScene); return 0; } xSceneResult.Add( nNewGroupID ); m_pKernelModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_RESULT, xSceneResult ); return 0; }