Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //An attempt at an automapping header.
- //v0.2.2
- //By: ZoriaRPG
- int MapFlags[214747]; //Holds map space datum, such as room type, and special icons to draw.
- int MapDoorFlags[214747]; //Holds room door pattern.
- ffc script SetMapFlags{
- void run(int doorUp, int doorDown, int doorLeft, int doorRight, int bossRoom, int specialItem, int miscFlag_1, int miscFlag2){
- int indx = GetCurrentMapIndex();
- //int MapData[214747];
- //int MapDMaps[214747];
- //int MapScreens[214747];
- //! Can we condense these into one flagset as an integer|?
- //! |No, we need one door flag, PER DOOR, so that's exceed 18 bits.
- //We're using 20 bits thus far. Can we simplify this to use the decimal values as a 32b flag?
- //Integer flags, for the room type and icons. 0 to 2048
- const int MAP_FLAG_BLANK = 000000000000b;
- const int MAP_FLAG_ROOM = 000000000001b;
- const int MAP_FLAG_VISITED = 000000000010b;
- const int MAP_FLAG_ITEM = 000000000100b;
- const int MAP_FLAG_CHEST = 000000001000b;
- const int MAP_FLAG_KEY = 000000010000b;
- const int MAP_FLAG_BOSSKEY = 000000100000b;
- const int MAP_FLAG_BOSSCHEST = 000001000000b;
- const int MAP_FLAG_SAVE = 000010000000b;
- const int MAP_FLAG_BOSS = 000100000000b;
- const int MAP_FLAG_MIDBOSS = 001000000000b;
- const int MAP_FLAG_TRIFORCE = 010000000000b;
- //Decimal flags, for the door types. 0 to 64
- //const int MAP_DOOR_ =
- const int MAP_DOOR_UP_NONE = 000000000000b;
- const int MAP_DOOR_UP_BOMB = 000000000001b;
- const int MAP_DOOR_UP_OPEN = 000000000010b;
- const int MAP_DOOR_UP_SHUTTER = 000000000100b;
- const int MAP_DOOR_UP_LOCKED = 000000001000b;
- const int MAP_DOOR_UP_BOSSLOCKED = 000000010000b;
- const int MAP_DOOR_UP_WALKTHROUGH = 000000100000b;
- const int MAP_DOOR_DOWN_NONE = 000000000000b;
- const int MAP_DOOR_DOWN_BOMB = 000000000001b;
- const int MAP_DOOR_DOWN_OPEN = 000000000010b;
- const int MAP_DOOR_DOWN_SHUTTER = 000000000100b;
- const int MAP_DOOR_DOWN_LOCKED = 000000001000b;
- const int MAP_DOOR_DOWN_BOSSLOCKED = 000000010000b;
- const int MAP_DOOR_DOWN_WALKTHROUGH = 000000100000b;
- const int MAP_DOOR_LEFT_NONE = 000000000000b;
- const int MAP_DOOR_LEFT_BOMB = 000000000001b;
- const int MAP_DOOR_LEFT_OPEN = 000000000010b;
- const int MAP_DOOR_LEFT_SHUTTER = 000000000100b;
- const int MAP_DOOR_LEFT_LOCKED = 000000001000b;
- const int MAP_DOOR_LEFT_BOSSLOCKED = 000000010000b;
- const int MAP_DOOR_LEFT_WALKTHROUGH = 000000100000b;
- const int MAP_DOOR_RIGHT_NONE = 000000000000b;
- const int MAP_DOOR_RIGHT_BOMB = 000000000001b;
- const int MAP_DOOR_RIGHT_OPEN = 000000000010b;
- const int MAP_DOOR_RIGHT_SHUTTER = 000000000100b;
- const int MAP_DOOR_RIGHT_LOCKED = 000000001000b;
- const int MAP_DOOR_RIGHT_BOSSLOCKED = 000000010000b;
- const int MAP_DOOR_RIGHT_WALKTHROUGH = 000000100000b;
- const int MAP_DOOR_UP_NONE = 0000000000000001b;
- const int MAP_DOOR_UP_BOMB = 0000000000000010b;
- const int MAP_DOOR_UP_OPEN = 0000000000000100b;
- const int MAP_DOOR_UP_SHUTTER = 0000000000001000b;
- const int MAP_DOOR_UP_LOCKED = 0000000000010000b;
- const int MAP_DOOR_UP_BOSSLOCKED = 0000000000100000b;
- const int MAP_DOOR_UP_WALKTHROUGH = 0000000001000000b;
- const int MAP_DOOR_DOWN_NONE = 0000000010000000b;
- const int MAP_DOOR_DOWN_BOMB = 0000000100000000b;
- const int MAP_DOOR_DOWN_OPEN = 0000001000000000b;
- const int MAP_DOOR_DOWN_SHUTTER = 0000010000000000b;
- const int MAP_DOOR_DOWN_LOCKED = 0000100000000000b;
- const int MAP_DOOR_DOWN_BOSSLOCKED = 0001000000000000b;
- const int MAP_DOOR_DOWN_WALKTHROUGH = 0010000000000000b;
- const int MAP_DOOR_LEFT_NONE = 01000000000000000b;
- const int MAP_DOOR_LEFT_BOMB = 10000000000000000b; //Last possible value under 214747.
- //! The rest would need to be the decimals.
- const int MAP_DOOR_LEFT_OPEN = 00000000000001b;
- const int MAP_DOOR_LEFT_SHUTTER = 00000000000010b;
- const int MAP_DOOR_LEFT_LOCKED = 00000000000100b;
- const int MAP_DOOR_LEFT_BOSSLOCKED = 00000000001000b;
- const int MAP_DOOR_LEFT_WALKTHROUGH = 00000000010000b;
- const int MAP_DOOR_RIGHT_NONE = 00000001000000b;
- const int MAP_DOOR_RIGHT_BOMB = 00000010000000b;
- const int MAP_DOOR_RIGHT_OPEN = 00000100000000b;
- const int MAP_DOOR_RIGHT_SHUTTER = 00001000000000b;
- const int MAP_DOOR_RIGHT_LOCKED = 00010000000000b;
- const int MAP_DOOR_RIGHT_BOSSLOCKED = 00100000000000b;
- const int MAP_DOOR_RIGHT_WALKTHROUGH = 01000000000000b; //through 2048 (4096 sum of flags)
- //! How would this look as a single flagset?!
- /*
- const int MAP_DOOR_UP_NONE = 00000000000000000000000000001b;
- const int MAP_DOOR_UP_BOMB = 00000000000000000000000000010b;
- const int MAP_DOOR_UP_OPEN = 00000000000000000000000000100b;
- const int MAP_DOOR_UP_SHUTTER = 00000000000000000000000001000b;
- const int MAP_DOOR_UP_LOCKED = 00000000000000000000000010000b;
- const int MAP_DOOR_UP_BOSSLOCKED = 00000000000000000000000100000b;
- const int MAP_DOOR_UP_WALKTHROUGH = 00000000000000000000001000000b;
- const int MAP_DOOR_DOWN_NONE = 00000000000000000000010000000b;
- const int MAP_DOOR_DOWN_BOMB = 00000000000000000000100000000b;
- const int MAP_DOOR_DOWN_OPEN = 00000000000000000001000000000b;
- const int MAP_DOOR_DOWN_SHUTTER = 00000000000000000010000000000b;
- const int MAP_DOOR_DOWN_LOCKED = 00000000000000000100000000000b;
- const int MAP_DOOR_DOWN_BOSSLOCKED = 00000000000000001000000000000b;
- const int MAP_DOOR_DOWN_WALKTHROUGH = 00000000000000010000000000000b;
- const int MAP_DOOR_LEFT_NONE = 00000000000001000000000000000b;
- const int MAP_DOOR_LEFT_BOMB = 00000000000010000000000000000b; //Last possible value under 214747.
- //! The rest would need to be the decimals.
- const int MAP_DOOR_LEFT_OPEN = 00000000000100000000000000000b;
- const int MAP_DOOR_LEFT_SHUTTER = 00000000001000000000000000000b;
- const int MAP_DOOR_LEFT_LOCKED = 00000000010000000000000000000b;
- const int MAP_DOOR_LEFT_BOSSLOCKED = 00000000100000000000000000000b;
- const int MAP_DOOR_LEFT_WALKTHROUGH = 00000001000000000000000000000b;
- const int MAP_DOOR_RIGHT_NONE = 00000010000000000000000000000b;
- const int MAP_DOOR_RIGHT_BOMB = 00000100000000000000000000000b;
- const int MAP_DOOR_RIGHT_OPEN = 00001000000000000000000000000b;
- const int MAP_DOOR_RIGHT_SHUTTER = 00010000000000000000000000000b;
- const int MAP_DOOR_RIGHT_LOCKED = 00100000000000000000000000000b;
- const int MAP_DOOR_RIGHT_BOSSLOCKED = 01000000000000000000000000000b;
- const int MAP_DOOR_RIGHT_WALKTHROUGH = 10000000000000000000000000000b; //through 2048 (4096 sum of flags)
- */
- const int MAP_DOOR_OTHER = 000001000000b;
- void SetMapFlag(int index, int flag, bool state){
- if ( state ) MapFlags[index] |= flag;
- else MapFlags[index] &= ~flag;
- }
- void GetMapFlag(int index, int flag){
- return ( MapFlags[index]&flag ) != 0;
- }
- //An arbitrary way to find the index for a specific screen and dmap.
- //We probably do not want to go tis route, and we'll use dmap sizing to stitch them together, then hardcode
- //their attributes so that we know what each index is.
- //
- //We can set constant floats for each room if desired, but this is certainly the lazy approach.
- int GetRoom(int dmap, int screen){
- int scr; int dmp; int q; int w; int index;
- for ( q = 0; q < SizeOfArray(MapDMaps); q++ ) {
- if ( MapDMaps[q] == dmap && MapScreens[q] == screen ) return q;
- }
- return -1;
- }
- //We draw 8x8 tiles for eacdh map space. These may be black (blank), grey (room), or blue (visited room).
- //We use the flags for each index to draw the rooms.
- const int MAP_TILE_EMPTYSPACE = 1000;
- const int MAP_TILE_ROOM = 1001;
- const int MAP_TILE_ROOMVISITED = 1002;
- const int MAP_ICON_ROOMITEM = 1003; //Overlay = icon
- const int MAP_ICON_ROOMSAVE = 1004;
- const int MAP_ICON_BOSS = 1005;
- const int MAP_OVERALL_WIDTH_COLUMNS = 500;
- const int MAP_OVERALL_HEIGHT_ROWS = 100;
- void DrawMapRoomsToBitmap(){
- int q; int w; int x; int y;
- for ( q = 0; q < SizeOfArray(MapFlags); q++ ) {
- //Draw those rows
- if ( q > 0 && q % MAP_OVERALL_WIDTH_COLUMNS == 0 ) { y += MAP_ROOM_Y; x = 0; } //New line
- //Draw the rooms and scale them.
- if ( GetMapFlag(q, MAP_FLAG_BLANK) ) DrawTile(q, MAP_TILE_EMPTYSPACE, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_ROOM) && !GetMapFlag(q, MAP_FLAG_VISITED) ) DrawTile(q, MAP_TILE_ROOM, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_ROOM) && GetMapFlag(q, MAP_FLAG_VISITED) ) DrawTile(q, MAP_TILE_VISITED, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- //Draw any room icons
- if ( GetMapFlag(q, MAP_FLAG_BOSS) ) DrawTile(q, MAP_ICON_BOSS, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_ITEM) ) DrawTile(q, MAP_ICON_ROOMITEM, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- if ( GetMapFlag(q, MAP_FLAG_SAVE) ) DrawTile(q, MAP_ICON_ROOMSAVE, MAP_TILE_WIDTH, MAP_TILE_HEIGHT);
- //Next room
- x += MAP_ROOM_X;
- }
- }
- const int MAP_TILE_WIDTH = 8;
- const int MAP_ROOM_X = 10;
- const int MAP_ROOM_Y = 10;
- const int MAP_ROOM_CENTER = 2;
- //We draw rooms in a pseudo-grid. Each room is a tile, drawn every ROOM_X pixels, in a row.
- //Each row is drawn ROOM_Y pixels below the previosu row, to the bitmap.
- const int MAP_BITMAP = 4;
- const int MAP_SLICE_X = 200; //20 rooms.
- const int MAP_SLICE_Y = 120; //12 rooms.
- void FindMapCentre(){} //Find the centre of the map based on the present room.
- const int MAP_DRAW_OFFSET_X = 100; //Half the size of the map, from the centre.
- const int MAP_DRAW_OFFSET_Y = 60; //Half the size of the map, from the centre.
- void MapToScreen(){
- // We draw the map from the bitmap, on layer 7. To accomplish this, we find its centre, and draw the
- // upper-left corner based on the true centre ( FindMapCentre() - OFFSETS), minus the offsets,
- // and set the full width and height to its size (MAP_SLICE).
- Screen->DrawBitmap(MAP_DRAW_LAYER, MAP_BITMAP, (FindMapCentre() - MAP_DRAW_OFFSET_X), (FindMapCentre() - MAP_DRAW_OFFSET_Y), MAP_SLICE_X, MAP_SLICE_Y, true);
- }
- const int MAP_DRAW_LAYER = 7;
- const int MAP_DRAW_X = 4; //Upper-left corner of map display.
- const int MAP_DRAW_Y = 4;
- //Dmaps
- //If we predefine the exact width and height of each dmap, we can stitch them together.
- const int DMAP_WIDTH_1 = 16; //16 rooma
- const int DMAP_HEIGHT_1 = 8; //8 rooms
- const int DMAP_WIDTH_1 = 8; //8 rooma
- const int DMAP_HEIGHT_1 = 8; //8 rooms
- //...
- ///...then we define the placement of the dmap in the overall map.
- const int FIRST_ROW_DMAP_1 = 0;
- const int FIRST_COLUMN_DMAP_1 = 0;
- const int LAST_COLUMN_DMAP_1 = 15;
- const int LAST_ROW_DMAP_1 = 7;
- const int FIRST_ROW_DMAP_2 = 0;
- const int FIRST_COLUMN_DMAP_2 = 16; //This dmap would be stitched to the exact right of dmap 1
- const int LAST_COLUMN_DMAP_1 = 23; //This would be an 8x8 DMAp attached to a 16x8 DMAP.
- const int LAST_ROW_DMAP_1 = 7;
- void DoMap(){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement