mirror of
https://github.com/JezuzLizard/t4sp_bot_warfare.git
synced 2025-10-29 08:56:56 +00:00
fmt
This commit is contained in:
@@ -22,7 +22,7 @@ connected()
|
||||
spawned()
|
||||
{
|
||||
self.bot_current_objective = undefined;
|
||||
|
||||
|
||||
self thread clean_objective_on_completion();
|
||||
self thread watch_for_objective_canceled();
|
||||
}
|
||||
@@ -32,18 +32,18 @@ watch_for_objective_canceled()
|
||||
self endon( "disconnect" );
|
||||
level endon( "intermission" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "cancel_bot_objective", reason );
|
||||
|
||||
|
||||
obj_name = "undefined";
|
||||
|
||||
|
||||
if ( isdefined( self.bot_current_objective ) )
|
||||
{
|
||||
obj_name = self.bot_current_objective.sname;
|
||||
}
|
||||
|
||||
|
||||
self BotNotifyBotEvent( "debug", "watch_for_objective_canceled: " + obj_name + ": " + reason );
|
||||
}
|
||||
}
|
||||
@@ -53,22 +53,22 @@ clean_objective_on_completion()
|
||||
self endon( "disconnect" );
|
||||
level endon( "intermission" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "completed_bot_objective", successful, reason );
|
||||
|
||||
|
||||
obj_name = "undefined";
|
||||
|
||||
|
||||
if ( isdefined( self.bot_current_objective ) )
|
||||
{
|
||||
obj_name = self.bot_current_objective.sname;
|
||||
|
||||
|
||||
self.bot_current_objective.eparentobj.abotprocesstimes[ self getentitynumber() + "" ] = gettime();
|
||||
}
|
||||
|
||||
|
||||
self BotNotifyBotEvent( "debug", "clean_objective_on_completion: " + obj_name + ": " + successful + ": " + reason );
|
||||
|
||||
|
||||
waittillframeend;
|
||||
self.bot_current_objective = undefined;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ start_bot_threads()
|
||||
self endon( "disconnect" );
|
||||
level endon( "intermission" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
self thread bot_objective_think();
|
||||
}
|
||||
|
||||
@@ -88,80 +88,80 @@ bot_objective_think()
|
||||
self endon( "disconnect" );
|
||||
level endon( "intermission" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 1;
|
||||
|
||||
|
||||
// find all avail objectives
|
||||
objectives = [];
|
||||
now = gettime();
|
||||
our_key = self getentitynumber() + "";
|
||||
|
||||
|
||||
for ( i = 0; i < level.bot_objectives.size; i++ )
|
||||
{
|
||||
objective = level.bot_objectives[ i ];
|
||||
|
||||
|
||||
// check the process rate
|
||||
if ( isdefined( objective.abotprocesstimes[ our_key ] ) && now - objective.abotprocesstimes[ our_key ] < objective.iprocessrate )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
objectives = array_merge( objectives, self [[ objective.fpfinder ]]( objective ) );
|
||||
objective.abotprocesstimes[ our_key ] = now;
|
||||
}
|
||||
|
||||
|
||||
if ( objectives.size <= 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// sort according to priority
|
||||
heap = NewHeap( ::HeapPriority );
|
||||
|
||||
|
||||
for ( i = 0; i < objectives.size; i++ )
|
||||
{
|
||||
if ( objectives[ i ].fpriority <= -100 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
heap HeapInsert( objectives[ i ] );
|
||||
}
|
||||
|
||||
|
||||
// pop the top!
|
||||
best_prio = heap.data[ 0 ];
|
||||
|
||||
|
||||
if ( !isdefined( best_prio ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// already on a better obj
|
||||
if ( isdefined( self.bot_current_objective ) && ( best_prio.guid == self.bot_current_objective.guid || best_prio.fpriority < self [[ self.bot_current_objective.eparentobj.fppriorty ]]( self.bot_current_objective.eparentobj, self.bot_current_objective.eent ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// DO THE OBJ
|
||||
// cancel the old obj
|
||||
if ( isdefined( self.bot_current_objective ) )
|
||||
{
|
||||
// cancel it
|
||||
self CancelObjective( "new obj: " + best_prio.sname );
|
||||
|
||||
|
||||
// wait for it to clean up
|
||||
self waittill( "completed_bot_objective" );
|
||||
|
||||
|
||||
// redo the loop, should do the obj next iteration
|
||||
best_prio.eparentobj.abotprocesstimes[ our_key ] = undefined;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// ready to execute
|
||||
self BotNotifyBotEvent( "debug", "bot_objective_think: " + best_prio.sname );
|
||||
|
||||
|
||||
self.bot_current_objective = best_prio;
|
||||
self thread [[ best_prio.eparentobj.fpexecuter ]]( best_prio );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user