Exemple #1
0
    public override RbyTile WarpCheck()
    {
        // TODO: This code does not take cave exits into account that don't always warp when walked on. (i.e. walked on from the side)
        RbyWarp sourceWarp = Map.Warps[X, Y];

        if (sourceWarp != null && sourceWarp.Allowed)
        {
            RbyMap destMap = Map.Game.Maps[sourceWarp.DestinationMap];
            if (destMap != null)
            {
                RbyWarp destWarp = destMap.Warps[sourceWarp.DestinationIndex];
                if (destWarp != null)
                {
                    RbyTile destTile = destMap[destWarp.X, destWarp.Y];
                    if (destTile.Collision == 27)
                    {
                        destTile = destTile.Neighbor(Action.Down);                          // Door tiles automatically move the player 1 tile down.
                    }
                    return(destTile);
                }
            }
        }

        return(this);
    }
Exemple #2
0
    private void LoadMissableSprites()
    {
        ReadStream data = ROM.From("MissableObjects");

        for (int id = 0; ; id++)
        {
            byte mapId    = data.u8();
            byte spriteId = data.u8();
            byte state    = data.u8();

            if (mapId == 0xff)
            {
                break;
            }

            RbyMap map = Maps[mapId];
            if (map == null)
            {
                continue;
            }

            RbySprite sprite = map.Sprites[spriteId - 1];
            if (sprite == null)
            {
                continue;
            }

            sprite.CanBeMissable   = true;
            sprite.MissableAddress = SYM["wMissableObjectFlags"] + id / 8;
            sprite.MissableBit     = id % 8;
        }
    }
Exemple #3
0
    public override byte[] ReadCollisionMap()
    {
        RbyMap map    = Map;
        int    width  = map.Width;
        int    height = map.Height;

        byte[] overworldMap = CpuRead("wOverworldMap", 1300);
        byte[] blocks       = new byte[width * height];

        for (int i = 0; i < height; i++)
        {
            Array.Copy(overworldMap, (i + 3) * (width + 6) + 3, blocks, i * width, width);
        }

        byte[] tiles     = map.Tileset.GetTiles(blocks, width);
        byte[] collision = new byte[width * 2 * height * 2];

        for (int y = 0; y < height * 2; y++)
        {
            for (int x = 0; x < width * 2; x++)
            {
                collision[x + y * width * 2] = tiles[(x * 2) + (y * 2) * width * 4 + width * 4];
            }
        }

        return(collision);
    }
Exemple #4
0
    public static void Start()
    {
        Yellow[] gbs = MultiThread.MakeThreads <Yellow>(8, "baseSaves/yellow_moon_backup.sav");
        Yellow   gb  = gbs[0];

        gb.Show();
        new RbyIntroSequence().Execute(gb);

        RbyMap map1 = gb.Maps[60];
        RbyMap map2 = gb.Maps[61];

        Pathfinding.GenerateEdges <RbyMap, RbyTile>(gb, 0, map2[12, 9], Action.Up | Action.Down | Action.Left | Action.Right | Action.A);

        map1[21, 16].GetEdge(0, Action.Down).NextTile  = map2[21, 17];
        map1[20, 17].GetEdge(0, Action.Right).NextTile = map2[21, 17];

        for (int x = 0xd; x <= 0x12; x++)
        {
            for (int y = 0x10; y <= 0x11; y++)
            {
                map1[x, y].RemoveEdge(0, Action.A);
                map1[x, y].RemoveEdge(0, Action.Down);
            }
        }

        for (int x = 0xd; x <= 0x12; x++)
        {
            for (int y = 0x10; y <= 0x11; y++)
            {
                map1[x, y].RemoveEdge(0, Action.A);
                map1[x, y].RemoveEdge(0, Action.Down);
            }
        }

        for (int x = 0x11; x <= 0x17; x++)
        {
            map2[x, 0x1f].RemoveEdge(0, Action.A);
        }

        IGTResults initialState = Yellow.IGTCheckParallel(gbs, new RbyIntroSequence(), 60);

        StreamWriter writer = new StreamWriter("moon.txt");

        writer.AutoFlush = true;

        DFParameters <Yellow, RbyMap, RbyTile> parameters = new DFParameters <Yellow, RbyMap, RbyTile>()
        {
            PruneAlreadySeenStates = true,
            MaxCost       = 20,
            NoEncounterSS = 60,
            RNGSS         = 56,
            EndTiles      = new RbyTile[] { map2[12, 9], },
            FoundCallback = state => writer.WriteLine(state.Log),
            EndEdgeSet    = 0,
        };

        DepthFirstSearch.StartSearch(gbs, parameters, gb.Tile, 0, initialState);
    }
