Beispiel #1
0
        void PutActorAtObject()
        {
            int   obj;
            Point p;
            var   a = Actors[GetVarOrDirectByte(OpCodeParameter.Param1)];

            int objId = ReadByte();

            if ((_opCode & 0x40) != 0)
            {
                obj = OBJECT_V0(objId, ObjectV0Type.Background);
            }
            else
            {
                obj = OBJECT_V0(objId, ObjectV0Type.Foreground);
            }

            if (GetWhereIsObject(obj) != WhereIsObject.NotFound)
            {
                p = GetObjectXYPos(obj);
                AdjustBoxResult r = a.AdjustXYToBeInBox(p);
                p = r.Position;
            }
            else
            {
                p = new Point(30, 60);
            }

            a.PutActor(p);
        }
Beispiel #2
0
        void LoadRoomWithEgo()
        {
            var obj  = ReadByte();
            var room = ReadByte();

            var a = (Actor0)Actors[Variables[VariableEgo.Value]];

            //0x634F
            if (a.MiscFlags.HasFlag(ActorV0MiscFlags.Freeze))
            {
                StopObjectCode();
                return;
            }

            // The original interpreter sets the actors new room X/Y to the last rooms X/Y
            // This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script
            // This scripts runs before the actor position is set to the correct room entry location
            a.PutActor(a.Position, room);
            EgoPositioned = false;

            StartScene(a.Room, a, obj);

            Point p;
            int   dir;

            GetObjectXYPos(obj, out p, out dir);
            AdjustBoxResult r = a.AdjustXYToBeInBox(p);

            p = r.Position;
            a.PutActor(p, CurrentRoom);

            Camera.DestinationPosition.X = Camera.CurrentPosition.X = a.Position.X;
            SetCameraAt(a.Position);
            SetCameraFollows(a);

            _fullRedraw = true;

            ResetSentence();

            if (p.X >= 0 && p.Y >= 0)
            {
                a.StartWalk(p, -1);
            }
        }
Beispiel #3
0
        public override AdjustBoxResult AdjustXYToBeInBox(Point dst)
        {
            var abr = new AdjustBoxResult();

            abr.Position = dst;
            abr.Box      = InvalidBox;

            var numBoxes = _scumm.GetNumBoxes() - 1;
            var bestDist = 0xFF;

            for (int i = 0; i <= numBoxes; i++)
            {
                // MM v0 prioritizes lower boxes, other engines higher boxes
                var box   = (byte)(_scumm.Game.Version == 0 ? i : numBoxes - i);
                var flags = _scumm.GetBoxFlags(box);
                if ((flags.HasFlag(BoxFlags.Invisible) && !((flags.HasFlag(BoxFlags.PlayerOnly) && !IsPlayer))))
                {
                    continue;
                }
                Point found;
                var   dist = CheckXYInBoxBounds(box, dst, out found); // also merged with getClosestPtOnBox
                if (dist == 0)
                {
                    abr.Position = found;
                    abr.Box      = box;
                    break;
                }
                if (dist < bestDist)
                {
                    bestDist     = dist;
                    abr.Position = found;
                    abr.Box      = box;
                }
            }

            return(abr);
        }