Currently event intervals can only be supplied as ints representing whole seconds, and I think this ought to allow them to be supplied as floats as well, so if you want sub-second intervals you don't need hacky events to do so but can simply use for example 0.25 for a quarter-second interval.
It works for me in-game, but since I can't compile FRED myself I don't know whether it works there or not. If anyone would like to test this or otherwise point out whether there's something wrong with it then that'd be great.
Index: fred2/messageeditordlg.cpp
===================================================================
--- fred2/messageeditordlg.cpp (revision 8847)
+++ fred2/messageeditordlg.cpp (working copy)
@@ -433,7 +433,7 @@
m_event_num = Num_mission_events++;
string_copy(Mission_events[m_event_num].name, m_message_name, NAME_LENGTH - 1);
Mission_events[m_event_num].repeat_count = 1;
- Mission_events[m_event_num].interval = 1;
+ Mission_events[m_event_num].interval = 1.0f;
Mission_events[m_event_num].score = 0;
Mission_events[m_event_num].chain_delay = -1;
Mission_events[m_event_num].objective_text = NULL;
Index: fred2/eventeditor.cpp
===================================================================
--- fred2/eventeditor.cpp (revision 8847)
+++ fred2/eventeditor.cpp (working copy)
@@ -37,7 +37,7 @@
//{{AFX_DATA_INIT(event_editor)
m_repeat_count = 0;
m_trigger_count = 0;
- m_interval = 0;
+ m_interval = 0.0f;
m_event_score = 0;
m_chain_delay = 0;
m_chained = FALSE;
@@ -711,7 +711,7 @@
m_events[num].repeat_count = 1;
m_events[num].trigger_count = 1;
- m_events[num].interval = 1;
+ m_events[num].interval = 1.0f;
m_events[num].score = 0;
m_events[num].chain_delay = -1;
m_events[num].objective_text = NULL;
@@ -928,7 +928,7 @@
if (cur_event < 0) {
m_repeat_count = 1;
m_trigger_count = 1;
- m_interval = 1;
+ m_interval = 1.0f;
m_chain_delay = 0;
m_team = -1;
m_obj_text.Empty();
@@ -980,7 +980,7 @@
GetDlgItem(IDC_TRIGGER_COUNT)->EnableWindow(TRUE);
if (( m_repeat_count <= 1) && (m_trigger_count <= 1)) {
- m_interval = 1;
+ m_interval = 1.0f;
GetDlgItem(IDC_INTERVAL_TIME) -> EnableWindow(FALSE);
} else {
GetDlgItem(IDC_INTERVAL_TIME) -> EnableWindow(TRUE);
Index: fred2/eventeditor.h
===================================================================
--- fred2/eventeditor.h (revision 8847)
+++ fred2/eventeditor.h (working copy)
@@ -56,7 +56,7 @@
event_sexp_tree m_event_tree;
UINT m_repeat_count;
UINT m_trigger_count;
- UINT m_interval;
+ float m_interval;
int m_event_score;
int m_chain_delay;
BOOL m_chained;
Index: fred2/missionsave.cpp
===================================================================
--- fred2/missionsave.cpp (revision 8847)
+++ fred2/missionsave.cpp (working copy)
@@ -3323,7 +3323,7 @@
fout("\n+Interval:");
}
- fout(" %d", Mission_events[i].interval);
+ fout(" %f", Mission_events[i].interval);
if ( Mission_events[i].score != 0 ) {
if ( optional_string_fred("+Score:", "$Formula:")){
Index: mission/missiongoals.h
===================================================================
--- mission/missiongoals.h (revision 8847)
+++ mission/missiongoals.h (working copy)
@@ -89,7 +89,7 @@
int result; // result of most recent evaluation of event
int repeat_count; // number of times to test this goal
int trigger_count; // number of times to allow this goal to trigger
- int interval; // interval (in seconds) at which an evaulation is repeated once true.
+ float interval; // interval (in seconds) at which an evaulation is repeated once true.
int timestamp; // set at 'interval' seconds when we start to eval.
int score; // score for this event
int chain_delay;
Index: mission/missionparse.cpp
===================================================================
--- mission/missionparse.cpp (revision 8847)
+++ mission/missionparse.cpp (working copy)
@@ -4488,9 +4488,9 @@
event->trigger_count = 1;
}
- event->interval = -1;
+ event->interval = -1.0f;
if ( optional_string("+Interval:")){
- stuff_int( &(event->interval) );
+ stuff_float( &(event->interval) );
}
event->score = 0;
Index: parse/lua.cpp
===================================================================
--- parse/lua.cpp (revision 8847)
+++ parse/lua.cpp (working copy)
@@ -939,7 +939,7 @@
ADE_VIRTVAR(Interval, l_Event, "number", "Time for event to repeat (in seconds)", "number", "Repeat time, or 0 if invalid handle")
{
int idx;
- int newinterval = 0;
+ float newinterval = 0.0f;
if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newinterval))
return ade_set_error(L, "i", 0);
Index: mission/missiongoals.cpp
===================================================================
--- mission/missiongoals.cpp (revision 8847)
+++ mission/missiongoals.cpp (working copy)
@@ -976,7 +976,7 @@
// this event didn't trigger this frame.
else if (bump_timestamp || (!( Mission_events[event].repeat_count == -1 && Mission_events[event].trigger_count > 0 ))) {
// set the timestamp to time out 'interval' seconds in the future.
- Mission_events[event].timestamp = timestamp( Mission_events[event].interval * 1000 );
+ Mission_events[event].timestamp = timestamp( int(Mission_events[event].interval * 1000.0f) );
}
}