Exemple #5
0
 public RbyConnection(RbyMap map, ByteStream data)
 {
     Map         = map;
     MapId       = data.u8();
     Source      = data.u16le();
     Destination = data.u16le();
     Length      = data.u8();
     Width       = data.u8();
     YAlignment  = data.u8();
     XAlignment  = data.u8();
     Window      = data.u16le();
 }
Exemple #6
0
 // Constructor to call from subclasses (RbyTrainer, RbyItemBall)
 public RbySprite(RbySprite baseSprite, ReadStream data)
 {
     Map       = baseSprite.Map;
     SpriteId  = baseSprite.SpriteId;
     Y         = baseSprite.Y;
     X         = baseSprite.X;
     Movement  = baseSprite.Movement;
     TextId    = baseSprite.TextId;
     IsTrainer = baseSprite.IsTrainer;
     IsItem    = baseSprite.IsItem;
     Direction = baseSprite.Direction;
     Range     = baseSprite.Range;
 }
Exemple #7
0
    public RbyWarp(Rby game, RbyMap map, byte index, ByteStream data)
    {
        Map              = map;
        Index            = index;
        Y                = data.u8();
        X                = data.u8();
        DestinationIndex = data.u8();
        DestinationMap   = data.u8();
        Allowed          = false;

        if (!(game is Yellow) && DestinationMap == 0xff)
        {
            DestinationMap = RedBlue.wLastMapDestinations[(map.Name, index)];
Exemple #8
0
    public RbySprite(Rby game, RbyMap map, byte spriteId, ReadStream data)
    {
        Map       = map;
        SpriteId  = spriteId;
        PictureId = data.u8();
        Y         = (byte)(data.u8() - 4);
        X         = (byte)(data.u8() - 4);
        Movement  = (RbySpriteMovement)data.u8();
        byte rangeOrDirection = data.u8();

        TextId    = data.u8();
        IsTrainer = (TextId & 0x40) != 0;
        IsItem    = (TextId & 0x80) != 0;

        if (IsTrainer)
        {
            TextId &= 0xbf;
        }
        if (IsItem)
        {
            TextId &= 0x7f;
        }

        if (Movement == RbySpriteMovement.Walk)
        {
            Range = rangeOrDirection;
        }
        else
        {
            switch ((RbySpriteMovement)rangeOrDirection)
            {
            case RbySpriteMovement.Down: Direction = Action.Down; break;

            case RbySpriteMovement.Up: Direction = Action.Up; break;

            case RbySpriteMovement.Left: Direction = Action.Left; break;

            case RbySpriteMovement.Right: Direction = Action.Right; break;

            case RbySpriteMovement.None:
                Movement = RbySpriteMovement.Turn;
                goto default;

            default:
                Direction = Action.None;
                break;
            }
        }
    }
Exemple #9
0
    public override int WalkTo(int targetX, int targetY)
    {
        RbyMap  map      = Map;
        RbyTile current  = map[XCoord, YCoord];
        RbyTile target   = map[targetX, targetY];
        RbyWarp warp     = map.Warps[XCoord, YCoord];
        bool    original = false;

        if (warp != null)
        {
            original     = warp.Allowed;
            warp.Allowed = true;
        }
        List <Action> path = Pathfinding.FindPath(map, current, 17, map.Tileset.LandPermissions, target);

        if (warp != null)
        {
            warp.Allowed = original;
        }
        return(Execute(path.ToArray()));
    }