I know bringing up an old thread is a no-no, I couldn't help but inquire as to how to implement a few more tokens into the script engine. specifically ArcSine, ArcCosine, and Atan2. support for those functions is included in Math.h for the idMath class:
Code:
static float ASin( float a ); // arc sine with 32 bits precision, input is clamped to [-1, 1] to avoid a silent NaN
static float ASin16( float a ); // arc sine with 16 bits precision, maximum absolute error is 6.7626e-05
static double ASin64( float a ); // arc sine with 64 bits precision
static float ACos( float a ); // arc cosine with 32 bits precision, input is clamped to [-1, 1] to avoid a silent NaN
static float ACos16( float a ); // arc cosine with 16 bits precision, maximum absolute error is 6.7626e-05
static double ACos64( float a ); // arc cosine with 64 bits precision
static float ATan( float a ); // arc tangent with 32 bits precision
static float ATan16( float a ); // arc tangent with 16 bits precision, maximum absolute error is 1.3593e-08
static double ATan64( float a ); // arc tangent with 64 bits precision
static float ATan( float y, float x ); // arc tangent with 32 bits precision
static float ATan16( float y, float x ); // arc tangent with 16 bits precision, maximum absolute error is 1.3593e-08
static double ATan64( float y, float x ); // arc tangent with 64 bits precision
here's how cos goes from script to the engine in the game:
Code:
##doom_events.script:343
scriptEvent float cos( float degrees );
becomes:
Code:
##Script_Thread.cpp:45
const idEventDef EV_Thread_Cosine( "cos", "f", 'f' );
becomes:
Code:
##Script_Thread.cpp:124
EVENT( EV_Thread_Cosine, idThread::Event_GetCosine )
becomes:
Code:
##Script_Thread.h:117
void Event_GetCosine( float angle );
becomes:
Code:
##Script_Thread.cpp:1259
/*
================
idThread::Event_GetCosine
================
*/
void idThread::Event_GetCosine( float angle ) {
ReturnFloat( idMath::Cos( DEG2RAD( angle ) ) );
}
It seems as though including those extra script arguments should be fairly easy to implement, no?