SKILL_RESULT_CODE CastOnSector(KCharacter pDisplayCaster, KCharacter pLogicCaster) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KSKILL_BULLET pBullet = new KSKILL_BULLET(); KTarget pTarget = new KTarget(); nRetCode = pTarget.SetTarget(pDisplayCaster); if (nRetCode == 0) { return(SKILL_RESULT_CODE.srcFailed); } nRetCode = SetupBullet(pBullet, pLogicCaster, ref pTarget); if (nRetCode == 0) { goto Exit0; } nRetCode = (int)ApplyOnSector(pBullet); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return((SKILL_RESULT_CODE)nRetCode); } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AISetState(KCharacter pCharacter, KAIAction pActionData) { int nState = pActionData.m_nParam[0]; pCharacter.m_AIVM.SetState(nState); return(-1); }
void ProcessBullet(KSKILL_BULLET pBullet) { KCharacter pCaster = null; KSkill pSkill = null; pCaster = pBullet.pSkillSrc; if (pCaster == null) { goto Exit0; } pSkill = pBullet.pSkillPointer; if (pSkill == null) { goto Exit0; } if ((pCaster.m_dwID == pBullet.dwSkillSrcID) == false) { goto Exit0; } switch (pSkill.m_pBaseInfo.nCastMode) { case KSKILL_CAST_MODE.scmTargetSingle: pSkill.ApplyOnSingle(pBullet); break; default: goto Exit0; break; } Exit0: return; }
SKILL_RESULT_CODE CastOnCasterArea(KCharacter pDisplayCaster, KCharacter pLogicCaster) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KTarget pTarget = new KTarget(); KSKILL_BULLET pBullet = new KSKILL_BULLET(); float fX = 0f; float fZ = 0f; nRetCode = pTarget.SetTarget(pDisplayCaster); if (nRetCode == 0) { goto Exit0; } nRetCode = SetupBullet(pBullet, pLogicCaster, ref pTarget); if (nRetCode == 0) { goto Exit0; } if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { pLogicCaster.AddBullet(pBullet); } else { pDisplayCaster.GetAbsoluteCoordinate(ref fX, ref fZ); nRetCode = (int)ApplyOnArea(pBullet, fX, fZ); } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AIKeepRange(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchInRange = 1; int nBranchKeep = 2; int nMinRange = pActionData.m_nParam[0]; int nMaxRange = pActionData.m_nParam[1]; nRetCode = KeepRange(pCharacter, (float)nMinRange, (float)nMaxRange); if (!(nRetCode > 0)) { goto Exit0; } if (nRetCode == 1) { nResult = nBranchInRange; goto Exit0; } nResult = nBranchKeep; Exit0: return(nResult); }
SKILL_RESULT_CODE CastOnCasterSingle(KCharacter pDisplayCaster, KCharacter pLogicCaster) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KSKILL_BULLET pBullet = new KSKILL_BULLET(); KTarget pTarget = new KTarget(); nRetCode = pTarget.SetTarget(pDisplayCaster); if (nRetCode == 0) { goto Exit0; } nRetCode = SetupBullet(pBullet, pLogicCaster, ref pTarget); if (nRetCode == 0) { goto Exit0; } if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { pLogicCaster.AddBullet(pBullet); } else { ApplyOnSingle(pBullet); } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AICastSkill(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchSuccess = 1; int nBranchFailed = 2; uint dwSkillID = (uint)pActionData.m_nParam[0]; uint dwSkillLevel = (uint)pActionData.m_nParam[1]; nRetCode = CastSkill(pCharacter, dwSkillID, dwSkillLevel, (int)AI_SKILL_TYPE.aistInvalid); if (nRetCode <= 0) { goto Exit0; } if (nRetCode == 2) { nResult = nBranchFailed; goto Exit0; } nResult = nBranchSuccess; Exit0: return(nResult); }
public int GetTarget(ref KCharacter ppCharacter) { int nResult = 0; switch (m_eTargetType) { case TARGET_TYPE.ttNpc: KNpc pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(m_dwID); if (pNpc == null) { goto Exit0; } ppCharacter = (KCharacter)pNpc; break; case TARGET_TYPE.ttPlayer: KPlayer pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(m_dwID); if (pPlayer == null) { goto Exit0; } ppCharacter = (KCharacter)pPlayer; break; default: goto Exit0; } nResult = 1; Exit0: return(nResult); }
public override bool OperatorSearch(KCharacter pCharacter) { int nRetCode = 0; //KTarget Target = new KTarget(); if (nLeftCount == 0) { return(false); } if (!bTargetArea || dwTargetID != pCharacter.m_dwID) { nRetCode = CanApply(pCharacter); if (nRetCode == 0) { goto Exit0; } nLeftCount--; pCharacter.ApplyBullet(pBullet); } Exit0: return(true); }
SKILL_RESULT_CODE ApplyOnArea(KSKILL_BULLET pBullet, float fX, float fZ) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; KCharacter pCaster = null; KSkill pSkill = null; KScene pScene = null; pSkill = pBullet.pSkillPointer; if (pSkill == null) { goto Exit0; } pCaster = pBullet.pSkillSrc; if (pCaster == null) { goto Exit0; } pScene = pCaster.m_pScene; if (pScene == null) { goto Exit0; } KSkillAreaTravFunc AreaTravFunc = new KSkillAreaTravFunc(); AreaTravFunc.pBullet = pBullet; AreaTravFunc.nLeftCount = 3; if (m_pBaseInfo.nCastMode == KSKILL_CAST_MODE.scmTargetArea) { KCharacter pObject = null; pBullet.pTarget.GetTarget(ref pObject); if (pObject == null) { goto Exit0; } AreaTravFunc.bTargetArea = true; AreaTravFunc.nTargetType = (int)pBullet.pTarget.GetTargetType(); AreaTravFunc.dwTargetID = pObject.m_dwID; AreaTravFunc.nLeftCount -= 1; } else { AreaTravFunc.bTargetArea = false; AreaTravFunc.nTargetType = (int)TARGET_TYPE.ttInvalid; AreaTravFunc.dwTargetID = 0; } pScene.TraverseRangePlayer <KSkillAreaTravFunc>(ref AreaTravFunc); pScene.TraverseRangeNpc <KSkillAreaTravFunc>(ref AreaTravFunc); nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AIStand(KCharacter pCharacter, KAIAction pActionData) { int nBranchSuccess = 1; pCharacter.Stand(); return(nBranchSuccess); }
public static int s_GetRelation(KCharacter pSrcCharacter, KCharacter pDstCharacter) { if (pSrcCharacter.m_dwForceID != pDstCharacter.m_dwForceID) { return(8); } return(0); }
public SKILL_RESULT_CODE CastSkill(uint dwSkillID, ref KTarget pTarget) { int nRetCode = 0; SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; KCharacter pTargetCharacter = null; if (m_pEntity == null) { return(SKILL_RESULT_CODE.srcFailed); } ISkillPart skillPart = m_pEntity.GetPart(EntityPart.Skill) as ISkillPart; if (skillPart == null) { return(SKILL_RESULT_CODE.srcFailed); } if (pTarget == null) { return(SKILL_RESULT_CODE.srcFailed); } nRetCode = pTarget.GetTarget(ref pTargetCharacter); if (nRetCode == 0 || pTargetCharacter == null) { return(SKILL_RESULT_CODE.srcFailed); } IEntity targetEntity = pTargetCharacter.m_pEntity; if (targetEntity == null) { return(SKILL_RESULT_CODE.srcFailed); } skillPart.ReqNpcUseSkill(targetEntity, dwSkillID); // KSkill pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID); pSkill.Cast(this, this, ref pTarget); //测试代码 // 伤害飘子 //FlyFontDataManager.Instance.ShowDamage(999, 1, pTargetCharacter.m_dwID, EntityType.EntityType_NPC, 1000000); //pTargetCharacter.Test_ConcludeResult(); nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AIKeepOriginDirection(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nBranchSuccess = 1; nResult = nBranchSuccess; Exit0: return(nResult); }
public static int AIIsInFight(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nBranchNotOut = 1; int nBranchOutFight = 2; nResult = nBranchNotOut; Exit0: return(nResult); }
public static int AIAddTargetToThreatList(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nBranchSuccess = 1; nResult = nBranchSuccess; Exit0: return(nResult); }
public uint dwTargetID; // 用来记录TargetArea开始作用的目标ID //public bool CanApply(KTarget rTarget) //{ // return true; //} public int CanApply(KCharacter pCharacter) { int nResult = 0; nResult = 1; Exit0: return(nResult); }
public bool Setup(KCharacter pCharacter, int nAIType) { bool bResult = false; bool bRetCode = false; KAILogic pAILogic = null; int nInitState = 0; if (m_nCurrentEvent != 0) { goto Exit0; } m_pOwner = pCharacter; if (nAIType == 0) { // 清除原有AI类型 m_pAILogic = null; goto Exit1; } pAILogic = FirstFightMgr.Instance().m_AIManager.GetAILogic(nAIType); if (pAILogic == null) { //error goto Exit0; } m_nAIType = nAIType; m_pAILogic = pAILogic; nInitState = m_pAILogic.GetInitState(); bRetCode = SetState(nInitState); if (bRetCode == false) { //error goto Exit0; } m_nPrimaryTimerFrame = 0; m_nSecondaryTimerFrame = 0; m_nTertiaryTimerFrame = 0; m_nCurrentEvent = 0; FireEvent((int)KAI_EVENT.aevOnPrimaryTimer, m_pOwner.m_dwID, FirstFightMgr.Instance().m_nGameLoop); Exit1: bResult = true; Exit0: return(bResult); }
public static int CastSkill(KCharacter pCharacter, uint dwSkillID, uint dwSkillLevel, int nAISkillType) { int nResult = 0; int nRetCode = 0; KCharacter pTarget = null; KSkill pSkill = null; if (!(pCharacter.m_eMoveState < CHARACTER_MOVE_STATE.cmsOnDeath)) { return(2); } pCharacter.m_pSkillTarget = pCharacter.m_pSelectTarget; if (pCharacter.m_pSkillTarget.GetTargetType() == TARGET_TYPE.ttNpc || pCharacter.m_pSkillTarget.GetTargetType() == TARGET_TYPE.ttPlayer) { nRetCode = pCharacter.m_pSkillTarget.GetTarget(ref pTarget); if (nRetCode == 0 || pTarget == null) { goto Exit0; } } pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID); if (pSkill == null) { goto Exit0; } nRetCode = (int)pSkill.CanCast(pCharacter, ref pCharacter.m_pSkillTarget); switch (nRetCode) { case (int)SKILL_RESULT_CODE.srcInvalidTarget: case (int)SKILL_RESULT_CODE.srcTooCloseTarget: case (int)SKILL_RESULT_CODE.srcTooFarTarget: break; } if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return(2); } nRetCode = (int)pCharacter.CastSkill(dwSkillID, ref pCharacter.m_pSkillTarget); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return(2); } nResult = 1; Exit0: return(nResult); }
public override bool OperatorSearch(KCharacter pCharacter) { bool bRetCode = false; bRetCode = KAI_SEARCH_CHARACTER.SearchCharacter(ref this.m_pResult, pCharacter, m_pSelf, this.m_fDistance2, this.m_nRelation); if (bRetCode) { return(false); } return(true); }
public static int AISetTertiaryTimer(KCharacter pCharacter, KAIAction pActionData) { int nBranchSuccess = 1; int nFrame = pActionData.m_nParam[0]; if (nFrame < KAIAction.MIN_TIMER_INTERVAL) { nFrame = KAIAction.MIN_TIMER_INTERVAL; } pCharacter.m_AIVM.SetTertiaryTimer((uint)nFrame); return(nBranchSuccess); }
public static int AINpcKeepSkillCastRange(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchInRange = 1; int nBranchKeep = 2; float fMinRange = 0f; float fMaxRange = 0f; uint dwSkillID = 0; KNpc pNpc = null; KSkill pSkill = null; pNpc = (KNpc)pCharacter; dwSkillID = pNpc.m_pTemplate.dwSkillIDList[pNpc.m_nSkillSelectIndex]; if (dwSkillID == 10001) { int gg = 0; } pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID); if (pSkill == null) { goto Exit0; } fMinRange = pSkill.m_fMinRadius; fMaxRange = pSkill.m_fMaxRadius; nRetCode = KeepRange(pCharacter, fMinRange, fMaxRange); if (!(nRetCode > 0)) { goto Exit0; } if (nRetCode == 1) { nResult = nBranchInRange; goto Exit0; } nResult = nBranchKeep; Exit0: return(nResult); }
public static int AINpcStandardSkillSelector(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nBranchSuccess = 1; KNpc pNpc = null; pNpc = (KNpc)pCharacter; pNpc.m_nSkillSelectIndex = 0; nResult = nBranchSuccess; Exit0: return(nResult); }
//以目标为中心的圆形区域 SKILL_RESULT_CODE CastOnTargetArea(KCharacter pDisplayCaster, KCharacter pLogicCaster, ref KTarget rTarget) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KSKILL_BULLET pBullet = new KSKILL_BULLET(); float fTargetX = 0f; float fTargetZ = 0f; nRetCode = SetupBullet(pBullet, pLogicCaster, ref rTarget); if (nRetCode == 0) { goto Exit0; } if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { pLogicCaster.AddBullet(pBullet); } else { nRetCode = rTarget.GetTarget(ref fTargetX, ref fTargetZ); if (nRetCode == 0) { goto Exit0; } nRetCode = (int)ApplyOnSingle(pBullet); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return((SKILL_RESULT_CODE)nRetCode); } nRetCode = (int)ApplyOnArea(pBullet, fTargetX, fTargetZ); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return((SKILL_RESULT_CODE)nRetCode); } } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AINpcCastSelectSkill(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchSuccess = 1; int nBranchFailed = 2; int nSelectIndex = 0; KNpc pNpc = null; uint dwSkillID = 0; pNpc = (KNpc)pCharacter; nSelectIndex = pNpc.m_nSkillSelectIndex; dwSkillID = pNpc.m_pTemplate.dwSkillIDList[nSelectIndex]; if (FirstFightMgr.Instance().m_nGameLoop < pNpc.m_nSkillCommomCD) { return(nBranchFailed); } if (FirstFightMgr.Instance().m_nGameLoop < pNpc.m_nSkillCastFrame[nSelectIndex]) { return(nBranchFailed); } nRetCode = CastSkill(pCharacter, dwSkillID, 0, (int)AI_SKILL_TYPE.aistInvalid); if (nRetCode <= 0) { goto Exit0; } if (nRetCode == 1) { pNpc.m_nSkillCastFrame[nSelectIndex] = (int)FirstFightMgr.Instance().m_nGameLoop + pNpc.m_pTemplate.nSkillCastInterval[nSelectIndex]; pNpc.m_nSkillCommomCD = (int)FirstFightMgr.Instance().m_nGameLoop + 1; nResult = nBranchSuccess; goto Exit0; } nResult = nBranchFailed; Exit0: return(nResult); }
public SKILL_RESULT_CODE CanCast(KCharacter pSrcCharacter, ref KTarget rTarget) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; SKILL_RESULT_CODE nRetCode = SKILL_RESULT_CODE.srcFailed; switch (m_pBaseInfo.nCastMode) { case KSKILL_CAST_MODE.scmCasterSingle: // 对单体对象(限于自己)施放 break; case KSKILL_CAST_MODE.scmCasterArea: // 以自己为中心的圆形区域 break; case KSKILL_CAST_MODE.scmTargetArea: // 以目标为中心的圆形区域 case KSKILL_CAST_MODE.scmTargetSingle: // 对单体对象(指定目标)施放 nRetCode = CheckTargetRange(pSrcCharacter, ref rTarget); if (nRetCode != SKILL_RESULT_CODE.srcSuccess) { return(nRetCode); } break; case KSKILL_CAST_MODE.scmSector: // 扇形范围,扇心固定在自己 break; default: goto Exit0; break; } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AISearchEnemy(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchFound = 1; int nBranchNotFound = 2; int nRange = pActionData.m_nParam[0]; TARGET_TYPE eTargetType = TARGET_TYPE.ttInvalid; KSearchForAnyCharacter Tactic = new KSearchForAnyCharacter(); Tactic.m_pSelf = pCharacter; Tactic.m_fDistance2 = (float)nRange; Tactic.m_nRelation = (int)SCENE_OBJ_RELATION_TYPE.sortEnemy; KAI_SEARCH_CHARACTER.AISearchCharacter <KSearchForAnyCharacter>(Tactic); if (Tactic.m_pResult == null) { return(nBranchNotFound); } if (KCharacter.IS_PLAYER(Tactic.m_pResult.m_dwID)) { eTargetType = TARGET_TYPE.ttPlayer; } else { eTargetType = TARGET_TYPE.ttNpc; } nRetCode = pCharacter.SelectTarget(eTargetType, Tactic.m_pResult.m_dwID); if (nRetCode == 0) { goto Exit0; } nResult = nBranchFound; Exit0: return(nResult); }
public int SetTarget(KCharacter pCharacter) { int nResult = 0; if (pCharacter == null) { goto Exit0; } m_dwID = pCharacter.m_dwID; m_eTargetType = TARGET_TYPE.ttNpc; if (pCharacter.m_dwID == 1) { m_eTargetType = TARGET_TYPE.ttPlayer; } nResult = 1; Exit0: return(nResult); }
public SKILL_RESULT_CODE CheckTargetRange(KCharacter pCaster, ref KTarget rTarget) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; float fMaxRange = 0f; float fCasterX = 0f; float fCasterZ = 0f; float fTargetX = 0f; float fTargetZ = 0f; float fTouchRange = 0f; pCaster.GetAbsoluteCoordinate(ref fCasterX, ref fCasterZ); nRetCode = rTarget.GetTarget(ref fTargetX, ref fTargetZ); if (nRetCode == 0) { goto Exit0; } fMaxRange = pCaster.m_fTouchRange + m_fMaxRadius + fTouchRange; nRetCode = (int)SkillInRange(fCasterX, fCasterZ, fTargetX, fTargetZ, m_fMinRadius, fMaxRange); if (nRetCode == (int)IN_RANGE_RESULT.irrTooClose) { return(SKILL_RESULT_CODE.srcTooCloseTarget); } if (nRetCode == (int)IN_RANGE_RESULT.irrTooFar) { return(SKILL_RESULT_CODE.srcTooFarTarget); } if (nRetCode != (int)IN_RANGE_RESULT.irrInRange) { goto Exit0; } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public SKILL_RESULT_CODE ApplyOnSingle(KSKILL_BULLET pBullet) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; TARGET_TYPE eTargetType = TARGET_TYPE.ttInvalid; KCharacter pCharacter = null; eTargetType = pBullet.pTarget.GetTargetType(); switch (eTargetType) { case TARGET_TYPE.ttNoTarget: break; case TARGET_TYPE.ttCoordination: break; case TARGET_TYPE.ttNpc: case TARGET_TYPE.ttPlayer: nRetCode = pBullet.pTarget.GetTarget(ref pCharacter); if (nRetCode == 0 || pCharacter == null) { goto Exit0; } pCharacter.ApplyBullet(pBullet); break; default: goto Exit0; break; } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }