init
This commit is contained in:
921 files changed
+337975
No files matched your search
@@ -0,0 +1,199 @@
|
||||
Line truncated
|
||||
|
||||
function setModelFromArray(a)
|
||||
{
|
||||
self setModel(a[randomint(a.size)]);
|
||||
}
|
||||
|
||||
function randomElement(a)
|
||||
{
|
||||
return a[randomint(a.size)];
|
||||
}
|
||||
|
||||
function attachFromArray(a)
|
||||
{
|
||||
self attach(randomElement(a), "", true);
|
||||
}
|
||||
|
||||
function newcharacter()
|
||||
{
|
||||
self detachAll();
|
||||
oldGunHand = self.anim_gunHand;
|
||||
if (!isdefined(oldGunHand))
|
||||
return;
|
||||
self.anim_gunHand = "none";
|
||||
self [[anim.PutGunInHand]](oldGunHand);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
info["gunHand"] = self.anim_gunHand;
|
||||
info["gunInHand"] = self.anim_gunInHand;
|
||||
info["model"] = self.model;
|
||||
info["hatModel"] = self.hatModel;
|
||||
info["gearModel"] = self.gearModel;
|
||||
if (isdefined (self.name))
|
||||
{
|
||||
info["name"] = self.name;
|
||||
/#println ("Save: Guy has name ", self.name);#/
|
||||
}
|
||||
else
|
||||
{
|
||||
/#println ("save: Guy had no name!");#/
|
||||
}
|
||||
|
||||
attachSize = self getAttachSize();
|
||||
for (i = 0; i < attachSize; i++)
|
||||
{
|
||||
info["attach"][i]["model"] = self getAttachModelName(i);
|
||||
info["attach"][i]["tag"] = self getAttachTagName(i);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
function load(info)
|
||||
{
|
||||
self detachAll();
|
||||
self.anim_gunHand = info["gunHand"];
|
||||
self.anim_gunInHand = info["gunInHand"];
|
||||
self setModel(info["model"]);
|
||||
self.hatModel = info["hatModel"];
|
||||
self.gearModel = info["gearModel"];
|
||||
if (isdefined (info["name"]))
|
||||
{
|
||||
self.name = info["name"];
|
||||
/#println ("Load: Guy has name ", self.name);#/
|
||||
}
|
||||
else
|
||||
{
|
||||
/#println ("Load: Guy had no name!");#/
|
||||
}
|
||||
|
||||
attachInfo = info["attach"];
|
||||
attachSize = attachInfo.size;
|
||||
for (i = 0; i < attachSize; i++)
|
||||
self attach(attachInfo[i]["model"], attachInfo[i]["tag"]);
|
||||
}
|
||||
|
||||
/*
|
||||
function sample save/precache/load usage (precache is only required if there are any waits in the level script before load):
|
||||
|
||||
save:
|
||||
info = foley character::save();
|
||||
game["foley"] = info;
|
||||
changelevel("burnville", 0, true);
|
||||
|
||||
precache:
|
||||
character::precache(game["foley"]);
|
||||
|
||||
load:
|
||||
foley character::load(game["foley"]);
|
||||
|
||||
*/
|
||||
|
||||
function get_random_character( amount )
|
||||
{
|
||||
self_info = strtok( self.classname, "_" );
|
||||
if ( self_info.size <= 2 )
|
||||
{
|
||||
// some custom guy that doesn't use standard naming convention
|
||||
return randomint( amount );
|
||||
}
|
||||
|
||||
|
||||
group = "auto"; // by default the type is an auto-selected character
|
||||
index = undefined;
|
||||
prefix = self_info[ 2 ]; // merc, marine, etc
|
||||
|
||||
// the designer can overwrite the character
|
||||
if ( isdefined( self.script_char_index ) )
|
||||
{
|
||||
index = self.script_char_index;
|
||||
}
|
||||
|
||||
// the designer can hint that this guy is a member of a group of like - spawned guys, so he should use a different index
|
||||
if ( isdefined( self.script_char_group ) )
|
||||
{
|
||||
type = "grouped";
|
||||
group = "group_" + self.script_char_group;
|
||||
}
|
||||
|
||||
if ( !isdefined( level.character_index_cache ) )
|
||||
{
|
||||
// separately store script grouped guys and auto guys so that they dont influence each other
|
||||
level.character_index_cache = [];
|
||||
}
|
||||
|
||||
if ( !isdefined( level.character_index_cache[ prefix ] ) )
|
||||
{
|
||||
// separately store script grouped guys and auto guys so that they dont influence each other
|
||||
level.character_index_cache[ prefix ] = [];
|
||||
}
|
||||
|
||||
if ( !isdefined( level.character_index_cache[ prefix ][ group ] ) )
|
||||
{
|
||||
initialize_character_group( prefix, group, amount );
|
||||
}
|
||||
|
||||
if ( !isdefined( index ) )
|
||||
{
|
||||
index = get_least_used_index( prefix, group );
|
||||
|
||||
if ( !isdefined( index ) )
|
||||
{
|
||||
// fail safe
|
||||
index = randomint( 5000 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while ( index >= amount )
|
||||
{
|
||||
index -= amount;
|
||||
}
|
||||
|
||||
level.character_index_cache[ prefix ][ group ][ index ]++;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
function get_least_used_index( prefix, group )
|
||||
{
|
||||
lowest_indices = [];
|
||||
lowest_use = level.character_index_cache[ prefix ][ group ][ 0 ];
|
||||
lowest_indices[ 0 ] = 0;
|
||||
|
||||
for ( i = 1; i < level.character_index_cache[ prefix ][ group ].size; i++ )
|
||||
{
|
||||
if ( level.character_index_cache[ prefix ][ group ][ i ] > lowest_use )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( level.character_index_cache[ prefix ][ group ][ i ] < lowest_use )
|
||||
{
|
||||
// if its the new lowest, start over on the array
|
||||
lowest_indices = [];
|
||||
lowest_use = level.character_index_cache[ prefix ][ group ][ i ];
|
||||
}
|
||||
|
||||
// the equal amounts end up in the array
|
||||
lowest_indices[ lowest_indices.size ] = i;
|
||||
}
|
||||
assert( lowest_indices.size, "Tried to spawn a character but the lowest indices didn't exist" );
|
||||
return random( lowest_indices );
|
||||
}
|
||||
|
||||
function initialize_character_group( prefix, group, amount )
|
||||
{
|
||||
for ( i = 0; i < amount; i++ )
|
||||
{
|
||||
level.character_index_cache[ prefix ][ group ][ i ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function random( array )
|
||||
{
|
||||
keys = GetArrayKeys( array );
|
||||
return array[ keys[RandomInt( keys.size )] ];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Line truncated
|
||||
|
||||
function main()
|
||||
{
|
||||
assert(isdefined(self));
|
||||
wait 0;
|
||||
if (isdefined(self))
|
||||
{
|
||||
/#
|
||||
if(isdefined(self.classname))
|
||||
{
|
||||
if( self.classname == "trigger_once" || self.classname == "trigger_radius" || self.classname == "trigger_multiple" )
|
||||
{
|
||||
println( "" );
|
||||
println( "*** trigger debug: delete.gsc is deleting trigger with ent#: " + self getentitynumber() + " at origin: " + self.origin );
|
||||
|
||||
//players = GetPlayers( localClientNum );
|
||||
//println( "*** trigger debug: player origin is: " + players[0].origin );
|
||||
|
||||
println( "" );
|
||||
}
|
||||
}
|
||||
#/
|
||||
self delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Line truncated
|
||||
|
||||
function main()
|
||||
{
|
||||
assert(isdefined(self));
|
||||
wait 0;
|
||||
if (isdefined(self))
|
||||
{
|
||||
/#
|
||||
if(isdefined(self.classname))
|
||||
{
|
||||
if( self.classname == "trigger_once" || self.classname == "trigger_radius" || self.classname == "trigger_multiple" )
|
||||
{
|
||||
println( "" );
|
||||
println( "*** trigger debug: delete.gsc is deleting trigger with ent#: " + self getentitynumber() + " at origin: " + self.origin );
|
||||
|
||||
//players = GetPlayers();
|
||||
//println( "*** trigger debug: player origin is: " + players[0].origin );
|
||||
|
||||
println( "" );
|
||||
}
|
||||
}
|
||||
#/
|
||||
self delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
#using scripts\shared\scene_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
function autoexec __init__()
|
||||
{
|
||||
// set up arrays even if there are no structs in the level
|
||||
|
||||
if ( !isdefined( level.struct ) )
|
||||
{
|
||||
init_structs();
|
||||
}
|
||||
}
|
||||
|
||||
function init_structs()
|
||||
{
|
||||
level.struct = [];
|
||||
level.scriptbundles = [];
|
||||
level.scriptbundlelists = [];
|
||||
|
||||
level.struct_class_names = [];
|
||||
level.struct_class_names[ "target" ] = [];
|
||||
level.struct_class_names[ "targetname" ] = [];
|
||||
level.struct_class_names[ "script_noteworthy" ] = [];
|
||||
level.struct_class_names[ "script_linkname" ] = [];
|
||||
level.struct_class_names[ "script_label" ] = [];
|
||||
level.struct_class_names[ "classname" ] = [];
|
||||
level.struct_class_names[ "script_unitrigger_type" ] = [];
|
||||
level.struct_class_names[ "scriptbundlename" ] = [];
|
||||
}
|
||||
|
||||
function remove_unneeded_kvps( struct )
|
||||
{
|
||||
// struct.vmtype = undefined;
|
||||
// struct.type = undefined;
|
||||
struct.igdtseqnum = undefined;
|
||||
struct.configstringfiletype = undefined;
|
||||
/#devstate = struct.devstate;#/
|
||||
struct.devstate = undefined;
|
||||
/#struct.devstate = devstate;#/
|
||||
}
|
||||
|
||||
function CreateStruct( struct, type, name )
|
||||
{
|
||||
if ( !isdefined( level.struct ) )
|
||||
{
|
||||
init_structs();
|
||||
}
|
||||
|
||||
if ( isdefined( type ) )
|
||||
{
|
||||
isFrontend = ( GetDvarString( "mapname" ) == "core_frontend" );
|
||||
if ( !isdefined( level.scriptbundles[ type ] ) )
|
||||
{
|
||||
level.scriptbundles[ type ] = [];
|
||||
}
|
||||
|
||||
if ( isdefined( level.scriptbundles[ type ][ name ] ) )
|
||||
{
|
||||
return level.scriptbundles[ type ][ name ];
|
||||
}
|
||||
|
||||
if ( type == "scene" )
|
||||
{
|
||||
level.scriptbundles[ type ][ name ] = scene::remove_invalid_scene_objects( struct );
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// clean out lots of shared data that is not specific to a game mode
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
else if( !( SessionModeIsMultiplayerGame() || isFrontend ) && type == "mpdialog_player" )
|
||||
{
|
||||
// do nothing, save vars
|
||||
}
|
||||
else if( !( SessionModeIsMultiplayerGame() || isFrontend ) && type == "gibcharacterdef" && IsSubStr(name,"c_t7_mp_") )
|
||||
{
|
||||
// do nothing, save vars
|
||||
}
|
||||
else if( !( SessionModeIsCampaignGame() || isFrontend ) && type == "collectibles" )
|
||||
{
|
||||
// do nothing, save vars
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
else
|
||||
{
|
||||
level.scriptbundles[ type ][ name ] = struct;
|
||||
}
|
||||
|
||||
remove_unneeded_kvps( struct );
|
||||
}
|
||||
else
|
||||
{
|
||||
struct init();
|
||||
}
|
||||
}
|
||||
|
||||
function CreateScriptBundleList( items, type, name )
|
||||
{
|
||||
if ( !isdefined( level.struct ) )
|
||||
{
|
||||
init_structs();
|
||||
}
|
||||
|
||||
level.scriptbundlelists[ type ][ name ] = items;
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
if ( !isdefined( level.struct ) ) level.struct = []; else if ( !IsArray( level.struct ) ) level.struct = array( level.struct ); level.struct[level.struct.size]=self;;
|
||||
|
||||
if(!isdefined(self.angles))self.angles=( 0, 0, 0 );
|
||||
|
||||
if ( isdefined( self.targetname ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "targetname" ][ self.targetname ] ) ) level.struct_class_names[ "targetname" ][ self.targetname ] = []; else if ( !IsArray( level.struct_class_names[ "targetname" ][ self.targetname ] ) ) level.struct_class_names[ "targetname" ][ self.targetname ] = array( level.struct_class_names[ "targetname" ][ self.targetname ] ); level.struct_class_names[ "targetname" ][ self.targetname ][level.struct_class_names[ "targetname" ][ self.targetname ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.target ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "target" ][ self.target ] ) ) level.struct_class_names[ "target" ][ self.target ] = []; else if ( !IsArray( level.struct_class_names[ "target" ][ self.target ] ) ) level.struct_class_names[ "target" ][ self.target ] = array( level.struct_class_names[ "target" ][ self.target ] ); level.struct_class_names[ "target" ][ self.target ][level.struct_class_names[ "target" ][ self.target ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_noteworthy ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] ) ) level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] = []; else if ( !IsArray( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] ) ) level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] = array( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] ); level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ][level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_linkname ) )
|
||||
{
|
||||
Assert( !isdefined( level.struct_class_names[ "script_linkname" ][ self.script_linkname ] ), "Two structs have the same linkname" );
|
||||
level.struct_class_names[ "script_linkname" ][ self.script_linkname ][ 0 ] = self;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_label ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "script_label" ][ self.script_label ] ) ) level.struct_class_names[ "script_label" ][ self.script_label ] = []; else if ( !IsArray( level.struct_class_names[ "script_label" ][ self.script_label ] ) ) level.struct_class_names[ "script_label" ][ self.script_label ] = array( level.struct_class_names[ "script_label" ][ self.script_label ] ); level.struct_class_names[ "script_label" ][ self.script_label ][level.struct_class_names[ "script_label" ][ self.script_label ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.classname ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "classname" ][ self.classname ] ) ) level.struct_class_names[ "classname" ][ self.classname ] = []; else if ( !IsArray( level.struct_class_names[ "classname" ][ self.classname ] ) ) level.struct_class_names[ "classname" ][ self.classname ] = array( level.struct_class_names[ "classname" ][ self.classname ] ); level.struct_class_names[ "classname" ][ self.classname ][level.struct_class_names[ "classname" ][ self.classname ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_unitrigger_type ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] ) ) level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] = []; else if ( !IsArray( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] ) ) level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] = array( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] ); level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ][level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.scriptbundlename ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] ) ) level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] = []; else if ( !IsArray( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] ) ) level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] = array( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] ); level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ][level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ].size]=self;;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/@
|
||||
"Name: get( <kvp_value> , [kvp_key] )"
|
||||
"Summary: Returns a struct with the specified kvp."
|
||||
"MandatoryArg: <kvp_value> : kvp value"
|
||||
"OptionalArg: [kvp_key] : defaults to targetname"
|
||||
"Example: struct::get( "some_value", "targetname" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get( kvp_value, kvp_key = "targetname" )
|
||||
{
|
||||
if ( !isdefined( kvp_value ) )
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if ( isdefined( level.struct_class_names[ kvp_key ][ kvp_value ] ) )
|
||||
{
|
||||
/#
|
||||
if ( level.struct_class_names[ kvp_key ][ kvp_value ].size > 1 )
|
||||
{
|
||||
AssertMsg( "struct::get used for more than one struct with kvp '" + kvp_key + "' = '" + kvp_value + "'." );
|
||||
return undefined;
|
||||
}
|
||||
#/
|
||||
|
||||
return level.struct_class_names[ kvp_key ][ kvp_value ][ 0 ];
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: spawn( [v_origin], [v_angles] )"
|
||||
"Summary: Returns a new struct."
|
||||
"OptionalArg: [v_origin] : optional origin"
|
||||
"OptionalArg: [v_angles] : optional angles"
|
||||
"Example: s = struct::spawn( self GetTagOrigin( "tag_origin" ) );"
|
||||
@/
|
||||
function spawn( v_origin = (0, 0, 0), v_angles = (0, 0, 0) )
|
||||
{
|
||||
s = SpawnStruct();
|
||||
s.origin = v_origin;
|
||||
s.angles = v_angles;
|
||||
return s;
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_array( <kvp_value> , [kvp_key] )"
|
||||
"Summary: Returns an array of structs with the specified kvp."
|
||||
"MandatoryArg: <kvp_value> : kvp value"
|
||||
"OptionalArg: [kvp_key] : defaults to targetname"
|
||||
"Example: fxemitters = struct::get_array( "streetlights", "targetname" )"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_array( kvp_value, kvp_key = "targetname" )
|
||||
{
|
||||
if ( isdefined( level.struct_class_names[ kvp_key ][ kvp_value ] ) )
|
||||
{
|
||||
return ArrayCopy( level.struct_class_names[ kvp_key ][ kvp_value ] );
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
if ( isdefined( self.target ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "target" ][ self.target ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.targetname ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "targetname" ][ self.targetname ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_noteworthy ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_linkname ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_linkname" ][ self.script_linkname ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_label) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_label" ][ self.script_label ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.classname) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "classname" ][ self.classname ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_unitrigger_type ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.scriptbundlename ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ], self);
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle( <str_type>, <str_name> )"
|
||||
"Summary: Returns a struct with the specified script bundle definition. This is the GDT data for the bundle."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle"
|
||||
"Example: struct::get_script_bundle( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundle( str_type, str_name )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles[ str_type ] ) && isdefined( level.scriptbundles[ str_type ][ str_name ] ) )
|
||||
{
|
||||
return level.scriptbundles[ str_type ][ str_name ];
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: delete_script_bundle( <str_type>, <str_name> )"
|
||||
"Summary: Deletes the specified script bundle definition. This is the GDT data for the bundle."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle"
|
||||
"Example: struct::delete_script_bundle( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function delete_script_bundle( str_type, str_name )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles[ str_type ] ) && isdefined( level.scriptbundles[ str_type ][ str_name ] ) )
|
||||
{
|
||||
level.scriptbundles[ str_type ][ str_name ] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle( <str_type>, <str_name> )"
|
||||
"Summary: Returns a struct with the specified script bundle definition. This is the GDT data for the bundle."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle"
|
||||
"Example: struct::get_script_bundle( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundles_of_type( str_type )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles[ str_type ] ) )
|
||||
{
|
||||
return ArrayCopy( level.scriptbundles[ str_type ] );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundles( <str_type> )"
|
||||
"Summary: Returns all of the script bundle definition structs for the specified type."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"Example: struct::get_script_bundles( "scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundles( str_type )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles ) && isdefined( level.scriptbundles[ str_type ] ) )
|
||||
{
|
||||
return level.scriptbundles[ str_type ];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle_list( <str_type>, <str_name> )"
|
||||
"Summary: Returns a string array with the items specified by the script bundle list."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle in the list"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle list"
|
||||
"Example: struct::get_script_bundle_list( "collectible", "completecollectibleslist" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundle_list( str_type, str_name )
|
||||
{
|
||||
if ( isdefined( level.scriptbundlelists[ str_type ] ) && isdefined( level.scriptbundlelists[ str_type ][ str_name ] ) )
|
||||
{
|
||||
return level.scriptbundlelists[ str_type ][ str_name ];
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle_instances( <str_type>, [str_name] )"
|
||||
"Summary: Returns an array of all the script bundle instances with the specified script bundle definition and name."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: [str_name] : The name of the script bundle"
|
||||
"Example: struct::get_script_bundle_instances( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundle_instances( str_type, str_name = "" )
|
||||
{
|
||||
a_instances = struct::get_array( "scriptbundle_" + str_type, "classname" );
|
||||
|
||||
if ( str_name != "" )
|
||||
{
|
||||
foreach ( i, s_instance in a_instances )
|
||||
{
|
||||
if ( s_instance.name != str_name )
|
||||
{
|
||||
ArrayRemoveIndex( a_instances, i, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a_instances;
|
||||
}
|
||||
|
||||
//please don't ever call this from script - it's only for radiant live
|
||||
// Search in each of the arrays for our desired struct
|
||||
// It is done this way because we have deleted the level.struct array
|
||||
// We are sacrificing performance in Radiant LiveUpdate in exchange
|
||||
// for freeing up variables in the game
|
||||
function FindStruct( position )
|
||||
{
|
||||
foreach ( key, _ in level.struct_class_names )
|
||||
{
|
||||
foreach ( val, s_array in level.struct_class_names[ key ] )
|
||||
{
|
||||
foreach ( struct in s_array )
|
||||
{
|
||||
if( DistanceSquared( struct.origin, position ) < 1 )
|
||||
{
|
||||
return struct;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( isdefined( level.struct ) )
|
||||
{
|
||||
foreach( struct in level.struct )
|
||||
{
|
||||
if( DistanceSquared( struct.origin, position ) < 1 )
|
||||
{
|
||||
return struct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
#using scripts\shared\scene_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
function autoexec __init__()
|
||||
{
|
||||
// set up arrays even if there are no structs in the level
|
||||
|
||||
if ( !isdefined( level.struct ) )
|
||||
{
|
||||
init_structs();
|
||||
}
|
||||
}
|
||||
|
||||
function init_structs()
|
||||
{
|
||||
level.struct = [];
|
||||
level.scriptbundles = [];
|
||||
level.scriptbundlelists = [];
|
||||
|
||||
level.struct_class_names = [];
|
||||
level.struct_class_names[ "target" ] = [];
|
||||
level.struct_class_names[ "targetname" ] = [];
|
||||
level.struct_class_names[ "script_noteworthy" ] = [];
|
||||
level.struct_class_names[ "script_linkname" ] = [];
|
||||
level.struct_class_names[ "script_label" ] = [];
|
||||
level.struct_class_names[ "classname" ] = [];
|
||||
level.struct_class_names[ "script_unitrigger_type" ] = [];
|
||||
level.struct_class_names[ "scriptbundlename" ] = [];
|
||||
level.struct_class_names[ "prefabname" ] = [];
|
||||
}
|
||||
|
||||
function remove_unneeded_kvps( struct )
|
||||
{
|
||||
// struct.vmtype = undefined;
|
||||
// struct.type = undefined;
|
||||
struct.igdtseqnum = undefined;
|
||||
struct.configstringfiletype = undefined;
|
||||
/#devstate = struct.devstate;#/
|
||||
struct.devstate = undefined;
|
||||
/#struct.devstate = devstate;#/
|
||||
}
|
||||
|
||||
function CreateStruct( struct, type, name )
|
||||
{
|
||||
if ( !isdefined( level.struct ) )
|
||||
{
|
||||
init_structs();
|
||||
}
|
||||
|
||||
if ( isdefined( type ) )
|
||||
{
|
||||
isFrontend = ( GetDvarString( "mapname" ) == "core_frontend" );
|
||||
if ( !isdefined( level.scriptbundles[ type ] ) )
|
||||
{
|
||||
level.scriptbundles[ type ] = [];
|
||||
}
|
||||
|
||||
if ( isdefined( level.scriptbundles[ type ][ name ] ) )
|
||||
{
|
||||
return level.scriptbundles[ type ][ name ];
|
||||
}
|
||||
|
||||
if ( type == "scene" )
|
||||
{
|
||||
level.scriptbundles[ type ][ name ] = scene::remove_invalid_scene_objects( struct );
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// clean out lots of shared data that is not specific to a game mode
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
else if( !( SessionModeIsMultiplayerGame() || isFrontend ) && type == "mpdialog_player" )
|
||||
{
|
||||
// do nothing, save vars
|
||||
}
|
||||
else if( !( SessionModeIsMultiplayerGame() || isFrontend ) && type == "gibcharacterdef" && IsSubStr(name,"c_t7_mp_") )
|
||||
{
|
||||
// do nothing, save vars
|
||||
}
|
||||
else if( !( SessionModeIsCampaignGame() || isFrontend ) && type == "collectibles" )
|
||||
{
|
||||
// do nothing, save vars
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
else
|
||||
{
|
||||
level.scriptbundles[ type ][ name ] = struct;
|
||||
}
|
||||
|
||||
remove_unneeded_kvps(struct);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct init();
|
||||
}
|
||||
}
|
||||
|
||||
function CreateScriptBundleList( items, assetType, name )
|
||||
{
|
||||
if ( !isdefined( level.struct ) )
|
||||
{
|
||||
init_structs();
|
||||
}
|
||||
|
||||
level.scriptbundlelists[ assetType ][ name ] = items;
|
||||
}
|
||||
|
||||
function init()
|
||||
{
|
||||
if ( !isdefined( level.struct ) ) level.struct = []; else if ( !IsArray( level.struct ) ) level.struct = array( level.struct ); level.struct[level.struct.size]=self;;
|
||||
|
||||
if(!isdefined(self.angles))self.angles=( 0, 0, 0 );
|
||||
|
||||
if ( isdefined( self.targetname ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "targetname" ][ self.targetname ] ) ) level.struct_class_names[ "targetname" ][ self.targetname ] = []; else if ( !IsArray( level.struct_class_names[ "targetname" ][ self.targetname ] ) ) level.struct_class_names[ "targetname" ][ self.targetname ] = array( level.struct_class_names[ "targetname" ][ self.targetname ] ); level.struct_class_names[ "targetname" ][ self.targetname ][level.struct_class_names[ "targetname" ][ self.targetname ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.target ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "target" ][ self.target ] ) ) level.struct_class_names[ "target" ][ self.target ] = []; else if ( !IsArray( level.struct_class_names[ "target" ][ self.target ] ) ) level.struct_class_names[ "target" ][ self.target ] = array( level.struct_class_names[ "target" ][ self.target ] ); level.struct_class_names[ "target" ][ self.target ][level.struct_class_names[ "target" ][ self.target ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_noteworthy ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] ) ) level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] = []; else if ( !IsArray( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] ) ) level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] = array( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ] ); level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ][level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_linkname ) )
|
||||
{
|
||||
Assert( !isdefined( level.struct_class_names[ "script_linkname" ][ self.script_linkname ] ), "Two structs have the same linkname" );
|
||||
level.struct_class_names[ "script_linkname" ][ self.script_linkname ][ 0 ] = self;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_label ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "script_label" ][ self.script_label ] ) ) level.struct_class_names[ "script_label" ][ self.script_label ] = []; else if ( !IsArray( level.struct_class_names[ "script_label" ][ self.script_label ] ) ) level.struct_class_names[ "script_label" ][ self.script_label ] = array( level.struct_class_names[ "script_label" ][ self.script_label ] ); level.struct_class_names[ "script_label" ][ self.script_label ][level.struct_class_names[ "script_label" ][ self.script_label ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.classname ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "classname" ][ self.classname ] ) ) level.struct_class_names[ "classname" ][ self.classname ] = []; else if ( !IsArray( level.struct_class_names[ "classname" ][ self.classname ] ) ) level.struct_class_names[ "classname" ][ self.classname ] = array( level.struct_class_names[ "classname" ][ self.classname ] ); level.struct_class_names[ "classname" ][ self.classname ][level.struct_class_names[ "classname" ][ self.classname ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_unitrigger_type ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] ) ) level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] = []; else if ( !IsArray( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] ) ) level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] = array( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ] ); level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ][level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.scriptbundlename ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] ) ) level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] = []; else if ( !IsArray( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] ) ) level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] = array( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ] ); level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ][level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ].size]=self;;
|
||||
}
|
||||
|
||||
if ( isdefined( self.prefabname ) )
|
||||
{
|
||||
if ( !isdefined( level.struct_class_names[ "prefabname" ][ self.prefabname ] ) ) level.struct_class_names[ "prefabname" ][ self.prefabname ] = []; else if ( !IsArray( level.struct_class_names[ "prefabname" ][ self.prefabname ] ) ) level.struct_class_names[ "prefabname" ][ self.prefabname ] = array( level.struct_class_names[ "prefabname" ][ self.prefabname ] ); level.struct_class_names[ "prefabname" ][ self.prefabname ][level.struct_class_names[ "prefabname" ][ self.prefabname ].size]=self;;
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get( <kvp_value> , [kvp_key] )"
|
||||
"Summary: Returns a struct with the specified kvp."
|
||||
"MandatoryArg: <kvp_value> : kvp value"
|
||||
"OptionalArg: [kvp_key] : defaults to targetname"
|
||||
"Example: struct::get( "some_value", "targetname" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get( kvp_value, kvp_key = "targetname" )
|
||||
{
|
||||
if ( isdefined( level.struct_class_names[ kvp_key ] ) && isdefined( level.struct_class_names[ kvp_key ][ kvp_value ] ) )
|
||||
{
|
||||
/#
|
||||
if ( level.struct_class_names[ kvp_key ][ kvp_value ].size > 1 )
|
||||
{
|
||||
AssertMsg( "struct::get used for more than one struct with kvp '" + kvp_key + "' = '" + kvp_value + "'." );
|
||||
return undefined;
|
||||
}
|
||||
#/
|
||||
|
||||
return level.struct_class_names[ kvp_key ][ kvp_value ][ 0 ];
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: spawn( [v_origin], [v_angles] )"
|
||||
"Summary: Returns a new struct."
|
||||
"OptionalArg: [v_origin] : optional origin"
|
||||
"OptionalArg: [v_angles] : optional angles"
|
||||
"Example: s = struct::spawn( self GetTagOrigin( "tag_origin" ) );"
|
||||
@/
|
||||
function spawn( v_origin = (0, 0, 0), v_angles = (0, 0, 0) )
|
||||
{
|
||||
s = SpawnStruct();
|
||||
s.origin = v_origin;
|
||||
s.angles = v_angles;
|
||||
return s;
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_array( <kvp_value> , [kvp_key] )"
|
||||
"Summary: Returns an array of structs with the specified kvp."
|
||||
"MandatoryArg: <kvp_value> : kvp value"
|
||||
"OptionalArg: [kvp_key] : defaults to targetname"
|
||||
"Example: fxemitters = struct::get_array( "streetlights", "targetname" )"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_array( kvp_value, kvp_key = "targetname" )
|
||||
{
|
||||
if ( isdefined( level.struct_class_names[ kvp_key ][ kvp_value ] ) )
|
||||
{
|
||||
return ArrayCopy( level.struct_class_names[ kvp_key ][ kvp_value ] );
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
if ( isdefined( self.target ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "target" ][ self.target ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.targetname ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "targetname" ][ self.targetname ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_noteworthy ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_noteworthy" ][ self.script_noteworthy ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_linkname ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_linkname" ][ self.script_linkname ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_label) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_label" ][ self.script_label ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.classname) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "classname" ][ self.classname ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.script_unitrigger_type ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "script_unitrigger_type" ][ self.script_unitrigger_type ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.scriptbundlename ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "scriptbundlename" ][ self.scriptbundlename ], self);
|
||||
}
|
||||
|
||||
if ( isdefined( self.prefabname ) )
|
||||
{
|
||||
ArrayRemoveValue( level.struct_class_names[ "prefabname" ][ self.prefabname ], self);
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle( <str_type>, <str_name> )"
|
||||
"Summary: Returns a struct with the specified script bundle definition. This is the GDT data for the bundle."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle"
|
||||
"Example: struct::get_script_bundle( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundle( str_type, str_name )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles[ str_type ] ) && isdefined( level.scriptbundles[ str_type ][ str_name ] ) )
|
||||
{
|
||||
return level.scriptbundles[ str_type ][ str_name ];
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: delete_script_bundle( <str_type>, <str_name> )"
|
||||
"Summary: Deletes the specified script bundle definition. This is the GDT data for the bundle."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle"
|
||||
"Example: struct::delete_script_bundle( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function delete_script_bundle( str_type, str_name )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles[ str_type ] ) && isdefined( level.scriptbundles[ str_type ][ str_name ] ) )
|
||||
{
|
||||
level.scriptbundles[ str_type ][ str_name ] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundles( <str_type> )"
|
||||
"Summary: Returns all of the script bundle definition structs for the specified type."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"Example: struct::get_script_bundles( "scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundles( str_type )
|
||||
{
|
||||
if ( isdefined( level.scriptbundles ) && isdefined( level.scriptbundles[ str_type ] ) )
|
||||
{
|
||||
return level.scriptbundles[ str_type ];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle_list( <str_type>, <str_name> )"
|
||||
"Summary: Returns a string array with the items specified by the script bundle list."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle in the list"
|
||||
"MandatoryArg: <str_name> : The name of the script bundle list"
|
||||
"Example: struct::get_script_bundle_list( "collectible", "completecollectibleslist" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundle_list( str_type, str_name )
|
||||
{
|
||||
if ( isdefined( level.scriptbundlelists[ str_type ] ) && isdefined( level.scriptbundlelists[ str_type ][ str_name ] ) )
|
||||
{
|
||||
return level.scriptbundlelists[ str_type ][ str_name ];
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_script_bundle_instances( <str_type>, [str_name] )"
|
||||
"Summary: Returns an array of all the script bundle instances with the specified script bundle definition and name."
|
||||
"MandatoryArg: <str_type> : The type of the script bundle"
|
||||
"MandatoryArg: [str_name] : The name of the script bundle"
|
||||
"Example: struct::get_script_bundle_instances( "scene", "my_scene" );"
|
||||
"SPMP: both"
|
||||
@/
|
||||
function get_script_bundle_instances( str_type, str_name = "" )
|
||||
{
|
||||
a_instances = struct::get_array( "scriptbundle_" + str_type, "classname" );
|
||||
|
||||
if ( str_name != "" )
|
||||
{
|
||||
foreach ( i, s_instance in a_instances )
|
||||
{
|
||||
if ( s_instance.name != str_name )
|
||||
{
|
||||
ArrayRemoveIndex( a_instances, i, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a_instances;
|
||||
}
|
||||
|
||||
//please don't ever call this from script - it's only for radiant live
|
||||
// Search in each of the arrays for our desired struct
|
||||
// It is done this way because we have deleted the level.struct array
|
||||
// We are sacrificing performance in Radiant LiveUpdate in exchange
|
||||
// for freeing up variables in the game
|
||||
function FindStruct( param1, name, index )
|
||||
{
|
||||
if( IsVec( param1 ) )
|
||||
{
|
||||
position = param1;
|
||||
|
||||
foreach ( key, _ in level.struct_class_names )
|
||||
{
|
||||
foreach ( val, s_array in level.struct_class_names[ key ] )
|
||||
{
|
||||
foreach ( struct in s_array )
|
||||
{
|
||||
if( DistanceSquared( struct.origin, position ) < 1 )
|
||||
{
|
||||
return struct;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( isdefined( level.struct ) )
|
||||
{
|
||||
foreach( struct in level.struct )
|
||||
{
|
||||
if( DistanceSquared( struct.origin, position ) < 1 )
|
||||
{
|
||||
return struct;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = get(param1);
|
||||
|
||||
if( isdefined(s) )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
s = get_script_bundle( param1, name );
|
||||
if( isdefined( s ) )
|
||||
{
|
||||
if( index < 0 )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isdefined( s.objects ) )
|
||||
{
|
||||
return s.objects[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\array_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
#namespace multi_extracam;
|
||||
|
||||
function extracam_reset_index( localClientNum, index )
|
||||
{
|
||||
if( !isdefined(level.camera_ents) || !isdefined(level.camera_ents[localClientNum]) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( isdefined( level.camera_ents[localClientNum][index] ) )
|
||||
{
|
||||
level.camera_ents[localClientNum][index] ClearExtraCam();
|
||||
level.camera_ents[localClientNum][index] Delete();
|
||||
level.camera_ents[localClientNum][index] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function extracam_init_index( localClientNum, target, index )
|
||||
{
|
||||
cameraStruct = struct::get( target, "targetname" );
|
||||
return extracam_init_item( localClientNum, cameraStruct, index );
|
||||
}
|
||||
|
||||
function extracam_init_item( localClientNum, copy_ent, index )
|
||||
{
|
||||
if(!isdefined(level.camera_ents))level.camera_ents=[];
|
||||
|
||||
if( !isdefined(level.camera_ents[localClientNum]) )
|
||||
{
|
||||
level.camera_ents[localClientNum] = [];
|
||||
}
|
||||
|
||||
if( isdefined( level.camera_ents[localClientNum][index] ) )
|
||||
{
|
||||
level.camera_ents[localClientNum][index] ClearExtraCam();
|
||||
level.camera_ents[localClientNum][index] Delete();
|
||||
level.camera_ents[localClientNum][index] = undefined;
|
||||
}
|
||||
|
||||
if ( isdefined( copy_ent ) )
|
||||
{
|
||||
level.camera_ents[localClientNum][index] = Spawn( localClientNum, copy_ent.origin, "script_origin" );
|
||||
level.camera_ents[localClientNum][index].angles = copy_ent.angles;
|
||||
|
||||
level.camera_ents[localClientNum][index] SetExtraCam( index );
|
||||
return level.camera_ents[localClientNum][index];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@@ -0,0 +1,873 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\array_shared;
|
||||
#using scripts\shared\flag_shared;
|
||||
#using scripts\shared\flagsys_shared;
|
||||
#using scripts\shared\gameobjects_shared;
|
||||
#using scripts\shared\lui_shared;
|
||||
#using scripts\shared\objpoints_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\trigger_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\cp\_util;
|
||||
|
||||
#precache( "material", "compass_waypoint_target" );
|
||||
#precache( "material", "compass_waypoint_captureneutral" );
|
||||
#precache( "material", "compass_waypoint_capture" );
|
||||
#precache( "material", "compass_waypoint_defend" );
|
||||
#precache( "material", "compass_waypoint_captureneutral_a" );
|
||||
#precache( "material", "compass_waypoint_capture_a" );
|
||||
#precache( "material", "compass_waypoint_defend_a" );
|
||||
#precache( "material", "compass_waypoint_captureneutral_b" );
|
||||
#precache( "material", "compass_waypoint_capture_b" );
|
||||
#precache( "material", "compass_waypoint_defend_b" );
|
||||
#precache( "material", "compass_waypoint_captureneutral_c" );
|
||||
#precache( "material", "compass_waypoint_capture_c" );
|
||||
#precache( "material", "compass_waypoint_defend_c" );
|
||||
|
||||
#precache( "material", "waypoint_return" );
|
||||
#precache( "material", "objective_arrow" );
|
||||
|
||||
#precache( "eventstring", "comms_event_message" );
|
||||
#precache( "string", "CP_SH_CAIRO_PLAYER_READY" );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#precache( "lui_menu_data", "obj_x" );
|
||||
#precache( "lui_menu_data", "obj_y" );
|
||||
|
||||
#namespace objectives;
|
||||
|
||||
class cObjective
|
||||
{
|
||||
var m_str_type;
|
||||
var m_a_game_obj;
|
||||
var m_a_targets;
|
||||
var m_str_lui_menu;
|
||||
|
||||
constructor()
|
||||
{
|
||||
}
|
||||
|
||||
function init( str_type, a_target_list, b_done = false )
|
||||
{
|
||||
m_a_targets = [];
|
||||
m_a_game_obj = [];
|
||||
m_str_type = str_type;
|
||||
|
||||
if ( b_done )
|
||||
{
|
||||
gobj_id = gameobjects::get_next_obj_id();
|
||||
m_a_game_obj = array( gobj_id );
|
||||
Objective_Add( gobj_id, "done", (0,0,0), iString(str_type) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isdefined( a_target_list ) && a_target_list.size > 0 )
|
||||
{
|
||||
foreach( target in a_target_list )
|
||||
{
|
||||
add_target( target );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gobj_id = gameobjects::get_next_obj_id();
|
||||
m_a_game_obj = array( gobj_id );
|
||||
Objective_Add( gobj_id, "active", (0,0,0), iString(str_type) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function update_value( str_menu_data_name, value )
|
||||
{
|
||||
gobj_id = m_a_game_obj[0];
|
||||
Objective_SetUIModelValue( gobj_id, str_menu_data_name, value );
|
||||
}
|
||||
|
||||
function update_counter( x_val, y_val )
|
||||
{
|
||||
update_value( "obj_x", x_val );
|
||||
|
||||
if ( isdefined( y_val ) )
|
||||
{
|
||||
update_value( "obj_y", y_val );
|
||||
}
|
||||
}
|
||||
|
||||
function add_target( target )
|
||||
{
|
||||
// do not add a target twice.
|
||||
if ( IsInArray( m_a_targets, target ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gobj_id = undefined;
|
||||
if ( m_a_targets.size < m_a_game_obj.size )
|
||||
{
|
||||
gobj_id = m_a_game_obj[m_a_game_obj.size-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
gobj_id = gameobjects::get_next_obj_id();
|
||||
array::add( m_a_game_obj, gobj_id );
|
||||
}
|
||||
|
||||
//Objective_Add can take in an entity or a vector for its 'target'
|
||||
if ( IsVec( target ) || IsEntity( target ) )
|
||||
{
|
||||
Objective_Add( gobj_id, "active", target, iString(m_str_type) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Objective_Add( gobj_id, "active", target.origin, iString(m_str_type) );
|
||||
}
|
||||
|
||||
array::add( m_a_targets, target );
|
||||
|
||||
assert( m_a_targets.size == m_a_game_obj.size );
|
||||
}
|
||||
|
||||
function complete( a_target_or_list )
|
||||
{
|
||||
if ( a_target_or_list.size > 0 )
|
||||
{
|
||||
// find specific targets to remove their objective
|
||||
foreach ( target in a_target_or_list )
|
||||
{
|
||||
for ( i = m_a_targets.size - 1; i >= 0; i-- )
|
||||
{
|
||||
if ( m_a_targets[ i ] == target )
|
||||
{
|
||||
Objective_State( m_a_game_obj[ i ], "done" );
|
||||
|
||||
ArrayRemoveIndex( m_a_game_obj, i );
|
||||
ArrayRemoveIndex( m_a_targets, i );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( n_gobj_id in m_a_game_obj )
|
||||
{
|
||||
Objective_State( n_gobj_id, "done" );
|
||||
}
|
||||
|
||||
for ( i = m_a_targets.size - 1; i >= 0; i-- )
|
||||
{
|
||||
ArrayRemoveIndex( m_a_game_obj, i );
|
||||
ArrayRemoveIndex( m_a_targets, i );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_a_game_obj.size == 0 )
|
||||
{
|
||||
ArrayRemoveValue( level.a_objectives, self, true );
|
||||
}
|
||||
}
|
||||
|
||||
//hide waypoint
|
||||
function hide( e_player )
|
||||
{
|
||||
if(isdefined( e_player) )
|
||||
{
|
||||
Assert( IsPlayer( e_player ), "Passed a non-player entity into cObjective::hide()" );
|
||||
|
||||
foreach( obj_id in m_a_game_obj )
|
||||
{
|
||||
Objective_SetInvisibleToPlayer( obj_id, e_player );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( obj_id in m_a_game_obj )
|
||||
{
|
||||
Objective_SetInvisibleToAll( obj_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//show waypoint
|
||||
function show( e_player )
|
||||
{
|
||||
if(isdefined( e_player) )
|
||||
{
|
||||
Assert( IsPlayer( e_player ), "Passed a non-player entity into cObjective::show()" );
|
||||
|
||||
foreach( obj_id in m_a_game_obj )
|
||||
{
|
||||
Objective_SetVisibleToPlayer( obj_id, e_player );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( obj_id in m_a_game_obj )
|
||||
{
|
||||
Objective_SetVisibleToAll( obj_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function hide_for_target( e_target )
|
||||
{
|
||||
foreach( i, obj_id in m_a_game_obj )
|
||||
{
|
||||
ent = m_a_targets[i];
|
||||
if ( isdefined( ent ) && ent == e_target )
|
||||
{
|
||||
Objective_State( obj_id, "invisible" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function show_for_target( e_target )
|
||||
{
|
||||
foreach( i, obj_id in m_a_game_obj )
|
||||
{
|
||||
ent = m_a_targets[i];
|
||||
if ( isdefined( ent ) && ent == e_target )
|
||||
{
|
||||
Objective_State( obj_id, "active" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_id_for_target( e_target )
|
||||
{
|
||||
foreach( i, obj_id in m_a_game_obj )
|
||||
{
|
||||
ent = m_a_targets[i];
|
||||
if ( isdefined( ent ) && ent == e_target )
|
||||
{
|
||||
return obj_id;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function is_breadcrumb()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class cBreadcrumbObjective : cObjective
|
||||
{
|
||||
var m_a_player_game_obj; // array of objective ids, one per player
|
||||
var m_str_first_trig_targetname; // the targetname of the first trigger in the breadcrumb sequence
|
||||
var m_done; // at least one of the players has reached the end of their breadcrumb trail
|
||||
|
||||
constructor()
|
||||
{
|
||||
}
|
||||
|
||||
function init( str_type, a_target_list, b_done = false )
|
||||
{
|
||||
// call the parent version
|
||||
cObjective::init( str_type, a_target_list, b_done );
|
||||
|
||||
// init some fields
|
||||
m_str_first_trig_targetname = "";
|
||||
m_done = b_done;
|
||||
|
||||
// create objectives for max players
|
||||
m_a_player_game_obj = [];
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
obj_id = gameobjects::get_next_obj_id();
|
||||
m_a_player_game_obj[i] = obj_id;
|
||||
if ( m_done )
|
||||
{
|
||||
Objective_Add( obj_id, "done", ( 0, 0, 0 ), iString( m_str_type ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Objective_Add( obj_id, "empty", ( 0, 0, 0 ), iString( m_str_type ) );
|
||||
}
|
||||
}
|
||||
|
||||
// hide the actual objective, since each player now has their own
|
||||
obj_id = m_a_game_obj[0];
|
||||
Objective_SetInvisibleToAll( obj_id );
|
||||
}
|
||||
|
||||
function complete( a_target_or_list )
|
||||
{
|
||||
// kill the threads
|
||||
level notify( "breadcrumb_" + m_str_type + "_complete" );
|
||||
|
||||
// destroy the objectives
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
obj_id = m_a_player_game_obj[i];
|
||||
Objective_State( obj_id, "done" );
|
||||
}
|
||||
|
||||
foreach( player in level.players )
|
||||
{
|
||||
player.v_current_active_breadcrumb = undefined;
|
||||
}
|
||||
|
||||
// call the parent version
|
||||
cObjective::complete( a_target_or_list );
|
||||
}
|
||||
|
||||
function hide( e_player )
|
||||
{
|
||||
if ( isdefined( e_player ) )
|
||||
{
|
||||
Assert( IsPlayer( e_player ), "Passed a non-player entity into cBreadcrumbObjective::hide()" );
|
||||
entnum = e_player GetEntityNumber();
|
||||
obj_id = m_a_player_game_obj[entnum];
|
||||
Objective_SetInvisibleToPlayer( obj_id, e_player );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
obj_id = m_a_player_game_obj[i];
|
||||
Objective_SetInvisibleToPlayerByIndex( obj_id, i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function show( e_player )
|
||||
{
|
||||
if ( isdefined( e_player ) )
|
||||
{
|
||||
Assert( IsPlayer( e_player ), "Passed a non-player entity into cBreadcrumbObjective::hide()" );
|
||||
entnum = e_player GetEntityNumber();
|
||||
obj_id = m_a_player_game_obj[entnum];
|
||||
Objective_SetVisibleToPlayer( obj_id, e_player );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
obj_id = m_a_player_game_obj[i];
|
||||
Objective_SetVisibleToPlayerByIndex( obj_id, i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function start( str_trig_targetname )
|
||||
{
|
||||
// remember the name of the first trigger
|
||||
m_str_first_trig_targetname = str_trig_targetname;
|
||||
m_done = false;
|
||||
|
||||
// create individual objectives for each player
|
||||
foreach( player in level.players )
|
||||
{
|
||||
add_player( player );
|
||||
}
|
||||
}
|
||||
|
||||
function add_player( player )
|
||||
{
|
||||
// activate the objective
|
||||
entnum = player GetEntityNumber();
|
||||
obj_id = m_a_player_game_obj[entnum];
|
||||
Objective_SetInvisibleToAll( obj_id );
|
||||
Objective_SetVisibleToPlayer( obj_id, player );
|
||||
Objective_State( obj_id, "active" );
|
||||
|
||||
// spawn a thread to track the player's movement along the breadcrumb trail
|
||||
thread do_player_breadcrumb( player );
|
||||
}
|
||||
|
||||
function private set_player_objective( player, target )
|
||||
{
|
||||
entnum = player GetEntityNumber();
|
||||
obj_id = m_a_player_game_obj[entnum];
|
||||
|
||||
n_breadcrumb_height = 72;
|
||||
|
||||
v_pos = target;
|
||||
if ( !IsVec( target ) )
|
||||
{
|
||||
v_pos = target.origin;
|
||||
|
||||
if ( isdefined( target.script_height ) )
|
||||
{
|
||||
n_breadcrumb_height = target.script_height;
|
||||
}
|
||||
}
|
||||
|
||||
v_pos = util::ground_position( v_pos, 300, n_breadcrumb_height );
|
||||
|
||||
// cache off the breadcrumb for other systems look up
|
||||
player.v_current_active_breadcrumb = v_pos;
|
||||
|
||||
Objective_Position( obj_id, v_pos );
|
||||
Objective_State( obj_id, "active" );
|
||||
}
|
||||
|
||||
function do_player_breadcrumb( player )
|
||||
{
|
||||
level endon( "breadcrumb_" + m_str_type );
|
||||
level endon( "breadcrumb_" + m_str_type + "_complete" );
|
||||
player endon( "death" );
|
||||
|
||||
str_trig_targetname = m_str_first_trig_targetname;
|
||||
entnum = player GetEntityNumber();
|
||||
obj_id = m_a_player_game_obj[entnum];
|
||||
Objective_SetVisibleToPlayer( obj_id, player );
|
||||
do
|
||||
{
|
||||
t_current = GetEnt( str_trig_targetname, "targetname" );
|
||||
|
||||
if ( isdefined( t_current ) )
|
||||
{
|
||||
if ( isdefined( t_current.target ) )
|
||||
{
|
||||
if ( isdefined( t_current.script_flag_true ) )
|
||||
{
|
||||
Objective_SetInvisibleToPlayer( obj_id, player );
|
||||
level flag::wait_till( t_current.script_flag_true );
|
||||
Objective_SetVisibleToPlayer( obj_id, player );
|
||||
}
|
||||
|
||||
s_current = struct::get( t_current.target, "targetname" );
|
||||
|
||||
if ( isdefined( s_current ) )
|
||||
{
|
||||
set_player_objective( player, s_current );
|
||||
}
|
||||
else
|
||||
{
|
||||
set_player_objective( player, t_current );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
set_player_objective( player, t_current );
|
||||
}
|
||||
|
||||
str_trig_targetname = t_current.target;
|
||||
//assert( !trigger::is_trigger_once( t_current ), "Trigger at " + t_current.origin + " in breadcrumb chain '" + m_str_first_trig_targetname + "' should not be set to TRIGGER_ONCE." );
|
||||
t_current trigger::wait_till( undefined, undefined, player );
|
||||
}
|
||||
else
|
||||
{
|
||||
str_trig_targetname = undefined;
|
||||
}
|
||||
}
|
||||
while ( isdefined( str_trig_targetname ) );
|
||||
Objective_SetInvisibleToPlayer( obj_id, player );
|
||||
|
||||
foreach( player in level.players )
|
||||
{
|
||||
player.v_current_active_breadcrumb = undefined;
|
||||
}
|
||||
|
||||
// done
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
function is_breadcrumb()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function is_done()
|
||||
{
|
||||
// we're done if at least one of the players has made it to the final breadcrumb
|
||||
return m_done;
|
||||
}
|
||||
}
|
||||
|
||||
function autoexec __init__sytem__() { system::register("objectives",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
level.a_objectives = []; // Declares an array of objectives to hold the objective strings.
|
||||
level.n_obj_index = 0; // This is the objective number associated with the objective strings.
|
||||
|
||||
callback::on_spawned( &on_player_spawned );
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: set( <str_obj_type>, <a_target_or_list>, <b_breadcrumb> )"
|
||||
"Summary: Used for all objective-related tasks."
|
||||
"CallOn: NA"
|
||||
"Example: objectives::set( "cp_level_lotus_hakim", level.ai_hakim );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function set( str_obj_type, a_target_or_list, b_breadcrumb )
|
||||
{
|
||||
if(!isdefined(level.a_objectives))level.a_objectives=[];
|
||||
if(!isdefined(b_breadcrumb))b_breadcrumb=false;
|
||||
|
||||
// Make an array out if it, if it's only one objective.
|
||||
if ( !isdefined( a_target_or_list ) ) a_target_or_list = []; else if ( !IsArray( a_target_or_list ) ) a_target_or_list = array( a_target_or_list );;
|
||||
|
||||
o_objective = undefined;
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
// TODO Slone: Clear old targets here?
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
if ( isdefined( a_target_or_list ) )
|
||||
{
|
||||
foreach( target in a_target_or_list )
|
||||
{
|
||||
[[o_objective]]->add_target( target );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( b_breadcrumb )
|
||||
{
|
||||
o_objective = new cBreadcrumbObjective();
|
||||
}
|
||||
else
|
||||
{
|
||||
o_objective = new cObjective();
|
||||
}
|
||||
[[o_objective]]->init( str_obj_type, a_target_or_list );
|
||||
level.a_objectives[ str_obj_type ] = o_objective;
|
||||
}
|
||||
|
||||
return o_objective;
|
||||
}
|
||||
|
||||
// Mark just one of many targets for this objective as complete.
|
||||
//
|
||||
// str_obj_type: the objective string ID we'd like to remove.
|
||||
// a_target_or_list: the object from which we'd like to remove the marker.
|
||||
//
|
||||
/@
|
||||
"Name: complete( <str_obj_type>, <a_target_or_list> )"
|
||||
"Summary: Mark specific targets for this objective as complete."
|
||||
"CallOn: NA"
|
||||
"MandatoryArg: <str_obj_type> The objective string ID we'd like to remove."
|
||||
"OptionalArg: <a_target_or_list> The target or targets from which we'd like to remove the marker."
|
||||
"Example: objectives::complete( "cp_level_lotus_minigun", self );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function complete( str_obj_type, a_target_or_list )
|
||||
{
|
||||
// Make an array out if it, if it's only one objective.
|
||||
if ( !isdefined( a_target_or_list ) ) a_target_or_list = []; else if ( !IsArray( a_target_or_list ) ) a_target_or_list = array( a_target_or_list );;
|
||||
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
[[o_objective]]->complete( a_target_or_list );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( str_obj_type == "cp_waypoint_breadcrumb" )
|
||||
{
|
||||
o_objective = new cBreadcrumbObjective();
|
||||
}
|
||||
else
|
||||
{
|
||||
o_objective = new cObjective();
|
||||
}
|
||||
[[o_objective]]->init( str_obj_type, undefined, true );
|
||||
level.a_objectives[ str_obj_type ] = o_objective;
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: set( <str_obj_id>, <a_target_or_list> )"
|
||||
"Summary: Set the objective and automatically set the counter to [0 of a_targets.size]"
|
||||
"CallOn: NA"
|
||||
"Example: objectives::set( "objective_kill_targets", a_targets );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function set_with_counter( str_obj_id, a_targets )
|
||||
{
|
||||
if ( !isdefined( a_targets ) ) a_targets = []; else if ( !IsArray( a_targets ) ) a_targets = array( a_targets );;
|
||||
o_obj = set( str_obj_id, a_targets );
|
||||
[[o_obj]]->update_counter( 0, a_targets.size );
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: update_counter( <str_obj_id>, <x_val>, <y_val> )"
|
||||
"Summary: Set the values on an objective with a counter."
|
||||
"CallOn: NA"
|
||||
"Example: objectives::update_counter( "objective_kill_targets", 2, a_targets.size );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function update_counter( str_obj_id, x_val, y_val )
|
||||
{
|
||||
o_obj = level.a_objectives[ str_obj_id ];
|
||||
if ( isdefined( o_obj ) )
|
||||
{
|
||||
[[o_obj]]->update_counter( x_val, y_val );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: set_value( <str_obj_id>, <str_menu_data_name>, <value> )"
|
||||
"Summary: Set the LUI model values on an objective."
|
||||
"CallOn: NA"
|
||||
"Example: objectives::set_value( "objective_kill_targets", "num_targets", a_targets.size );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function set_value( str_obj_id, str_menu_data_name, value )
|
||||
{
|
||||
o_obj = level.a_objectives[ str_obj_id ];
|
||||
if ( isdefined( o_obj ) )
|
||||
{
|
||||
[[o_obj]]->update_value( str_menu_data_name, value );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: breadcrumb( <str_trig_targetname>, [str_obj_id] )"
|
||||
"Summary: Automatically advances a chain of triggered objective structs."
|
||||
"Module: Objectives"
|
||||
"CallOn: Level"
|
||||
"MandatoryArg: <str_trig_targetname> The first trigger in the string of breadcrumbs."
|
||||
"OptionalArg: [str_obj_id] The objective string ID we'd like to hide the marker and menu entry of. Default behavior hides for ALL players."
|
||||
"Example: objectives::breadcrumb( "trig_breadcrumb" );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function breadcrumb( str_trig_targetname, str_obj_id = "cp_waypoint_breadcrumb", b_complete_on_first_player_finish = true )
|
||||
{
|
||||
level notify( "breadcrumb_" + str_obj_id );
|
||||
level endon( "breadcrumb_" + str_obj_id );
|
||||
|
||||
if ( isdefined( level.a_objectives[ str_obj_id ] ) )
|
||||
{
|
||||
complete( str_obj_id );
|
||||
}
|
||||
|
||||
o_objective = set( str_obj_id, undefined, true );
|
||||
[[o_objective]]->start( str_trig_targetname );
|
||||
|
||||
while ( ![[o_objective]]->is_done() )
|
||||
{
|
||||
wait 0.05;
|
||||
}
|
||||
|
||||
if ( b_complete_on_first_player_finish )
|
||||
{
|
||||
complete( str_obj_id );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: hide( <str_obj_type>, <e_player> )"
|
||||
"Summary: Hide the objective marker and menu entry for an objective."
|
||||
"CallOn: NA"
|
||||
"MandatoryArg: <str_obj_type> The objective string ID we'd like to hide the marker and menu entry of. Default behavior hides for ALL players"
|
||||
"OptionalArg: <e_player> The specific player you would like to hide the objective waypoint from."
|
||||
"Example: objectives::hide( "objective_to_do_things", e_player_2 );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function hide( str_obj_type, e_player )
|
||||
{
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
[[o_objective]]->hide( e_player );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( false, "Attempting to hide a marker on an objective that does not exist." );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: hide_for_target( <str_obj_type>, <e_target> )"
|
||||
"Summary: Hide the objective marker for a specific target."
|
||||
"CallOn: NA"
|
||||
"MandatoryArg: <str_obj_type> The objective string ID we'd like to hide the marker."
|
||||
"MandatoryArg: <e_target> The target for which you want to hide the objective marker."
|
||||
"Example: objectives::hide_for_target( "tank_marker", vh_tank_3 );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function hide_for_target( str_obj_type, e_target )
|
||||
{
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
[[o_objective]]->hide_for_target( e_target );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( false, "Attempting to hide a marker on an objective that does not exist." );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: show( <str_obj_type>, <e_player> )"
|
||||
"Summary: Show the objective marker and menu entry for an objective."
|
||||
"CallOn: NA"
|
||||
"MandatoryArg: <str_obj_type> The objective string ID we'd like to show the marker and menu entry of. Default behavior shows for ALL players"
|
||||
"OptionalArg: <e_player> The specific player you would like to show the objective waypoint to."
|
||||
"Example: objectives::show( "objective_to_do_things", e_player_2 );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function show( str_obj_type, e_player )
|
||||
{
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
[[o_objective]]->show( e_player );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( false, "Attempting to show a marker on an objective that does not exist." );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: show_for_target( <str_obj_type>, <e_target> )"
|
||||
"Summary: Show the objective marker for a specific target."
|
||||
"CallOn: NA"
|
||||
"MandatoryArg: <str_obj_type> The objective string ID we'd like to show the marker."
|
||||
"MandatoryArg: <e_target> The target for which you want to show the objective marker."
|
||||
"Example: objectives::show_for_target( "tank_marker", vh_tank_3 );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function show_for_target( str_obj_type, e_target )
|
||||
{
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
[[o_objective]]->show_for_target( e_target );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( false, "Attempting to hide a marker on an objective that does not exist." );
|
||||
}
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: get_id_for_target( <str_obj_type>, <e_target> )"
|
||||
"Summary: Get objective ID for a specific target."
|
||||
"CallOn: NA"
|
||||
"MandatoryArg: <str_obj_type> The objective string ID."
|
||||
"MandatoryArg: <e_target> The target for which you want the ID."
|
||||
"Example: id = objectives::get_id_for_target( "tank_marker", vh_tank_3 );"
|
||||
"SPMP: singleplayer"
|
||||
@/
|
||||
function get_id_for_target( str_obj_type, e_target )
|
||||
{
|
||||
id = -1;
|
||||
if ( isdefined( level.a_objectives[str_obj_type] ) )
|
||||
{
|
||||
o_objective = level.a_objectives[str_obj_type];
|
||||
id = [[o_objective]]->get_id_for_target( e_target );
|
||||
}
|
||||
|
||||
if ( id < 0 )
|
||||
{
|
||||
Assert( false, "get_id_for_target called for an objective that does not exist." );
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/@
|
||||
"Name: event_message( <istr_message> )"
|
||||
"Summary: Show an event message on the HUD."
|
||||
"MandatoryArg: <istr_message> The localized string to show."
|
||||
"Example: objectives::event_message( "Kill the quadtank" );"
|
||||
@/
|
||||
function event_message( istr_message )
|
||||
{
|
||||
foreach ( player in level.players )
|
||||
{
|
||||
util::show_event_message( player, istring( istr_message ) );
|
||||
}
|
||||
}
|
||||
|
||||
//str_obj_type - the icon type ( target, capture, defend, defend_b, etc )
|
||||
//str_obj_name - a unique identifier for this icon. Creating a new icon with a name already in use, will destroy/override the previous icon
|
||||
//v_pos - the position the icon will be placed
|
||||
function create_temp_icon( str_obj_type, str_obj_name, v_pos, v_offset=(0,0,0) )
|
||||
{
|
||||
switch( str_obj_type )
|
||||
{
|
||||
case "target":
|
||||
str_shader = "waypoint_targetneutral";
|
||||
break;
|
||||
|
||||
case "capture":
|
||||
str_shader = "waypoint_capture";
|
||||
break;
|
||||
|
||||
case "capture_a":
|
||||
str_shader = "waypoint_capture_a";
|
||||
break;
|
||||
|
||||
case "capture_b":
|
||||
str_shader = "waypoint_capture_b";
|
||||
break;
|
||||
|
||||
case "capture_c":
|
||||
str_shader = "waypoint_capture_c";
|
||||
break;
|
||||
|
||||
case "defend":
|
||||
str_shader = "waypoint_defend";
|
||||
break;
|
||||
|
||||
case "defend_a":
|
||||
str_shader = "waypoint_defend_a";
|
||||
break;
|
||||
|
||||
case "defend_b":
|
||||
str_shader = "waypoint_defend_b";
|
||||
break;
|
||||
|
||||
case "defend_c":
|
||||
str_shader = "waypoint_defend_c";
|
||||
break;
|
||||
|
||||
case "return":
|
||||
str_shader = "waypoint_return";
|
||||
break;
|
||||
|
||||
default:
|
||||
AssertMsg( "Type '" + str_obj_type + "' not supported. Please see create_temp_icon() in _objectives.gsc for supported types." );
|
||||
break;
|
||||
}
|
||||
|
||||
nextObjPoint = objpoints::create( str_obj_name, v_pos + v_offset, "all", str_shader );
|
||||
nextObjPoint setWayPoint( true, str_shader );
|
||||
|
||||
return nextObjPoint;
|
||||
}
|
||||
|
||||
function destroy_temp_icon()
|
||||
{
|
||||
objpoints::delete( self );
|
||||
}
|
||||
|
||||
function private on_player_spawned() // self = player
|
||||
{
|
||||
// find any active breadcrumbs, and initialize them on this player
|
||||
if ( isdefined( level.a_objectives ) )
|
||||
{
|
||||
foreach( o_objective in level.a_objectives )
|
||||
{
|
||||
if ( [[o_objective]]->is_breadcrumb() && ![[o_objective]]->is_done() )
|
||||
{
|
||||
[[o_objective]]->add_player( self );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+450
@@ -0,0 +1,450 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\array_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\flagsys_shared;
|
||||
#using scripts\shared\scene_shared;
|
||||
#using scripts\shared\spawner_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\visionset_mgr_shared;
|
||||
|
||||
#using scripts\cp\gametypes\_save;
|
||||
|
||||
Line truncated
|
||||
|
||||
|
||||
|
||||
|
||||
#namespace oed;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("oed",&__init__,&__main__,undefined); }
|
||||
|
||||
//TODO - add in support for the animated portion of the hud/lui when it comes online
|
||||
|
||||
function __init__()
|
||||
{
|
||||
clientfield::register( "toplayer", "ev_toggle", 1, 1, "int" );
|
||||
clientfield::register( "toplayer", "sitrep_toggle", 1, 1, "int" );
|
||||
clientfield::register( "toplayer", "tmode_toggle", 1, 3, "int" );
|
||||
clientfield::register( "toplayer", "active_dni_fx", 1, 1, "counter" );
|
||||
clientfield::register( "toplayer", "hack_dni_fx", 1, 1, "counter" );
|
||||
|
||||
clientfield::register( "actor", "thermal_active", 1, 1, "int" );
|
||||
clientfield::register( "actor", "sitrep_material", 1, 1, "int" );
|
||||
clientfield::register( "actor", "force_tmode", 1, 1, "int" );
|
||||
clientfield::register( "actor", "tagged", 1, 1, "int" );
|
||||
|
||||
clientfield::register( "vehicle", "thermal_active", 1, 1, "int" );
|
||||
clientfield::register( "vehicle", "sitrep_material", 1, 1, "int" );
|
||||
|
||||
clientfield::register( "scriptmover", "thermal_active", 1, 1, "int" );
|
||||
clientfield::register( "scriptmover", "sitrep_material", 1, 1, "int" );
|
||||
|
||||
clientfield::register( "item", "sitrep_material", 1, 1, "int" );
|
||||
|
||||
if ( !IsDefined( level.vsmgr_prio_visionset_tmode ) )
|
||||
{
|
||||
level.vsmgr_prio_visionset_tmode = 50;
|
||||
}
|
||||
visionset_mgr::register_info( "visionset", "tac_mode", 1, level.vsmgr_prio_visionset_tmode, 15, true, &visionset_mgr::ramp_in_out_thread_per_player, false );
|
||||
|
||||
callback::on_spawned( &on_player_spawned );
|
||||
|
||||
// Have all enemies show up on thermal
|
||||
spawner::add_global_spawn_function( "axis", &enable_thermal_on_spawned );
|
||||
spawner::add_global_spawn_function( "allies", &enable_thermal_on_spawned );
|
||||
|
||||
level.b_enhanced_vision_enabled = true;
|
||||
level.b_tactical_mode_enabled = true;
|
||||
level.b_player_scene_active = false;
|
||||
|
||||
level.enable_thermal = &enable_thermal;
|
||||
level.disable_thermal = &disable_thermal;
|
||||
}
|
||||
|
||||
function __main__()
|
||||
{
|
||||
keyline_weapons();
|
||||
}
|
||||
|
||||
function keyline_weapons()
|
||||
{
|
||||
waittillframeend; // clientfields can't be set before a wait
|
||||
if ( level.b_tactical_mode_enabled )
|
||||
{
|
||||
array::thread_all(
|
||||
util::query_ents(
|
||||
AssociativeArray( "classname", "weapon_" ), true,
|
||||
[],
|
||||
true,
|
||||
true
|
||||
), &enable_keyline );
|
||||
}
|
||||
}
|
||||
|
||||
function on_player_spawned()
|
||||
{
|
||||
// ev init
|
||||
self.b_enhanced_vision_enabled = level.b_enhanced_vision_enabled;
|
||||
self.ev_state = false;
|
||||
self ev_activate_on_player( self.ev_state );
|
||||
|
||||
// tmode init
|
||||
self.b_tactical_mode_enabled = level.b_tactical_mode_enabled;
|
||||
self.tmode_state = false;
|
||||
|
||||
b_playsound = false;
|
||||
|
||||
if ( !( SessionModeIsCampaignZombiesGame() ) )
|
||||
if ( ( isdefined( GetLocalProfileInt( "tacticalModeAutoOn" ) ) && GetLocalProfileInt( "tacticalModeAutoOn" ) ) )
|
||||
{
|
||||
self.tmode_state = true;
|
||||
b_playsound = false;
|
||||
}
|
||||
|
||||
self tmode_activate_on_player( self.tmode_state, b_playsound );
|
||||
|
||||
// sitrep
|
||||
self clientfield::set_to_player( "sitrep_toggle", 1 );
|
||||
|
||||
self thread check_keys_for_ev_and_tmode();
|
||||
self thread init_heroes();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// EV and TMODE
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
function check_keys_for_ev_and_tmode()
|
||||
{
|
||||
self endon( "death" );
|
||||
self endon("killOEDMonitor");
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
/# level flagsys::wait_till_clear( "menu_open" ); #/
|
||||
|
||||
// EV on up dpad
|
||||
if ( level.b_enhanced_vision_enabled && self.b_enhanced_vision_enabled && self ActionSlotOneButtonPressed() )
|
||||
{
|
||||
if ( !scene::is_igc_active() )
|
||||
{
|
||||
|
||||
self.ev_state = !( isdefined( self.ev_state ) && self.ev_state );
|
||||
self ev_activate_on_player( self.ev_state );
|
||||
|
||||
// wait until the key is released
|
||||
while( self ActionSlotOneButtonPressed() )
|
||||
{
|
||||
{wait(.05);};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TMode on right dpad
|
||||
if ( !( SessionModeIsCampaignZombiesGame() ) && level.b_tactical_mode_enabled && self.b_tactical_mode_enabled && self ActionSlotFourButtonPressed() )
|
||||
{
|
||||
if ( !scene::is_igc_active() )
|
||||
{
|
||||
self.tmode_state = !( isdefined( self.tmode_state ) && self.tmode_state );
|
||||
self tmode_activate_on_player( self.tmode_state );
|
||||
|
||||
visionset_mgr::activate( "visionset", "tac_mode", self, 0.05, 0.0, 0.8 );
|
||||
wait 0.05 + 0.0 + 0.8;
|
||||
|
||||
while ( self ActionSlotFourButtonPressed() )
|
||||
{
|
||||
{wait(.05);};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{wait(.05);};
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
///ENHANCED VISION - THERMAL
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Spawn function to automatically enable thermal on enemies
|
||||
function enable_thermal_on_spawned()
|
||||
{
|
||||
if ( self.team == "axis" )
|
||||
{
|
||||
self enable_thermal();
|
||||
}
|
||||
else if( self.team == "allies" )//keep seperate for now in case we need extra logic here
|
||||
{
|
||||
self enable_thermal();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO - will likely need to add in support for hud/lui changes
|
||||
// Called externally to enable an entity to have a thermal shader when EV is activated
|
||||
// self is the entity to have a thermal signature
|
||||
// str_disable - a notify that can be used to deactivate the thermal signature
|
||||
function enable_thermal( str_disable )
|
||||
{
|
||||
self endon( "death" );
|
||||
|
||||
self clientfield::set( "thermal_active", 1 );
|
||||
self thread disable_thermal_on_death();
|
||||
|
||||
if( isdefined( str_disable ) )
|
||||
{
|
||||
level waittill( str_disable );
|
||||
|
||||
self disable_thermal();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the thermal signature on death
|
||||
// self is the entity that has a thermal signature
|
||||
function disable_thermal_on_death()
|
||||
{
|
||||
self endon( "disable_thermal" );
|
||||
|
||||
self waittill( "death" );
|
||||
|
||||
if( isdefined( self ) )
|
||||
{
|
||||
self disable_thermal();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the thermal signature from the entity
|
||||
// self is the entity that has a thermal signature
|
||||
function disable_thermal()
|
||||
{
|
||||
self clientfield::set( "thermal_active", 0 );
|
||||
|
||||
self notify( "disable_thermal" );
|
||||
}
|
||||
|
||||
//Toggles the vars used to enable/disable player access to thermal mode, also called EV
|
||||
//This should be used when toggling during the course of the level
|
||||
//If you just want to disable thermal access by default at level start, just use level.b_enhanced_vision_enabled = false;
|
||||
function toggle_thermal_mode_for_players( b_enabled = true )
|
||||
{
|
||||
level.b_enhanced_vision_enabled = b_enabled;
|
||||
foreach( e_player in level.players )
|
||||
{
|
||||
e_player.b_enhanced_vision_enabled = b_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TMODE and EV are disabled & turned off or enabled for the player from a level script here.
|
||||
//
|
||||
function enable_ev( b_enabled = true )
|
||||
{
|
||||
self.b_enhanced_vision_enabled = b_enabled;
|
||||
|
||||
if ( !b_enabled )
|
||||
self ev_activate_on_player( b_enabled );
|
||||
}
|
||||
|
||||
function enable_tac_mode( b_enabled = true )
|
||||
{
|
||||
self.b_tactical_mode_enabled = b_enabled;
|
||||
|
||||
if ( b_enabled )
|
||||
{
|
||||
if ( !( SessionModeIsCampaignZombiesGame() ) && ( isdefined( GetLocalProfileInt( "tacticalModeAutoOn" ) ) && GetLocalProfileInt( "tacticalModeAutoOn" ) ) )
|
||||
{
|
||||
self tmode_activate_on_player( true, false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self tmode_activate_on_player( false, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// external call from other scripts to turn ev on and off on a player
|
||||
//
|
||||
function set_player_ev( b_enabled = true )
|
||||
{
|
||||
ev_activate_on_player( b_enabled );
|
||||
}
|
||||
|
||||
function ev_activate_on_player( b_enabled = true )
|
||||
{
|
||||
self.ev_state = b_enabled;
|
||||
|
||||
// turn on ev - so turn off tmode
|
||||
if ( self.ev_state )
|
||||
{
|
||||
if ( ( isdefined( self.tmode_state ) && self.tmode_state ) )
|
||||
self.tmode_state_before_ev = true;
|
||||
else
|
||||
self.tmode_state_before_ev = false;
|
||||
|
||||
self tmode_activate_on_player( false, false, false );
|
||||
}
|
||||
|
||||
//the tutorial moment in New World is listening for this
|
||||
if ( self.ev_state )
|
||||
self notify( "enhanced_vision_activated" );
|
||||
else
|
||||
self notify( "enhanced_vision_deactivated" );
|
||||
|
||||
self clientfield::set_to_player( "ev_toggle", self.ev_state );
|
||||
|
||||
// turn off ev - maybe turn tmode back on
|
||||
if ( !self.ev_state )
|
||||
{
|
||||
if ( ( isdefined( self.tmode_state_before_ev ) && self.tmode_state_before_ev ) )
|
||||
{
|
||||
if ( !( SessionModeIsCampaignZombiesGame() ) && ( isdefined( GetLocalProfileInt( "tacticalModeAutoOn" ) ) && GetLocalProfileInt( "tacticalModeAutoOn" ) ) )
|
||||
{
|
||||
self tmode_activate_on_player( true, false, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tmode_activate_on_player( b_enabled = true, b_playsound = true, b_turnoffev = true )
|
||||
{
|
||||
self.tmode_state = b_enabled;
|
||||
|
||||
|
||||
if ( b_turnoffev && self.tmode_state )
|
||||
self ev_activate_on_player( false );
|
||||
|
||||
if ( self.tmode_state )
|
||||
self notify( "tactical_mode_activated" );
|
||||
else
|
||||
self notify( "tactical_mode_deactivated" );
|
||||
|
||||
self TmodeSetServerUser( self.tmode_state );
|
||||
|
||||
code = 0;
|
||||
|
||||
if( !isdefined( self.tmode_count ) )
|
||||
self.tmode_count = 0;
|
||||
|
||||
self.tmode_count++;
|
||||
self.tmode_count &= 1;
|
||||
|
||||
code = self.tmode_count;
|
||||
|
||||
if ( b_playsound )
|
||||
code |= 0x2;
|
||||
|
||||
if ( self.tmode_state )
|
||||
code |= 0x4;
|
||||
|
||||
self clientfield::set_to_player( "tmode_toggle", code );
|
||||
|
||||
self savegame::set_player_data("tmode", self.tmode_state );
|
||||
}
|
||||
|
||||
function init_heroes()
|
||||
{
|
||||
a_e_heroes = GetEntArray();
|
||||
foreach( e_hero in a_e_heroes )
|
||||
{
|
||||
if( ( isdefined( e_hero.is_hero ) && e_hero.is_hero ) )
|
||||
{
|
||||
e_hero thread enable_thermal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// TACTICAL MODE
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Toggles the vars used to enable/disable player access to tactical mode
|
||||
//This should be used when toggling during the course of the level
|
||||
//If you just want to disable tac mode access by default at level start, just use level.b_tactical_mode_enabled = false;
|
||||
|
||||
|
||||
function toggle_tac_mode_for_players( b_enabled = true )
|
||||
{
|
||||
level.b_tactical_mode_enabled = b_enabled;
|
||||
foreach( e_player in level.players )
|
||||
{
|
||||
e_player.b_tactical_mode_enabled = b_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//self = AI enemy actor that will draw in tmode for all players no matter what
|
||||
function set_force_tmode( b_enabled = true )
|
||||
{
|
||||
self.b_force_tmode = b_enabled;
|
||||
self clientfield::set( "force_tmode", b_enabled );
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// SITREP - KEYLINE
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Set b_interact to true if this is an interactive entity//TODO we may need support now for non-interactable, for now we assume this is an interact object
|
||||
function enable_keyline( b_interact = false, str_disable )
|
||||
{
|
||||
self endon( "death" );
|
||||
|
||||
self clientfield::set( "sitrep_material", 1 );
|
||||
|
||||
self thread disable_on_death();
|
||||
|
||||
if( isdefined( str_disable ) )
|
||||
{
|
||||
level waittill( str_disable );
|
||||
self disable_keyline();
|
||||
}
|
||||
}
|
||||
|
||||
function disable_on_death()
|
||||
{
|
||||
self waittill( "death" );
|
||||
if( isdefined( self ) )
|
||||
{
|
||||
self disable_keyline();
|
||||
}
|
||||
}
|
||||
|
||||
function disable_keyline()
|
||||
{
|
||||
self clientfield::set( "sitrep_material", 0 );
|
||||
}
|
||||
|
||||
function toggle_sitrep_for_players( b_active = true )
|
||||
{
|
||||
foreach( player in level.players )
|
||||
{
|
||||
player.sitrep_active = !( isdefined( player.sitrep_active ) && player.sitrep_active );
|
||||
player clientfield::set_to_player( "sitrep_toggle", player.sitrep_active );
|
||||
}
|
||||
}
|
||||
|
||||
function init_sitrep_model()
|
||||
{
|
||||
if( !IsDefined(self.angles) )
|
||||
{
|
||||
self.angles = (0, 0 ,0 );
|
||||
}
|
||||
|
||||
s_sitrep_bundle = level.scriptbundles[ "sitrep" ][ self.scriptbundlename ];
|
||||
|
||||
e_sitrep = util::spawn_model( s_sitrep_bundle.model, self.origin, self.angles );
|
||||
|
||||
if( isdefined( s_sitrep_bundle.sitrep_interact ) )
|
||||
{
|
||||
e_sitrep.script_sitrep_id = s_sitrep_bundle.sitrep_interact;
|
||||
}
|
||||
else
|
||||
{
|
||||
e_sitrep.script_sitrep_id = 0;
|
||||
}
|
||||
|
||||
return e_sitrep;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
|
||||
// Name of the visionset file
|
||||
// alias in script
|
||||
// priority vs other visionsets
|
||||
// number of steps when ramping in/out
|
||||
// activation ramp-in time
|
||||
// How long to hold after ramp-in is done and before ramping-out
|
||||
// deactivation ramp-out time
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+1967
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,308 @@
|
||||
|
||||
// ----------------------
|
||||
// AI RELATED
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 100 Deg
|
||||
|
||||
// 180 Deg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// SPAWNERS
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// AITYPES
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// DROPS
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// FFOTD ( 11/03/2015 ) Fix for DT#141451
|
||||
// Following list comes from the # texture/material index column of the weaponOptions.csv. Any indexes beyond these ones are post ship versions,
|
||||
// which we do not want to use. The following indexes will not change at all in post ship environment so they are safe to use.
|
||||
|
||||
|
||||
// ----------------------
|
||||
// POST FX
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// GDT DATA
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// WEAPONS
|
||||
//-----------------------
|
||||
|
||||
// Weapons Table path
|
||||
|
||||
|
||||
// weapon
|
||||
|
||||
|
||||
// min_attachments
|
||||
|
||||
|
||||
// max_attachments
|
||||
|
||||
|
||||
// attachments
|
||||
|
||||
|
||||
// magicbox_only
|
||||
|
||||
|
||||
// ----------------------
|
||||
// PATHABILITY - FOR AI
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// REACHABILITY - FOR PLAYER
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// MATURE
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// Zombie Suicide Explosion
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// Zombie Sparky
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// Deimos Zombie
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// ETHEREAL OVERLAY
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// SPAWNING
|
||||
//-----------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Control Set
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Martial Set
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Chaos Set
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//rigs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Enumerations for the different types of arm pulse patterns.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//1023
|
||||
|
||||
|
||||
@@ -0,0 +1,960 @@
|
||||
#using scripts\shared\array_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\flag_shared;
|
||||
#using scripts\shared\flagsys_shared;
|
||||
#using scripts\shared\hud_util_shared;
|
||||
#using scripts\shared\lui_shared;
|
||||
#using scripts\shared\scene_shared;
|
||||
#using scripts\shared\string_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
|
||||
#using scripts\cp\gametypes\_loadout;
|
||||
#using scripts\cp\gametypes\_globallogic;
|
||||
#using scripts\cp\gametypes\_globallogic_player;
|
||||
#using scripts\cp\gametypes\_save;
|
||||
#using scripts\cp\gametypes\_spectating;
|
||||
|
||||
#using scripts\cp\_util;
|
||||
#using scripts\cp\teams\_teams;
|
||||
|
||||
#precache( "string", "MP_HALFTIME" );
|
||||
#precache( "string", "MP_OVERTIME" );
|
||||
#precache( "string", "MP_ROUNDEND" );
|
||||
#precache( "string", "MP_INTERMISSION" );
|
||||
#precache( "string", "MP_SWITCHING_SIDES_CAPS" );
|
||||
#precache( "string", "MP_FRIENDLY_FIRE_WILL_NOT" );
|
||||
#precache( "string", "MP_RAMPAGE" );
|
||||
#precache( "string", "MP_ENDED_GAME" );
|
||||
#precache( "string", "MP_HOST_ENDED_GAME" );
|
||||
|
||||
#precache( "eventstring", "medal_received" );
|
||||
#precache( "eventstring", "killstreak_received" );
|
||||
#precache( "eventstring", "player_callout" );
|
||||
#precache( "eventstring", "score_event" );
|
||||
#precache( "eventstring", "rank_up" );
|
||||
#precache( "eventstring", "client_rank_up" );
|
||||
#precache( "eventstring", "weapon_unlocked" );
|
||||
#precache( "eventstring", "token_unlocked" );
|
||||
#precache( "eventstring", "gun_level_complete" );
|
||||
#precache( "eventstring", "challenge_complete" );
|
||||
|
||||
#precache( "menu", "InitialBlack" );
|
||||
|
||||
|
||||
|
||||
#namespace globallogic_ui;
|
||||
|
||||
//REGISTER_SYSTEM( "globallogic_ui", &__init__, undefined )
|
||||
|
||||
function init()
|
||||
{
|
||||
callback::add_callback( #"on_player_spawned", &on_player_spawn);
|
||||
clientfield::register( "clientuimodel", "hudItems.cybercoreSelectMenuDisabled", 1, 1, "int" );
|
||||
clientfield::register( "clientuimodel", "hudItems.playerInCombat", 1, 1, "int" );
|
||||
clientfield::register( "clientuimodel", "playerAbilities.repulsorIndicatorDirection", 1, 2, "int" );
|
||||
clientfield::register( "clientuimodel", "playerAbilities.repulsorIndicatorIntensity", 1, 2, "int" );
|
||||
clientfield::register( "clientuimodel", "playerAbilities.proximityIndicatorDirection", 1, 2, "int" );
|
||||
clientfield::register( "clientuimodel", "playerAbilities.proximityIndicatorIntensity", 1, 2, "int" );
|
||||
clientfield::register( "clientuimodel", "serverDifficulty", 1, 3, "int" );
|
||||
}
|
||||
|
||||
function on_player_spawn()
|
||||
{
|
||||
self thread watch_player_in_combat();
|
||||
|
||||
assert( isdefined( level.gameSkill ) );
|
||||
|
||||
self clientfield::set_player_uimodel( "serverDifficulty", level.gameSkill );
|
||||
}
|
||||
|
||||
function IsAnyAIAttackingThePlayer( playerEnt )
|
||||
{
|
||||
ais = GetAITeamArray( "axis" );
|
||||
ais = ArrayCombine( ais, GetAITeamArray( "team3" ), false, false ); // sometimes enemy AI is on team 3 as well
|
||||
|
||||
foreach( ai in ais )
|
||||
{
|
||||
if ( IsSentient( ai ) )
|
||||
{
|
||||
if ( ai AttackedRecently( playerEnt, 10 ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( ai.enemy === playerEnt &&
|
||||
IsDefined( ai.weapon ) &&
|
||||
ai.weapon.name === "none" &&
|
||||
DistanceSquared( ai.origin, playerEnt.origin ) < ( (240) * (240) ) )
|
||||
{
|
||||
// Melee AI is close to the player.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function IsAnyAIAwareOfPlayer( playerEnt )
|
||||
{
|
||||
ais = GetAITeamArray( "axis" );
|
||||
ais = ArrayCombine( ais, GetAITeamArray( "team3" ), false, false ); // sometimes enemy AI is on team 3 as well
|
||||
|
||||
foreach( ai in ais )
|
||||
{
|
||||
if ( IsSentient( ai ) )
|
||||
{
|
||||
// Has known about player recently?
|
||||
if ( ( ai LastKnownTime( playerEnt ) + 4000 ) >= GetTime() )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function IsPlayerHurt( playerEnt )
|
||||
{
|
||||
return playerEnt.health < playerEnt.maxhealth;
|
||||
}
|
||||
|
||||
function watch_player_in_combat()
|
||||
{
|
||||
self endon("kill_watch_player_in_combat");
|
||||
self endon( "disconnect" );
|
||||
|
||||
while( true )
|
||||
{
|
||||
if ( IsPlayerHurt( self ) || IsAnyAIAttackingThePlayer( self ) )
|
||||
{
|
||||
self clientfield::set_player_uimodel( "hudItems.playerInCombat", 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
self clientfield::set_player_uimodel( "hudItems.playerInCombat", 0 );
|
||||
}
|
||||
|
||||
wait( 0.5 );
|
||||
}
|
||||
}
|
||||
|
||||
function SetupCallbacks()
|
||||
{
|
||||
level.autoassign =&menuAutoAssign;
|
||||
level.spectator =&menuSpectator;
|
||||
level.curClass =&menuClass;
|
||||
level.teamMenu =&menuTeam;
|
||||
}
|
||||
|
||||
function freeGameplayHudElems()
|
||||
{
|
||||
// free up some hud elems so we have enough for other things.
|
||||
|
||||
// perk icons
|
||||
if ( isdefined( self.perkicon ) )
|
||||
{
|
||||
for ( numSpecialties = 0; numSpecialties < level.maxSpecialties; numSpecialties++ )
|
||||
{
|
||||
if ( isdefined( self.perkicon[ numSpecialties ] ) )
|
||||
{
|
||||
self.perkicon[ numSpecialties ] hud::destroyElem();
|
||||
self.perkname[ numSpecialties ] hud::destroyElem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isdefined( self.perkHudelem ) )
|
||||
{
|
||||
self.perkHudelem hud::destroyElem();
|
||||
}
|
||||
|
||||
// Killstreak icons
|
||||
if ( isdefined( self.killstreakicon ) )
|
||||
{
|
||||
if ( isdefined( self.killstreakicon[0] ) )
|
||||
{
|
||||
self.killstreakicon[0] hud::destroyElem();
|
||||
}
|
||||
if ( isdefined( self.killstreakicon[1] ) )
|
||||
{
|
||||
self.killstreakicon[1] hud::destroyElem();
|
||||
}
|
||||
if ( isdefined( self.killstreakicon[2] ) )
|
||||
{
|
||||
self.killstreakicon[2] hud::destroyElem();
|
||||
}
|
||||
if ( isdefined( self.killstreakicon[3] ) )
|
||||
{
|
||||
self.killstreakicon[3] hud::destroyElem();
|
||||
}
|
||||
if ( isdefined( self.killstreakicon[4] ) )
|
||||
{
|
||||
self.killstreakicon[4] hud::destroyElem();
|
||||
}
|
||||
}
|
||||
|
||||
// lower message
|
||||
if ( isdefined( self.lowerMessage ) )
|
||||
self.lowerMessage hud::destroyElem();
|
||||
if ( isdefined( self.lowerTimer ) )
|
||||
self.lowerTimer hud::destroyElem();
|
||||
|
||||
// progress bar
|
||||
if ( isdefined( self.proxBar ) )
|
||||
self.proxBar hud::destroyElem();
|
||||
if ( isdefined( self.proxBarText ) )
|
||||
self.proxBarText hud::destroyElem();
|
||||
|
||||
// carry icon
|
||||
if ( isdefined( self.carryIcon ) )
|
||||
self.carryIcon hud::destroyElem();
|
||||
}
|
||||
|
||||
function teamPlayerCountsEqual( playerCounts )
|
||||
{
|
||||
count = undefined;
|
||||
|
||||
foreach( team in level.teams )
|
||||
{
|
||||
if ( !isdefined( count ) )
|
||||
{
|
||||
count = playerCounts[team];
|
||||
continue;
|
||||
}
|
||||
if ( count != playerCounts[team] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function teamWithLowestPlayerCount( playerCounts, ignore_team )
|
||||
{
|
||||
count = 9999;
|
||||
lowest_team = undefined;
|
||||
|
||||
foreach( team in level.teams )
|
||||
{
|
||||
if ( count > playerCounts[team] )
|
||||
{
|
||||
count = playerCounts[team];
|
||||
lowest_team = team;
|
||||
}
|
||||
}
|
||||
|
||||
return lowest_team;
|
||||
}
|
||||
|
||||
function menuAutoAssign( comingFromMenu )
|
||||
{
|
||||
teamKeys = GetArrayKeys( level.teams );
|
||||
assignment = teamKeys[randomInt(teamKeys.size)];
|
||||
|
||||
self closeMenus();
|
||||
|
||||
assignment = "allies";
|
||||
|
||||
if ( level.teamBased )
|
||||
{
|
||||
if ( assignment == self.pers["team"] && (self.sessionstate == "playing" || self.sessionstate == "dead") )
|
||||
{
|
||||
self beginClassChoice();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( GetDvarint( "party_autoteams" ) == 1 )
|
||||
{
|
||||
// after they have spawned in once then we should let the random team assignment logic handle itself.
|
||||
if( level.allow_teamchange != "1" || ( !self.hasSpawned && !comingFromMenu ) )
|
||||
{
|
||||
team = getAssignedTeam( self );
|
||||
if( isdefined( level.teams[team] ) )
|
||||
{
|
||||
assignment = team;
|
||||
}
|
||||
else if ( team == "spectator" && (!level.forceAutoAssign) )
|
||||
{
|
||||
self SetClientScriptMainMenu( game[ "menu_start_menu" ] );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( assignment != self.pers["team"] && (self.sessionstate == "playing" || self.sessionstate == "dead") )
|
||||
{
|
||||
self.switching_teams = true;
|
||||
self.switchedTeamsResetGadgets = true;
|
||||
self.joining_team = assignment;
|
||||
self.leaving_team = self.pers["team"];
|
||||
self suicide();
|
||||
}
|
||||
|
||||
self.pers["team"] = assignment;
|
||||
self.team = assignment;
|
||||
self.pers["class"] = undefined;
|
||||
self.curClass = undefined;
|
||||
self.pers["weapon"] = undefined;
|
||||
self.pers["savedmodel"] = undefined;
|
||||
|
||||
self updateObjectiveText();
|
||||
|
||||
self.sessionteam = assignment;
|
||||
|
||||
if ( !isAlive( self ) )
|
||||
self.statusicon = "hud_status_dead";
|
||||
|
||||
self notify("joined_team");
|
||||
level notify( "joined_team" );
|
||||
callback::callback( #"on_joined_team" );
|
||||
self notify("end_respawn");
|
||||
|
||||
self beginClassChoice();
|
||||
self SetClientScriptMainMenu( game[ "menu_start_menu" ] );
|
||||
|
||||
}
|
||||
|
||||
function teamScoresEqual( )
|
||||
{
|
||||
score = undefined;
|
||||
|
||||
foreach( team in level.teams )
|
||||
{
|
||||
if ( !isdefined( score ) )
|
||||
{
|
||||
score = getTeamScore(team);
|
||||
continue;
|
||||
}
|
||||
if ( score != getTeamScore(team) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function teamWithLowestScore()
|
||||
{
|
||||
score = 99999999;
|
||||
lowest_team = undefined;
|
||||
|
||||
foreach( team in level.teams )
|
||||
{
|
||||
if ( score > getTeamScore(team ) )
|
||||
lowest_team = team;
|
||||
}
|
||||
|
||||
return lowest_team;
|
||||
}
|
||||
|
||||
function pickTeamFromScores(teams)
|
||||
{
|
||||
assignment = "allies";
|
||||
|
||||
if ( teamScoresEqual() )
|
||||
assignment = teams[randomInt(teams.size)];
|
||||
else
|
||||
assignment = teamWithLowestScore();
|
||||
|
||||
return assignment;
|
||||
}
|
||||
|
||||
function get_splitscreen_team()
|
||||
{
|
||||
for ( index = 0; index < level.players.size; index++ )
|
||||
{
|
||||
if ( !isdefined(level.players[index]) )
|
||||
continue;
|
||||
|
||||
if ( level.players[index] == self )
|
||||
continue;
|
||||
|
||||
if ( !(self IsPlayerOnSameMachine( level.players[index] )) )
|
||||
continue;
|
||||
|
||||
team = level.players[index].sessionteam;
|
||||
|
||||
// going to assume first non-spectator
|
||||
if ( team != "spectator" )
|
||||
return team;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function updateObjectiveText()
|
||||
{
|
||||
if ( SessionModeIsZombiesGame() || (self.pers["team"] == "spectator") )
|
||||
{
|
||||
self SetClientCGObjectiveText( "" );
|
||||
return;
|
||||
}
|
||||
|
||||
if( level.scorelimit > 0 )
|
||||
{
|
||||
self SetClientCGObjectiveText( util::getObjectiveScoreText( self.pers["team"] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
self SetClientCGObjectiveText( util::getObjectiveText( self.pers["team"] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function closeMenus()
|
||||
{
|
||||
self closeInGameMenu();
|
||||
}
|
||||
|
||||
function beginClassChoice()
|
||||
{
|
||||
assert( isdefined( level.teams[self.pers["team"]] ) );
|
||||
|
||||
team = self.pers["team"];
|
||||
|
||||
self CloseMenu( game["menu_start_menu"] );
|
||||
|
||||
if ( !GetDvarInt( "art_review", 0 ) )
|
||||
{
|
||||
self thread fullscreen_black();
|
||||
}
|
||||
|
||||
b_disable_cac = GetDvarInt( "force_no_cac", 0 );
|
||||
|
||||
if ( !GetDvarInt( "force_cac", 0 ) || b_disable_cac )
|
||||
{
|
||||
prevclass = self savegame::get_player_data( "playerClass", undefined );
|
||||
prevHeroWeapons = self savegame::get_player_data( savegame::get_mission_name() + "hero_weapon", undefined );
|
||||
|
||||
if ( isdefined( prevclass ) || b_disable_cac
|
||||
|| ( isdefined( level.disableClassSelection ) && level.disableClassSelection )
|
||||
|| ( isdefined( self.disableClassSelection ) && self.disableClassSelection )
|
||||
|| GetDvarint( "migration_soak" ) == 1 )
|
||||
{
|
||||
self.curClass = (isdefined(prevclass)?prevclass:level.defaultClass);
|
||||
self.pers[ "class" ] = self.curClass;
|
||||
|
||||
{wait(.05);};
|
||||
|
||||
if ( self.sessionstate != "playing" && game[ "state" ] == "playing" )
|
||||
{
|
||||
self thread [[ level.spawnClient ]]();
|
||||
}
|
||||
|
||||
globallogic::updateTeamStatus();
|
||||
self thread spectating::set_permissions_for_machine();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// menu_changeclass_team is the one where you choose one of the n classes to play as.
|
||||
// menu_class_team is where you can choose to change your team, class, controls, or leave game.
|
||||
self CloseMenu( game[ "menu_changeclass" ] );
|
||||
self openMenu( game[ "menu_changeclass_" + team ] );
|
||||
|
||||
//if ( level.rankedMatch )
|
||||
// self openMenu( game[ "menu_changeclass_" + team ] );
|
||||
//else
|
||||
// self openMenu( game[ "menu_start_menu" ] );
|
||||
}
|
||||
|
||||
function fullscreen_black()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
util::show_hud( 0 );
|
||||
|
||||
self CloseMenu( "InitialBlack" );
|
||||
self OpenMenu( "InitialBlack" );
|
||||
|
||||
b_hot_joining = false;
|
||||
if ( level flag::get( "all_players_spawned" ) )
|
||||
{
|
||||
b_hot_joining = true;
|
||||
}
|
||||
|
||||
self.fullscreen_black_active = true;
|
||||
self thread fullscreen_black_checkpoint_restore(); //this thread makes sure the fullscreen black is held up even if you restore from checkpoint and it needs to be held up
|
||||
|
||||
self Hide();
|
||||
|
||||
{wait(.05);};
|
||||
|
||||
if ( isdefined( level.str_level_start_flag ) || isdefined( level.str_player_start_flag ) )
|
||||
{
|
||||
init_start_flags();
|
||||
|
||||
self thread fullscreen_black_freeze_controls();
|
||||
|
||||
if ( isdefined( level.str_level_start_flag ) )
|
||||
{
|
||||
level flag::wait_till( level.str_level_start_flag );
|
||||
}
|
||||
|
||||
if ( isdefined( level.str_player_start_flag ) )
|
||||
{
|
||||
self flag::wait_till( level.str_player_start_flag );
|
||||
}
|
||||
}
|
||||
|
||||
if ( b_hot_joining && !( isdefined( level.is_safehouse ) && level.is_safehouse ) )
|
||||
{
|
||||
while ( self.sessionstate !== "playing" )
|
||||
{
|
||||
{wait(.05);};
|
||||
}
|
||||
|
||||
self thread fullscreen_black_freeze_controls();
|
||||
|
||||
while ( self IsLoadingCinematicPlaying() )
|
||||
{
|
||||
{wait(.05);};
|
||||
}
|
||||
|
||||
self flag::wait_till( "loadout_given" );
|
||||
waittillframeend; // if we are hot-joining an IGC wait until we can detect that
|
||||
|
||||
wait 2;
|
||||
|
||||
// hold black and wait for streamer
|
||||
self util::streamer_wait( undefined, 5, 5 );
|
||||
|
||||
self thread lui::screen_fade_in( .3, "black", "hot_join" );
|
||||
}
|
||||
|
||||
if ( !flagsys::get( "shared_igc" ) )
|
||||
{
|
||||
self Show();
|
||||
}
|
||||
|
||||
self flagsys::set( "kill_fullscreen_black" );
|
||||
|
||||
self clientfield::set_to_player( "sndLevelStartSnapOff", 1 );
|
||||
self CloseMenu( "InitialBlack" );
|
||||
|
||||
self.fullscreen_black_active = undefined;
|
||||
|
||||
util::show_hud( 1 );
|
||||
|
||||
/#
|
||||
PrintTopRightln( "["+GetTime()+"] KILL INITIAL BLACKSCREEN: PLAYER " + self GetEntityNumber(), ( 1, 1, 1 ) );
|
||||
streamerSkiptoDebug( GetSkiptos() );
|
||||
#/
|
||||
}
|
||||
|
||||
function fullscreen_black_checkpoint_restore()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "kill_fullscreen_black" ); //this seems to be set when the initial fullscreen is done
|
||||
|
||||
b_fullscreen_black = self.fullscreen_black_active;
|
||||
|
||||
level waittill( "save_restore" );
|
||||
|
||||
if( ( isdefined( b_fullscreen_black ) && b_fullscreen_black ) )
|
||||
{
|
||||
self CloseMenu( "InitialBlack" );
|
||||
self OpenMenu( "InitialBlack" );
|
||||
}
|
||||
}
|
||||
|
||||
function init_start_flags()
|
||||
{
|
||||
if ( isdefined( level.str_player_start_flag ) && !self flag::exists( level.str_player_start_flag ) )
|
||||
{
|
||||
self flag::init( level.str_player_start_flag );
|
||||
}
|
||||
|
||||
if ( isdefined( level.str_level_start_flag ) && !level flag::exists( level.str_level_start_flag ) )
|
||||
{
|
||||
level flag::init( level.str_level_start_flag );
|
||||
}
|
||||
}
|
||||
|
||||
function fullscreen_black_freeze_controls()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
self.b_game_start_invulnerability = true;
|
||||
|
||||
self flagsys::wait_till( "loadout_given" );
|
||||
|
||||
self DisableWeapons();
|
||||
self FreezeControls( true );
|
||||
|
||||
wait 0.1; // Several other scripts unfreeze controls when spawning, need to wait
|
||||
waittillframeend;
|
||||
|
||||
self FreezeControls( true );
|
||||
self DisableWeapons();
|
||||
|
||||
self flagsys::wait_till( "kill_fullscreen_black" );
|
||||
|
||||
self EnableWeapons();
|
||||
self FreezeControls( false );
|
||||
|
||||
self.b_game_start_invulnerability = undefined;
|
||||
}
|
||||
|
||||
function showMainMenuForTeam()
|
||||
{
|
||||
assert( isdefined( level.teams[self.pers["team"]] ) );
|
||||
|
||||
team = self.pers["team"];
|
||||
|
||||
// menu_changeclass_team is the one where you choose one of the n classes to play as.
|
||||
// menu_class_team is where you can choose to change your team, class, controls, or leave game.
|
||||
|
||||
self openMenu( game[ "menu_changeclass_" + team ] );
|
||||
}
|
||||
|
||||
function menuTeam( team )
|
||||
{
|
||||
self closeMenus();
|
||||
|
||||
if ( !level.console && level.allow_teamchange == "0" && (isdefined(self.hasDoneCombat) && self.hasDoneCombat) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(self.pers["team"] != team)
|
||||
{
|
||||
// allow respawn when switching teams during grace period.
|
||||
if ( level.inGracePeriod && (!isdefined(self.hasDoneCombat) || !self.hasDoneCombat) )
|
||||
self.hasSpawned = false;
|
||||
|
||||
if(self.sessionstate == "playing")
|
||||
{
|
||||
self.switching_teams = true;
|
||||
self.switchedTeamsResetGadgets = true;
|
||||
self.joining_team = team;
|
||||
self.leaving_team = self.pers["team"];
|
||||
self suicide();
|
||||
}
|
||||
|
||||
self.pers["team"] = team;
|
||||
self.team = team;
|
||||
self.pers["class"] = undefined;
|
||||
self.curClass = undefined;
|
||||
self.pers["weapon"] = undefined;
|
||||
self.pers["savedmodel"] = undefined;
|
||||
|
||||
self updateObjectiveText();
|
||||
|
||||
if ( !level.rankedMatch && !level.leagueMatch )
|
||||
{
|
||||
self.sessionstate = "spectator";
|
||||
}
|
||||
|
||||
self.sessionteam = team;
|
||||
|
||||
self SetClientScriptMainMenu( game[ "menu_start_menu" ] );
|
||||
|
||||
self notify("joined_team");
|
||||
level notify( "joined_team" );
|
||||
callback::callback( #"on_joined_team" );
|
||||
self notify("end_respawn");
|
||||
}
|
||||
|
||||
self beginClassChoice();
|
||||
}
|
||||
|
||||
function menuSpectator()
|
||||
{
|
||||
self closeMenus();
|
||||
|
||||
if(self.pers["team"] != "spectator")
|
||||
{
|
||||
if(isAlive(self))
|
||||
{
|
||||
self.switching_teams = true;
|
||||
self.switchedTeamsResetGadgets = true;
|
||||
self.joining_team = "spectator";
|
||||
self.leaving_team = self.pers["team"];
|
||||
self suicide();
|
||||
}
|
||||
|
||||
self.pers["team"] = "spectator";
|
||||
self.team = "spectator";
|
||||
self.pers["class"] = undefined;
|
||||
self.curClass = undefined;
|
||||
self.pers["weapon"] = undefined;
|
||||
self.pers["savedmodel"] = undefined;
|
||||
|
||||
self updateObjectiveText();
|
||||
|
||||
self.sessionteam = "spectator";
|
||||
|
||||
[[level.spawnSpectator]]();
|
||||
|
||||
self thread globallogic_player::spectate_player_watcher();
|
||||
|
||||
self SetClientScriptMainMenu( game[ "menu_start_menu" ] );
|
||||
|
||||
self notify("joined_spectators");
|
||||
callback::callback( #"on_joined_spectate" );
|
||||
}
|
||||
}
|
||||
|
||||
function menuClass( response )
|
||||
{
|
||||
self closeMenus();
|
||||
|
||||
// this should probably be an assert
|
||||
if ( !isdefined( self.pers[ "team" ] ) || !( isdefined( level.teams[ self.pers[ "team" ]] ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//-- mobile armory handles these changes within the system
|
||||
if ( flagsys::get( "mobile_armory_in_use" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
playerclass = "";
|
||||
|
||||
if ( response == "cancel" )
|
||||
{
|
||||
prevclass = self savegame::get_player_data( "playerClass", undefined );
|
||||
|
||||
if ( isdefined( prevclass ) )
|
||||
{
|
||||
playerclass = prevclass;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerclass = level.defaultClass;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responseArray = strtok( response, "," );
|
||||
if( responseArray.size > 1 )
|
||||
{
|
||||
str_class_chosen = responseArray[0];
|
||||
clientNum = Int( responseArray[1] );
|
||||
|
||||
altPlayer = util::getPlayerFromClientNum( clientNum );
|
||||
}
|
||||
else
|
||||
{
|
||||
str_class_chosen = response;
|
||||
}
|
||||
|
||||
playerclass = self loadout::getClassChoice( str_class_chosen );
|
||||
|
||||
if( IsDefined( altPlayer ) )
|
||||
{
|
||||
xuid = altPlayer GetXUID();
|
||||
self savegame::set_player_data( "altPlayerID", xuid );
|
||||
}
|
||||
else
|
||||
{
|
||||
self savegame::set_player_data( "altPlayerID", undefined );
|
||||
}
|
||||
|
||||
self savegame::set_player_data( "saved_weapon", undefined );
|
||||
self savegame::set_player_data( "saved_weapondata", undefined );
|
||||
self savegame::set_player_data( "lives", undefined );
|
||||
self savegame::set_player_data( "saved_rig1", undefined );
|
||||
self savegame::set_player_data( "saved_rig1_upgraded", undefined );
|
||||
self savegame::set_player_data( "saved_rig2", undefined );
|
||||
self savegame::set_player_data( "saved_rig2_upgraded", undefined );
|
||||
}
|
||||
|
||||
if( (isdefined( self.pers["class"] ) && self.pers["class"] == playerclass) )
|
||||
return;
|
||||
|
||||
self.pers["changed_class"] = true;
|
||||
self notify ( "changed_class" );
|
||||
waittillframeend;
|
||||
//The player selected the class they are currently using
|
||||
if( isdefined(self.curClass) && self.curClass == playerclass )
|
||||
{
|
||||
self.pers["changed_class"] = false;
|
||||
}
|
||||
|
||||
if ( self.sessionstate == "playing" )
|
||||
{
|
||||
self savegame::set_player_data( "playerClass", playerClass );
|
||||
self.pers["class"] = playerClass;
|
||||
self.curClass = playerclass;
|
||||
self.pers["weapon"] = undefined;
|
||||
|
||||
if ( game["state"] == "postgame" )
|
||||
return;
|
||||
|
||||
supplyStationClassChange = isdefined( self.usingSupplyStation ) && self.usingSupplyStation;
|
||||
self.usingSupplyStation = false;
|
||||
|
||||
if ( ( level.inGracePeriod && !self.hasDoneCombat ) || supplyStationClassChange ) // used weapons check?
|
||||
{
|
||||
self loadout::setClass( self.pers["class"] );
|
||||
self.tag_stowed_back = undefined;
|
||||
self.tag_stowed_hip = undefined;
|
||||
self loadout::giveLoadout( self.pers["team"], self.pers["class"] );
|
||||
}
|
||||
else if ( !( self IsSplitScreen() ) )
|
||||
{
|
||||
self IPrintLnBold( game["strings"]["change_class"] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self savegame::set_player_data( "playerClass",playerClass);
|
||||
self.pers["class"] = playerclass;
|
||||
self.curClass = playerclass;
|
||||
self.pers["weapon"] = undefined;
|
||||
|
||||
if ( game["state"] == "postgame" )
|
||||
return;
|
||||
|
||||
if ( self.sessionstate != "spectator" )
|
||||
{
|
||||
if ( self IsInVehicle() )
|
||||
return;
|
||||
|
||||
if ( self IsRemoteControlling() )
|
||||
return;
|
||||
|
||||
if ( self IsWeaponViewOnlyLinked() )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( game["state"] == "playing" )
|
||||
{
|
||||
timePassed = undefined;
|
||||
|
||||
if ( isdefined( self.respawnTimerStartTime ) )
|
||||
{
|
||||
timePassed = (gettime() - self.respawnTimerStartTime) / 1000;
|
||||
}
|
||||
|
||||
self thread [[level.spawnClient]](timePassed);
|
||||
|
||||
self.respawnTimerStartTime = undefined;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
globallogic::updateTeamStatus();
|
||||
|
||||
self thread spectating::set_permissions_for_machine();
|
||||
self notify("class_changed");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function showSafeSpawnMessage()
|
||||
{
|
||||
if ( level.splitscreen )
|
||||
return;
|
||||
|
||||
// don't show it if they've already asked for a safe spawn
|
||||
if ( self.wantSafeSpawn )
|
||||
return;
|
||||
|
||||
if ( !isdefined( self.safeSpawnMsg ) )
|
||||
{
|
||||
self.safeSpawnMsg = hud::createFontString( "default", 1.4 );
|
||||
self.safeSpawnMsg hud::setPoint( "CENTER", level.lowerTextYAlign, 0, level.lowerTextY + 50 );
|
||||
self.safeSpawnMsg setText( &"PLATFORM_PRESS_TO_SAFESPAWN" );
|
||||
self.safeSpawnMsg.archived = false;
|
||||
}
|
||||
self.safeSpawnMsg.alpha = 1;
|
||||
}
|
||||
function hideSafeSpawnMessage()
|
||||
{
|
||||
if ( !isdefined( self.safeSpawnMsg ) )
|
||||
return;
|
||||
|
||||
self.safeSpawnMsg.alpha = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
function removeSpawnMessageShortly( delay )
|
||||
{
|
||||
self endon("disconnect");
|
||||
|
||||
waittillframeend; // so we don't endon the end_respawn from spawning as a spectator
|
||||
|
||||
self endon("end_respawn");
|
||||
|
||||
wait delay;
|
||||
|
||||
self util::clearLowerMessage( 2.0 );
|
||||
}
|
||||
|
||||
// weakpoint helpers
|
||||
#precache( "eventstring", "weakpoint_update" );
|
||||
|
||||
// self = entity
|
||||
function weakpoint_anim_watch( precachedBoneName )
|
||||
{
|
||||
self endon( "death" );
|
||||
self endon( "weakpoint_destroyed" );
|
||||
|
||||
while(true)
|
||||
{
|
||||
self waittill( "weakpoint_update", boneName, event );
|
||||
|
||||
if ( boneName == precachedBoneName )
|
||||
{
|
||||
if ( event == "damage" )
|
||||
{
|
||||
LUINotifyEvent( &"weakpoint_update", 3, 2, self getEntityNumber(), precachedBoneName );
|
||||
}
|
||||
else if ( event == "repulse" )
|
||||
{
|
||||
LUINotifyEvent( &"weakpoint_update", 3, 3, self getEntityNumber(), precachedBoneName );
|
||||
}
|
||||
|
||||
wait 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// self = entity
|
||||
function destroyWeakpointWidget( precachedBoneName )
|
||||
{
|
||||
LUINotifyEvent( &"weakpoint_update", 3, 0, self getEntityNumber(), precachedBoneName );
|
||||
self notify( "weakpoint_destroyed" );
|
||||
}
|
||||
|
||||
// self = entity
|
||||
function createWeakpointWidget( precachedBoneName, closeStateMaxDistance = undefined, mediumStateMaxDistance = undefined )
|
||||
{
|
||||
if ( !isdefined( closeStateMaxDistance ) )
|
||||
{
|
||||
closeStateMaxDistance = GetDVarInt( "ui_weakpointIndicatorNear", 1050 );
|
||||
}
|
||||
|
||||
if ( !isdefined( mediumStateMaxDistance ) )
|
||||
{
|
||||
mediumStateMaxDistance = GetDVarInt( "ui_weakpointIndicatorMedium", 1900 );
|
||||
}
|
||||
|
||||
LUINotifyEvent( &"weakpoint_update", 5, 1, self getEntityNumber(), precachedBoneName, closeStateMaxDistance, mediumStateMaxDistance );
|
||||
|
||||
self thread weakpoint_anim_watch( precachedBoneName );
|
||||
}
|
||||
|
||||
// self = entity
|
||||
function triggerWeakpointDamage( precachedBoneName )
|
||||
{
|
||||
self notify( "weakpoint_update", precachedBoneName, "damage" );
|
||||
}
|
||||
|
||||
// self = entity
|
||||
function triggerWeakpointRepulsed( precachedBoneName )
|
||||
{
|
||||
self notify( "weakpoint_update", precachedBoneName, "repulse" );
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_acousticsensor;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
#namespace acousticsensor;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("acousticsensor",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
acousticsensor::init_shared();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_acousticsensor;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
#namespace acousticsensor;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("acousticsensor",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
acousticsensor::init_shared();
|
||||
}
|
||||
+714
@@ -0,0 +1,714 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\array_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\sound_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#namespace ambient;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("ambient",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
callback::on_localclient_connect( &on_player_connect );
|
||||
}
|
||||
|
||||
function on_player_connect( localclientnum )
|
||||
{
|
||||
thread ceiling_fans_init( localclientnum );
|
||||
thread clocks_init( localclientnum );
|
||||
thread spin_anemometers( localclientnum );
|
||||
if ( isdefined( level._levelSpecificAmbient ) )
|
||||
{
|
||||
thread [[level._levelSpecificAmbient]]( localClientNum );
|
||||
}
|
||||
}
|
||||
|
||||
// setup a script_struct to play scripted Flak88 tracers FX
|
||||
function setup_point_fx(point, fx_id)
|
||||
{
|
||||
if(isdefined(point.script_fxid))
|
||||
{
|
||||
fx_id = point.script_fxid;
|
||||
}
|
||||
|
||||
point.fx_id = fx_id;
|
||||
|
||||
if(isdefined(point.angles))
|
||||
{
|
||||
point.forward = anglesToForward(point.angles);
|
||||
point.up = anglesToUp(point.angles);
|
||||
}
|
||||
else
|
||||
{
|
||||
point.angles = (0, 0, 0);
|
||||
point.forward = (0, 0, 0);
|
||||
point.up = (0, 0, 0);
|
||||
}
|
||||
|
||||
if(point.targetname == "flak_fire_fx")
|
||||
{
|
||||
level thread ambient_flak_think(point);
|
||||
}
|
||||
|
||||
if(point.targetname == "fake_fire_fx")
|
||||
{
|
||||
level thread ambient_fakefire_think(point);
|
||||
}
|
||||
}
|
||||
|
||||
// rotate the Flak88 tracers FX
|
||||
function ambient_flak_think(point)
|
||||
{
|
||||
amount = undefined;
|
||||
speed = undefined;
|
||||
night = false;
|
||||
|
||||
min_delay = 0.4;
|
||||
max_delay = 4;
|
||||
|
||||
min_burst_time = 1;
|
||||
max_burst_time = 3;
|
||||
|
||||
point.is_firing = false;
|
||||
level thread ambient_flak_rotate(point);
|
||||
level thread ambient_flak_flash(point, min_burst_time, max_burst_time);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
timer = randomFloatRange(min_burst_time, max_burst_time);
|
||||
while(timer > 0)
|
||||
{
|
||||
point.is_firing = true;
|
||||
playFX(0, level._effect[point.fx_id], point.origin, point.forward, point.up);
|
||||
thread sound::play_in_space(0, "wpn_triple25_fire", point.origin);
|
||||
wait(0.2);
|
||||
|
||||
timer -= 0.2;
|
||||
}
|
||||
|
||||
point.is_firing = false;
|
||||
wait(randomFloatRange(min_delay, max_delay));
|
||||
}
|
||||
}
|
||||
|
||||
// This mimics the rotation of the FX, but without using an ent (or client-ent)
|
||||
// Updates the forward and up vectors which are used above
|
||||
function ambient_flak_rotate(point)
|
||||
{
|
||||
min_pitch = 30;
|
||||
max_pitch = 80;
|
||||
|
||||
if(isdefined(point.angles))
|
||||
{
|
||||
pointangles = point.angles;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointangles = (0, 0, 0);
|
||||
}
|
||||
|
||||
for(;;)
|
||||
{
|
||||
time = randomFloatRange(0.5, 2);
|
||||
steps = time * 10;
|
||||
|
||||
random_angle = (randomIntRange(min_pitch, max_pitch) * -1, randomInt(360), 0);
|
||||
|
||||
forward = anglesToForward(random_angle);
|
||||
up = anglesToUp(random_angle);
|
||||
|
||||
diff_forward = (forward - point.forward) / steps;
|
||||
diff_up = (up - point.up) / steps;
|
||||
|
||||
for(i = 0; i < steps; i++)
|
||||
{
|
||||
point.forward += diff_forward;
|
||||
point.up += diff_up;
|
||||
|
||||
wait(0.1);
|
||||
}
|
||||
|
||||
point.forward = forward;
|
||||
point.up = up;
|
||||
}
|
||||
}
|
||||
|
||||
// This gives a random chance to play a cloud flash
|
||||
// or flak burst FX for the ambient Flak
|
||||
function ambient_flak_flash(point, min_burst_time, max_burst_time)
|
||||
{
|
||||
min_dist = 5000;
|
||||
max_dist = 6500;
|
||||
|
||||
if(isdefined(point.script_mindist))
|
||||
{
|
||||
min_dist = point.script_mindist;
|
||||
}
|
||||
|
||||
if(isdefined(point.script_maxdist))
|
||||
{
|
||||
max_dist = point.script_maxdist;
|
||||
}
|
||||
|
||||
min_burst_time = 0.25;
|
||||
max_burst_time = 1;
|
||||
|
||||
fxpos = undefined;
|
||||
|
||||
while(1)
|
||||
{
|
||||
if( !point.is_firing )
|
||||
{
|
||||
wait( 0.25 );
|
||||
continue;
|
||||
}
|
||||
|
||||
fxpos = point.origin + VectorScale(point.forward, randomIntRange(min_dist, max_dist));
|
||||
|
||||
playFX(0, level._effect["flak_burst_single"], fxpos);
|
||||
|
||||
if(isdefined(level.timeofday) && (level.timeofday == "evening" || level.timeofday == "night"))
|
||||
{
|
||||
playFX(0, level._effect["flak_cloudflash_night"], fxpos);
|
||||
}
|
||||
|
||||
wait randomFloatRange(min_burst_time, max_burst_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *******************************************************************************************************
|
||||
// Ambient Weapon Muzzleflashes
|
||||
//
|
||||
// point = a script_struct in the map
|
||||
// This is used to play the ambient fake fire fx and sound
|
||||
function ambient_fakefire_think(point)
|
||||
{
|
||||
fireSound = undefined;
|
||||
weapType = undefined;
|
||||
|
||||
burstMin = undefined;
|
||||
burstMax = undefined;
|
||||
betweenShotsMin = undefined;
|
||||
betweenShotsMax = undefined;
|
||||
reloadTimeMin = undefined;
|
||||
reloadTimeMax = undefined;
|
||||
soundChance = undefined;
|
||||
|
||||
if(!isdefined(point.weaponinfo))
|
||||
{
|
||||
point.weaponinfo = "axis_turret";
|
||||
}
|
||||
|
||||
// determine what type of weapon the script_struct is faking
|
||||
switch(point.weaponinfo)
|
||||
{
|
||||
case "allies_assault":
|
||||
|
||||
if(isdefined(level.allies_team) && (level.allies_team == "marines"))
|
||||
{
|
||||
fireSound = "weap_bar_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_dp28_fire_plr";
|
||||
}
|
||||
|
||||
burstMin = 16;
|
||||
burstMax = 24;
|
||||
betweenShotsMin = 0.05;
|
||||
betweenShotsMax = 0.08;
|
||||
reloadTimeMin = 4;
|
||||
reloadTimeMax = 7;
|
||||
soundChance = 75;
|
||||
weapType = "assault";
|
||||
break;
|
||||
|
||||
case "axis_assault":
|
||||
|
||||
if(isdefined(level.axis_team) && (level.axis_team == "german"))
|
||||
{
|
||||
fireSound = "weap_mp44_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_type99_fire";
|
||||
}
|
||||
|
||||
burstMin = 16;
|
||||
burstMax = 24;
|
||||
betweenShotsMin = 0.05;
|
||||
betweenShotsMax = 0.08;
|
||||
reloadTimeMin = 4;
|
||||
reloadTimeMax = 7;
|
||||
soundChance = 75;
|
||||
weapType = "assault";
|
||||
break;
|
||||
|
||||
case "allies_rifle":
|
||||
|
||||
if(isdefined(level.allies_team) && (level.allies_team == "marines"))
|
||||
{
|
||||
fireSound = "weap_m1garand_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_mosinnagant_fire";
|
||||
}
|
||||
|
||||
burstMin = 1;
|
||||
burstMax = 3;
|
||||
betweenShotsMin = 0.8;
|
||||
betweenShotsMax = 1.3;
|
||||
reloadTimeMin = 3;
|
||||
reloadTimeMax = 6;
|
||||
soundChance = 95;
|
||||
weapType = "rifle";
|
||||
break;
|
||||
|
||||
case "axis_rifle":
|
||||
|
||||
if(isdefined(level.axis_team) && (level.axis_team == "german"))
|
||||
{
|
||||
fireSound = "weap_kar98k_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_arisaka_fire";
|
||||
}
|
||||
|
||||
burstMin = 1;
|
||||
burstMax = 3;
|
||||
betweenShotsMin = 0.8;
|
||||
betweenShotsMax = 1.3;
|
||||
reloadTimeMin = 3;
|
||||
reloadTimeMax = 6;
|
||||
soundChance = 95;
|
||||
weapType = "rifle";
|
||||
break;
|
||||
|
||||
case "allies_smg":
|
||||
|
||||
if(isdefined(level.allies_team) && (level.allies_team == "marines"))
|
||||
{
|
||||
fireSound = "weap_thompson_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_ppsh_fire";
|
||||
}
|
||||
|
||||
burstMin = 14;
|
||||
burstMax = 28;
|
||||
betweenShotsMin = 0.08;
|
||||
betweenShotsMax = 0.12;
|
||||
reloadTimeMin = 2;
|
||||
reloadTimeMax = 5;
|
||||
soundChance = 75;
|
||||
weapType = "smg";
|
||||
break;
|
||||
|
||||
case "axis_smg":
|
||||
|
||||
if(isdefined(level.axis_team) && (level.axis_team == "german"))
|
||||
{
|
||||
fireSound = "weap_mp40_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_type100_fire";
|
||||
}
|
||||
|
||||
burstMin = 14;
|
||||
burstMax = 28;
|
||||
betweenShotsMin = 0.08;
|
||||
betweenShotsMax = 0.12;
|
||||
reloadTimeMin = 2;
|
||||
reloadTimeMax = 5;
|
||||
soundChance = 75;
|
||||
weapType = "smg";
|
||||
break;
|
||||
|
||||
case "allies_turret":
|
||||
|
||||
if(isdefined(level.allies_team) && (level.allies_team == "marines"))
|
||||
{
|
||||
fireSound = "weap_30cal_fire";
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_dp28_fire_plr";
|
||||
}
|
||||
|
||||
burstMin = 60;
|
||||
burstMax = 90;
|
||||
betweenShotsMin = 0.05;
|
||||
betweenShotsMax = 0.08;
|
||||
reloadTimeMin = 3;
|
||||
reloadTimeMax = 6;
|
||||
soundChance = 95;
|
||||
weapType = "turret";
|
||||
break;
|
||||
|
||||
case "axis_turret":
|
||||
|
||||
if(isdefined(level.axis_team) && (level.axis_team == "german"))
|
||||
{
|
||||
fireSound = "weap_bar_fire"; //update this if the sound changes
|
||||
}
|
||||
else
|
||||
{
|
||||
fireSound = "weap_type92_fire";
|
||||
}
|
||||
|
||||
burstMin = 60;
|
||||
burstMax = 90;
|
||||
betweenShotsMin = 0.05;
|
||||
betweenShotsMax = 0.08;
|
||||
reloadTimeMin = 3;
|
||||
reloadTimeMax = 6;
|
||||
soundChance = 95;
|
||||
weapType = "turret";
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERTMSG("Ambient Fakefire: Weapon Info '" + point.weaponinfo + "' is not recognized.");
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
// burst fire
|
||||
burst = randomIntRange(burstMin, burstMax);
|
||||
|
||||
for(i = 0; i < burst; i++)
|
||||
{
|
||||
traceDist = 10000;
|
||||
|
||||
target = point.origin + VectorScale(anglesToForward(point.angles + (-3 + randomInt(6), -5 + randomInt(10), 0)), traceDist);
|
||||
|
||||
// -- not using real weaponsettings
|
||||
if ( randomInt(100) <= 20 )
|
||||
{
|
||||
bulletTracer(point.origin, target);
|
||||
}
|
||||
|
||||
playFX(0, level._effect[point.fx_id], point.origin, point.forward);
|
||||
|
||||
// snyder steez - reduce popcorn effect
|
||||
// if(randomInt(100) <= soundChance)
|
||||
// {
|
||||
// thread sound::play_in_space(0, fireSound, point.origin);
|
||||
// }
|
||||
|
||||
wait (randomFloatRange(betweenShotsMin, betweenShotsMax));
|
||||
}
|
||||
|
||||
wait (randomFloatRange(reloadTimeMin, reloadTimeMax));
|
||||
}
|
||||
}
|
||||
|
||||
function ceiling_fans_init(clientNum)
|
||||
{
|
||||
// grab all of the ceiling fans and make them spin
|
||||
fan_array = GetEntArray(clientNum, "ceiling_fan", "targetname");
|
||||
if( isdefined(fan_array) )
|
||||
{
|
||||
/# println("**********fan array is defined, size: " + fan_array.size); #/
|
||||
array::thread_all( fan_array,&spin_fan );
|
||||
}
|
||||
}
|
||||
|
||||
function spin_fan() // self == fan from the array
|
||||
{
|
||||
self endon("entityshutdown");
|
||||
|
||||
//println("**********fan running");
|
||||
// get the speed from the fan, if no speed then make it random
|
||||
if ( !isdefined ( self.speed ) )
|
||||
{
|
||||
self.speed = RandomIntRange(1, 100);
|
||||
self.speed = (self.speed % 10) + 1;
|
||||
}
|
||||
if ( self.speed < 1 )
|
||||
{
|
||||
self.speed = RandomIntRange(1, 100);
|
||||
self.speed = (self.speed % 10) + 1;
|
||||
}
|
||||
|
||||
// see if they want it to wobble
|
||||
do_wobble = false;
|
||||
wobble = self.script_noteworthy;
|
||||
if( isdefined(wobble) )
|
||||
{
|
||||
if( wobble == "wobble" )
|
||||
{
|
||||
do_wobble = true;
|
||||
self.wobble_speed = self.speed * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
//println("**********fan speed: " + self.speed);
|
||||
//println("**********fan wobble: " + do_wobble);
|
||||
|
||||
while(true)
|
||||
{
|
||||
if( !do_wobble )
|
||||
{
|
||||
self RotateYaw(180, self.speed);
|
||||
self waittill("rotatedone");
|
||||
}
|
||||
else
|
||||
{
|
||||
self RotateYaw(340, self.speed);
|
||||
self waittill("rotatedone");
|
||||
self RotateYaw(20, self.wobble_speed);
|
||||
self waittill("rotatedone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clocks_init(clientNum)
|
||||
{
|
||||
// the format should be an array (hour, min, sec), military time
|
||||
// if we pass in a 1 then we'll get GMT 0 London time, else we get the local time on the kit
|
||||
curr_time = GetSystemTime();
|
||||
|
||||
// put the hands in the right place
|
||||
hours = curr_time[0];
|
||||
if( hours > 12 )
|
||||
{
|
||||
hours -= 12;
|
||||
}
|
||||
if( hours == 0 )
|
||||
{
|
||||
hours = 12;
|
||||
}
|
||||
minutes = curr_time[1];
|
||||
seconds = curr_time[2];
|
||||
|
||||
// set the starting time
|
||||
// hoping that all of the hands start pointing straight up at 12
|
||||
// each hour is 30 degrees of rotation ...
|
||||
// it should also rotate a little bit each time the minute hand moves
|
||||
// the math is 30 degrees of rotations in 3600 seconds (1 hour)
|
||||
hour_hand = GetEntArray(clientNum, "hour_hand", "targetname");
|
||||
hour_values = [];
|
||||
hour_values["hand_time"] = hours;
|
||||
hour_values["rotate"] = 30;
|
||||
hour_values["rotate_bit"] = 30 / 3600;
|
||||
// we need to do the first rotation based on the beginning time, if we don't do this the time will look like it's off a little bit
|
||||
hour_values["first_rotate"] = ((minutes * 60) + seconds) * hour_values["rotate_bit"];
|
||||
|
||||
// each minute is 6 degrees of rotation ...
|
||||
// it should also rotate a little bit each time the second hand moves
|
||||
// the math is 6 degrees of rotations in 60 seconds (1 minute)
|
||||
minute_hand = GetEntArray(clientNum, "minute_hand", "targetname");
|
||||
minute_values = [];
|
||||
minute_values["hand_time"] = minutes;
|
||||
minute_values["rotate"] = 6;
|
||||
minute_values["rotate_bit"] = 6 / 60;
|
||||
// we need to do the first rotation based on the beginning time, if we don't do this the time will look like it's off a little bit
|
||||
minute_values["first_rotate"] = seconds * minute_values["rotate_bit"];
|
||||
|
||||
// each second is 6 degrees of rotation
|
||||
second_hand = GetEntArray(clientNum, "second_hand", "targetname");
|
||||
second_values = [];
|
||||
second_values["hand_time"] = seconds;
|
||||
second_values["rotate"] = 6;
|
||||
second_values["rotate_bit"] = 6;
|
||||
|
||||
hour_hand_array = GetEntArray(clientNum, "hour_hand", "targetname");
|
||||
if( isdefined(hour_hand_array) )
|
||||
{
|
||||
/# println("**********hour_hand_array is defined, size: " + hour_hand_array.size); #/
|
||||
array::thread_all( hour_hand_array,&clock_run, hour_values );
|
||||
}
|
||||
minute_hand_array = GetEntArray(clientNum, "minute_hand", "targetname");
|
||||
if( isdefined(minute_hand_array) )
|
||||
{
|
||||
/# println("**********minute_hand_array is defined, size: " + minute_hand_array.size); #/
|
||||
array::thread_all( minute_hand_array,&clock_run, minute_values );
|
||||
}
|
||||
second_hand_array = GetEntArray(clientNum, "second_hand", "targetname");
|
||||
if( isdefined(second_hand_array) )
|
||||
{
|
||||
/# println("**********second_hand_array is defined, size: " + second_hand_array.size); #/
|
||||
array::thread_all( second_hand_array,&clock_run, second_values );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clock_run(time_values) // self == either hour hand, minute hand, or second hand
|
||||
{
|
||||
self endon("entityshutdown");
|
||||
|
||||
// hour hands will have script_noteworthy = time zone if they want a different time zone
|
||||
if( isdefined(self.script_noteworthy) )
|
||||
{
|
||||
hour = time_values["hand_time"];
|
||||
curr_time = GetSystemTime(1);
|
||||
|
||||
switch( ToLower(self.script_noteworthy) )
|
||||
{
|
||||
case "honolulu": // GMT -10
|
||||
hour = curr_time[0] - 10;
|
||||
break;
|
||||
case "alaska": // GMT -9
|
||||
hour = curr_time[0] - 9;
|
||||
break;
|
||||
case "los angeles": // GMT -8
|
||||
hour = curr_time[0] - 8;
|
||||
break;
|
||||
case "denver": // GMT -7
|
||||
hour = curr_time[0] - 7;
|
||||
break;
|
||||
case "chicago": // GMT -6
|
||||
hour = curr_time[0] - 6;
|
||||
break;
|
||||
case "new york": // GMT -5
|
||||
hour = curr_time[0] - 5;
|
||||
break;
|
||||
case "halifax": // GMT -4
|
||||
hour = curr_time[0] - 4;
|
||||
break;
|
||||
case "greenland": // GMT -3
|
||||
hour = curr_time[0] - 3;
|
||||
break;
|
||||
case "london": // GMT 0
|
||||
hour = curr_time[0];
|
||||
break;
|
||||
case "paris": // GMT +1
|
||||
hour = curr_time[0] + 1;
|
||||
break;
|
||||
case "helsinki": // GMT +2
|
||||
hour = curr_time[0] + 2;
|
||||
break;
|
||||
case "moscow": // GMT +3
|
||||
hour = curr_time[0] + 3;
|
||||
break;
|
||||
case "vietnam": // GMT +7
|
||||
hour = curr_time[0] + 7;
|
||||
break;
|
||||
case "china": // GMT +8
|
||||
hour = curr_time[0] + 8;
|
||||
break;
|
||||
}
|
||||
|
||||
if( hour < 1 )
|
||||
{
|
||||
hour += 12;
|
||||
}
|
||||
if( hour > 12 )
|
||||
{
|
||||
hour -= 12;
|
||||
}
|
||||
time_values["hand_time"] = hour;
|
||||
}
|
||||
|
||||
self RotatePitch(time_values["hand_time"] * time_values["rotate"], 0.05);
|
||||
self waittill("rotatedone");
|
||||
|
||||
if( isdefined(time_values["first_rotate"]) )
|
||||
{
|
||||
self RotatePitch(time_values["first_rotate"], 0.05);
|
||||
self waittill("rotatedone");
|
||||
}
|
||||
|
||||
prev_time = GetSystemTime();
|
||||
|
||||
while(true)
|
||||
{
|
||||
curr_time = GetSystemTime();
|
||||
if( prev_time != curr_time )
|
||||
{
|
||||
self RotatePitch(time_values["rotate_bit"], 0.05);
|
||||
|
||||
prev_time = curr_time;
|
||||
}
|
||||
|
||||
wait(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
//Makes it so anemometers will spin whenever builders drop them into their map
|
||||
function spin_anemometers( clientNum )
|
||||
{
|
||||
spoon_spinners = GetEntArray(clientNum, "spinner1","targetname");
|
||||
flat_spinners = GetEntArray( clientNum, "spinner2","targetname");
|
||||
|
||||
if( isdefined( spoon_spinners ))
|
||||
{
|
||||
/# println("**********spoon_spinners is defined, size: " + spoon_spinners.size); #/
|
||||
array::thread_all( spoon_spinners,&spoon_spin_func);
|
||||
}
|
||||
|
||||
if( isdefined( flat_spinners ))
|
||||
{
|
||||
/# println("**********flat_spinners is defined, size: " + flat_spinners.size); #/
|
||||
array::thread_all( flat_spinners,&arrow_spin_func);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Self is the "spoon" like script model within the anemometer
|
||||
function spoon_spin_func()
|
||||
{
|
||||
self endon( "entityshutdown" );
|
||||
|
||||
if(isdefined( self.script_float))
|
||||
{
|
||||
model_speed = self.script_float;
|
||||
}
|
||||
else
|
||||
{
|
||||
model_speed = 2;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
speed = RandomFloatRange( model_speed * .6, model_speed);
|
||||
self RotateYaw( 1200, speed);
|
||||
self waittill ("rotatedone");
|
||||
}
|
||||
}
|
||||
|
||||
//Self is the "arrow" like script model within the anemometer
|
||||
function arrow_spin_func()
|
||||
{
|
||||
self endon( "entityshutdown" );
|
||||
|
||||
if(isdefined( self.script_int))
|
||||
{
|
||||
model_direction_change = self.script_int;
|
||||
}
|
||||
else
|
||||
{
|
||||
model_direction_change = 25;
|
||||
}
|
||||
|
||||
if(isdefined( self.script_float))
|
||||
{
|
||||
model_speed = self.script_float;
|
||||
}
|
||||
else
|
||||
{
|
||||
model_speed = .8;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
direction_change = model_direction_change + RandomIntRange(-11, 11);
|
||||
speed_change = RandomFloatRange(model_speed * .3, model_speed);
|
||||
|
||||
self RotateYaw( direction_change, speed_change);
|
||||
self waittill ("rotatedone");
|
||||
self RotateYaw( (direction_change * -1), speed_change);
|
||||
self waittill ("rotatedone");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\teams\_teams;
|
||||
|
||||
#namespace arena;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("arena",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
callback::on_connect( &on_connect );
|
||||
}
|
||||
|
||||
function on_connect()
|
||||
{
|
||||
if( isdefined( self.pers["arenaInit"] ) && self.pers["arenaInit"] == 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
draftEnabled = ( GetGametypeSetting( "pregameDraftEnabled" ) == 1 );
|
||||
voteEnabled = ( GetGametypeSetting( "pregameItemVoteEnabled" ) == 1 );
|
||||
|
||||
if( !draftEnabled && !voteEnabled )
|
||||
{
|
||||
self ArenaBeginMatch();
|
||||
}
|
||||
|
||||
self.pers["arenaInit"] = 1;
|
||||
}
|
||||
|
||||
function update_arena_challenge_seasons()
|
||||
{
|
||||
perSeasonWins = self GetDStat( "arenaPerSeasonStats", "wins" );
|
||||
if( perSeasonWins >= GetDvarInt( "arena_seasonVetChallengeWins" ) )
|
||||
{
|
||||
arenaSlot = ArenaGetSlot();
|
||||
currentSeason = self GetDStat( "arenaStats", arenaSlot, "season" );
|
||||
seasonVetChallengeArrayCount = self GetDStatArrayCount( "arenaChallengeSeasons" );
|
||||
for( i = 0; i < seasonVetChallengeArrayCount; i++ )
|
||||
{
|
||||
challengeSeason = self GetDStat( "arenaChallengeSeasons", i );
|
||||
if( challengeSeason == currentSeason ) // don't add a single season more than once
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( challengeSeason == 0 )
|
||||
{
|
||||
self SetDStat( "arenaChallengeSeasons", i, currentSeason );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function match_end( winner )
|
||||
{
|
||||
for( index = 0; index < level.players.size; index++ )
|
||||
{
|
||||
player = level.players[index];
|
||||
|
||||
if( isdefined( player.pers["arenaInit"] ) && player.pers["arenaInit"] == 1 )
|
||||
{
|
||||
if( winner == "tie" )
|
||||
{
|
||||
player ArenaEndMatch( 0 );
|
||||
}
|
||||
else if( winner == player.pers["team"] )
|
||||
{
|
||||
player ArenaEndMatch( 1 );
|
||||
player arena::update_arena_challenge_seasons();
|
||||
}
|
||||
else
|
||||
{
|
||||
player ArenaEndMatch( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\weapons\_proximity_grenade;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
|
||||
#namespace armblade;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("armblade",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
level.weaponArmblade = GetWeapon( "hero_armblade" );
|
||||
callback::on_spawned( &on_player_spawned );
|
||||
}
|
||||
|
||||
function on_player_spawned()
|
||||
{
|
||||
self thread armblade_sound_thread();
|
||||
}
|
||||
|
||||
function armblade_sound_thread()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "death" );
|
||||
for( ;; )
|
||||
{
|
||||
result = self util::waittill_any_return( "weapon_change", "disconnect" );
|
||||
if( IsDefined( result ) )
|
||||
{
|
||||
if( ( result == "weapon_change" ) && ( self GetCurrentWeapon() == level.weaponArmblade ) )
|
||||
{
|
||||
if( !IsDefined( self.armblade_loop_sound ) )
|
||||
{
|
||||
self.armblade_loop_sound = spawn( "script_origin", self.origin );
|
||||
self.armblade_loop_sound linkto( self );
|
||||
}
|
||||
|
||||
self.armblade_loop_sound PlayLoopSound( "wpn_armblade_idle", 0.25 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( IsDefined( self.armblade_loop_sound ) )
|
||||
{
|
||||
self.armblade_loop_sound StopLoopSound( 0.25 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\math_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
#precache( "lui_menu_data", "hudItems.armorPercent" );
|
||||
|
||||
#namespace armor;
|
||||
|
||||
function setLightArmorHP( newValue )
|
||||
{
|
||||
if ( IsDefined( newValue ) )
|
||||
{
|
||||
self.lightArmorHP = newValue;
|
||||
if( IsPlayer( self ) && IsDefined( self.maxLightArmorHP ) && self.maxLightArmorHP > 0 )
|
||||
{
|
||||
lightArmorPercent = math::clamp( self.lightArmorHP / self.maxLightArmorHP, 0, 1 );
|
||||
self SetControllerUIModelValue( "hudItems.armorPercent", lightArmorPercent );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.lightArmorHP = undefined;
|
||||
self.maxLightArmorHP = undefined;
|
||||
self SetControllerUIModelValue( "hudItems.armorPercent", 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// ARMOR: give a health boost
|
||||
function setLightArmor( optionalArmorValue )
|
||||
{
|
||||
self notify( "give_light_armor" );
|
||||
|
||||
if( IsDefined( self.lightArmorHP ) )
|
||||
unsetLightArmor();
|
||||
|
||||
self thread removeLightArmorOnDeath();
|
||||
self thread removeLightArmorOnMatchEnd();
|
||||
|
||||
if( IsDefined( optionalArmorValue ) )
|
||||
self.maxLightArmorHP = optionalArmorValue;
|
||||
else
|
||||
self.maxLightArmorHP = 150;
|
||||
|
||||
self setLightArmorHP( self.maxLightArmorHP );
|
||||
}
|
||||
|
||||
function removeLightArmorOnDeath()
|
||||
{
|
||||
self endon ( "disconnect" );
|
||||
self endon( "give_light_armor" );
|
||||
self endon( "remove_light_armor" );
|
||||
|
||||
self waittill ( "death" );
|
||||
unsetLightArmor();
|
||||
}
|
||||
|
||||
function unsetLightArmor()
|
||||
{
|
||||
self setLightArmorHP( undefined );
|
||||
|
||||
self notify( "remove_light_armor" );
|
||||
}
|
||||
|
||||
function removeLightArmorOnMatchEnd()
|
||||
{
|
||||
self endon ( "disconnect" );
|
||||
self endon ( "remove_light_armor" );
|
||||
|
||||
level waittill( "game_ended" );
|
||||
|
||||
self thread unsetLightArmor();
|
||||
}
|
||||
|
||||
function hasLightArmor()
|
||||
{
|
||||
return ( IsDefined( self.lightArmorHP ) && self.lightArmorHP > 0 );
|
||||
}
|
||||
|
||||
function getArmor()
|
||||
{
|
||||
if( IsDefined( self.lightArmorHP ) )
|
||||
{
|
||||
return self.lightArmorHP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+332
@@ -0,0 +1,332 @@
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#namespace art;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("art",&__init__,undefined,undefined); }
|
||||
|
||||
// This function should take care of grain and glow settings for each map, plus anything else that artists
|
||||
// need to be able to tweak without bothering level designers.
|
||||
|
||||
function __init__()
|
||||
{
|
||||
/#
|
||||
if( GetDvarString( "scr_art_tweak" ) == "" || GetDvarString( "scr_art_tweak" ) == "0" )
|
||||
{
|
||||
SetDvar( "scr_art_tweak", 0 );
|
||||
}
|
||||
|
||||
if( GetDvarString( "scr_dof_enable" ) == "" )
|
||||
{
|
||||
SetDvar( "scr_dof_enable", "1" );
|
||||
}
|
||||
|
||||
if( GetDvarString( "scr_cinematic_autofocus" ) == "" )
|
||||
{
|
||||
SetDvar( "scr_cinematic_autofocus", "1" );
|
||||
}
|
||||
|
||||
if( GetDvarString( "scr_art_visionfile" ) == "" && isdefined(level.script) )
|
||||
{
|
||||
SetDvar( "scr_art_visionfile", level.script );
|
||||
}
|
||||
#/
|
||||
|
||||
if( !isdefined( level.dofDefault ) )
|
||||
{
|
||||
level.dofDefault["nearStart"] = 0;
|
||||
level.dofDefault["nearEnd"] = 1;
|
||||
level.dofDefault["farStart"] = 8000;
|
||||
level.dofDefault["farEnd"] = 10000;
|
||||
level.dofDefault["nearBlur"] = 6;
|
||||
level.dofDefault["farBlur"] = 0;
|
||||
}
|
||||
|
||||
level.curDoF = ( level.dofDefault["farStart"] - level.dofDefault["nearEnd"] ) / 2;
|
||||
|
||||
/#
|
||||
thread tweakart();
|
||||
#/
|
||||
}
|
||||
|
||||
function artfxprintln( file, string )
|
||||
{
|
||||
/#
|
||||
// printing to file is optional now
|
||||
if( file == -1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
fprintln( file, string );
|
||||
#/
|
||||
}
|
||||
|
||||
|
||||
// Nate - hack Fixmed and replace with proper script command call once it's fixed.
|
||||
// assumes " " as the deliiter. I'm not getting fancy.
|
||||
// I would really like to go work on jeepride so here's a
|
||||
// quick function that works for now untill engineering fixes strtok.
|
||||
|
||||
function strtok_loc( string, par1 )
|
||||
{
|
||||
stringlist = [];
|
||||
indexstring = "";
|
||||
for( i = 0 ; i < string.size ; i ++ )
|
||||
{
|
||||
if( string[i] == " " )
|
||||
{
|
||||
stringlist[stringlist.size] = indexstring;
|
||||
indexstring = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
indexstring = indexstring+string[i];
|
||||
}
|
||||
}
|
||||
if( indexstring.size )
|
||||
{
|
||||
stringlist[stringlist.size] = indexstring;
|
||||
}
|
||||
return stringlist;
|
||||
}
|
||||
|
||||
|
||||
function setfogsliders()
|
||||
{
|
||||
//fixme. replace strtok_loc with strtok if it ever works properly.
|
||||
fogall = strtok_loc( GetDvarString( "g_fogColorReadOnly" ), " " ) ;
|
||||
red = fogall[ 0 ];
|
||||
green = fogall[ 1 ];
|
||||
blue = fogall[ 2 ];
|
||||
halfplane = GetDvarString( "g_fogHalfDistReadOnly" );
|
||||
nearplane = GetDvarString( "g_fogStartDistReadOnly" );
|
||||
|
||||
if ( !isdefined( red )
|
||||
|| !isdefined( green )
|
||||
|| !isdefined( blue )
|
||||
|| !isdefined( halfplane )
|
||||
)
|
||||
{
|
||||
red = 1;
|
||||
green = 1;
|
||||
blue = 1;
|
||||
halfplane = 10000001;
|
||||
nearplane = 10000000;
|
||||
}
|
||||
SetDvar("scr_fog_exp_halfplane",halfplane);
|
||||
SetDvar("scr_fog_nearplane",nearplane);
|
||||
SetDvar("scr_fog_color",red+" "+green+" "+blue);
|
||||
}
|
||||
|
||||
function tweakart()
|
||||
{
|
||||
/#
|
||||
if( !isdefined( level.tweakfile ) )
|
||||
{
|
||||
level.tweakfile = false;
|
||||
}
|
||||
|
||||
|
||||
// Default values
|
||||
|
||||
if(GetDvarString( "scr_fog_baseheight") == "")
|
||||
{
|
||||
SetDvar( "scr_fog_exp_halfplane", "500" );
|
||||
SetDvar( "scr_fog_exp_halfheight", "500" );
|
||||
SetDvar( "scr_fog_nearplane", "0" );
|
||||
SetDvar( "scr_fog_baseheight", "0" );
|
||||
}
|
||||
|
||||
// not in DEVGUI
|
||||
SetDvar( "scr_fog_fraction", "1.0" );
|
||||
SetDvar( "scr_art_dump", "0" );
|
||||
SetDvar("scr_art_sun_fog_dir_set", "0");
|
||||
|
||||
// update the devgui variables to current settings
|
||||
SetDvar( "scr_dof_nearStart", level.dofDefault["nearStart"] );
|
||||
SetDvar( "scr_dof_nearEnd", level.dofDefault["nearEnd"] );
|
||||
SetDvar( "scr_dof_farStart", level.dofDefault["farStart"] );
|
||||
SetDvar( "scr_dof_farEnd", level.dofDefault["farEnd"] );
|
||||
SetDvar( "scr_dof_nearBlur", level.dofDefault["nearBlur"] );
|
||||
SetDvar( "scr_dof_farBlur", level.dofDefault["farBlur"] );
|
||||
|
||||
|
||||
file = undefined;
|
||||
filename = undefined;
|
||||
|
||||
// set dofvars from < levelname > _art.gsc
|
||||
|
||||
|
||||
tweak_toggle = 1;
|
||||
for( ;; )
|
||||
{
|
||||
while(GetDvarint( "scr_art_tweak" ) == 0 )
|
||||
{
|
||||
tweak_toggle = 1;
|
||||
wait .05;
|
||||
}
|
||||
|
||||
if(tweak_toggle)
|
||||
{
|
||||
tweak_toggle = 0;
|
||||
fogsettings = getfogsettings();
|
||||
|
||||
SetDvar( "scr_fog_nearplane", fogsettings[0] );
|
||||
SetDvar( "scr_fog_exp_halfplane", fogsettings[1] );
|
||||
SetDvar( "scr_fog_exp_halfheight", fogsettings[3] );
|
||||
SetDvar( "scr_fog_baseheight", fogsettings[2] );
|
||||
|
||||
SetDvar("scr_fog_color", fogsettings[4]+" "+fogsettings[5]+" "+fogsettings[6]);
|
||||
SetDvar("scr_fog_color_scale", fogsettings[7]);
|
||||
SetDvar("scr_sun_fog_color", fogsettings[8]+" "+fogsettings[9]+" "+fogsettings[10]);
|
||||
|
||||
level.fogsundir = [];
|
||||
level.fogsundir[0] = fogsettings[11];
|
||||
level.fogsundir[1] = fogsettings[12];
|
||||
level.fogsundir[2] = fogsettings[13];
|
||||
|
||||
SetDvar("scr_sun_fog_start_angle",fogsettings[14] );
|
||||
SetDvar("scr_sun_fog_end_angle",fogsettings[15] );
|
||||
|
||||
SetDvar("scr_fog_max_opacity", fogsettings[16]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//translate the slider values to script variables
|
||||
|
||||
level.fogexphalfplane = GetDvarfloat( "scr_fog_exp_halfplane");
|
||||
level.fogexphalfheight = GetDvarfloat( "scr_fog_exp_halfheight");
|
||||
level.fognearplane = GetDvarfloat( "scr_fog_nearplane");
|
||||
level.fogbaseheight = GetDvarfloat( "scr_fog_baseheight");
|
||||
|
||||
colors = StrTok(GetDvarString("scr_fog_color")," ");
|
||||
level.fogcolorred = int(colors[0]);
|
||||
level.fogcolorgreen = int(colors[1]);
|
||||
level.fogcolorblue = int(colors[2]);
|
||||
level.fogcolorscale = GetDvarfloat( "scr_fog_color_scale");
|
||||
|
||||
colors = StrTok(GetDvarString("scr_sun_fog_color")," ");
|
||||
level.sunfogcolorred = int(colors[0]);
|
||||
level.sunfogcolorgreen = int(colors[1]);
|
||||
level.sunfogcolorblue = int(colors[2]);
|
||||
|
||||
level.sunstartangle = GetDvarfloat( "scr_sun_fog_start_angle");
|
||||
level.sunendangle = GetDvarfloat( "scr_sun_fog_end_angle");
|
||||
level.fogmaxopacity = GetDvarfloat( "scr_fog_max_opacity");
|
||||
|
||||
if( GetDvarint( "scr_art_sun_fog_dir_set") )
|
||||
{
|
||||
SetDvar( "scr_art_sun_fog_dir_set", "0" );
|
||||
|
||||
println("Setting sun fog direction to facing of player");
|
||||
|
||||
players = GetPlayers();
|
||||
|
||||
dir = VectorNormalize( AnglesToForward( players[0] GetPlayerAngles() ) );
|
||||
|
||||
level.fogsundir = [];
|
||||
level.fogsundir[0] = dir[0];
|
||||
level.fogsundir[1] = dir[1];
|
||||
level.fogsundir[2] = dir[2];
|
||||
}
|
||||
|
||||
|
||||
// catch all those cases where a slider can be pushed to a place of conflict
|
||||
fovslidercheck();
|
||||
|
||||
dumpsettings(); // dumps and returns true if the dump dvar is set
|
||||
|
||||
// updates fog to the variables
|
||||
|
||||
if ( ! GetDvarint( "scr_fog_disable" ) )
|
||||
{
|
||||
if(!isdefined(level.fogsundir)) {
|
||||
level.fogsundir = [];
|
||||
level.fogsundir[0] = 1;
|
||||
level.fogsundir[1] = 0;
|
||||
level.fogsundir[2] = 0;
|
||||
}
|
||||
|
||||
setVolFog( level.fognearplane, level.fogexphalfplane, level.fogexphalfheight, level.fogbaseheight, level.fogcolorred, level.fogcolorgreen, level.fogcolorblue,
|
||||
level.fogcolorscale, level.sunfogcolorred, level.sunfogcolorgreen, level.sunfogcolorblue, level.fogsundir[0], level.fogsundir[1], level.fogsundir[2], level.sunstartangle, level.sunendangle, 0, level.fogmaxopacity );
|
||||
}
|
||||
else
|
||||
{
|
||||
setExpFog( 100000000, 100000001, 0, 0, 0, 0 ); // couldn't find discreet fog disabling other than to never set it in the first place
|
||||
}
|
||||
|
||||
wait .1;
|
||||
}
|
||||
#/
|
||||
}
|
||||
|
||||
function fovslidercheck()
|
||||
{
|
||||
// catch all those cases where a slider can be pushed to a place of conflict
|
||||
if( level.dofDefault["nearStart"] >= level.dofDefault["nearEnd"] )
|
||||
{
|
||||
level.dofDefault["nearStart"] = level.dofDefault["nearEnd"] - 1;
|
||||
SetDvar( "scr_dof_nearStart", level.dofDefault["nearStart"] );
|
||||
}
|
||||
if( level.dofDefault["nearEnd"] <= level.dofDefault["nearStart"] )
|
||||
{
|
||||
level.dofDefault["nearEnd"] = level.dofDefault["nearStart"] + 1;
|
||||
SetDvar( "scr_dof_nearEnd", level.dofDefault["nearEnd"] );
|
||||
}
|
||||
if( level.dofDefault["farStart"] >= level.dofDefault["farEnd"] )
|
||||
{
|
||||
level.dofDefault["farStart"] = level.dofDefault["farEnd"] - 1;
|
||||
SetDvar( "scr_dof_farStart", level.dofDefault["farStart"] );
|
||||
}
|
||||
if( level.dofDefault["farEnd"] <= level.dofDefault["farStart"] )
|
||||
{
|
||||
level.dofDefault["farEnd"] = level.dofDefault["farStart"] + 1;
|
||||
SetDvar( "scr_dof_farEnd", level.dofDefault["farEnd"] );
|
||||
}
|
||||
if( level.dofDefault["farBlur"] >= level.dofDefault["nearBlur"] )
|
||||
{
|
||||
level.dofDefault["farBlur"] = level.dofDefault["nearBlur"] - .1;
|
||||
SetDvar( "scr_dof_farBlur", level.dofDefault["farBlur"] );
|
||||
}
|
||||
if( level.dofDefault["farStart"] <= level.dofDefault["nearEnd"] )
|
||||
{
|
||||
level.dofDefault["farStart"] = level.dofDefault["nearEnd"] + 1;
|
||||
SetDvar( "scr_dof_farStart", level.dofDefault["farStart"] );
|
||||
}
|
||||
}
|
||||
|
||||
function dumpsettings()
|
||||
{
|
||||
/#
|
||||
if ( GetDvarString( "scr_art_dump" ) != "0" )
|
||||
{
|
||||
PrintLn("\tstart_dist = " + level.fognearplane + ";");
|
||||
PrintLn("\thalf_dist = " + level.fogexphalfplane + ";");
|
||||
PrintLn("\thalf_height = " + level.fogexphalfheight + ";");
|
||||
PrintLn("\tbase_height = " + level.fogbaseheight + ";");
|
||||
PrintLn("\tfog_r = " + level.fogcolorred + ";");
|
||||
PrintLn("\tfog_g = " + level.fogcolorgreen + ";");
|
||||
PrintLn("\tfog_b = " + level.fogcolorblue + ";");
|
||||
PrintLn("\tfog_scale = " + level.fogcolorscale + ";");
|
||||
PrintLn("\tsun_col_r = " + level.sunfogcolorred + ";");
|
||||
PrintLn("\tsun_col_g = " + level.sunfogcolorgreen + ";");
|
||||
PrintLn("\tsun_col_b = " + level.sunfogcolorblue + ";");
|
||||
PrintLn("\tsun_dir_x = " + level.fogsundir[0] + ";");
|
||||
PrintLn("\tsun_dir_y = " + level.fogsundir[1] + ";");
|
||||
PrintLn("\tsun_dir_z = " + level.fogsundir[2] + ";");
|
||||
PrintLn("\tsun_start_ang = " + level.sunstartangle + ";");
|
||||
PrintLn("\tsun_stop_ang = " + level.sunendangle + ";");
|
||||
PrintLn("\ttime = 0;");
|
||||
PrintLn("\tmax_fog_opacity = " + level.fogmaxopacity +";");
|
||||
PrintLn("");
|
||||
PrintLn("\tsetVolFog(start_dist, half_dist, half_height, base_height, fog_r, fog_g, fog_b, fog_scale,");
|
||||
PrintLn("\t\tsun_col_r, sun_col_g, sun_col_b, sun_dir_x, sun_dir_y, sun_dir_z, sun_start_ang, ");
|
||||
PrintLn("\t\tsun_stop_ang, time, max_fog_opacity);");
|
||||
|
||||
SetDvar( "scr_art_dump", "0" );
|
||||
}
|
||||
#/
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\weapons\_ballistic_knife;
|
||||
|
||||
Line truncated
|
||||
|
||||
#namespace ballistic_knife;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("ballistic_knife",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
ballistic_knife::init_shared();
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#using scripts\codescripts\struct;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\bb_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#namespace bb;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("bb",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
bb::init_shared();
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
#using scripts\shared\math_shared;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#namespace behaviorTracker;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
///// Inititialize & Finaliize ////
|
||||
/////////////////////////////////////////////////////
|
||||
function SetupTraits()
|
||||
{
|
||||
if ( isDefined( self.behaviorTracker.traits ) )
|
||||
return;
|
||||
|
||||
self.behaviorTracker.traits = [];
|
||||
// Define the traits with a default value. This default value will be used if we dont have stats.
|
||||
// Add the information to the BBPrint()
|
||||
self.behaviorTracker.traits["effectiveCombat"] = 0.5;
|
||||
self.behaviorTracker.traits["effectiveWallRunCombat"] = 0.5;
|
||||
self.behaviorTracker.traits["effectiveDoubleJumpCombat"] = 0.5;
|
||||
self.behaviorTracker.traits["effectiveSlideCombat"] = 0.5;
|
||||
|
||||
if ( self.behaviorTracker.version != 0 )
|
||||
{
|
||||
traits = getArrayKeys( self.behaviorTracker.traits );
|
||||
|
||||
for ( i = 0; i < traits.size; i++ )
|
||||
{
|
||||
trait = traits[i];
|
||||
self.behaviorTracker.traits[trait] = float( self GetTraitStatValue( trait ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Initialize()
|
||||
{
|
||||
if ( isdefined( self.pers["isBot"] ) )
|
||||
return;
|
||||
|
||||
if ( isDefined( self.behaviorTracker ) )
|
||||
return;
|
||||
|
||||
if ( isdefined( level.disableBehaviorTracker ) && level.disableBehaviorTracker == true )
|
||||
return;
|
||||
|
||||
self.behaviorTracker = spawnstruct();
|
||||
self.behaviorTracker.version = int( self GetTraitStatValue( "version" ) );
|
||||
self.behaviorTracker.numRecords = int( self GetTraitStatValue( "numRecords" ) ) + 1;
|
||||
self SetupTraits();
|
||||
|
||||
self.behaviorTracker.valid = true;
|
||||
}
|
||||
|
||||
function Finalize()
|
||||
{
|
||||
if ( !( self IsAllowed() ) )
|
||||
return;
|
||||
|
||||
self SetTraitStats();
|
||||
|
||||
self PrintTrackerToBlackBox();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
///// Utility Functions ////
|
||||
/////////////////////////////////////////////////////
|
||||
function IsAllowed()
|
||||
{
|
||||
if ( !isDefined( self ) )
|
||||
return false;
|
||||
|
||||
if ( !isDefined( self.behaviorTracker ) )
|
||||
return false;
|
||||
|
||||
if ( !self.behaviorTracker.valid )
|
||||
return false;
|
||||
|
||||
if ( isdefined( level.disableBehaviorTracker ) && level.disableBehaviorTracker == true )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function PrintTrackerToBlackBox()
|
||||
{
|
||||
// Prepare the list of traits & its values
|
||||
// TODO: Construct the string with all the traits so that it can just be added as a single variable in the print.
|
||||
/*traitsStr = "";
|
||||
traits = getArrayKeys( self.behaviorTracker.traits );
|
||||
|
||||
for ( i = 0; i < traits.size; i++ )
|
||||
{
|
||||
trait = traits[i];
|
||||
value = self.behaviorTracker.traits[trait];
|
||||
|
||||
traitsStr = traitsStr + trait + " " + value + " ";
|
||||
}
|
||||
|
||||
bbPrint( "mpbehaviortracker", "username %s version %d numRecords %d %s", self.name, self.behaviorTracker.version, self.behaviorTracker.numRecords, traitsStr ); */
|
||||
|
||||
bbPrint( "mpbehaviortracker", "username %s version %d numRecords %d effectiveSlideCombat %f effectiveDoubleJumpCombat %f effectiveWallRunCombat %f effectiveCombat %f",
|
||||
self.name, self.behaviorTracker.version, self.behaviorTracker.numRecords, self.behaviorTracker.traits["effectiveSlideCombat"],
|
||||
self.behaviorTracker.traits["effectiveDoubleJumpCombat"], self.behaviorTracker.traits["effectiveWallRunCombat"], self.behaviorTracker.traits["effectiveCombat"] );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
///// Set, Get & Update Trait ////
|
||||
/////////////////////////////////////////////////////
|
||||
function GetTraitValue( trait )
|
||||
{
|
||||
return self.behaviorTracker.traits[ trait ];
|
||||
}
|
||||
|
||||
function SetTraitValue( trait, value )
|
||||
{
|
||||
self.behaviorTracker.traits[trait] = value;
|
||||
}
|
||||
|
||||
function UpdateTrait( trait, percent )
|
||||
{
|
||||
if ( !( self IsAllowed() ) )
|
||||
return;
|
||||
|
||||
math::clamp( percent, -1.0, 1.0 );
|
||||
|
||||
currentValue = self GetTraitValue( trait );
|
||||
|
||||
if ( percent >= 0 )
|
||||
{
|
||||
delta = ( 1.0 - currentValue ) * percent;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = ( currentValue - 0.0 ) * percent;
|
||||
}
|
||||
|
||||
weightedDelta = 0.1 * delta;
|
||||
|
||||
newValue = currentvalue + weightedDelta;
|
||||
newValue = math::clamp( newValue, 0.0, 1.0 );
|
||||
self SetTraitValue( trait, newValue );
|
||||
|
||||
bbprint( "mpbehaviortraitupdate", "username %s trait %s percent %f", self.name, trait, percent );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
///// Game Side Hooks ////
|
||||
/////////////////////////////////////////////////////
|
||||
function UpdatePlayerDamage( attacker, victim, damage )
|
||||
{
|
||||
if ( isDefined( victim ) && victim IsAllowed() )
|
||||
{
|
||||
damageRatio = float( damage ) / float( victim.maxhealth );
|
||||
math::clamp( damageRatio, 0.0, 1.0 );
|
||||
|
||||
damageRatio = damageRatio * -1.0; // Negative damage percent since this is the victim
|
||||
|
||||
victim UpdateTrait( "effectiveCombat", damageRatio );
|
||||
|
||||
if ( victim IsWallRunning() )
|
||||
{
|
||||
victim UpdateTrait( "effectiveWallRunCombat", damageRatio );
|
||||
}
|
||||
|
||||
if ( victim IsSliding() )
|
||||
{
|
||||
victim UpdateTrait( "effectiveSlideCombat", damageRatio );
|
||||
}
|
||||
|
||||
if ( victim IsDoubleJumping() )
|
||||
{
|
||||
victim UpdateTrait( "effectiveDoubleJumpCombat", damageRatio );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isDefined( attacker ) && ( attacker IsAllowed() ) && attacker != victim )
|
||||
{
|
||||
damageRatio = float( damage ) / float( attacker.maxhealth );
|
||||
math::clamp( damageRatio, 0.0, 1.0 );
|
||||
|
||||
attacker UpdateTrait( "effectiveCombat", damageRatio );
|
||||
|
||||
if ( attacker IsWallRunning() )
|
||||
{
|
||||
attacker UpdateTrait( "effectiveWallRunCombat", damageRatio );
|
||||
}
|
||||
|
||||
if ( attacker IsSliding() )
|
||||
{
|
||||
attacker UpdateTrait( "effectiveSlideCombat", damageRatio );
|
||||
}
|
||||
|
||||
if ( attacker IsDoubleJumping() )
|
||||
{
|
||||
attacker UpdateTrait( "effectiveDoubleJumpCombat", damageRatio );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UpdatePlayerKilled( attacker, victim )
|
||||
{
|
||||
if ( isDefined( victim ) && victim IsAllowed() )
|
||||
{
|
||||
// Passing -1.0 since to denote negative 100%.
|
||||
victim UpdateTrait( "effectiveCombat", -1.0 );
|
||||
|
||||
if ( victim IsWallRunning() )
|
||||
{
|
||||
victim UpdateTrait( "effectiveWallRunCombat", -1.0 );
|
||||
}
|
||||
|
||||
if ( victim IsSliding() )
|
||||
{
|
||||
victim UpdateTrait( "effectiveSlideCombat", -1.0 );
|
||||
}
|
||||
|
||||
if ( victim IsDoubleJumping() )
|
||||
{
|
||||
victim UpdateTrait( "effectiveDoubleJumpCombat", -1.0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isDefined( attacker ) && ( attacker IsAllowed() ) && attacker != victim )
|
||||
{
|
||||
// Passing 1.0 since to denote positive 100%.
|
||||
attacker UpdateTrait( "effectiveCombat", 1.0 );
|
||||
|
||||
if ( attacker IsWallRunning() )
|
||||
{
|
||||
attacker UpdateTrait( "effectiveWallRunCombat", 1.0 );
|
||||
}
|
||||
|
||||
if ( attacker IsSliding() )
|
||||
{
|
||||
attacker UpdateTrait( "effectiveSlideCombat", 1.0 );
|
||||
}
|
||||
|
||||
if ( attacker IsDoubleJumping() )
|
||||
{
|
||||
attacker UpdateTrait( "effectiveDoubleJumpCombat", 1.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
///// Stats Related ////
|
||||
/////////////////////////////////////////////////////
|
||||
function SetTraitStats()
|
||||
{
|
||||
if ( self.behaviorTracker.version == 0 )
|
||||
return;
|
||||
|
||||
self.behaviorTracker.numRecords = self.behaviorTracker.numRecords + 1;
|
||||
self SetTraitStatValue( "numRecords", self.behaviorTracker.numRecords );
|
||||
|
||||
traits = getArrayKeys( self.behaviorTracker.traits );
|
||||
|
||||
for ( i = 0; i < traits.size; i++ )
|
||||
{
|
||||
trait = traits[i];
|
||||
value = self.behaviorTracker.traits[trait];
|
||||
|
||||
self SetTraitStatValue( trait, value );
|
||||
}
|
||||
}
|
||||
|
||||
function GetTraitStatValue( trait )
|
||||
{
|
||||
return self getDStat( "behaviorTracker", trait );
|
||||
}
|
||||
|
||||
function SetTraitStatValue( trait, value )
|
||||
{
|
||||
self setDStat( "behaviorTracker", trait, value );
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\challenges_shared;
|
||||
#using scripts\shared\drown;
|
||||
#using scripts\shared\scoreevents_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_weapon_utils;
|
||||
|
||||
#using scripts\mp\_challenges;
|
||||
#using scripts\mp\gametypes\_loadout;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
|
||||
|
||||
|
||||
// for blackjack challenge: kills while using a specialist weapon or ability
|
||||
// for blackjack challenge: count of unique specialist weapons or abilities used to kill
|
||||
|
||||
#namespace blackjack_challenges;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("blackjack_challenges",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
callback::on_start_gametype( &start_gametype );
|
||||
}
|
||||
|
||||
function start_gametype()
|
||||
{
|
||||
if ( !isdefined( level.ChallengesCallbacks ) )
|
||||
{
|
||||
level.ChallengesCallbacks = [];
|
||||
}
|
||||
|
||||
waittillframeend;
|
||||
|
||||
if ( challenges::canProcessChallenges() )
|
||||
{
|
||||
challenges::registerChallengesCallback( "playerKilled",&challenge_kills );
|
||||
challenges::registerChallengesCallback( "roundEnd",&challenge_round_ended );
|
||||
challenges::registerChallengesCallback( "gameEnd",&challenge_game_ended );
|
||||
scoreevents::register_hero_ability_kill_event( &on_hero_ability_kill );
|
||||
}
|
||||
|
||||
callback::on_connect( &on_player_connect );
|
||||
}
|
||||
|
||||
function on_player_connect()
|
||||
{
|
||||
player = self;
|
||||
if ( challenges::canProcessChallenges() )
|
||||
{
|
||||
specialistIndex = player GetSpecialistIndex();
|
||||
isBlackjack = ( specialistIndex == 9 );
|
||||
if ( isBlackjack )
|
||||
{
|
||||
player thread track_blackjack_consumable();
|
||||
|
||||
if ( !isdefined( self.pers[ "blackjack_challenge_active" ] ) )
|
||||
{
|
||||
remaining_time = player ConsumableGet( "blackjack", "awarded" ) - player ConsumableGet( "blackjack", "consumed" );
|
||||
|
||||
if ( remaining_time > 0 )
|
||||
{
|
||||
special_card_earned = player get_challenge_stat( "special_card_earned" );
|
||||
if ( !special_card_earned )
|
||||
{
|
||||
player.pers[ "blackjack_challenge_active" ] = true;
|
||||
player.pers[ "blackjack_unique_specialist_kills" ] = 0;
|
||||
player.pers[ "blackjack_specialist_kills" ] = 0;
|
||||
player.pers[ "blackjack_unique_weapon_mask" ] = 0;
|
||||
player.pers[ "blackjack_unique_ability_mask" ] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function is_challenge_active()
|
||||
{
|
||||
return ( self.pers[ "blackjack_challenge_active" ] === true );
|
||||
}
|
||||
|
||||
function on_hero_ability_kill( ability, victimAbility )
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
|
||||
if ( !isdefined( player.isRoulette ) || !player.isRoulette )
|
||||
return;
|
||||
|
||||
if ( player is_challenge_active() )
|
||||
{
|
||||
player.pers[ "blackjack_specialist_kills" ]++;
|
||||
|
||||
currentHeroAbilityMask = player.pers[ "blackjack_unique_ability_mask" ];
|
||||
heroAbilityMask = get_hero_ability_mask( ability );
|
||||
newHeroAbilityMask = heroAbilityMask | currentHeroAbilityMask;
|
||||
if ( newHeroAbilityMask != currentHeroAbilityMask )
|
||||
{
|
||||
player.pers[ "blackjack_unique_specialist_kills" ]++;
|
||||
player.pers[ "blackjack_unique_ability_mask" ] = newHeroAbilityMask;
|
||||
}
|
||||
|
||||
player check_blackjack_challenge();
|
||||
}
|
||||
}
|
||||
|
||||
/#
|
||||
function debug_print_already_earned()
|
||||
{
|
||||
if ( GetDvarInt( "scr_blackjack_sidebet_debug", 0 ) == 0 )
|
||||
return;
|
||||
|
||||
IPrintLn( "Blackjack Side Bet already earned this game." );
|
||||
}
|
||||
#/
|
||||
|
||||
/#
|
||||
function debug_print_kill_info()
|
||||
{
|
||||
if ( GetDvarInt( "scr_blackjack_sidebet_debug", 0 ) == 0 )
|
||||
return;
|
||||
|
||||
player = self;
|
||||
IPrintLn( "Blackjack Side Bet kills: " + player.pers[ "blackjack_specialist_kills" ] + " uniques: " + player.pers[ "blackjack_unique_specialist_kills" ] );
|
||||
}
|
||||
#/
|
||||
|
||||
/#
|
||||
function debug_print_earned()
|
||||
{
|
||||
if ( GetDvarInt( "scr_blackjack_sidebet_debug", 0 ) == 0 )
|
||||
return;
|
||||
|
||||
IPrintLn( "Blackjack Side Bet earned!!!" );
|
||||
}
|
||||
#/
|
||||
|
||||
function check_blackjack_challenge()
|
||||
{
|
||||
player = self;
|
||||
|
||||
/# debug_print_kill_info(); #/
|
||||
|
||||
special_card_earned = player get_challenge_stat( "special_card_earned" );
|
||||
if ( special_card_earned )
|
||||
{
|
||||
/# debug_print_already_earned(); #/
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( player.pers[ "blackjack_specialist_kills" ] >= 4 ) &&
|
||||
( player.pers[ "blackjack_unique_specialist_kills" ] >= 2 ) )
|
||||
{
|
||||
player set_challenge_stat( "special_card_earned", 1 );
|
||||
player AddPlayerStat( "blackjack_challenge", 1 );
|
||||
|
||||
/# debug_print_earned(); #/
|
||||
}
|
||||
}
|
||||
|
||||
function challenge_kills( data )
|
||||
{
|
||||
attackerisThief = data.attackerIsThief;
|
||||
attackerIsRoulette = data.attackerIsRoulette;
|
||||
attackerIsThiefOrRoulette = attackerisThief || attackerIsRoulette;
|
||||
|
||||
if ( !attackerIsThiefOrRoulette )
|
||||
return;
|
||||
|
||||
victim = data.victim;
|
||||
attacker = data.attacker;
|
||||
player = attacker;
|
||||
weapon = data.weapon;
|
||||
|
||||
if ( !isdefined( weapon ) || ( weapon == level.weaponNone ) )
|
||||
return;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
|
||||
if ( attackerIsThief )
|
||||
{
|
||||
if ( weapon.isHeroWeapon === true )
|
||||
{
|
||||
if ( player is_challenge_active() )
|
||||
{
|
||||
player.pers[ "blackjack_specialist_kills" ]++;
|
||||
|
||||
currentHeroWeaponMask = player.pers[ "blackjack_unique_weapon_mask" ];
|
||||
heroWeaponMask = get_hero_weapon_mask( attacker, weapon );
|
||||
newHeroWeaponMask = heroWeaponMask | currentHeroWeaponMask;
|
||||
if ( newHeroWeaponMask != currentHeroWeaponMask )
|
||||
{
|
||||
player.pers[ "blackjack_unique_specialist_kills" ] += 1;
|
||||
player.pers[ "blackjack_unique_weapon_mask" ] = newHeroWeaponMask;
|
||||
}
|
||||
|
||||
player check_blackjack_challenge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ability kills are handled as events fired from score events
|
||||
// if ( attackerIsRoulette )
|
||||
// {
|
||||
// }
|
||||
}
|
||||
|
||||
function get_challenge_stat( stat_name )
|
||||
{
|
||||
return self GetDStat( "tenthspecialistcontract", stat_name );
|
||||
}
|
||||
|
||||
function set_challenge_stat( stat_name, stat_value )
|
||||
{
|
||||
return self SetDStat( "tenthspecialistcontract", stat_name, stat_value );
|
||||
}
|
||||
|
||||
function get_hero_weapon_mask( attacker, weapon )
|
||||
{
|
||||
if ( !isdefined( weapon ) )
|
||||
return 0;
|
||||
|
||||
if ( isdefined( weapon.isHeroWeapon ) && !weapon.isHeroWeapon )
|
||||
return 0;
|
||||
|
||||
switch( weapon.name )
|
||||
{
|
||||
case "hero_minigun":
|
||||
case "hero_minigun_body3":
|
||||
return 1; // note: heroWeaponMask needs to stay unique and consistent for function across TUs and FFOTDs
|
||||
break;
|
||||
case "hero_flamethrower":
|
||||
return 1 << 1;
|
||||
break;
|
||||
case "hero_lightninggun":
|
||||
case "hero_lightninggun_arc":
|
||||
return 1 << 2;
|
||||
break;
|
||||
case "hero_chemicalgelgun":
|
||||
case "hero_firefly_swarm":
|
||||
return 1 << 3;
|
||||
break;
|
||||
case "hero_pineapplegun":
|
||||
case "hero_pineapple_grenade":
|
||||
return 1 << 4;
|
||||
break;
|
||||
case "hero_armblade":
|
||||
return 1 << 5;
|
||||
break;
|
||||
case "hero_bowlauncher":
|
||||
case "hero_bowlauncher2":
|
||||
case "hero_bowlauncher3":
|
||||
case "hero_bowlauncher4":
|
||||
return 1 << 6;
|
||||
break;
|
||||
case "hero_gravityspikes":
|
||||
return 1 << 7;
|
||||
break;
|
||||
case "hero_annihilator":
|
||||
return 1 << 8;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function get_hero_ability_mask( ability )
|
||||
{
|
||||
if ( !isdefined( ability ) )
|
||||
return 0;
|
||||
|
||||
switch( ability.name )
|
||||
{
|
||||
case "gadget_clone":
|
||||
return 1; // note: heroAbilityMask needs to stay unique and consistent for functions across TUs and FFOTDs
|
||||
break;
|
||||
case "gadget_heat_wave":
|
||||
return 1 << 1;
|
||||
break;
|
||||
case "gadget_flashback":
|
||||
return 1 << 2;
|
||||
break;
|
||||
case "gadget_resurrect":
|
||||
return 1 << 3;
|
||||
break;
|
||||
case "gadget_armor":
|
||||
return 1 << 4;
|
||||
break;
|
||||
case "gadget_camo":
|
||||
return 1 << 5;
|
||||
break;
|
||||
case "gadget_vision_pulse":
|
||||
return 1 << 6;
|
||||
break;
|
||||
case "gadget_speed_burst":
|
||||
return 1 << 7;
|
||||
break;
|
||||
case "gadget_combat_efficiency":
|
||||
return 1 << 8;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function challenge_game_ended( data )
|
||||
{
|
||||
if ( !isdefined( data ) )
|
||||
return;
|
||||
|
||||
player = data.player;
|
||||
if ( !isdefined( player ) )
|
||||
return;
|
||||
|
||||
if ( !isPlayer( player ) )
|
||||
return;
|
||||
|
||||
if ( player util::is_bot() )
|
||||
return;
|
||||
|
||||
if ( !player is_challenge_active() )
|
||||
return;
|
||||
|
||||
player report_consumable();
|
||||
}
|
||||
|
||||
function challenge_round_ended( data )
|
||||
{
|
||||
if ( !isdefined( data ) )
|
||||
return;
|
||||
|
||||
player = data.player;
|
||||
if ( !isdefined( player ) )
|
||||
return;
|
||||
|
||||
if ( !isPlayer( player ) )
|
||||
return;
|
||||
|
||||
if ( player util::is_bot() )
|
||||
return;
|
||||
|
||||
if ( !player is_challenge_active() )
|
||||
return;
|
||||
|
||||
player report_consumable();
|
||||
}
|
||||
|
||||
function track_blackjack_consumable()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
self notify( "track_blackjack_consumable_singleton" );
|
||||
self endon( "track_blackjack_consumable_singleton" );
|
||||
self endon( "disconnect" );
|
||||
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player.last_blackjack_consumable_time ) )
|
||||
player.last_blackjack_consumable_time = 0;
|
||||
|
||||
while ( isdefined( player ) )
|
||||
{
|
||||
random_wait_time = GetDvarFloat( "mp_blackjack_consumable_wait", 20.0 ) + RandomFloatRange( -5.0, 5.0 );
|
||||
wait random_wait_time;
|
||||
|
||||
player report_consumable();
|
||||
}
|
||||
}
|
||||
|
||||
function report_consumable()
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player ) )
|
||||
return;
|
||||
|
||||
if ( !isdefined( player.timePlayed ) || !isdefined( player.timePlayed["total"] ) )
|
||||
return;
|
||||
|
||||
current_time_played = player.timePlayed["total"];
|
||||
|
||||
time_to_report = current_time_played - player.last_blackjack_consumable_time;
|
||||
|
||||
if ( time_to_report > 0 )
|
||||
{
|
||||
max_time_to_report = player ConsumableGet( "blackjack", "awarded" ) - player ConsumableGet( "blackjack", "consumed" );
|
||||
consumable_increment = int( min( time_to_report, max_time_to_report ) );
|
||||
if ( consumable_increment > 0 )
|
||||
{
|
||||
player ConsumableIncrement( "blackjack", "consumed", consumable_increment ); // so we don't go over awarded time
|
||||
}
|
||||
}
|
||||
|
||||
player.last_blackjack_consumable_time = current_time_played;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
// bonusCards_t
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_bouncingbetty;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
#namespace bouncingbetty;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("bouncingbetty",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__( localClientNum )
|
||||
{
|
||||
bouncingbetty::init_shared();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_bouncingbetty;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
#namespace bouncingbetty;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("bouncingbetty",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
bouncingbetty::init_shared();
|
||||
|
||||
level.trackBouncingBettiesOnOwner = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
#using scripts\shared\audio_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\exploder_shared;
|
||||
#using scripts\shared\filter_shared;
|
||||
#using scripts\shared\footsteps_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\vehicle_shared;
|
||||
#using scripts\shared\vehicles\_driving_fx;
|
||||
#using scripts\shared\abilities\gadgets\_gadget_vision_pulse;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\shared\weapons\_sticky_grenade;
|
||||
|
||||
#using scripts\mp\killstreaks\_ai_tank;
|
||||
#using scripts\mp\killstreaks\_airsupport;
|
||||
#using scripts\mp\killstreaks\_helicopter;
|
||||
#using scripts\mp\killstreaks\_qrdrone;
|
||||
#using scripts\mp\killstreaks\_rcbomb;
|
||||
#using scripts\shared\_burnplayer;
|
||||
#using scripts\mp\_callbacks;
|
||||
#using scripts\mp\_util;
|
||||
#using scripts\mp\_vehicle;
|
||||
|
||||
#using scripts\mp\gametypes\_globallogic;
|
||||
#using scripts\mp\gametypes\_globallogic_actor;
|
||||
|
||||
#namespace callback;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("callback",&__init__,undefined,undefined); }
|
||||
|
||||
// Callback set up, clientside.
|
||||
function __init__()
|
||||
{
|
||||
level thread set_default_callbacks();
|
||||
}
|
||||
|
||||
function set_default_callbacks()
|
||||
{
|
||||
level.callbackPlayerSpawned = &playerspawned;
|
||||
level.callbackLocalClientConnect = &localclientconnect;
|
||||
level.callbackCreatingCorpse = &creating_corpse;
|
||||
level.callbackEntitySpawned = &entityspawned;
|
||||
level.callbackAirSupport = &airsupport;
|
||||
//level.callbackDogSoundNotify = &dogs::play_dog_sound;
|
||||
level.callbackPlayAIFootstep = &footsteps::playaifootstep;
|
||||
level.callbackPlayLightLoopExploder = &exploder::playlightloopexploder;
|
||||
|
||||
level._custom_weapon_CB_Func = &callback::spawned_weapon_type;
|
||||
|
||||
level.gadgetVisionPulse_reveal_func = &gadget_vision_pulse::gadget_visionpulse_reveal;
|
||||
}
|
||||
|
||||
function localclientconnect( localClientNum )
|
||||
{
|
||||
/# println( "*** Client script VM : Local client connect " + localClientNum ); #/
|
||||
|
||||
if ( isdefined( level.characterCustomizationSetup ) )
|
||||
{
|
||||
[[ level.characterCustomizationSetup ]]( localclientnum );
|
||||
}
|
||||
|
||||
callback::callback( #"on_localclient_connect", localClientNum );
|
||||
}
|
||||
|
||||
function playerspawned(localClientNum)
|
||||
{
|
||||
self endon( "entityshutdown" );
|
||||
self notify( "playerspawned_callback" );
|
||||
self endon( "playerspawned_callback" );
|
||||
|
||||
player = GetLocalPlayer(localClientNum);
|
||||
|
||||
if ( isdefined( level.infraredVisionset ) )
|
||||
{
|
||||
player SetInfraredVisionset( level.infraredVisionset );
|
||||
}
|
||||
|
||||
if ( isdefined( level._playerspawned_override ) )
|
||||
{
|
||||
self thread [[level._playerspawned_override]]( localClientNum );
|
||||
return;
|
||||
}
|
||||
|
||||
/# PrintLn( "Player spawned" ); #/
|
||||
if ( self isLocalPlayer() )
|
||||
callback::callback( #"on_localplayer_spawned", localClientNum );
|
||||
|
||||
callback::callback( #"on_player_spawned", localClientNum );
|
||||
}
|
||||
|
||||
function entityspawned(localClientNum)
|
||||
{
|
||||
self endon( "entityshutdown" );
|
||||
|
||||
if( self IsPlayer() )
|
||||
{
|
||||
if( isdefined( level._clientFaceAnimOnPlayerSpawned ) )
|
||||
{
|
||||
self thread [[level._clientFaceAnimOnPlayerSpawned]](localClientNum);
|
||||
}
|
||||
}
|
||||
|
||||
if ( isdefined( level._entityspawned_override ) )
|
||||
{
|
||||
self thread [[level._entityspawned_override]]( localClientNum );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isdefined( self.type ) )
|
||||
{
|
||||
/# println( "Entity type undefined!" ); #/
|
||||
return;
|
||||
}
|
||||
|
||||
if ( self.type == "missile" )
|
||||
{
|
||||
if( isdefined( level._custom_weapon_CB_Func ) )
|
||||
{
|
||||
self thread [[level._custom_weapon_CB_Func]]( localClientNum );
|
||||
}
|
||||
}
|
||||
else if ( self.type == "vehicle" || self.type == "helicopter" || self.type == "plane" )
|
||||
{
|
||||
if( isdefined(level._customVehicleCBFunc) )
|
||||
{
|
||||
self thread [[level._customVehicleCBFunc]](localClientNum);
|
||||
}
|
||||
|
||||
self thread vehicle::field_toggle_exhaustfx_handler( localClientNum, undefined, false, true );
|
||||
self thread vehicle::field_toggle_lights_handler( localClientNum, undefined, false, true );
|
||||
|
||||
if ( self.type == "plane" || self.type == "helicopter" )
|
||||
{
|
||||
self thread vehicle::aircraft_dustkick();
|
||||
}
|
||||
else
|
||||
{
|
||||
self thread driving_fx::play_driving_fx(localClientNum);
|
||||
self thread vehicle::vehicle_rumble(localClientNum);
|
||||
}
|
||||
|
||||
if( self.type == "helicopter" )
|
||||
{
|
||||
self thread helicopter::startfx_loop( localClientNum );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( self.type == "actor" )
|
||||
{
|
||||
if( isdefined(level._customActorCBFunc) )
|
||||
{
|
||||
self thread [[level._customActorCBFunc]](localClientNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function airsupport( localClientNum, x, y, z, type, yaw, team, teamfaction, owner, exittype, time, height )
|
||||
{
|
||||
pos = ( x, y, z );
|
||||
switch( teamFaction )
|
||||
{
|
||||
case "v":
|
||||
teamfaction = "vietcong";
|
||||
break;
|
||||
case "n":
|
||||
case "nva":
|
||||
teamfaction = "nva";
|
||||
break;
|
||||
case "j":
|
||||
teamfaction = "japanese";
|
||||
break;
|
||||
case "m":
|
||||
teamfaction = "marines";
|
||||
break;
|
||||
case "s":
|
||||
teamfaction = "specops";
|
||||
break;
|
||||
case "r":
|
||||
teamfaction = "russian";
|
||||
break;
|
||||
default:
|
||||
/# println( "Warning: Invalid team char provided, defaulted to marines" ); #/
|
||||
/# println( "Teamfaction received: " + teamFaction + "\n" ); #/
|
||||
teamfaction = "marines";
|
||||
break;
|
||||
}
|
||||
|
||||
switch( team )
|
||||
{
|
||||
case "x":
|
||||
team = "axis";
|
||||
break;
|
||||
case "l":
|
||||
team = "allies";
|
||||
break;
|
||||
case "r":
|
||||
team = "free";
|
||||
break;
|
||||
default:
|
||||
/# println( "Invalid team used with playclientAirstike/napalm: " + team + "\n"); #/
|
||||
team = "allies";
|
||||
break;
|
||||
}
|
||||
|
||||
data = spawnstruct();
|
||||
|
||||
data.team = team;
|
||||
data.owner = owner;
|
||||
data.bombsite = pos;
|
||||
data.yaw = yaw;
|
||||
direction = ( 0, yaw, 0 );
|
||||
data.direction = direction;
|
||||
data.flyHeight = height;
|
||||
|
||||
if ( type == "a" )
|
||||
{
|
||||
planeHalfDistance = 12000;
|
||||
data.planeHalfDistance = planeHalfDistance;
|
||||
data.startPoint = pos + VectorScale( anglestoforward( direction ), -1 * planeHalfDistance );
|
||||
data.endPoint = pos + VectorScale( anglestoforward( direction ), planeHalfDistance );
|
||||
data.planeModel = "t5_veh_air_b52";
|
||||
data.flyBySound = "null";
|
||||
data.washSound = "veh_b52_flyby_wash";
|
||||
data.apexTime = 6145;
|
||||
data.exitType = -1;
|
||||
data.flySpeed = 2000;
|
||||
data.flyTime = ( ( planeHalfDistance * 2 ) / data.flySpeed );
|
||||
planeType = "airstrike";
|
||||
//_airstrike::addPlaneEvent( localClientNum, planeType, data, time );
|
||||
}
|
||||
else if ( type == "n" )
|
||||
{
|
||||
planeHalfDistance = 24000;
|
||||
data.planeHalfDistance = planeHalfDistance;
|
||||
data.startPoint = pos + VectorScale( anglestoforward( direction ), -1 * planeHalfDistance );
|
||||
data.endPoint = pos + VectorScale( anglestoforward( direction ), planeHalfDistance );
|
||||
data.planeModel = airsupport::getPlaneModel( teamFaction );
|
||||
data.flyBySound = "null";
|
||||
data.washSound = "evt_us_napalm_wash";
|
||||
data.apexTime = 2362;
|
||||
data.exitType = exitType;
|
||||
data.flySpeed = 7000;
|
||||
data.flyTime = ( ( planeHalfDistance * 2 ) / data.flySpeed );
|
||||
planeType = "napalm";
|
||||
//_plane::addPlaneEvent( localClientNum, planeType, data, time );
|
||||
}
|
||||
else
|
||||
{
|
||||
/#
|
||||
println( "" );
|
||||
println( "Unhandled airsupport type, only A (airstrike) and N (napalm) supported" );
|
||||
println( type );
|
||||
println( "" );
|
||||
#/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function creating_corpse(localClientNum, player )
|
||||
{
|
||||
}
|
||||
|
||||
function callback_stunned( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
|
||||
{
|
||||
self.stunned = newVal;
|
||||
|
||||
/# PrintLn("stunned_callback"); #/
|
||||
|
||||
if ( newVal )
|
||||
{
|
||||
self notify("stunned");
|
||||
}
|
||||
else
|
||||
{
|
||||
self notify("not_stunned");
|
||||
}
|
||||
}
|
||||
|
||||
function callback_emp( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
|
||||
{
|
||||
self.emp = newVal;
|
||||
|
||||
/# PrintLn("emp_callback"); #/
|
||||
|
||||
if ( newVal )
|
||||
{
|
||||
self notify("emp");
|
||||
}
|
||||
else
|
||||
{
|
||||
self notify("not_emp");
|
||||
}
|
||||
}
|
||||
|
||||
function callback_proximity( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
|
||||
{
|
||||
self.enemyInProximity = newVal;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#using scripts\codescripts\struct;
|
||||
#using scripts\shared\ai\systems\blackboard;
|
||||
#using scripts\shared\audio_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\gametypes\_globallogic;
|
||||
#using scripts\mp\gametypes\_globallogic_actor;
|
||||
#using scripts\mp\gametypes\_globallogic_player;
|
||||
#using scripts\mp\gametypes\_globallogic_vehicle;
|
||||
#using scripts\mp\gametypes\_hostmigration;
|
||||
#using scripts\shared\bots\bot_traversals;
|
||||
|
||||
#namespace callback;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("callback",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
set_default_callbacks();
|
||||
}
|
||||
|
||||
// Callback Setup
|
||||
// This script provides the hooks from code into script for the gametype callback functions.
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*================
|
||||
Setup any misc callbacks stuff like defines and default callbacks
|
||||
================*/
|
||||
|
||||
/*================
|
||||
Called from the gametype script to store off the default callback functions.
|
||||
This allows the callbacks to be overridden by level script, but not lost.
|
||||
================*/
|
||||
function set_default_callbacks()
|
||||
{
|
||||
level.callbackStartGameType = &globallogic::Callback_StartGameType;
|
||||
level.callbackPlayerConnect = &globallogic_player::Callback_PlayerConnect;
|
||||
level.callbackPlayerDisconnect = &globallogic_player::Callback_PlayerDisconnect;
|
||||
level.callbackPlayerDamage = &globallogic_player::Callback_PlayerDamage;
|
||||
level.callbackPlayerKilled = &globallogic_player::Callback_PlayerKilled;
|
||||
level.callbackPlayerMelee = &globallogic_player::Callback_PlayerMelee;
|
||||
level.callbackPlayerLastStand = &globallogic_player::Callback_PlayerLastStand;
|
||||
level.callbackActorSpawned = &globallogic_actor::Callback_ActorSpawned;
|
||||
level.callbackActorDamage = &globallogic_actor::Callback_ActorDamage;
|
||||
level.callbackActorKilled = &globallogic_actor::Callback_ActorKilled;
|
||||
level.callbackActorCloned = &globallogic_actor::Callback_ActorCloned;
|
||||
level.callbackVehicleSpawned = &globallogic_vehicle::Callback_VehicleSpawned;
|
||||
level.callbackVehicleDamage = &globallogic_vehicle::Callback_VehicleDamage;
|
||||
level.callbackVehicleKilled = &globallogic_vehicle::Callback_VehicleKilled;
|
||||
level.callbackVehicleRadiusDamage = &globallogic_vehicle::Callback_VehicleRadiusDamage;
|
||||
level.callbackPlayerMigrated = &globallogic_player::Callback_PlayerMigrated;
|
||||
level.callbackHostMigration = &hostmigration::Callback_HostMigration;
|
||||
level.callbackHostMigrationSave = &hostmigration::Callback_HostMigrationSave;
|
||||
level.callbackPreHostMigrationSave = &hostmigration::Callback_PreHostMigrationSave;
|
||||
level.callbackBotEnteredUserEdge = &bot::Callback_BotEnteredUserEdge;
|
||||
|
||||
level._custom_weapon_damage_func = &callback::callback_weapon_damage;
|
||||
|
||||
level._gametype_default = "tdm";
|
||||
}
|
||||
+1952
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,45 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
#precache( "client_fx", "_t6/weapon/claymore/fx_claymore_laser" );
|
||||
|
||||
#namespace claymore;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("claymore",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__( localClientNum )
|
||||
{
|
||||
level._effect["fx_claymore_laser"] = "_t6/weapon/claymore/fx_claymore_laser";
|
||||
|
||||
callback::add_weapon_type( "claymore", &spawned );
|
||||
}
|
||||
|
||||
function spawned( localClientNum )
|
||||
{
|
||||
self endon( "entityshutdown" );
|
||||
|
||||
self util::waittill_dobj(localClientNum);
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( isdefined( self.stunned ) && self.stunned )
|
||||
{
|
||||
wait( 0.1 );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
self.claymoreLaserFXId = PlayFXOnTag( localClientNum, level._effect["fx_claymore_laser"], self, "tag_fx" );
|
||||
|
||||
self waittill( "stunned" );
|
||||
stopfx(localClientNum, self.claymoreLaserFXId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,991 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\challenges_shared;
|
||||
#using scripts\shared\drown;
|
||||
#using scripts\shared\scoreevents_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_weapon_utils;
|
||||
|
||||
#using scripts\mp\_util;
|
||||
#using scripts\mp\_challenges;
|
||||
#using scripts\mp\gametypes\_globallogic;
|
||||
#using scripts\mp\gametypes\_globallogic_score;
|
||||
#using scripts\mp\gametypes\_loadout;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
|
||||
|
||||
|
||||
// look for dvar loot_cryptokeyCost
|
||||
// look for dvar loot_cryptokeyCost
|
||||
|
||||
|
||||
|
||||
|
||||
// should coincide with contracts array size on mp_stats.ddl
|
||||
|
||||
|
||||
|
||||
// contract string table and columns
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// mp_stats.ddl, PlayerStatsList[ <stat_name> ]
|
||||
// mp_stats.ddl, PlayerStatsList[ <stat_name> ]
|
||||
// mp_stats.ddl
|
||||
|
||||
// table index values from mp_contractTable.csv
|
||||
|
||||
// weekly contracts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// daily contracts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// special contracts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#namespace contracts;
|
||||
|
||||
#precache( "eventstring", "mp_daily_challenge_complete" );
|
||||
#precache( "eventstring", "mp_weekly_challenge_complete" );
|
||||
#precache( "eventstring", "mp_special_contract_complete" );
|
||||
|
||||
function autoexec __init__sytem__() { system::register("contracts",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
callback::on_start_gametype( &start_gametype );
|
||||
|
||||
/# level thread watch_contract_debug(); #/
|
||||
}
|
||||
|
||||
function start_gametype()
|
||||
{
|
||||
if ( !isdefined( level.ChallengesCallbacks ) )
|
||||
{
|
||||
level.ChallengesCallbacks = [];
|
||||
}
|
||||
|
||||
util::init_player_contract_events(); // must always initialize
|
||||
|
||||
waittillframeend;
|
||||
|
||||
if ( can_process_contracts() )
|
||||
{
|
||||
/# execdevgui( "devgui/mp/mp_devgui_contracts" ); #/
|
||||
|
||||
challenges::registerChallengesCallback( "playerKilled",&contract_kills );
|
||||
challenges::registerChallengesCallback( "gameEnd",&contract_game_ended );
|
||||
globallogic_score::registerContractWinEvent( &contract_win );
|
||||
scoreevents::register_hero_ability_kill_event( &on_hero_ability_kill );
|
||||
scoreevents::register_hero_ability_multikill_event( &on_hero_ability_multikill );
|
||||
scoreevents::register_hero_weapon_multikill_event( &on_hero_weapon_multikill );
|
||||
|
||||
util::register_player_contract_event( "score", &on_player_score, 1 );
|
||||
util::register_player_contract_event( "killstreak_score", &on_killstreak_score, 2 );
|
||||
util::register_player_contract_event( "offender_kill", &on_offender_kill );
|
||||
util::register_player_contract_event( "defender_kill", &on_defender_kill );
|
||||
util::register_player_contract_event( "headshot", &on_headshot_kill );
|
||||
util::register_player_contract_event( "killed_hero_ability_enemy", &on_killed_hero_ability_enemy );
|
||||
util::register_player_contract_event( "killed_hero_weapon_enemy", &on_killed_hero_weapon_enemy );
|
||||
util::register_player_contract_event( "earned_specialist_ability_medal", &on_hero_ability_medal );
|
||||
|
||||
// globallogic::registerOtherLootXPAwards( &award_loot_xp ); // intentionally commented out, will use mp_loot_xp_due instead for now
|
||||
}
|
||||
|
||||
callback::on_connect( &on_player_connect );
|
||||
}
|
||||
|
||||
function on_killed_hero_ability_enemy()
|
||||
{
|
||||
self add_stat( 1014 );
|
||||
}
|
||||
|
||||
function on_killed_hero_weapon_enemy()
|
||||
{
|
||||
self add_stat( 1014 );
|
||||
}
|
||||
|
||||
function on_player_connect()
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( can_process_contracts() )
|
||||
{
|
||||
player setup_player_contracts();
|
||||
}
|
||||
}
|
||||
|
||||
function can_process_contracts()
|
||||
{
|
||||
if ( GetDvarInt( "contracts_enabled_mp", 1 ) == 0 ) // mp contracts kill switch
|
||||
return false;
|
||||
|
||||
return challenges::canProcessChallenges();
|
||||
}
|
||||
|
||||
function setup_player_contracts()
|
||||
{
|
||||
player = self;
|
||||
|
||||
player.pers["contracts"] = [];
|
||||
|
||||
// no need to setup active contracts for bots
|
||||
if ( player util::is_bot() )
|
||||
return;
|
||||
|
||||
for( slot = 0; slot < 10; slot++ )
|
||||
{
|
||||
if ( get_contract_stat( slot, "active" ) && !get_contract_stat( slot, "award_given" ) )
|
||||
{
|
||||
contract_index = get_contract_stat( slot, "index" );
|
||||
player.pers["contracts"][contract_index] = SpawnStruct();
|
||||
player.pers["contracts"][contract_index].slot = slot;
|
||||
table_row = TableLookupRowNum( "gamedata/tables/mp/mp_contractTable.csv", 0, contract_index );
|
||||
player.pers["contracts"][contract_index].table_row = table_row;
|
||||
player.pers["contracts"][contract_index].target_value = int( TableLookupColumnForRow( "gamedata/tables/mp/mp_contractTable.csv", table_row, 2 ) );
|
||||
player.pers["contracts"][contract_index].calling_card_stat = TableLookupColumnForRow( "gamedata/tables/mp/mp_contractTable.csv", table_row, 7 );
|
||||
player.pers["contracts"][contract_index].weapon_camo_stat = TableLookupColumnForRow( "gamedata/tables/mp/mp_contractTable.csv", table_row, 8 );
|
||||
player.pers["contracts"][contract_index].absolute_stat_path = TableLookupColumnForRow( "gamedata/tables/mp/mp_contractTable.csv", table_row, 9 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/#
|
||||
function watch_contract_debug()
|
||||
{
|
||||
level notify( "watch_contract_debug_singleton" );
|
||||
level endon( "watch_contract_debug_singleton" );
|
||||
|
||||
level endon( "game_ended" );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if ( GetDvarInt( "scr_contract_deactivate_all_slots" ) > 0 )
|
||||
{
|
||||
if ( isdefined( level.players ) )
|
||||
{
|
||||
new_index = GetDvarInt( "scr_contract_new_test_index", 0 );
|
||||
|
||||
foreach( player in level.players )
|
||||
{
|
||||
if ( !isdefined( player ) )
|
||||
continue;
|
||||
|
||||
if ( player util::is_bot() )
|
||||
continue;
|
||||
|
||||
for ( slot = 0; slot < 10; slot++ )
|
||||
{
|
||||
player set_contract_stat( slot, "active", 0 );
|
||||
}
|
||||
|
||||
IPrintLn( "All contract slots deactivated for " + player.name );
|
||||
|
||||
player setup_player_contracts();
|
||||
}
|
||||
}
|
||||
|
||||
SetDvar( "scr_contract_deactivate_all_slots", 0 );
|
||||
}
|
||||
|
||||
if ( GetDvarInt( "scr_contract_new_test_index", 0 ) > 0 )
|
||||
{
|
||||
if ( isdefined( level.players ) )
|
||||
{
|
||||
new_index = GetDvarInt( "scr_contract_new_test_index", 0 );
|
||||
|
||||
foreach( player in level.players )
|
||||
{
|
||||
if ( !isdefined( player ) )
|
||||
continue;
|
||||
|
||||
if ( player util::is_bot() )
|
||||
continue;
|
||||
|
||||
test_slot = GetDvarInt( "scr_contract_debug_slot", 10 - 1 );
|
||||
|
||||
player set_contract_stat( test_slot, "active", 1 );
|
||||
player set_contract_stat( test_slot, "index", new_index );
|
||||
player set_contract_stat( test_slot, "progress", 0 );
|
||||
player set_contract_stat( test_slot, "award_given", 0 );
|
||||
player setup_player_contracts();
|
||||
|
||||
IPrintLn( "Contract Slot " + test_slot + " table index set to " + new_index + " for " + player.name + ". Progress reset." );
|
||||
}
|
||||
}
|
||||
|
||||
SetDvar( "scr_contract_new_test_index", 0 );
|
||||
}
|
||||
|
||||
if ( GetDvarInt( "scr_contract_deactivate_debug_slot", 0 ) > 0 )
|
||||
{
|
||||
if ( isdefined( level.players ) )
|
||||
{
|
||||
test_slot = GetDvarInt( "scr_contract_debug_slot", 10 - 1 );
|
||||
IPrintLn( "Contract Debug Off" );
|
||||
|
||||
foreach( player in level.players )
|
||||
{
|
||||
if ( !isdefined( player ) )
|
||||
continue;
|
||||
|
||||
if ( player util::is_bot() )
|
||||
continue;
|
||||
|
||||
if ( test_slot >= 3 )
|
||||
{
|
||||
player set_contract_stat( test_slot, "active", 0 );
|
||||
player setup_player_contracts();
|
||||
|
||||
IPrintLn( "Contract Slot " + test_slot + " deactivated for " + player.name );
|
||||
}
|
||||
else
|
||||
{
|
||||
IPrintLn( "Contract Slot " + test_slot + " left active for " + player.name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetDvar( "scr_contract_deactivate_debug_slot", 0 );
|
||||
}
|
||||
|
||||
if ( GetDvarInt( "scr_contract_msg_front_end_only", 0 ) > 0 )
|
||||
{
|
||||
IPrintLn( "Assign Slot menu(s) only available in FrontEnd." );
|
||||
SetDvar( "scr_contract_msg_front_end_only", 0 );
|
||||
}
|
||||
|
||||
if ( GetDvarInt( "scr_contract_msg_debug_on", 0 ) > 0 )
|
||||
{
|
||||
IPrintLn( "Contracts Debug On. No slots altered." );
|
||||
SetDvar( "scr_contract_msg_debug_on", 0 );
|
||||
}
|
||||
|
||||
wait 0.5;
|
||||
}
|
||||
}
|
||||
#/
|
||||
|
||||
function is_contract_active( challenge_index )
|
||||
{
|
||||
if ( !isPlayer( self ) )
|
||||
return false;
|
||||
|
||||
if ( !isdefined( self.pers["contracts"] ) )
|
||||
return false;
|
||||
|
||||
if ( !isdefined( self.pers["contracts"][challenge_index] ) )
|
||||
return false;
|
||||
|
||||
// sanity check... better than causing an SRE
|
||||
if ( self.pers["contracts"][challenge_index].table_row == -1 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function on_hero_ability_kill( ability, victimAbility )
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
}
|
||||
|
||||
function on_hero_ability_medal()
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
|
||||
player add_stat( 1013 );
|
||||
player add_stat( 3 );
|
||||
}
|
||||
|
||||
function on_hero_ability_multikill( killcount, ability )
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
}
|
||||
|
||||
function on_hero_weapon_multikill( killcount, weapon )
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
}
|
||||
|
||||
function on_player_score( delta_score )
|
||||
{
|
||||
self add_stat( 1009, delta_score );
|
||||
self add_stat( 5, delta_score );
|
||||
}
|
||||
|
||||
function on_killstreak_score( delta_score, killstreak_purchased )
|
||||
{
|
||||
if ( killstreak_purchased )
|
||||
{
|
||||
self add_stat( 1011, delta_score );
|
||||
}
|
||||
}
|
||||
|
||||
function contract_kills( data )
|
||||
{
|
||||
victim = data.victim;
|
||||
attacker = data.attacker;
|
||||
player = attacker;
|
||||
weapon = data.weapon;
|
||||
time = data.time;
|
||||
|
||||
if ( !isdefined( weapon ) || ( weapon == level.weaponNone ) )
|
||||
return;
|
||||
|
||||
if ( !isdefined( player ) || !isplayer( player ) )
|
||||
return;
|
||||
|
||||
player add_stat( 1015 );
|
||||
player add_stat( 4 );
|
||||
|
||||
if ( weapon.isHeroWeapon === true )
|
||||
{
|
||||
player add_stat( 1012 );
|
||||
player add_stat( 7 );
|
||||
player add_stat( 3006 );
|
||||
}
|
||||
|
||||
isKillstreak = isdefined( data.eInflictor ) && isdefined( data.eInflictor.killstreakid );
|
||||
if ( !isKillstreak && isdefined( level.isKillstreakWeapon ) )
|
||||
{
|
||||
isKillstreakWeapon = [[level.isKillstreakWeapon]]( weapon );
|
||||
}
|
||||
|
||||
if ( isKillstreak || ( isKillstreakWeapon === true ) )
|
||||
{
|
||||
player add_stat( 1010 );
|
||||
player add_stat( 8 );
|
||||
}
|
||||
|
||||
statItemIndex = weapon.statIndex;
|
||||
|
||||
if ( player isItemPurchased( statItemIndex ) )
|
||||
{
|
||||
weaponClass = util::getWeaponClass( weapon );
|
||||
|
||||
switch ( weaponClass ) // aka group in mp_statsTable
|
||||
{
|
||||
case "weapon_assault":
|
||||
player add_stat( 1019 );
|
||||
player add_stat( 3001 );
|
||||
break;
|
||||
|
||||
case "weapon_smg":
|
||||
player add_stat( 1020 );
|
||||
player add_stat( 3000 );
|
||||
break;
|
||||
|
||||
case "weapon_sniper":
|
||||
player add_stat( 1021 );
|
||||
player add_stat( 3004 );
|
||||
break;
|
||||
|
||||
case "weapon_lmg":
|
||||
player add_stat( 1022 );
|
||||
player add_stat( 3003 );
|
||||
break;
|
||||
|
||||
case "weapon_cqb":
|
||||
player add_stat( 1023 );
|
||||
player add_stat( 3002 );
|
||||
break;
|
||||
|
||||
case "weapon_pistol":
|
||||
player add_stat( 1024 );
|
||||
break;
|
||||
|
||||
case "weapon_knife":
|
||||
player add_stat( 3005 );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
total_unlocked = player GetTotalUnlockedWeaponAttachments( weapon );
|
||||
if ( total_unlocked >= 4 )
|
||||
{
|
||||
player add_stat( 1025 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function add_stat( contract_index, delta )
|
||||
{
|
||||
if ( self is_contract_active( contract_index ) )
|
||||
{
|
||||
self add_active_stat( contract_index, delta );
|
||||
}
|
||||
}
|
||||
|
||||
function add_active_stat( contract_index, delta = 1 )
|
||||
{
|
||||
slot = self.pers["contracts"][contract_index].slot;
|
||||
target_value = self.pers["contracts"][contract_index].target_value;
|
||||
|
||||
/#
|
||||
if ( GetDvarInt( "scr_contract_debug_multiplier", 0 ) > 0 )
|
||||
delta *= GetDvarInt( "scr_contract_debug_multiplier", 1 );
|
||||
#/
|
||||
|
||||
old_progress = get_contract_stat( slot, "progress" );
|
||||
new_progress = old_progress + delta;
|
||||
|
||||
if ( new_progress > target_value )
|
||||
new_progress = target_value;
|
||||
|
||||
if ( new_progress != old_progress )
|
||||
self set_contract_stat( slot, "progress", new_progress );
|
||||
|
||||
just_completed = false;
|
||||
if ( old_progress < target_value && target_value <= new_progress )
|
||||
{
|
||||
just_completed = true;
|
||||
|
||||
// notify contract achieved
|
||||
event = &"mp_weekly_challenge_complete";
|
||||
display_rewards = false;
|
||||
|
||||
if ( slot == 2 )
|
||||
{
|
||||
event = &"mp_daily_challenge_complete";
|
||||
display_rewards = true;
|
||||
|
||||
self award_loot_xp_due( award_daily_contract() );
|
||||
self set_contract_stat( 2, "award_given", 1 );
|
||||
}
|
||||
else if ( slot == 0 || slot == 1 )
|
||||
{
|
||||
other_slot = 1;
|
||||
if ( slot == 1 )
|
||||
{
|
||||
other_slot = 0;
|
||||
}
|
||||
|
||||
foreach ( c_index,c_data in self.pers["contracts"] )
|
||||
{
|
||||
if ( c_data.slot == other_slot )
|
||||
{
|
||||
if ( c_data.target_value <= get_contract_stat( other_slot, "progress" ) )
|
||||
{
|
||||
display_rewards = true;
|
||||
|
||||
self award_loot_xp_due( award_weekly_contract() );
|
||||
self set_contract_stat( 0, "award_given", 1 );
|
||||
self set_contract_stat( 1, "award_given", 1 );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( slot == 3 )
|
||||
{
|
||||
event = &"mp_special_contract_complete";
|
||||
display_rewards = true;
|
||||
|
||||
absolute_stat_path = self.pers["contracts"][contract_index].absolute_stat_path;
|
||||
if ( absolute_stat_path != "" )
|
||||
{
|
||||
set_contract_award_stat_from_path( absolute_stat_path, true );
|
||||
}
|
||||
|
||||
calling_card_stat = self.pers["contracts"][contract_index].calling_card_stat;
|
||||
if ( calling_card_stat != "" )
|
||||
{
|
||||
set_contract_award_stat( "calling_card", calling_card_stat );
|
||||
}
|
||||
|
||||
weapon_camo_stat = self.pers["contracts"][contract_index].weapon_camo_stat;
|
||||
if ( weapon_camo_stat != "" )
|
||||
{
|
||||
set_contract_award_stat( "weapon_camo", weapon_camo_stat );
|
||||
}
|
||||
|
||||
self set_contract_stat( 3, "award_given", 1 );
|
||||
}
|
||||
|
||||
/#
|
||||
test_slot = GetDvarInt( "scr_contract_debug_slot", 10 - 1 );
|
||||
if ( slot == test_slot )
|
||||
{
|
||||
if ( contract_index >= 1000 && contract_index <= 2999 )
|
||||
{
|
||||
event = &"mp_daily_challenge_complete";
|
||||
}
|
||||
display_rewards = true;
|
||||
}
|
||||
#/
|
||||
|
||||
self LUINotifyEvent( event, 2, contract_index, display_rewards );
|
||||
}
|
||||
|
||||
/#
|
||||
if ( GetDvarInt( "scr_contract_debug", 0 ) > 0 )
|
||||
{
|
||||
IPrintLn( "Contract Slot "+ slot + " table index " + contract_index + " progress: " + new_progress + "/" + target_value );
|
||||
}
|
||||
#/
|
||||
}
|
||||
|
||||
function get_contract_stat( slot, stat_name )
|
||||
{
|
||||
return self GetDStat( "contracts", slot, stat_name );
|
||||
}
|
||||
|
||||
function set_contract_stat( slot, stat_name, stat_value )
|
||||
{
|
||||
return self SetDStat( "contracts", slot, stat_name, stat_value );
|
||||
}
|
||||
|
||||
function set_contract_award_stat( award_type, stat_name, stat_value = 1 )
|
||||
{
|
||||
// award_type is unused for now as we use PlayerStatsList for now
|
||||
|
||||
return self AddPlayerStat( stat_name, stat_value );
|
||||
}
|
||||
|
||||
function set_contract_award_stat_from_path( stat_path, stat_value )
|
||||
{
|
||||
stat_path_array = StrTok( stat_path, " " );
|
||||
|
||||
string_path_1 = "";
|
||||
string_path_2 = "";
|
||||
string_path_3 = "";
|
||||
string_path_4 = "";
|
||||
string_path_5 = "";
|
||||
|
||||
switch( stat_path_array.size )
|
||||
{
|
||||
case 5:
|
||||
string_path_5 = stat_path_array[4];
|
||||
if( StrIsNumber( string_path_5 ) )
|
||||
{
|
||||
string_path_5 = Int( string_path_5 );
|
||||
}
|
||||
case 4:
|
||||
string_path_4 = stat_path_array[3];
|
||||
if( StrIsNumber( string_path_4 ) )
|
||||
{
|
||||
string_path_4 = Int( string_path_4 );
|
||||
}
|
||||
case 3:
|
||||
string_path_3 = stat_path_array[2];
|
||||
if( StrIsNumber( string_path_3 ) )
|
||||
{
|
||||
string_path_3 = Int( string_path_3 );
|
||||
}
|
||||
case 2:
|
||||
string_path_2 = stat_path_array[1];
|
||||
if( StrIsNumber( string_path_2 ) )
|
||||
{
|
||||
string_path_2 = Int( string_path_2 );
|
||||
}
|
||||
case 1:
|
||||
string_path_1 = stat_path_array[0];
|
||||
if( StrIsNumber( string_path_1 ) )
|
||||
{
|
||||
string_path_1 = Int( string_path_1 );
|
||||
}
|
||||
}
|
||||
|
||||
switch( stat_path_array.size )
|
||||
{
|
||||
case 1:
|
||||
return self SetDStat( string_path_1, stat_value );
|
||||
break;
|
||||
case 2:
|
||||
return self SetDStat( string_path_1, string_path_2, stat_value );
|
||||
break;
|
||||
case 3:
|
||||
return self SetDStat( string_path_1, string_path_2, string_path_3, stat_value );
|
||||
break;
|
||||
case 4:
|
||||
return self SetDStat( string_path_1, string_path_2, string_path_3, string_path_4, stat_value );
|
||||
break;
|
||||
case 5:
|
||||
return self SetDStat( string_path_1, string_path_2, string_path_3, string_path_4, string_path_5, stat_value );
|
||||
break;
|
||||
default:
|
||||
AssertMsg( "Stat path depth of " + stat_path_array.size + " is too large. Limit to 5 deep" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function award_loot_xp_due( amount )
|
||||
{
|
||||
if ( !isdefined( self ) )
|
||||
return;
|
||||
|
||||
if ( amount <= 0 )
|
||||
return;
|
||||
|
||||
current_amount = (isdefined(self GetDStat( "mp_loot_xp_due" ))?self GetDStat( "mp_loot_xp_due" ):0);
|
||||
new_amount = current_amount + amount;
|
||||
self SetDStat( "mp_loot_xp_due", new_amount );
|
||||
}
|
||||
|
||||
function get_hero_weapon_mask( attacker, weapon )
|
||||
{
|
||||
if ( !isdefined( weapon ) )
|
||||
return 0;
|
||||
|
||||
if ( isdefined( weapon.isHeroWeapon ) && !weapon.isHeroWeapon )
|
||||
return 0;
|
||||
|
||||
switch( weapon.name )
|
||||
{
|
||||
case "hero_minigun":
|
||||
case "hero_minigun_body3":
|
||||
return 1; // note: heroWeaponMask needs to stay unique and consistent for function across TUs and FFOTDs
|
||||
break;
|
||||
case "hero_flamethrower":
|
||||
return 1 << 1;
|
||||
break;
|
||||
case "hero_lightninggun":
|
||||
case "hero_lightninggun_arc":
|
||||
return 1 << 2;
|
||||
break;
|
||||
case "hero_chemicalgelgun":
|
||||
case "hero_firefly_swarm":
|
||||
return 1 << 3;
|
||||
break;
|
||||
case "hero_pineapplegun":
|
||||
case "hero_pineapple_grenade":
|
||||
return 1 << 4;
|
||||
break;
|
||||
case "hero_armblade":
|
||||
return 1 << 5;
|
||||
break;
|
||||
case "hero_bowlauncher":
|
||||
case "hero_bowlauncher2":
|
||||
case "hero_bowlauncher3":
|
||||
case "hero_bowlauncher4":
|
||||
return 1 << 6;
|
||||
break;
|
||||
case "hero_gravityspikes":
|
||||
return 1 << 7;
|
||||
break;
|
||||
case "hero_annihilator":
|
||||
return 1 << 8;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function get_hero_ability_mask( ability )
|
||||
{
|
||||
if ( !isdefined( ability ) )
|
||||
return 0;
|
||||
|
||||
switch( ability.name )
|
||||
{
|
||||
case "gadget_clone":
|
||||
return 1; // note: heroAbilityMask needs to stay unique and consistent for functions across TUs and FFOTDs
|
||||
break;
|
||||
case "gadget_heat_wave":
|
||||
return 1 << 1;
|
||||
break;
|
||||
case "gadget_flashback":
|
||||
return 1 << 2;
|
||||
break;
|
||||
case "gadget_resurrect":
|
||||
return 1 << 3;
|
||||
break;
|
||||
case "gadget_armor":
|
||||
return 1 << 4;
|
||||
break;
|
||||
case "gadget_camo":
|
||||
return 1 << 5;
|
||||
break;
|
||||
case "gadget_vision_pulse":
|
||||
return 1 << 6;
|
||||
break;
|
||||
case "gadget_speed_burst":
|
||||
return 1 << 7;
|
||||
break;
|
||||
case "gadget_combat_efficiency":
|
||||
return 1 << 8;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function contract_game_ended( data )
|
||||
{
|
||||
// TODO: award challenge award here: maybe
|
||||
}
|
||||
|
||||
function contract_win( winner )
|
||||
{
|
||||
winner add_stat( 1000 );
|
||||
winner add_stat( 1 );
|
||||
winner add_stat( 3007 );
|
||||
winner add_stat( 3008 );
|
||||
winner add_stat( 3009 );
|
||||
winner add_stat( 3010 );
|
||||
winner add_stat( 3011 );
|
||||
winner add_stat( 3012 );
|
||||
winner add_stat( 3013 );
|
||||
winner add_stat( 3014 );
|
||||
winner add_stat( 3015 );
|
||||
winner add_stat( 3016 );
|
||||
winner add_stat( 3017 );
|
||||
winner add_stat( 3018 );
|
||||
winner add_stat( 3019 );
|
||||
winner add_stat( 3020 );
|
||||
winner add_stat( 3021 );
|
||||
winner add_stat( 3022 );
|
||||
winner add_stat( 3023 );
|
||||
winner add_stat( 3024 );
|
||||
winner add_stat( 3025 );
|
||||
winner add_stat( 3026 );
|
||||
winner add_stat( 3027 );
|
||||
winner add_stat( 3028 );
|
||||
|
||||
if ( util::is_objective_game( level.gametype ) )
|
||||
{
|
||||
winner add_stat( 2 );
|
||||
}
|
||||
|
||||
if ( IsArenaMode() )
|
||||
{
|
||||
winner add_stat( 1001 );
|
||||
}
|
||||
|
||||
gametype_win( winner );
|
||||
}
|
||||
|
||||
function gametype_win( winner )
|
||||
{
|
||||
switch ( level.gametype )
|
||||
{
|
||||
case "tdm":
|
||||
winner add_stat( 1002 );
|
||||
break;
|
||||
|
||||
case "ball":
|
||||
winner add_stat( 1003 );
|
||||
break;
|
||||
|
||||
case "escort":
|
||||
winner add_stat( 1004 );
|
||||
break;
|
||||
|
||||
case "conf":
|
||||
winner add_stat( 1005 );
|
||||
break;
|
||||
|
||||
case "sd":
|
||||
winner add_stat( 1006 );
|
||||
break;
|
||||
|
||||
case "koth":
|
||||
winner add_stat( 1007 );
|
||||
break;
|
||||
|
||||
case "dom":
|
||||
winner add_stat( 1008 );
|
||||
break;
|
||||
|
||||
case "ctf":
|
||||
winner add_stat( 1026 );
|
||||
break;
|
||||
|
||||
case "dem":
|
||||
winner add_stat( 1027 );
|
||||
break;
|
||||
|
||||
case "dm":
|
||||
winner add_stat( 1028 );
|
||||
break;
|
||||
|
||||
case "clean":
|
||||
winner add_stat( 1029 );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function on_offender_kill()
|
||||
{
|
||||
self add_stat( 1018 );
|
||||
self add_stat( 6 );
|
||||
}
|
||||
|
||||
function on_defender_kill()
|
||||
{
|
||||
self add_stat( 1017 );
|
||||
self add_stat( 6 );
|
||||
}
|
||||
|
||||
function on_headshot_kill()
|
||||
{
|
||||
self add_stat( 1016, 1 );
|
||||
}
|
||||
|
||||
function award_loot_xp()
|
||||
{
|
||||
player = self;
|
||||
|
||||
if ( !isdefined( player.pers["contracts"] ) )
|
||||
return 0;
|
||||
|
||||
loot_xp = 0;
|
||||
|
||||
//
|
||||
// daily contract
|
||||
//
|
||||
daily_slot = 2;
|
||||
if ( get_contract_stat( daily_slot, "active" ) && !get_contract_stat( daily_slot, "award_given" ) )
|
||||
{
|
||||
if ( contract_slot_met( daily_slot ) )
|
||||
{
|
||||
loot_xp += player award_daily_contract();
|
||||
player set_contract_stat( daily_slot, "award_given", 1 );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// weekly contract
|
||||
//
|
||||
weekly_slot_A = 0;
|
||||
weekly_slot_B = 1;
|
||||
if ( get_contract_stat( weekly_slot_A, "active" ) && !get_contract_stat( weekly_slot_A, "award_given" ) &&
|
||||
get_contract_stat( weekly_slot_B, "active" ) && !get_contract_stat( weekly_slot_B, "award_given" ) )
|
||||
{
|
||||
if ( contract_slot_met( weekly_slot_A ) && contract_slot_met( weekly_slot_B ) )
|
||||
{
|
||||
loot_xp += player award_weekly_contract();
|
||||
player set_contract_stat( weekly_slot_A, "award_given", 1 );
|
||||
player set_contract_stat( weekly_slot_B, "award_given", 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return loot_xp;
|
||||
}
|
||||
|
||||
function contract_slot_met( slot )
|
||||
{
|
||||
player = self;
|
||||
|
||||
contract_index = get_contract_stat( slot, "index" );
|
||||
|
||||
if ( !isdefined( player.pers["contracts"][contract_index] ) )
|
||||
return false;
|
||||
|
||||
progress = player get_contract_stat( slot, "progress" );
|
||||
target_value = player.pers["contracts"][contract_index].target_value;
|
||||
|
||||
return ( progress >= target_value );
|
||||
}
|
||||
|
||||
function award_daily_contract()
|
||||
{
|
||||
return GetDvarInt( "daily_contract_cryptokey_reward_count", 10 ) * GetDvarInt( "loot_cryptokeyCost", 100 );
|
||||
}
|
||||
|
||||
function award_weekly_contract()
|
||||
{
|
||||
self award_blackjack_contract();
|
||||
|
||||
return GetDvarInt( "weekly_contract_cryptokey_reward_count", 30 ) * GetDvarInt( "loot_cryptokeyCost", 100 );
|
||||
}
|
||||
|
||||
function award_blackjack_contract()
|
||||
{
|
||||
contract_count = self GetDStat( "blackjack_contract_count" );
|
||||
reward_count = GetDvarInt( "weekly_contract_blackjack_contract_reward_count", 1 );
|
||||
self SetDStat( "blackjack_contract_count", contract_count + reward_count );
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// mp contract header
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
|
||||
#namespace client_flag;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("client_flag",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
clientfield::register( "scriptmover", "ctf_flag_away", 1, 1, "int", &setCTFAway, !true, !true );
|
||||
}
|
||||
|
||||
function setCTFAway( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
|
||||
{
|
||||
team = self.team;
|
||||
|
||||
SetFlagAsAway( localClientNum, team, newVal );
|
||||
|
||||
self thread clearCTFAway( localClientNum, team );
|
||||
}
|
||||
|
||||
function clearCTFAway( localClientNum, team )
|
||||
{
|
||||
self waittill( "entityshutdown" );
|
||||
|
||||
SetFlagAsAway( localClientNum, team, 0 );
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\weapons\_decoy;
|
||||
|
||||
Line truncated
|
||||
|
||||
#namespace decoy;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("decoy",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
decoy::init_shared();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons\_decoy;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\_util;
|
||||
|
||||
#namespace decoy;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("decoy",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
decoy::init_shared();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
|
||||
|
||||
|
||||
#namespace destructible;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("destructible",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
clientfield::register( "scriptmover", "start_destructible_explosion", 1, 10, "int", &doExplosion, !true, !true );
|
||||
}
|
||||
|
||||
function playGrenadeRumble( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
|
||||
{
|
||||
PlayRumbleOnPosition( localClientNum, "grenade_rumble", self.origin );
|
||||
GetLocalPlayer( localClientNum ) Earthquake( 0.5, 0.5, self.origin, 800 );
|
||||
}
|
||||
|
||||
function doExplosion( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
|
||||
{
|
||||
if( newVal == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
physics_explosion = false;
|
||||
|
||||
if( newVal & ( 1 << ( 10 - 1 ) ) )
|
||||
{
|
||||
physics_explosion = true;
|
||||
|
||||
newVal -= ( 1 << ( 10 - 1 ) ) ;
|
||||
}
|
||||
|
||||
physics_force = 0.3;
|
||||
|
||||
if( physics_explosion )
|
||||
{
|
||||
PhysicsExplosionSphere( localClientNum, self.origin, newVal, newVal - 1, physics_force, 25, 400 );
|
||||
}
|
||||
|
||||
playGrenadeRumble( localClientNum, self.origin );
|
||||
}
|
||||
@@ -0,0 +1,610 @@
|
||||
#using scripts\shared\challenges_shared;
|
||||
#using scripts\shared\clientfield_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
|
||||
Line truncated
|
||||
|
||||
|
||||
|
||||
#using scripts\mp\gametypes\_battlechatter;
|
||||
#using scripts\mp\gametypes\_globallogic_player;
|
||||
|
||||
#using scripts\mp\_challenges;
|
||||
|
||||
|
||||
|
||||
#namespace destructible;
|
||||
|
||||
function autoexec __init__sytem__() { system::register("destructible",&__init__,undefined,undefined); }
|
||||
|
||||
#using_animtree ( "mp_vehicles" );
|
||||
|
||||
function __init__()
|
||||
{
|
||||
clientfield::register( "scriptmover", "start_destructible_explosion", 1, 10, "int" );
|
||||
|
||||
level.destructible_callbacks = [];
|
||||
destructibles = GetEntArray( "destructible", "targetname" );
|
||||
|
||||
// since this is globally run, only continue if we have a destructible in the level
|
||||
if( destructibles.size <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// array::thread_all( destructibles,&destructible_think );
|
||||
|
||||
for ( i = 0; i < destructibles.size; i++ )
|
||||
{
|
||||
if ( GetSubStr( destructibles[i].destructibledef, 0, 4 ) == "veh_" )
|
||||
{
|
||||
destructibles[i] thread car_death_think();
|
||||
destructibles[i] thread car_grenade_stuck_think();
|
||||
}
|
||||
else if ( destructibles[i].destructibledef == "fxdest_upl_metal_tank_01" )
|
||||
{
|
||||
destructibles[i] thread tank_grenade_stuck_think();
|
||||
}
|
||||
}
|
||||
|
||||
init_explosions();
|
||||
}
|
||||
|
||||
function init_explosions()
|
||||
{
|
||||
level.explosion_manager = SpawnStruct();
|
||||
level.explosion_manager.count = 0;
|
||||
level.explosion_manager.a_explosions = [];
|
||||
|
||||
i = 0;
|
||||
while( i < 32 )
|
||||
{
|
||||
sExplosion = Spawn( "script_model", (0,0,0) );
|
||||
if ( !isdefined( level.explosion_manager.a_explosions ) ) level.explosion_manager.a_explosions = []; else if ( !IsArray( level.explosion_manager.a_explosions ) ) level.explosion_manager.a_explosions = array( level.explosion_manager.a_explosions ); level.explosion_manager.a_explosions[level.explosion_manager.a_explosions.size]=sExplosion;;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
function get_unused_explosion()
|
||||
{
|
||||
foreach( explosion in level.explosion_manager.a_explosions )
|
||||
{
|
||||
if( !( isdefined( explosion.in_use ) && explosion.in_use ) )
|
||||
{
|
||||
return explosion;
|
||||
}
|
||||
}
|
||||
return level.explosion_manager.a_explosions[0];
|
||||
}
|
||||
|
||||
//assumes explosion radius will never be greater than 2 ^ ( DESTRUCTIBLE_CLIENTFIELD_NUM_BITS )
|
||||
function physics_explosion_and_rumble( origin, radius, physics_explosion )
|
||||
{
|
||||
sExplosion = get_unused_explosion();
|
||||
sExplosion.in_use = true;
|
||||
sExplosion.origin = origin;
|
||||
|
||||
assert( radius <= pow( 2, 10 ) - 1 );
|
||||
|
||||
if( ( isdefined( physics_explosion ) && physics_explosion ) )
|
||||
{
|
||||
radius += ( 1 << ( 10 - 1 ) );
|
||||
}
|
||||
|
||||
{wait(.05);};
|
||||
|
||||
sExplosion clientfield::set( "start_destructible_explosion", radius );
|
||||
|
||||
sExplosion.in_use = false;
|
||||
}
|
||||
|
||||
function event_callback( destructible_event, attacker, weapon ) // self == the destructible object (like the car or barrel)
|
||||
{
|
||||
explosion_radius = 0;
|
||||
if(IsSubStr(destructible_event, "explode") && destructible_event != "explode")
|
||||
{
|
||||
tokens = StrTok(destructible_event, "_");
|
||||
explosion_radius = tokens[1];
|
||||
|
||||
if(explosion_radius == "sm")
|
||||
{
|
||||
explosion_radius = 150;
|
||||
}
|
||||
else if(explosion_radius == "lg")
|
||||
{
|
||||
explosion_radius = 450;
|
||||
}
|
||||
else
|
||||
{
|
||||
explosion_radius = Int(explosion_radius);
|
||||
}
|
||||
|
||||
destructible_event = "explode_complex"; // use a different explosion function
|
||||
}
|
||||
|
||||
if( IsSubStr( destructible_event, "explosive" ) )
|
||||
{
|
||||
tokens = StrTok(destructible_event, "_");
|
||||
explosion_radius_type = tokens[3];
|
||||
|
||||
if(explosion_radius_type == "small")
|
||||
{
|
||||
explosion_radius = 150;
|
||||
}
|
||||
else if(explosion_radius_type == "large")
|
||||
{
|
||||
explosion_radius = 450;
|
||||
}
|
||||
else
|
||||
{
|
||||
explosion_radius = 300;
|
||||
}
|
||||
}
|
||||
|
||||
if ( IsSubStr( destructible_event, "simple_timed_explosion" ) )
|
||||
{
|
||||
self thread simple_timed_explosion( destructible_event, attacker );
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( destructible_event )
|
||||
{
|
||||
case "destructible_car_explosion":
|
||||
self car_explosion( attacker );
|
||||
if ( isdefined( weapon ) )
|
||||
{
|
||||
self.destroyingWeapon = weapon;
|
||||
}
|
||||
break;
|
||||
|
||||
case "destructible_car_fire":
|
||||
level thread battlechatter::on_player_near_explodable( self, "car" );
|
||||
self thread car_fire_think(attacker);
|
||||
if ( isdefined( weapon ) )
|
||||
{
|
||||
self.destroyingWeapon = weapon;
|
||||
}
|
||||
break;
|
||||
|
||||
case "explode":
|
||||
self thread simple_explosion( attacker );
|
||||
break;
|
||||
|
||||
case "explode_complex":
|
||||
self thread complex_explosion( attacker, explosion_radius );
|
||||
break;
|
||||
|
||||
case "destructible_explosive_incendiary_small":
|
||||
case "destructible_explosive_incendiary_large":
|
||||
self explosive_incendiary_explosion( attacker, explosion_radius, false );
|
||||
if ( isdefined( weapon ) )
|
||||
{
|
||||
self.destroyingWeapon = weapon;
|
||||
}
|
||||
break;
|
||||
|
||||
case "destructible_explosive_electrical_small":
|
||||
case "destructible_explosive_electrical_large":
|
||||
self explosive_electrical_explosion( attacker, explosion_radius, false );
|
||||
if ( isdefined( weapon ) )
|
||||
{
|
||||
self.destroyingWeapon = weapon;
|
||||
}
|
||||
break;
|
||||
|
||||
case "destructible_explosive_concussive_small":
|
||||
case "destructible_explosive_concussive_large":
|
||||
self explosive_concussive_explosion( attacker, explosion_radius, false );
|
||||
if ( isdefined( weapon ) )
|
||||
{
|
||||
self.destroyingWeapon = weapon;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
//iprintln( "_destructible.gsc: unknown destructible event: '" + destructible_event + "'" );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( isdefined( level.destructible_callbacks[ destructible_event ] ) )
|
||||
{
|
||||
self thread [[level.destructible_callbacks[ destructible_event ]]]( destructible_event, attacker, weapon );
|
||||
}
|
||||
}
|
||||
|
||||
function simple_explosion( attacker )
|
||||
{
|
||||
if ( ( isdefined( self.exploded ) && self.exploded ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self.exploded = true;
|
||||
|
||||
offset = (0, 0, 5);
|
||||
self RadiusDamage( self.origin + offset, 256, 300, 75, attacker, "MOD_EXPLOSIVE", GetWeapon( "explodable_barrel" ) );
|
||||
physics_explosion_and_rumble( self.origin, 255, true );
|
||||
|
||||
if ( isdefined( attacker ) )
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + offset, attacker );
|
||||
}
|
||||
else
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + offset );
|
||||
}
|
||||
}
|
||||
|
||||
function simple_timed_explosion( destructible_event, attacker )
|
||||
{
|
||||
self endon( "death" );
|
||||
|
||||
wait_times = [];
|
||||
|
||||
str = GetSubStr( destructible_event, 23 /* strlen( simple_timed_explosion ) */ );
|
||||
tokens = StrTok( str, "_" );
|
||||
|
||||
for ( i = 0; i < tokens.size; i++ )
|
||||
{
|
||||
wait_times[ wait_times.size ] = Int( tokens[i] );
|
||||
}
|
||||
|
||||
if ( wait_times.size <= 0 )
|
||||
{
|
||||
wait_times[ 0 ] = 5;
|
||||
wait_times[ 1 ] = 10;
|
||||
}
|
||||
|
||||
wait( RandomIntRange( wait_times[0], wait_times[1] ) );
|
||||
simple_explosion( attacker );
|
||||
}
|
||||
|
||||
function complex_explosion( attacker, max_radius )
|
||||
{
|
||||
offset = (0, 0, 5);
|
||||
|
||||
if( isdefined( attacker ) )
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, max_radius, 300, 100, attacker );
|
||||
}
|
||||
else
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, max_radius, 300, 100 );
|
||||
}
|
||||
|
||||
physics_explosion_and_rumble( self.origin, max_radius, true );
|
||||
if( isdefined( attacker ) )
|
||||
{
|
||||
self DoDamage( 20000, self.origin + offset, attacker );
|
||||
}
|
||||
else
|
||||
{
|
||||
self DoDamage( 20000, self.origin + offset );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function car_explosion( attacker, physics_explosion )
|
||||
{
|
||||
if ( isdefined( self.car_dead ) && self.car_dead )
|
||||
{
|
||||
// prevents recursive entry caused by DoDamage call below
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isdefined( physics_explosion ) )
|
||||
{
|
||||
physics_explosion = true;
|
||||
}
|
||||
|
||||
self notify( "car_dead" );
|
||||
self.car_dead = true;
|
||||
|
||||
if ( isdefined( attacker ))
|
||||
{
|
||||
self RadiusDamage( self.origin, 256, 300, 75, attacker, "MOD_EXPLOSIVE", GetWeapon( "destructible_car" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
self RadiusDamage( self.origin, 256, 300, 75 );
|
||||
}
|
||||
|
||||
physics_explosion_and_rumble( self.origin, 255, physics_explosion );
|
||||
|
||||
if ( isdefined ( attacker ) )
|
||||
attacker thread challenges::destroyed_car();
|
||||
|
||||
level.globalCarsDestroyed++;
|
||||
if ( isdefined ( attacker ) )
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + (0, 0, 1), attacker );
|
||||
}
|
||||
else
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + (0, 0, 1));
|
||||
}
|
||||
|
||||
self MarkDestructibleDestroyed();
|
||||
}
|
||||
|
||||
function tank_grenade_stuck_think()
|
||||
{
|
||||
self endon( "destructible_base_piece_death" );
|
||||
self endon( "death" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "grenade_stuck", missile );
|
||||
|
||||
if ( !IsDefined( missile ) || !IsDefined( missile.model ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( missile.model == "t5_weapon_crossbow_bolt" || missile.model == "t6_wpn_grenade_semtex_projectile" || missile.model == "wpn_t7_c4_world" )
|
||||
{
|
||||
self thread tank_grenade_stuck_explode( missile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tank_grenade_stuck_explode( missile )
|
||||
{
|
||||
self endon( "destructible_base_piece_death" );
|
||||
self endon( "death" );
|
||||
|
||||
owner = GetMissileOwner( missile );
|
||||
|
||||
if ( IsDefined( owner ) && missile.model == "wpn_t7_c4_world" )
|
||||
{
|
||||
owner endon( "disconnect" );
|
||||
owner endon( "weapon_object_destroyed" );
|
||||
missile endon( "picked_up" );
|
||||
|
||||
missile thread tank_hacked_c4( self );
|
||||
}
|
||||
|
||||
missile waittill( "explode" );
|
||||
|
||||
if ( IsDefined( owner ) )
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + (0, 0, 1), owner );
|
||||
}
|
||||
else
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + (0, 0, 1) );
|
||||
}
|
||||
}
|
||||
|
||||
function tank_hacked_c4( tank )
|
||||
{
|
||||
tank endon( "destructible_base_piece_death" );
|
||||
tank endon( "death" );
|
||||
self endon( "death" );
|
||||
|
||||
self waittill( "hacked" );
|
||||
|
||||
self notify( "picked_up" );
|
||||
tank thread tank_grenade_stuck_explode( self );
|
||||
}
|
||||
|
||||
function car_death_think()
|
||||
{
|
||||
self endon( "car_dead" );
|
||||
self.car_dead = false;
|
||||
|
||||
self thread car_death_notify();
|
||||
|
||||
self waittill( "destructible_base_piece_death", attacker );
|
||||
|
||||
if ( isdefined( self ) )
|
||||
{
|
||||
self thread car_explosion( attacker, false );
|
||||
}
|
||||
}
|
||||
|
||||
function car_grenade_stuck_think()
|
||||
{
|
||||
self endon( "destructible_base_piece_death" );
|
||||
self endon( "car_dead" );
|
||||
self endon( "death" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "grenade_stuck", missile );
|
||||
|
||||
if ( !isdefined( missile ) || !isdefined( missile.model ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( missile.model == "t5_weapon_crossbow_bolt" || missile.model == "t6_wpn_grenade_semtex_projectile" || missile.model == "wpn_t7_c4_world" )
|
||||
{
|
||||
self thread car_grenade_stuck_explode( missile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function car_grenade_stuck_explode( missile )
|
||||
{
|
||||
self endon( "destructible_base_piece_death" );
|
||||
self endon( "car_dead" );
|
||||
self endon( "death" );
|
||||
|
||||
owner = GetMissileOwner( missile );
|
||||
|
||||
if ( isdefined( owner ) && missile.model == "wpn_t7_c4_world" )
|
||||
{
|
||||
owner endon( "disconnect" );
|
||||
owner endon( "weapon_object_destroyed" );
|
||||
missile endon( "picked_up" );
|
||||
|
||||
missile thread car_hacked_c4( self );
|
||||
}
|
||||
|
||||
missile waittill( "explode" );
|
||||
|
||||
if ( isdefined( owner ) )
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + (0, 0, 1), owner );
|
||||
}
|
||||
else
|
||||
{
|
||||
self DoDamage( self.health + 10000, self.origin + (0, 0, 1) );
|
||||
}
|
||||
}
|
||||
|
||||
function car_hacked_c4( car )
|
||||
{
|
||||
car endon( "destructible_base_piece_death" );
|
||||
car endon( "car_dead" );
|
||||
car endon( "death" );
|
||||
self endon( "death" );
|
||||
|
||||
self waittill( "hacked" );
|
||||
|
||||
self notify( "picked_up" );
|
||||
car thread car_grenade_stuck_explode( self );
|
||||
}
|
||||
|
||||
function car_death_notify()
|
||||
{
|
||||
self endon( "car_dead" );
|
||||
|
||||
self waittill( "death", attacker );
|
||||
self notify( "destructible_base_piece_death", attacker );
|
||||
}
|
||||
|
||||
function car_fire_think(attacker)
|
||||
{
|
||||
self endon( "death" );
|
||||
|
||||
wait( RandomIntRange( 7, 10 ) );
|
||||
|
||||
self thread car_explosion( attacker );
|
||||
}
|
||||
|
||||
function CodeCallback_DestructibleEvent( event, param1, param2, param3, param4 )
|
||||
{
|
||||
if( event == "broken" )
|
||||
{
|
||||
notify_type = param1;
|
||||
attacker = param2;
|
||||
piece = param3;
|
||||
weapon = param4;
|
||||
|
||||
event_callback( notify_type, attacker, weapon );
|
||||
|
||||
self notify( event, notify_type, attacker );
|
||||
}
|
||||
else if( event == "breakafter" )
|
||||
{
|
||||
piece = param1;
|
||||
time = param2;
|
||||
damage = param3;
|
||||
self thread breakAfter( time, damage, piece );
|
||||
}
|
||||
}
|
||||
|
||||
function breakAfter( time, damage, piece )
|
||||
{
|
||||
self notify( "breakafter" );
|
||||
self endon( "breakafter" );
|
||||
|
||||
wait time;
|
||||
|
||||
// this does not work in mp. DoDamage does not take a piece for mp.
|
||||
self dodamage( damage, self.origin, undefined, /*piece*/undefined );
|
||||
}
|
||||
|
||||
function explosive_incendiary_explosion( attacker, explosion_radius, physics_explosion )
|
||||
{
|
||||
if ( !IsVehicle( self ) )
|
||||
{
|
||||
offset = (0, 0, 5);
|
||||
if ( isdefined( attacker ))
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, explosion_radius, 256, 75, attacker, "MOD_BURNED", GetWeapon( "incendiary_fire" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, explosion_radius, 256, 75 );
|
||||
}
|
||||
physics_explosion_and_rumble( self.origin, 255, physics_explosion );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// delete the clip that is attached
|
||||
if( isdefined( self.target ) )
|
||||
{
|
||||
dest_clip = GetEnt( self.target, "targetname" );
|
||||
if( isDefined( dest_clip ) )
|
||||
{
|
||||
dest_clip delete();
|
||||
}
|
||||
}
|
||||
|
||||
self MarkDestructibleDestroyed();
|
||||
}
|
||||
|
||||
function explosive_electrical_explosion( attacker, explosion_radius, physics_explosion )
|
||||
{
|
||||
if ( !IsVehicle( self ) )
|
||||
{
|
||||
offset = (0, 0, 5);
|
||||
if ( isdefined( attacker ))
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, explosion_radius, 256, 75, attacker, "MOD_ELECTROCUTED" );
|
||||
}
|
||||
else
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, explosion_radius, 256, 75 );
|
||||
}
|
||||
physics_explosion_and_rumble( self.origin, 255, physics_explosion );
|
||||
}
|
||||
|
||||
|
||||
// delete the clip that is attached
|
||||
if( isdefined( self.target ) )
|
||||
{
|
||||
dest_clip = GetEnt( self.target, "targetname" );
|
||||
if( isDefined( dest_clip ) )
|
||||
{
|
||||
dest_clip delete();
|
||||
}
|
||||
}
|
||||
|
||||
self MarkDestructibleDestroyed();
|
||||
}
|
||||
|
||||
function explosive_concussive_explosion( attacker, explosion_radius, physics_explosion )
|
||||
{
|
||||
if ( !IsVehicle( self ) )
|
||||
{
|
||||
offset = (0, 0, 5);
|
||||
if ( isdefined( attacker ))
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, explosion_radius, 256, 75, attacker, "MOD_GRENADE" );
|
||||
}
|
||||
else
|
||||
{
|
||||
self RadiusDamage( self.origin + offset, explosion_radius, 256, 75 );
|
||||
}
|
||||
physics_explosion_and_rumble( self.origin, 255, physics_explosion );
|
||||
}
|
||||
|
||||
|
||||
// delete the clip that is attached
|
||||
if( isdefined( self.target ) )
|
||||
{
|
||||
dest_clip = GetEnt( self.target, "targetname" );
|
||||
if( isDefined( dest_clip ) )
|
||||
{
|
||||
dest_clip delete();
|
||||
}
|
||||
}
|
||||
|
||||
self MarkDestructibleDestroyed();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+915
@@ -0,0 +1,915 @@
|
||||
#using scripts\codescripts\struct;
|
||||
|
||||
#using scripts\shared\array_shared;
|
||||
#using scripts\shared\flag_shared;
|
||||
#using scripts\shared\callbacks_shared;
|
||||
#using scripts\shared\dev_shared;
|
||||
#using scripts\shared\killstreaks_shared;
|
||||
#using scripts\shared\load_shared;
|
||||
#using scripts\shared\system_shared;
|
||||
#using scripts\shared\util_shared;
|
||||
#using scripts\shared\weapons_shared;
|
||||
#using scripts\shared\weapons\_weapons;
|
||||
#using scripts\shared\vehicle_ai_shared;
|
||||
#using scripts\shared\vehicle_shared;
|
||||
#using scripts\mp\_vehicle;
|
||||
|
||||
Line truncated
|
||||
|
||||
#using scripts\mp\killstreaks\_killstreaks;
|
||||
#using scripts\shared\bots\_bot;
|
||||
|
||||
/#
|
||||
|
||||
#namespace devgui;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function autoexec __init__sytem__() { system::register("devgui",&__init__,undefined,undefined); }
|
||||
|
||||
function __init__()
|
||||
{
|
||||
SetDvar( "mp_weap_devgui", "" );
|
||||
SetDvar( "debug_center_screen", 0 );
|
||||
SetDvar( "mp_lockspawn_command_devgui", 0 );
|
||||
SetDvar( "mp_weap_use_give_console_command_devgui", 0 );
|
||||
SetDvar( "mp_weap_asset_name_display_devgui", 0 );
|
||||
SetDvar( "mp_weap_attachment_cosmetic_variant_index_devgui", 0 );
|
||||
SetDvar( "mp_weap_attachment_cosmetic_variant_attachment_1_devgui", "none" );
|
||||
SetDvar( "mp_weap_attachment_cosmetic_variant_attachment_2_devgui", "none" );
|
||||
|
||||
SetDvar( "mp_attachment_cycling_state_devgui", "none" );
|
||||
|
||||
SetDvar( "mp_attachment_cycling_1_devgui", "none" );
|
||||
SetDvar( "mp_attachment_cycling_2_devgui", "none" );
|
||||
SetDvar( "mp_attachment_cycling_3_devgui", "none" );
|
||||
SetDvar( "mp_attachment_cycling_4_devgui", "none" );
|
||||
SetDvar( "mp_attachment_cycling_5_devgui", "none" );
|
||||
SetDvar( "mp_attachment_cycling_6_devgui", "none" );
|
||||
|
||||
level.attachment_cycling_dvars = [];
|
||||
level.attachment_cycling_dvars[level.attachment_cycling_dvars.size] = "mp_attachment_cycling_1_devgui";
|
||||
level.attachment_cycling_dvars[level.attachment_cycling_dvars.size] = "mp_attachment_cycling_2_devgui";
|
||||
level.attachment_cycling_dvars[level.attachment_cycling_dvars.size] = "mp_attachment_cycling_3_devgui";
|
||||
level.attachment_cycling_dvars[level.attachment_cycling_dvars.size] = "mp_attachment_cycling_4_devgui";
|
||||
level.attachment_cycling_dvars[level.attachment_cycling_dvars.size] = "mp_attachment_cycling_5_devgui";
|
||||
level.attachment_cycling_dvars[level.attachment_cycling_dvars.size] = "mp_attachment_cycling_6_devgui";
|
||||
|
||||
SetDvar( "mp_acv_cycling_1_devgui", 0 );
|
||||
SetDvar( "mp_acv_cycling_2_devgui", 0 );
|
||||
SetDvar( "mp_acv_cycling_3_devgui", 0 );
|
||||
SetDvar( "mp_acv_cycling_4_devgui", 0 );
|
||||
SetDvar( "mp_acv_cycling_5_devgui", 0 );
|
||||
SetDvar( "mp_acv_cycling_6_devgui", 0 );
|
||||
|
||||
level.acv_cycling_dvars = [];
|
||||
level.acv_cycling_dvars[level.acv_cycling_dvars.size] = "mp_acv_cycling_1_devgui";
|
||||
level.acv_cycling_dvars[level.acv_cycling_dvars.size] = "mp_acv_cycling_2_devgui";
|
||||
level.acv_cycling_dvars[level.acv_cycling_dvars.size] = "mp_acv_cycling_3_devgui";
|
||||
level.acv_cycling_dvars[level.acv_cycling_dvars.size] = "mp_acv_cycling_4_devgui";
|
||||
level.acv_cycling_dvars[level.acv_cycling_dvars.size] = "mp_acv_cycling_5_devgui";
|
||||
level.acv_cycling_dvars[level.acv_cycling_dvars.size] = "mp_acv_cycling_6_devgui";
|
||||
|
||||
level thread devgui_weapon_think();
|
||||
level thread devgui_weapon_asset_name_display_think();
|
||||
level thread devgui_player_weapons();
|
||||
level thread devgui_test_chart_think();
|
||||
level thread devgui_player_spawn_think();
|
||||
level thread devgui_vehicle_spawn_think();
|
||||
|
||||
// center lines for making sure the gun aims properly
|
||||
thread init_debug_center_screen();
|
||||
|
||||
level thread dev::body_customization_devgui( 1 );
|
||||
|
||||
callback::on_connect( &hero_art_on_player_connect );
|
||||
callback::on_connect( &on_player_connect );
|
||||
}
|
||||
|
||||
function on_player_connect()
|
||||
{
|
||||
/#
|
||||
self.devguiLockSpawn = false;
|
||||
self thread devgui_player_spawn();
|
||||
#/
|
||||
}
|
||||
|
||||
function devgui_player_spawn()
|
||||
{
|
||||
wait(1);
|
||||
|
||||
player_devgui_base_mp = "devgui_cmd \"Player/Lock Spawn/";
|
||||
|
||||
{wait(.05);}; // so we don't overflow the Cbuf_InsertText()
|
||||
|
||||
players = GetPlayers();
|
||||
foreach( player in players )
|
||||
{
|
||||
if ( player != self )
|
||||
continue;
|
||||
|
||||
temp = player_devgui_base_mp + player.playername + "\" \"set " + "mp_lockspawn_command_devgui" + " " + player.playername + "\"\n";
|
||||
|
||||
AddDebugCommand( player_devgui_base_mp + player.playername + "\" \"set " + "mp_lockspawn_command_devgui" + " " + player.playername + "\"\n");
|
||||
}
|
||||
}
|
||||
|
||||
function devgui_player_spawn_think()
|
||||
{
|
||||
for ( ;; )
|
||||
{
|
||||
playername = GetDvarString( "mp_lockspawn_command_devgui" );
|
||||
if (playername=="")
|
||||
{
|
||||
{wait(.05);};
|
||||
continue;
|
||||
}
|
||||
|
||||