add processrate to objs

This commit is contained in:
ineed bots 2023-07-13 02:21:14 -06:00
parent 7c9f6fca11
commit 1302a40869
2 changed files with 20 additions and 16 deletions

View File

@ -6,8 +6,8 @@
init() init()
{ {
level.bot_objectives = []; level.bot_objectives = [];
level.bot_objectives[level.bot_objectives.size] = CreateObjectiveForManger( "revive", maps\bots\objectives\_revive::Finder, maps\bots\objectives\_revive::Executer, maps\bots\objectives\_revive::Priority ); level.bot_objectives[level.bot_objectives.size] = CreateObjectiveForManger( "revive", maps\bots\objectives\_revive::Finder, maps\bots\objectives\_revive::Executer, maps\bots\objectives\_revive::Priority, 1000 );
level.bot_objectives[level.bot_objectives.size] = CreateObjectiveForManger( "powerup", maps\bots\objectives\_powerup::Finder, maps\bots\objectives\_powerup::Executer, maps\bots\objectives\_powerup::Priority ); level.bot_objectives[level.bot_objectives.size] = CreateObjectiveForManger( "powerup", maps\bots\objectives\_powerup::Finder, maps\bots\objectives\_powerup::Executer, maps\bots\objectives\_powerup::Priority, 2500 );
} }
connected() connected()
@ -59,6 +59,8 @@ clean_objective_on_completion()
if ( isDefined( self.bot_current_objective ) ) if ( isDefined( self.bot_current_objective ) )
{ {
obj_name = self.bot_current_objective.sName; obj_name = self.bot_current_objective.sName;
self.bot_current_objective.eParentObj.aBotProcessTimes[self GetEntityNumber() + ""] = getTime();
} }
PrintConsole( "clean_objective_on_completion: " + self.playername + ": " + obj_name + ": " + successful + ": " + reason ); PrintConsole( "clean_objective_on_completion: " + self.playername + ": " + obj_name + ": " + successful + ": " + reason );
@ -89,12 +91,21 @@ bot_objective_think()
// find all avail objectives // find all avail objectives
objectives = []; objectives = [];
now = getTime();
our_key = self GetEntityNumber() + "";
for ( i = 0; i < level.bot_objectives.size; i++ ) for ( i = 0; i < level.bot_objectives.size; i++ )
{ {
objective = level.bot_objectives[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 ) ); objectives = array_merge( objectives, self [[objective.fpFinder]]( objective ) );
objective.aBotProcessTimes[our_key] = now;
} }
if ( objectives.size <= 0 ) if ( objectives.size <= 0 )
@ -135,6 +146,7 @@ bot_objective_think()
self waittill( "completed_bot_objective" ); self waittill( "completed_bot_objective" );
// redo the loop, should do the obj next iteration // redo the loop, should do the obj next iteration
best_prio.eParentObj.aBotProcessTimes[our_key] = undefined;
continue; continue;
} }

View File

@ -2,22 +2,17 @@
#include maps\_utility; #include maps\_utility;
#include maps\bots\_bot_utility; #include maps\bots\_bot_utility;
CreateObjectiveForManger( sName, fpFinder, fpExecuter, fpPriority ) CreateObjectiveForManger( sName, fpFinder, fpExecuter, fpPriority, iProcessRate )
{ {
Answer = SpawnStruct(); Answer = SpawnStruct();
Answer.sName = sName; Answer.sName = sName;
Answer.fpFinder = fpFinder; Answer.fpFinder = fpFinder;
Answer.fpExecuter = fpExecuter; Answer.fpExecuter = fpExecuter;
Answer.fpPriority = fpPriority;
if ( !IsDefined( fpPriority ) ) Answer.aBotProcessTimes = [];
{ Answer.iProcessRate = iProcessRate;
Answer.fpPriority = ::DefaultPriority;
}
else
{
Answer.fpPriority = fpPriority;
}
return Answer; return Answer;
} }
@ -38,11 +33,6 @@ CreateFinderObjective( eObj, sName, eEnt, fPriority )
return Answer; return Answer;
} }
DefaultPriority( eObj, eEnt )
{
return 0;
}
/* /*
Checks whether the path generated by the ASTAR path finding is inaccessible Checks whether the path generated by the ASTAR path finding is inaccessible
*/ */
@ -168,10 +158,12 @@ get_angle_offset_node( forward_size, angle_offset, offset )
{ {
forward_size = 40; forward_size = 40;
} }
if ( !isDefined( angle_offset ) ) if ( !isDefined( angle_offset ) )
{ {
angle_offset = ( 0, 0, 0 ); angle_offset = ( 0, 0, 0 );
} }
if ( !isDefined( offset ) ) if ( !isDefined( offset ) )
{ {
offset = ( 0, 0, 0 ); offset = ( 0, 0, 0 );