From 1302a408697c7508b0368c01ef3ad59f876334e4 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 13 Jul 2023 02:21:14 -0600 Subject: [PATCH] add processrate to objs --- maps/bots/objectives/_manager.gsc | 16 ++++++++++++++-- maps/bots/objectives/_utility.gsc | 20 ++++++-------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/maps/bots/objectives/_manager.gsc b/maps/bots/objectives/_manager.gsc index 1133ad4..1a6dfa1 100644 --- a/maps/bots/objectives/_manager.gsc +++ b/maps/bots/objectives/_manager.gsc @@ -6,8 +6,8 @@ init() { 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( "powerup", maps\bots\objectives\_powerup::Finder, maps\bots\objectives\_powerup::Executer, maps\bots\objectives\_powerup::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, 2500 ); } connected() @@ -59,6 +59,8 @@ clean_objective_on_completion() if ( isDefined( self.bot_current_objective ) ) { 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 ); @@ -89,12 +91,21 @@ bot_objective_think() // 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 ) @@ -135,6 +146,7 @@ bot_objective_think() self waittill( "completed_bot_objective" ); // redo the loop, should do the obj next iteration + best_prio.eParentObj.aBotProcessTimes[our_key] = undefined; continue; } diff --git a/maps/bots/objectives/_utility.gsc b/maps/bots/objectives/_utility.gsc index 6fcebbf..abbcf67 100644 --- a/maps/bots/objectives/_utility.gsc +++ b/maps/bots/objectives/_utility.gsc @@ -2,22 +2,17 @@ #include maps\_utility; #include maps\bots\_bot_utility; -CreateObjectiveForManger( sName, fpFinder, fpExecuter, fpPriority ) +CreateObjectiveForManger( sName, fpFinder, fpExecuter, fpPriority, iProcessRate ) { Answer = SpawnStruct(); Answer.sName = sName; Answer.fpFinder = fpFinder; Answer.fpExecuter = fpExecuter; + Answer.fpPriority = fpPriority; - if ( !IsDefined( fpPriority ) ) - { - Answer.fpPriority = ::DefaultPriority; - } - else - { - Answer.fpPriority = fpPriority; - } + Answer.aBotProcessTimes = []; + Answer.iProcessRate = iProcessRate; return Answer; } @@ -38,11 +33,6 @@ CreateFinderObjective( eObj, sName, eEnt, fPriority ) return Answer; } -DefaultPriority( eObj, eEnt ) -{ - return 0; -} - /* 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; } + if ( !isDefined( angle_offset ) ) { angle_offset = ( 0, 0, 0 ); } + if ( !isDefined( offset ) ) { offset = ( 0, 0, 0 );