コード例 #1
0
    public bool ExecCommand(StoryInstance instance, StoryMessageHandler handler, StoryValueParams _params, long delta)
    {
        ArrayList args = _params.Values;

        if (!m_KeepAwayStarted)
        {
            m_KeepAwayStarted = true;

            m_ObjId     = (int)args[0];
            m_SkillInfo = args[1] as SkillInfo;
            m_Ratio     = (float)System.Convert.ChangeType(args[2], typeof(float));
        }
        EntityInfo npc = PluginFramework.Instance.GetEntityById(m_ObjId);

        if (null != npc && !npc.IsUnderControl())
        {
            AiStateInfo info   = npc.GetAiStateInfo();
            EntityInfo  target = PluginFramework.Instance.GetEntityById(info.Target);
            if (null != target && null != m_SkillInfo)
            {
                info.Time += delta;
                if (info.Time > 100)
                {
                    info.Time = 0;
                }
                else
                {
                    return(true);
                }
                ScriptRuntime.Vector3 srcPos    = npc.GetMovementStateInfo().GetPosition3D();
                ScriptRuntime.Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D();
                float distSqr             = Geometry.DistanceSquare(srcPos, targetPos);
                ScriptRuntime.Vector3 dir = srcPos - targetPos;
                dir.Normalize();
                targetPos = targetPos + dir * m_Ratio * m_SkillInfo.Distance;
                if (distSqr < m_Ratio * m_Ratio * m_SkillInfo.Distance * m_SkillInfo.Distance)
                {
                    AiCommand.AiPursue(npc, targetPos);
                    return(true);
                }
            }
        }
        return(false);
    }
コード例 #2
0
    public bool ExecCommand(StoryInstance instance, StoryValueParams _params, long delta)
    {
        ArrayList args = _params.Values;

        if (!m_ChaseStarted)
        {
            m_ChaseStarted = true;

            m_ObjId     = (int)args[0];
            m_SkillInfo = args[1] as SkillInfo;
        }
        EntityInfo npc = PluginFramework.Instance.GetEntityById(m_ObjId);

        if (null != npc && !npc.IsUnderControl())
        {
            AiStateInfo info   = npc.GetAiStateInfo();
            EntityInfo  target = PluginFramework.Instance.GetEntityById(info.Target);
            if (null != target && null != m_SkillInfo)
            {
                info.Time += delta;
                if (info.Time > 100)
                {
                    info.Time = 0;
                }
                else
                {
                    return(true);
                }
                ScriptRuntime.Vector3 srcPos    = npc.GetMovementStateInfo().GetPosition3D();
                ScriptRuntime.Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D();
                float distSqr = Geometry.DistanceSquare(srcPos, targetPos);
                if (distSqr > m_SkillInfo.Distance * m_SkillInfo.Distance)
                {
                    AiCommand.AiPursue(npc, targetPos);
                    return(true);
                }
            }
        }
        return(false);
    }