Original Post
Hi, I've been playing CoD4 for a while now, and been making some modifications. I've noticed that the scripting language they use, is very easy and familiar to work with, it has a C-like syntax. I would like to use something similair in my projects aswell, though I don't know how the language is called, if it's IW's (CoD4 makers) property and if it's free to use/downloadable. See this for an explaination of CoD4 scripting language Quake 3 has C files as 'scripting' language (AI logic), but I wonder how they do it. Is it compiled on the fly/when the game lauches/before hand? In other words, is it just hardcoded or like CoD4 approaches this matter? I've seen Lua, but I'm not familiar with the syntax/don't like it very much (problematic to run too for me). I've also tried Cint, which executes C on-the-fly (so C as a scipting language), but I'm unsure if it's wise to use it for games/projects...it rather looks like a learning language... Any thoughts? Thanks. This is an example of C-like script:
#include common_scripts\utility;
#include maps\mp\_utility;
// This script automaticly plays a users specified oneshot effect on all prefabs that have the
// specified "script_struct" and "targetname" It also excepts angles from the "script_struct"
// but will set a default angle of ( 0, 0, 0 ) if none is defined.
//
// example of the syntax:
// global_FX( "targetname", "fxIDname", "fxFile", "delay"
main()
{
randomStartDelay = randomfloatrange( -20, -15);
//map_source/prefabs/misc_models/com_barrel_fire.map
global_FX( "barrel_fireFX_origin", "global_barrel_fire", "fire/firelp_barrel_pm", randomStartDelay, "fire_barrel_small" );
//map_source/prefabs/misc_models/ch_street_light_02_on.map
//prefabs/misc_models/ch_street_wall_light_01_on.map
global_FX( "ch_streetlight_02_FX_origin", "ch_streetlight_02_FX", "misc/lighthaze", randomStartDelay );
//prefabs/misc_models/me_streetlight_on_scaleddown80.map
global_FX( "me_streetlight_01_FX_origin", "me_streetlight_01_FX", "misc/lighthaze_bog_a", randomStartDelay );
//prefabs\village_assault\misc\lamp_post.map
global_FX( "ch_street_light_01_on", "lamp_glow_FX", "misc/light_glow_white", randomStartDelay );
//prefabs\village_assault\misc\highway_lamp_post.map
global_FX( "highway_lamp_post", "ch_streetlight_02_FX", "misc/lighthaze_villassault", randomStartDelay );
//prefabs/misc_models/cs_cargoship_spotlight_on.map
global_FX( "cs_cargoship_spotlight_on_FX_origin", "cs_cargoship_spotlight_on_FX", "misc/lighthaze", randomStartDelay );
//prefabs/misc_models/me_dumpster_fire.map
global_FX( "me_dumpster_fire_FX_origin", "me_dumpster_fire_FX", "fire/firelp_med_pm_nodistort", randomStartDelay, "fire_dumpster_medium" );
//map_source/prefabs/misc_models/com_tires01_burning.map
global_FX( "com_tires_burning01_FX_origin", "com_tires_burning01_FX", "fire/tire_fire_med", randomStartDelay );
//map_source/prefabs/icbm/icbm_powerlinetower02.map
global_FX( "icbm_powerlinetower_FX_origin", "icbm_powerlinetower_FX", "misc/power_tower_light_red_blink", randomStartDelay );
}
global_FX( targetname, fxName, fxFile, delay, soundalias )
{
// script_structs
ents = getstructarray(targetname,"targetname");
if ( !isdefined( ents ) )
return;
if ( ents.size <= 0 )
return;
for ( i = 0 ; i < ents.size ; i++ )
ents global_FX_create( fxName, fxFile, delay, soundalias );
}
global_FX_create( fxName, fxFile, delay, soundalias )
{
if ( !isdefined( level._effect ) )
level._effect = [];
if ( !isdefined( level._effect[ fxName ] ) )
level._effect[ fxName ] = loadfx( fxFile );
// default effect angles if they dont exist
if ( !isdefined( self.angles ) )
self.angles = ( 0, 0, 0 );
ent = createOneshotEffect( fxName );
ent.v[ "origin" ] = ( self.origin );
ent.v[ "angles" ] = ( self.angles );
ent.v[ "fxid" ] = fxName;
ent.v[ "delay" ] = delay;
if ( isdefined( soundalias ) )
{
ent.v[ "soundalias" ] = soundalias;
}
}