示例#1
0
        /// <summary>
        /// Updates the internal subgoals array.  Will rebuild if out of sync.
        /// </summary>
        public override void Update()
        {
            mSubGoals.Clear();

            PC pc = new PC();

            // should check if we are on a level that doesn't have a waypoint

            // get the waypoint's preset unit on the target level
            AreaLevel area = mSource == AreaLevel.None ? pc.Area : mSource;

            foreach (PresetUnit waypoint in PresetUnit.Get(area, UnitType.Object))
            {
                foreach (int classid in new int[] { 119, 145, 156, 157, 237, 238, 288, 323, 324, 398, 402, 429, 494, 496, 511, 539 })
                {
                    if (waypoint.ClassID == classid)
                    {
                        if (Math.Abs(pc.X - waypoint.X) > 5 || Math.Abs(pc.Y - waypoint.Y) > 5)
                        {
                            mSubGoals.Enqueue(new MoveToWaypoint(this, mPriority + 2, area, mTeleport));
                        }
                        goto WAYPOINTFOUND;
                    }
                }
            }
WAYPOINTFOUND:

            // call base classes Update()
            base.Update();
        }
示例#2
0
        /// <summary>
        /// Finds a Path to the given PresetUnit
        /// </summary>
        /// <param name="Preset">The Preset Unit to path to</param>
        /// <returns>A Path object containg the Path's Coordinates</returns>
        public Path FindPath(PresetUnit Preset)
        {
            PC Me = new PC();

            this.presetunit = Preset;
            return(FindPath(Preset.X, Preset.Y, Me.X, Me.Y));
        }
示例#3
0
        /// <summary>
        /// Updates the internal subgoals array.  Will rebuild if out of sync.
        /// </summary>
        public override void Update()          // change name to Update()
        {
            mSubGoals.Clear();

            PC pc = new PC();

            if (pc.Area != mArea)
            {
//				mSubGoals.Enqueue( new MoveToArea( ) );
            }

            if (mLocation == 1)              // this is TownPortal in all ActXTown enums
            {
                // do stuff here
            }
            else
            {
                UnitBase location = new Missile();                 // need to add UnitBase default constructor
                switch (mUnitType)
                {
                case UnitType.NPC:
                    location = new NPC(mLocation);
                    break;

                case UnitType.GameObject:
                    location = new GameObject(mLocation);
                    break;
                }

                if (location.IsValid())
                {
                    if (Math.Abs(pc.X - location.X) > 5 || Math.Abs(pc.Y - location.Y) > 5)
                    {
                        mSubGoals.Enqueue(new MoveToPoint(this, mPriority, location.Point, false));
                    }
                }
                else
                {
                    foreach (PresetUnit unit in PresetUnit.Get(mArea, mUnitType))
                    {
                        if (unit.ClassID == mLocation)
                        {
                            if (Math.Abs(pc.X - unit.X) > 5 || Math.Abs(pc.Y - unit.Y) > 5)
                            {
                                mSubGoals.Enqueue(new MoveToPoint(this, mPriority, unit.Point, false));
                            }
                            break;
                        }
                    }
                }
            }

            // call base classes Update()
            base.Update();
        }
示例#4
0
        /// <summary>
        /// Finds a Path to the given Warps
        /// </summary>
        /// <param name="WarpID">The ID of the warp to path to</param>
        /// <returns></returns>
        public Path FindPathToWarp(int[] WarpID)
        {
            PC Me = new PC();

            PresetUnit[] presets = PresetUnit.Get(Me.Area, UnitType.Warp);

            foreach (PresetUnit p in presets)
            {
                foreach (int i in WarpID)
                {
                    if (p.ClassID == i)
                    {
                        return(FindPath(p));
                    }
                }
            }

            throw new ApplicationException("Could not find the given warp ID");
        }
示例#5
0
        /// <summary>
        /// Finds a Path to the given Warp
        /// </summary>
        /// <returns></returns>
        public Path FindPathToWaypoint()
        {
            PC Me = new PC();

            int[] waypoints = new int[] { 119, 145, 156, 157, 237, 238, 288, 323, 324, 398, 402, 429, 494, 496, 511, 539 };

            PresetUnit[] presets = PresetUnit.Get(Me.Area, UnitType.Object);

            foreach (PresetUnit p in presets)
            {
                foreach (int i in waypoints)
                {
                    if (p.ClassID == i)
                    {
                        return(FindPath(p));
                    }
                }
            }

            throw new ApplicationException("Could not find a waypoint");
        }
示例#6
0
        protected void DrawPreset(Room2 room, Level lvl, PresetUnit preset)
        {
            var cellNo = -1;

            // Special NPC Check
            if (preset.dwType == 1)
            {
                // Izual
                if (preset.dwTxtFileNo == 256)
                {
                    cellNo = 300;
                }
                // Hephasto
                else if (preset.dwTxtFileNo == 402)
                {
                    cellNo = 745;
                }
            }
            else if (preset.dwType == 2)
            {
                switch (preset.dwTxtFileNo)
                {
                case 580:       // Uber Chest in Lower Kurast
                    if (lvl.dwLevelNo == 79)
                    {
                        cellNo = 9;
                    }
                    break;

                case 371:       // Countess Chest
                    cellNo = 301;
                    break;

                case 152:       // Act 2 Orifice
                    cellNo = 300;
                    break;

                case 460:       // Frozen Anya
                    cellNo = 1468;
                    break;

                case 402:       // Canyon / Arcane Waypoint
                    if (lvl.dwLevelNo == 46)
                    {
                        cellNo = 0;
                    }
                    break;

                case 376:       // Hell Forge
                    cellNo = 376;
                    break;

                default:
                    break;
                }

                if (cellNo == -1 && preset.dwTxtFileNo <= 572)
                {
                    var pTxt = game.Debugger.Call <IntPtr>(D2Common.GetObjectTxt,
                                                           MagicConvention.StdCall,
                                                           preset.dwTxtFileNo);
                    if (pTxt != IntPtr.Zero)
                    {
                        var txt = game.Debugger.Read <ObjectTxt>(pTxt);
                        cellNo = (int)txt.nAutoMap;
                    }
                }
            }

            if (cellNo > 0 /* && cellNo < 1258*/)
            {
                var pCell = game.Debugger.Call <IntPtr>(D2Client.NewAutomapCell,
                                                        MagicConvention.FastCall);

                var cell = game.Debugger.Read <AutomapCell>(pCell);

                var x = preset.dwPosX + room.dwPosX * 5;
                var y = preset.dwPosY + room.dwPosY * 5;

                cell.nCellNo = (ushort)cellNo;
                cell.xPixel  = (ushort)(((short)x - (short)y) * 1.6 + 1);
                cell.yPixel  = (ushort)((y + x) * 0.8 - 3);

                game.Debugger.Write <AutomapCell>(pCell, cell);

                var pAutomapLayer = game.Debugger.Read <uint>(D2Client.pAutoMapLayer);
                game.Debugger.Call(D2Client.AddAutomapCell,
                                   MagicConvention.FastCall,
                                   pCell,
                                   pAutomapLayer + 0x10); // &((*p_D2CLIENT_AutomapLayer)->pObjects)
            }
        }