mirror of
https://github.com/JezuzLizard/Recompilable-gscs-for-BO2-zombies-and-multiplayer.git
synced 2025-06-11 03:07:57 -05:00
Reorganized the scripts so its easier to search thru.
This commit is contained in:
216
Zombie Core/common_zm/codescripts/character.gsc
Normal file
216
Zombie Core/common_zm/codescripts/character.gsc
Normal file
@ -0,0 +1,216 @@
|
||||
|
||||
setmodelfromarray( a )
|
||||
{
|
||||
self setmodel( a[ randomint( a.size ) ] );
|
||||
}
|
||||
|
||||
precachemodelarray( a )
|
||||
{
|
||||
i = 0;
|
||||
while ( i < a.size )
|
||||
{
|
||||
precachemodel( a[ i ] );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
randomelement( a )
|
||||
{
|
||||
return a[ randomint( a.size ) ];
|
||||
}
|
||||
|
||||
attachfromarray( a )
|
||||
{
|
||||
self attach( randomelement( a ), "", 1 );
|
||||
}
|
||||
|
||||
new()
|
||||
{
|
||||
self detachall();
|
||||
oldgunhand = self.anim_gunhand;
|
||||
if ( !isDefined( oldgunhand ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
self.anim_gunhand = "none";
|
||||
self [[ anim.putguninhand ]]( oldgunhand );
|
||||
}
|
||||
|
||||
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();
|
||||
i = 0;
|
||||
while ( i < attachsize )
|
||||
{
|
||||
info[ "attach" ][ i ][ "model" ] = self getattachmodelname( i );
|
||||
info[ "attach" ][ i ][ "tag" ] = self getattachtagname( i );
|
||||
i++;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
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;
|
||||
i = 0;
|
||||
while ( i < attachsize )
|
||||
{
|
||||
self attach( attachinfo[ i ][ "model" ], attachinfo[ i ][ "tag" ] );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
precache( info )
|
||||
{
|
||||
if ( isDefined( info[ "name" ] ) )
|
||||
{
|
||||
/#
|
||||
println( "Precache: Guy has name ", info[ "name" ] );
|
||||
#/
|
||||
}
|
||||
else
|
||||
{
|
||||
/#
|
||||
println( "Precache: Guy had no name!" );
|
||||
#/
|
||||
}
|
||||
precachemodel( info[ "model" ] );
|
||||
attachinfo = info[ "attach" ];
|
||||
attachsize = attachinfo.size;
|
||||
i = 0;
|
||||
while ( i < attachsize )
|
||||
{
|
||||
precachemodel( attachinfo[ i ][ "model" ] );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
get_random_character( amount )
|
||||
{
|
||||
self_info = strtok( self.classname, "_" );
|
||||
if ( self_info.size <= 2 )
|
||||
{
|
||||
return randomint( amount );
|
||||
}
|
||||
group = "auto";
|
||||
index = undefined;
|
||||
prefix = self_info[ 2 ];
|
||||
if ( isDefined( self.script_char_index ) )
|
||||
{
|
||||
index = self.script_char_index;
|
||||
}
|
||||
if ( isDefined( self.script_char_group ) )
|
||||
{
|
||||
type = "grouped";
|
||||
group = "group_" + self.script_char_group;
|
||||
}
|
||||
if ( !isDefined( level.character_index_cache ) )
|
||||
{
|
||||
level.character_index_cache = [];
|
||||
}
|
||||
if ( !isDefined( level.character_index_cache[ prefix ] ) )
|
||||
{
|
||||
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 ) )
|
||||
{
|
||||
index = randomint( 5000 );
|
||||
}
|
||||
}
|
||||
while ( index >= amount )
|
||||
{
|
||||
index -= amount;
|
||||
}
|
||||
level.character_index_cache[ prefix ][ group ][ index ]++;
|
||||
return index;
|
||||
}
|
||||
|
||||
get_least_used_index( prefix, group )
|
||||
{
|
||||
lowest_indices = [];
|
||||
lowest_use = level.character_index_cache[ prefix ][ group ][ 0 ];
|
||||
lowest_indices[ 0 ] = 0;
|
||||
i = 1;
|
||||
while ( i < level.character_index_cache[ prefix ][ group ].size )
|
||||
{
|
||||
if ( level.character_index_cache[ prefix ][ group ][ i ] > lowest_use )
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( level.character_index_cache[ prefix ][ group ][ i ] < lowest_use )
|
||||
{
|
||||
lowest_indices = [];
|
||||
lowest_use = level.character_index_cache[ prefix ][ group ][ i ];
|
||||
}
|
||||
lowest_indices[ lowest_indices.size ] = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/#
|
||||
assert( lowest_indices.size, "Tried to spawn a character but the lowest indices didn't exist" );
|
||||
#/
|
||||
return random( lowest_indices );
|
||||
}
|
||||
|
||||
initialize_character_group( prefix, group, amount )
|
||||
{
|
||||
i = 0;
|
||||
while ( i < amount )
|
||||
{
|
||||
level.character_index_cache[ prefix ][ group ][ i ] = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
random( array )
|
||||
{
|
||||
return array[ randomint( array.size ) ];
|
||||
}
|
23
Zombie Core/common_zm/codescripts/delete.gsc
Normal file
23
Zombie Core/common_zm/codescripts/delete.gsc
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
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 );
|
||||
println( "" );
|
||||
#/
|
||||
}
|
||||
}
|
||||
self delete();
|
||||
}
|
||||
}
|
41
Zombie Core/common_zm/codescripts/struct.gsc
Normal file
41
Zombie Core/common_zm/codescripts/struct.gsc
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
initstructs()
|
||||
{
|
||||
level.struct = [];
|
||||
}
|
||||
|
||||
createstruct()
|
||||
{
|
||||
struct = spawnstruct();
|
||||
level.struct[ level.struct.size ] = struct;
|
||||
return struct;
|
||||
}
|
||||
|
||||
findstruct( position )
|
||||
{
|
||||
_a20 = level.struct_class_names;
|
||||
key = getFirstArrayKey( _a20 );
|
||||
while ( isDefined( key ) )
|
||||
{
|
||||
_ = _a20[ key ];
|
||||
_a22 = level.struct_class_names[ key ];
|
||||
val = getFirstArrayKey( _a22 );
|
||||
while ( isDefined( val ) )
|
||||
{
|
||||
s_array = _a22[ val ];
|
||||
_a24 = s_array;
|
||||
_k24 = getFirstArrayKey( _a24 );
|
||||
while ( isDefined( _k24 ) )
|
||||
{
|
||||
struct = _a24[ _k24 ];
|
||||
if ( distancesquared( struct.origin, position ) < 1 )
|
||||
{
|
||||
return struct;
|
||||
}
|
||||
_k24 = getNextArrayKey( _a24, _k24 );
|
||||
}
|
||||
val = getNextArrayKey( _a22, val );
|
||||
}
|
||||
key = getNextArrayKey( _a20, key );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user