mirror of
https://github.com/stevenhowes/CTheEscape.git
synced 2026-05-26 15:53:29 +01:00
Event scheduling
This commit is contained in:
Binary file not shown.
@@ -48,8 +48,6 @@ o.Input: c.Input
|
|||||||
o.Input: C:h.swis
|
o.Input: C:h.swis
|
||||||
o.Input: C:h.kernel
|
o.Input: C:h.kernel
|
||||||
o.Input: C:h.kernel
|
o.Input: C:h.kernel
|
||||||
o.Intro: c.Intro
|
|
||||||
o.Intro: h.Graphics
|
|
||||||
o.CTheEscape: c.CTheEscape
|
o.CTheEscape: c.CTheEscape
|
||||||
o.CTheEscape: C:h.swis
|
o.CTheEscape: C:h.swis
|
||||||
o.CTheEscape: C:h.kernel
|
o.CTheEscape: C:h.kernel
|
||||||
@@ -61,6 +59,8 @@ o.Sound: C:h.swis
|
|||||||
o.Sound: C:h.kernel
|
o.Sound: C:h.kernel
|
||||||
o.Sound: C:h.kernel
|
o.Sound: C:h.kernel
|
||||||
o.Sound: h.Sound
|
o.Sound: h.Sound
|
||||||
|
o.Intro: c.Intro
|
||||||
|
o.Intro: h.Graphics
|
||||||
o.Mission1: c.Mission1
|
o.Mission1: c.Mission1
|
||||||
o.Mission1: h.Graphics
|
o.Mission1: h.Graphics
|
||||||
o.Mission1: h.Sound
|
o.Mission1: h.Sound
|
||||||
|
|||||||
+14
-8
@@ -51,17 +51,23 @@ o.Mission2: h.Graphics
|
|||||||
o.Mission2: C:h.swis
|
o.Mission2: C:h.swis
|
||||||
o.Mission2: C:h.kernel
|
o.Mission2: C:h.kernel
|
||||||
o.Mission2: C:h.kernel
|
o.Mission2: C:h.kernel
|
||||||
o.Input: c.Input
|
|
||||||
o.Input: C:h.swis
|
|
||||||
o.Input: C:h.kernel
|
|
||||||
o.Input: C:h.kernel
|
|
||||||
o.Graphics: c.Graphics
|
|
||||||
o.Graphics: C:h.swis
|
|
||||||
o.Graphics: C:h.kernel
|
|
||||||
o.Graphics: C:h.kernel
|
|
||||||
o.MapEdit: c.MapEdit
|
o.MapEdit: c.MapEdit
|
||||||
o.MapEdit: C:h.swis
|
o.MapEdit: C:h.swis
|
||||||
o.MapEdit: C:h.kernel
|
o.MapEdit: C:h.kernel
|
||||||
o.MapEdit: C:h.kernel
|
o.MapEdit: C:h.kernel
|
||||||
o.MapEdit: h.Sound
|
o.MapEdit: h.Sound
|
||||||
o.MapEdit: h.Graphics
|
o.MapEdit: h.Graphics
|
||||||
|
o.MapEdit: c.MapEdit
|
||||||
|
o.MapEdit: C:h.swis
|
||||||
|
o.MapEdit: C:h.kernel
|
||||||
|
o.MapEdit: C:h.kernel
|
||||||
|
o.MapEdit: h.Sound
|
||||||
|
o.MapEdit: h.Graphics
|
||||||
|
o.Graphics: c.Graphics
|
||||||
|
o.Graphics: C:h.swis
|
||||||
|
o.Graphics: C:h.kernel
|
||||||
|
o.Graphics: C:h.kernel
|
||||||
|
o.Input: c.Input
|
||||||
|
o.Input: C:h.swis
|
||||||
|
o.Input: C:h.kernel
|
||||||
|
o.Input: C:h.kernel
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
|
||||||
//#define SKIP_INTRO
|
#define SKIP_INTRO
|
||||||
//#define SKIP_MISSION1
|
#define SKIP_MISSION1
|
||||||
//#define SKIP_MISSION2
|
//#define SKIP_MISSION2
|
||||||
|
|
||||||
// SWI Registers
|
// SWI Registers
|
||||||
|
|||||||
+63
-5
@@ -83,9 +83,9 @@ struct SmartTile_s SmartTiles[SMARTTILES];
|
|||||||
|
|
||||||
struct EventAction_s {
|
struct EventAction_s {
|
||||||
int Event;
|
int Event;
|
||||||
unsigned char Action; //0=change tile / 1=change area / 2=sound / 3=rearm
|
unsigned char Action; //0=change tile / 1=change area / 2=sound / 3=rearm / 4=schedule
|
||||||
unsigned char ActionValue; //tile sprite no. / area ID / sound ID / na
|
unsigned char ActionValue; //tile sprite no. / area ID / sound ID / na / eventid
|
||||||
int ActionTarget; //tile ID / n/a / channel ID / eventid
|
int ActionTarget; //tile ID / n/a / channel ID / eventid / ticks
|
||||||
};
|
};
|
||||||
struct EventAction_s EventActions[MAXEVENTACTIONS];
|
struct EventAction_s EventActions[MAXEVENTACTIONS];
|
||||||
|
|
||||||
@@ -97,6 +97,13 @@ struct Event_s {
|
|||||||
};
|
};
|
||||||
struct Event_s Events[MAXEVENTS];
|
struct Event_s Events[MAXEVENTS];
|
||||||
|
|
||||||
|
struct ScheduledEvent_s {
|
||||||
|
int Event;
|
||||||
|
int Ticks;
|
||||||
|
};
|
||||||
|
struct ScheduledEvent_s ScheduledEvents[MAXEVENTS];
|
||||||
|
|
||||||
|
|
||||||
void game2_saveevents(char* filename)
|
void game2_saveevents(char* filename)
|
||||||
{
|
{
|
||||||
// Attempt to get file info
|
// Attempt to get file info
|
||||||
@@ -133,6 +140,10 @@ void game2_loadevents(char* filename)
|
|||||||
Events[i].Triggered = 1;
|
Events[i].Triggered = 1;
|
||||||
Events[i].RearmDelay = -1;
|
Events[i].RearmDelay = -1;
|
||||||
Events[i].NextRearm = -1;
|
Events[i].NextRearm = -1;
|
||||||
|
|
||||||
|
// We can populate these here as we use MAXEVENTS for both
|
||||||
|
ScheduledEvents[i].Event = -1;
|
||||||
|
ScheduledEvents[i].Ticks = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to get file info
|
// Attempt to get file info
|
||||||
@@ -578,6 +589,29 @@ void game2_tick_input()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int game2_newevent()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int freeid = -1;
|
||||||
|
|
||||||
|
for(i = 0; i<MAXEVENTS; i++)
|
||||||
|
{
|
||||||
|
if(ScheduledEvents[i].Event < 0)
|
||||||
|
{
|
||||||
|
freeid = i;
|
||||||
|
i = MAXEVENTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(freeid < 0)
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
printf("No free slots in event scheduler!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return freeid;
|
||||||
|
}
|
||||||
|
|
||||||
void game2_triggerevent(int id)
|
void game2_triggerevent(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -616,12 +650,34 @@ void game2_triggerevent(int id)
|
|||||||
sound_pcm_playsample_ifidle(EventActions[i].ActionTarget,EventActions[i].ActionValue);
|
sound_pcm_playsample_ifidle(EventActions[i].ActionTarget,EventActions[i].ActionValue);
|
||||||
else if(EventActions[i].Action == 3) // Re-arm
|
else if(EventActions[i].Action == 3) // Re-arm
|
||||||
Events[EventActions[i].ActionTarget].Triggered = 0;
|
Events[EventActions[i].ActionTarget].Triggered = 0;
|
||||||
|
else if(EventActions[i].Action == 4) // Schedule Event
|
||||||
|
{
|
||||||
|
int scheduleid = game2_newevent();
|
||||||
|
ScheduledEvents[scheduleid].Event = EventActions[i].ActionValue;
|
||||||
|
ScheduledEvents[scheduleid].Ticks = tick + EventActions[i].ActionTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void game2_triggerscheduledevents()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i<MAXEVENTS; i++)
|
||||||
|
{
|
||||||
|
if(ScheduledEvents[i].Event > 0)
|
||||||
|
{
|
||||||
|
if(tick > ScheduledEvents[i].Ticks)
|
||||||
|
{
|
||||||
|
// Trigger the event
|
||||||
|
game2_triggerevent(ScheduledEvents[i].Event);
|
||||||
|
|
||||||
|
// Clear it
|
||||||
|
ScheduledEvents[i].Event = -1;
|
||||||
|
ScheduledEvents[i].Ticks = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int game2_tick()
|
int game2_tick()
|
||||||
@@ -703,6 +759,8 @@ int game2_tick()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game2_triggerscheduledevents();
|
||||||
|
|
||||||
game2_tick_input();
|
game2_tick_input();
|
||||||
|
|
||||||
if((TilePlayer.facedirection & (1 << DIRECTION_N)) && (TilePlayer.facedirection & (1 << DIRECTION_E))) //NE
|
if((TilePlayer.facedirection & (1 << DIRECTION_N)) && (TilePlayer.facedirection & (1 << DIRECTION_E))) //NE
|
||||||
|
|||||||
@@ -96,6 +96,28 @@
|
|||||||
$eventactions[] = array("Event"=>$inevent,"Action"=>3,"ActionValue"=>255,"ActionTarget"=>$target);
|
$eventactions[] = array("Event"=>$inevent,"Action"=>3,"ActionValue"=>255,"ActionTarget"=>$target);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "Schedule":
|
||||||
|
if($inevent < 0)
|
||||||
|
{
|
||||||
|
echo " Invalid outside event\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$csv = str_getcsv($split[1]);
|
||||||
|
|
||||||
|
$target = -1;
|
||||||
|
foreach($events as $eventid=>$event)
|
||||||
|
{
|
||||||
|
if($event['Name'] == $csv[0])
|
||||||
|
$target = $eventid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($target < 0)
|
||||||
|
echo " Unknown target: " . $csv[0] . "\n";
|
||||||
|
else
|
||||||
|
$eventactions[] = array("Event"=>$inevent,"Action"=>4,"ActionValue"=>$target,"ActionTarget"=>$csv[1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
echo " Unknown command: " . $split[0] . "\n";
|
echo " Unknown command: " . $split[0] . "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -12,8 +12,13 @@ AddEvent(6,"CB1-DOORCLOSE",1,-1,-1)
|
|||||||
AddEvent(7,"CB2-DOOROPEN",0,-1,-1)
|
AddEvent(7,"CB2-DOOROPEN",0,-1,-1)
|
||||||
AddEvent(8,"CB2-DOORCLOSE",1,-1,-1)
|
AddEvent(8,"CB2-DOORCLOSE",1,-1,-1)
|
||||||
|
|
||||||
|
AddEvent(9,"Brief",0,-1,-1)
|
||||||
|
|
||||||
Event("PlayerStart")
|
Event("PlayerStart")
|
||||||
AreaName(1)
|
AreaName(1)
|
||||||
|
Schedule("Brief",200)
|
||||||
|
|
||||||
|
Event("Brief")
|
||||||
Sound(8,4)
|
Sound(8,4)
|
||||||
|
|
||||||
Event("SBBR-DOOROPEN")
|
Event("SBBR-DOOROPEN")
|
||||||
|
|||||||
Reference in New Issue
Block a user