UGX-Mods

Call of Duty 5: World at War => Tutorial Desk => Scripting => Topic started by: SparkyMcSparks on June 03, 2014, 09:41:06 pm

Title: [Tutorial] Zombie History Debugging
Post by: SparkyMcSparks on June 03, 2014, 09:41:06 pm
What is Zombie History?
Every time a Zombie is instructed to do something it is logged in the Zombie History for each individual zombie. Normally this is seen through a debugger, but I made a function to print it out in-game.

How Do I View Zombie History?
You'll want to add this line somewhere in your scripts, even the map script is fine:
Code Snippet
Plaintext
array_thread( GetSpawnerArray(), ::add_spawn_function, ::zombie_history_print );

Here is the function I wrote that you'll need to copy and paste, I put it in _zombiemode_utility.gsc since almost every script includes it:
Code Snippet
Plaintext
zombie_history_print()
{
/#
self endon( "death" );

if ( !IsDefined( self.zombie_history ) )
{
self.zombie_history = [];
}

last_zombie_history_size = 0;

while ( true )
{
max_prints = GetDvarInt( "zombie_history_debug" );

if ( self.zombie_history.size != last_zombie_history_size )
{
last_zombie_history_size = self.zombie_history.size;
prints = 0;

for ( x = self.zombie_history.size; x > 0; x-- )
{
if ( IsDefined( self.zombie_history[ x ] ) && prints < max_prints )
{
thread print3d_at_pos( self.zombie_history[ x ], undefined, "update_zombie_history_" + prints, ( 0, 0, 64 + prints * 10 ) );
prints++;
}
}
}

wait ( 0.05 );
}
#/
}

Then after, you'll want to toggle the DVAR "zombie_history_debug" to any number of history events you want to see. It'll print the most recent at the bottom, like the console.

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FtKlCJUG.jpg&hash=e93bc0e51d794ee83c2d0e3146cc259a6641375f)

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FTKhu6tj.jpg&hash=a858ce7d6f5dd9fdec4bf62fccb8aa3e12703d77)

How Can I Log My Own Events?
Stock scripts already log events for you, but if you want to log your own you'd want to do something like:
Code Snippet
Plaintext
self zombie_history( "zombie_assure_node -> failed to find a good entrance point" );

Call it on a Zombie AI and the first and only parameter is a message (usually is the function name the log is in and some helpful description about what is happening).
Title: Re: [Tutorial] Zombie History Debugging
Post by: RamboBadass on June 12, 2014, 10:36:25 pm
cool thanks man !!!