diff --git a/!TheEsc/!RunImage,ff8 b/!TheEsc/!RunImage,ff8 index ec9d1b9..fc49592 100644 Binary files a/!TheEsc/!RunImage,ff8 and b/!TheEsc/!RunImage,ff8 differ diff --git a/!TheEsc/c/Mission2 b/!TheEsc/c/Mission2 index befbeb6..61f04de 100644 --- a/!TheEsc/c/Mission2 +++ b/!TheEsc/c/Mission2 @@ -15,6 +15,9 @@ extern _kernel_swi_regs outreg; #define SMARTTILES 200 #define AREAS 20 +#define MAXEVENTS 200 +#define MAXEVENTACTIONS 1000 + // map[0] is the 'master', [1] and [2] represents what is currently // believed to be displayed in the corresponding (+1) screen buffer // and we run a compare to see if re-drawing is needed. 0xFF is used @@ -67,14 +70,67 @@ struct TilePlayer_s { struct TilePlayer_s TilePlayer; +/* VVV deprecated VVV */ struct SmartTile_s { int Tile; int ActionTarget; unsigned char Action; unsigned char ActionValue; }; - struct SmartTile_s SmartTiles[SMARTTILES]; +/* ^^^ deprecated ^^^ */ + + +struct EventAction_s { + int Event; + unsigned char Action; //0=change tile / 1=change area / sound + unsigned char ActionValue; //tile sprite no. / area ID / sound ID + int ActionTarget; //tile ID / n/a / channel ID +}; +struct EventAction_s EventActions[MAXEVENTACTIONS]; + +struct Event_s { + unsigned char Name[16]; + unsigned char Triggered; + int RearmDelay; + int NextRearm; +}; +struct Event_s Events[MAXEVENTS]; + +void game2_loadevents() +{ + int i; + for(i = 0; i 0) + { + if(tick > Events[id].NextRearm) + { + Events[id].Triggered = 0; + Events[id].NextRearm = -1; + } + } + + // Don't trigger if we've been fired and not reset + if(Events[id].Triggered == 1) + { + printf("Not triggering event %d - %s\n",id,Events[id].Name); + return; + } + + // Record firing + Events[id].Triggered = 1; + printf("Triggering event %d - %s\n",id,Events[id].Name); + + // Schedule re-arm if required + if(Events[id].RearmDelay >= 0) + Events[id].NextRearm = tick + Events[id].RearmDelay; + + // Go through our actions + for(i = 0; i