示例#1
0
    public static int AISetState(KCharacter pCharacter, KAIAction pActionData)
    {
        int nState = pActionData.m_nParam[0];

        pCharacter.m_AIVM.SetState(nState);
        return(-1);
    }
示例#2
0
    public KAIActionHandle GetEventHandler(int nEvent)
    {
        KAIActionHandle pResult = new KAIActionHandle();

        pResult.nAIActionID = KAIAction.KAI_ACTION_ID_NONE;
        pResult.pAIAction   = null;

        for (int i = 0; i < m_EventHandleVector.Count; i++)
        {
            if (m_EventHandleVector[i].nEvent == nEvent)
            {
                if (m_EventHandleVector[i].ActionKey.pAIAction == null)
                {
                    KAIAction pAction = null;

                    pAction = m_pAILogic.GetAction(m_EventHandleVector[i].ActionKey.nAIActionID);
                    if (pAction == null)
                    {
                        //error
                        return(null);
                    }

                    m_EventHandleVector[i].ActionKey.pAIAction = pAction;
                }
                pResult = m_EventHandleVector[i].ActionKey;
                break;
            }
        }


        return(pResult);
    }
示例#3
0
    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);
    }
示例#4
0
    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);
    }
示例#5
0
    public static int AIStand(KCharacter pCharacter, KAIAction pActionData)
    {
        int nBranchSuccess = 1;

        pCharacter.Stand();

        return(nBranchSuccess);
    }
示例#6
0
    public static int AIKeepOriginDirection(KCharacter pCharacter, KAIAction pActionData)
    {
        int nResult        = 0;
        int nBranchSuccess = 1;

        nResult = nBranchSuccess;
Exit0:
        return(nResult);
    }
示例#7
0
    public static int AIIsInFight(KCharacter pCharacter, KAIAction pActionData)
    {
        int nResult         = 0;
        int nBranchNotOut   = 1;
        int nBranchOutFight = 2;

        nResult = nBranchNotOut;
Exit0:
        return(nResult);
    }
示例#8
0
    public static int AIAddTargetToThreatList(KCharacter pCharacter, KAIAction pActionData)
    {
        int nResult        = 0;
        int nBranchSuccess = 1;


        nResult = nBranchSuccess;
Exit0:
        return(nResult);
    }
示例#9
0
    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);
    }
示例#10
0
    public KAIAction NewAction(int nActionID, int nActionKey)
    {
        if (nActionID <= KAIAction.KAI_ACTION_ID_NONE)
        {
            //error
            goto Exit0;
        }

        if (nActionKey <= (int)KAI_ACTION_KEY.eakInvalid)
        {
            //error
            goto Exit0;
        }

        if (nActionKey < KAIAction.KAI_USER_ACTION)
        {
            KAIManager.KAI_ACTION_FUNC pFucAction = null;

            pFucAction = FirstFightMgr.Instance().m_AIManager.GetActionFunction(nActionKey);

            if (pFucAction == null)
            {
                //error
                goto Exit0;
            }
        }
        else
        {
            //error
            goto Exit0;
        }

        if (m_ActionTable.ContainsKey(nActionID))
        {
            //error
            goto Exit0;
        }

        KAIAction pAIAction = new KAIAction();

        pAIAction.m_nKey = nActionKey;

        m_ActionTable.Add(nActionID, pAIAction);

        return(pAIAction);

Exit0:
        return(null);
    }
示例#11
0
    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);
    }
示例#12
0
    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);
    }
示例#13
0
    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);
    }
示例#14
0
    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);
    }
示例#15
0
    public static int AIIsTargetExist(KCharacter pCharacter, KAIAction pActionData)
    {
        int nResult         = 0;
        int nBranchExist    = 1;
        int nBranchNotExist = 2;

        KCharacter pTarget = null;

        pCharacter.m_pSelectTarget.GetTarget(ref pTarget);
        if (pTarget == null)
        {
            return(nBranchNotExist);
        }

        if ((pTarget.m_eMoveState != CHARACTER_MOVE_STATE.cmsOnDeath) == false)
        {
            return(nBranchNotExist);
        }

        nResult = nBranchExist;
Exit0:
        return(nResult);
    }
示例#16
0
    public KAIActionHandle CallAction(KCharacter pCharacter, KAIActionHandle pActionKey)
    {
        KAIActionHandle pResult     = new KAIActionHandle();
        KAIActionHandle pNextAction = new KAIActionHandle();

        KAIAction pAction    = pActionKey.pAIAction;
        int       nActionKey = 0;

        if (pAction == null)
        {
            pAction = GetAction(pActionKey.nAIActionID);
        }

        if (pAction == null)
        {
            //error
            goto Exit0;
        }

        nActionKey = pAction.m_nKey;

        if (nActionKey < KAIAction.KAI_USER_ACTION)
        {
            int   nBranchIndex    = 0;
            ulong ulPrevTickCount = 0;
            ulong ulPostTickCount = 0;
            KAIManager.KAI_ACTION_FUNC PAction = null;

            PAction = FirstFightMgr.Instance().m_AIManager.GetActionFunction(nActionKey);
            if (PAction == null)
            {
                //error
                goto Exit0;
            }


            nBranchIndex = PAction(pCharacter, pAction);

            if (nBranchIndex > 0 && nBranchIndex <= KAIAction.KAI_ACTION_BRANCH_NUM)
            {
                int       nNextActionID   = pAction.m_nBranch[nBranchIndex - 1];
                KAIAction pNextActionTemp = pAction.m_pBranch[nBranchIndex - 1];

                if (pNextActionTemp == null)
                {
                    pNextActionTemp = GetAction(nNextActionID);
                    pAction.m_pBranch[nBranchIndex - 1] = pNextActionTemp;
                }
                pNextAction.nAIActionID = nNextActionID;
                pNextAction.pAIAction   = pNextActionTemp;
            }
            if (nBranchIndex == -1)
            {
                pNextAction.nAIActionID = KAIAction.KAI_ACTION_ID_NONE;
                pNextAction.pAIAction   = null;
            }
        }
        else
        {
            // 没做
            //error
        }


        pResult = pNextAction;
Exit0:
        return(pResult);
    }
示例#17
0
    public static void Setup(int nType, KAILogic pAI)
    {
        const int PRISONER_INIT  = 100;
        const int PRISONER_IDLE  = 20;
        const int PRISONER_FIGHT = 30;

        if (pAI == null)
        {
            return;
        }

        KAIAction pAIAction = null;
        KAIState  pAIState  = null;


        pAIState = pAI.NewState(PRISONER_INIT);
        pAIState.HandleEvent((int)KAI_EVENT.aevOnPrimaryTimer, 101);


        pAIAction = pAI.NewAction(101, (int)KAI_ACTION_KEY.eakRecordOriginPosition);
        pAIAction.SetBranch(28);


        pAIState = pAI.NewState(PRISONER_IDLE);
        pAIState.HandleEvent((int)KAI_EVENT.aevOnPrimaryTimer, 21);


        pAIAction = pAI.NewAction(21, (int)KAI_ACTION_KEY.eakSearchEnemy);
        pAIAction.SetParam(50);
        pAIAction.SetBranch(23, 22);


        pAIAction = pAI.NewAction(22, (int)KAI_ACTION_KEY.eakKeepOriginDirection);
        pAIAction.SetBranch(28);

        pAIAction = pAI.NewAction(23, (int)KAI_ACTION_KEY.eakAddTargetToThreatList);
        pAIAction.SetBranch(24);

        pAIAction = pAI.NewAction(24, (int)KAI_ACTION_KEY.eakRecordReturnPosition);
        pAIAction.SetBranch(31);


        pAIAction = pAI.NewAction(28, (int)KAI_ACTION_KEY.eakSetPrimaryTimer);
        pAIAction.SetParam(16);
        pAIAction.SetBranch(29);


        pAIAction = pAI.NewAction(29, (int)KAI_ACTION_KEY.eakSetState);
        pAIAction.SetParam(PRISONER_IDLE);


        pAIAction = pAI.NewAction(31, (int)KAI_ACTION_KEY.eakIsInFight);
        pAIAction.SetBranch(219, 41);


        // 选技能
        pAIAction = pAI.NewAction(219, (int)KAI_ACTION_KEY.eakNpcStandardSkillSelector);
        pAIAction.SetBranch(1120, 998);


        pAIAction = pAI.NewAction(1120, (int)KAI_ACTION_KEY.eakIsTargetExist);
        pAIAction.SetBranch(225, 28);

        pAIAction = pAI.NewAction(225, (int)KAI_ACTION_KEY.eakNpcKeepSkillCastRange);
        pAIAction.SetBranch(230, 38);


        pAIAction = pAI.NewAction(230, (int)KAI_ACTION_KEY.eakStand);
        pAIAction.SetBranch(231);


        pAIAction = pAI.NewAction(231, (int)KAI_ACTION_KEY.eakNpcCastSelectSkill);
        pAIAction.SetBranch(755, 38);

        // 动画播放时间就算了
        //pAIAction = pAI.NewAction(532..................................................)
        pAIAction = pAI.NewAction(755, (int)KAI_ACTION_KEY.eakSetPrimaryTimer);
        pAIAction.SetParam(8);
        pAIAction.SetBranch(39);


        pAIAction = pAI.NewAction(38, (int)KAI_ACTION_KEY.eakSetPrimaryTimer);
        pAIAction.SetParam(2);
        pAIAction.SetBranch(39);


        pAIAction = pAI.NewAction(39, (int)KAI_ACTION_KEY.eakSetState);
        pAIAction.SetParam(PRISONER_FIGHT);


        pAI.SetInitState(PRISONER_INIT);
    }
示例#18
0
    public static int AIRecordReturnPosition(KCharacter pCharacter, KAIAction pActionData)
    {
        int nBranchSuccess = 1;

        return(nBranchSuccess);
    }