mirror of
https://github.com/JezuzLizard/t4sp_bot_warfare.git
synced 2025-06-30 00:01:58 +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 );
|
||||
}
|
||||
|
@ -6,17 +6,17 @@
|
||||
init()
|
||||
{
|
||||
vending_triggers = getentarray( "zombie_vending", "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( vending_triggers ) || vending_triggers.size < 1 )
|
||||
{
|
||||
vending_triggers = getentarray( "harrybo21_perk_trigger", "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( vending_triggers ) || vending_triggers.size < 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ( i = 0 ; i < vending_triggers.size; i++ )
|
||||
{
|
||||
vending_triggers[ i ] thread init_vending_trigger();
|
||||
@ -26,22 +26,22 @@ init()
|
||||
init_vending_trigger()
|
||||
{
|
||||
self endon( "death" );
|
||||
|
||||
|
||||
if ( self.targetname == "harrybo21_perk_trigger" )
|
||||
{
|
||||
machine = self getMachine();
|
||||
|
||||
|
||||
machine waittill( "activate_machine" );
|
||||
|
||||
|
||||
self.bot_powered_on = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
perk = self getVendingPerk();
|
||||
notify_name = perk + "_power_on";
|
||||
|
||||
|
||||
level waittill( notify_name );
|
||||
|
||||
|
||||
self.bot_powered_on = true;
|
||||
}
|
||||
}
|
||||
@ -49,64 +49,64 @@ init_vending_trigger()
|
||||
Finder( eObj )
|
||||
{
|
||||
answer = [];
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
vending_triggers = getentarray( "zombie_vending", "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( vending_triggers ) || vending_triggers.size < 1 )
|
||||
{
|
||||
vending_triggers = getentarray( "harrybo21_perk_trigger", "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( vending_triggers ) || vending_triggers.size < 1 )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ( i = 0 ; i < vending_triggers.size; i++ )
|
||||
{
|
||||
vending = vending_triggers[ i ];
|
||||
|
||||
|
||||
if ( !isdefined( vending.bot_powered_on ) || !vending.bot_powered_on )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
perk = vending getVendingPerk();
|
||||
cost = vending getPerkCost();
|
||||
|
||||
|
||||
if ( self.score < cost )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// perk limit??
|
||||
if ( self hasperk( perk ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
machine = vending getMachine();
|
||||
|
||||
|
||||
if ( !isdefined( machine ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
org = self getOffset( machine );
|
||||
|
||||
|
||||
if ( GetPathIsInaccessible( self.origin, org ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
answer[ answer.size ] = self CreateFinderObjectiveEZ( eObj, vending );
|
||||
}
|
||||
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ getVendingPerk()
|
||||
machine = self getMachine();
|
||||
return machine.script_string;
|
||||
}
|
||||
|
||||
|
||||
return self.script_noteworthy;
|
||||
}
|
||||
|
||||
@ -132,39 +132,39 @@ getPerkCost()
|
||||
{
|
||||
return level.zombie_perks[ self getVendingPerk() ].perk_cost;
|
||||
}
|
||||
|
||||
|
||||
cost = level.zombie_vars[ "zombie_perk_cost" ];
|
||||
|
||||
|
||||
switch ( self getVendingPerk() )
|
||||
{
|
||||
case "specialty_armorvest":
|
||||
cost = 2500;
|
||||
break;
|
||||
|
||||
|
||||
case "specialty_quickrevive":
|
||||
cost = 1500;
|
||||
break;
|
||||
|
||||
|
||||
case "specialty_fastreload":
|
||||
cost = 3000;
|
||||
break;
|
||||
|
||||
|
||||
case "specialty_rof":
|
||||
cost = 2000;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
cost = 10000;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
getOffset( model )
|
||||
{
|
||||
org = model get_angle_offset_node( 40, ( 0, -90, 0 ), ( 0, 0, 1 ) );
|
||||
|
||||
|
||||
return org;
|
||||
}
|
||||
|
||||
@ -173,12 +173,12 @@ Priority( eObj, eEnt )
|
||||
// TODO rank perks
|
||||
base_priority = 2;
|
||||
base_priority += ClampLerp( get_path_dist( self.origin, eEnt.origin ), 500, 1600, 3, 0 );
|
||||
|
||||
|
||||
if ( self HasBotObjective() && self GetBotObjectiveEnt() != eEnt )
|
||||
{
|
||||
base_priority -= 1;
|
||||
}
|
||||
|
||||
|
||||
return base_priority;
|
||||
}
|
||||
|
||||
@ -186,17 +186,17 @@ Executer( eObj )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
vending = eObj.eent;
|
||||
|
||||
|
||||
self thread WatchForCancel( vending );
|
||||
|
||||
|
||||
self GoDoPerkMachine( eObj );
|
||||
|
||||
|
||||
self WatchForCancelCleanup();
|
||||
self ClearScriptAimPos();
|
||||
self ClearScriptGoal();
|
||||
|
||||
|
||||
self CompletedObjective( eObj.bwassuccessful, eObj.sreason );
|
||||
}
|
||||
|
||||
@ -210,11 +210,11 @@ WatchForCancel( vending )
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "WatchForCancelPerkmachine" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
self CancelObjective( "self inLastStand()" );
|
||||
@ -231,11 +231,11 @@ WatchToGoToMachine( vending )
|
||||
self endon( "goal" );
|
||||
self endon( "bad_path" );
|
||||
self endon( "new_goal" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self istouching( vending ) || vending PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
self notify( "goal" );
|
||||
@ -247,40 +247,40 @@ WatchToGoToMachine( vending )
|
||||
GoDoPerkMachine( eObj )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
|
||||
|
||||
vending = eObj.eent;
|
||||
machine = vending getMachine();
|
||||
perk = vending getVendingPerk();
|
||||
org = self getOffset( machine );
|
||||
|
||||
|
||||
// go to machine
|
||||
self thread WatchToGoToMachine( vending );
|
||||
self SetScriptGoal( org, 32 );
|
||||
|
||||
|
||||
result = self waittill_any_return( "goal", "bad_path", "new_goal" );
|
||||
|
||||
|
||||
if ( result != "goal" )
|
||||
{
|
||||
eObj.sreason = "didn't go to machine";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !self istouching( vending ) && !vending PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
eObj.sreason = "not touching machine";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ok we are touching machine, lets look at it
|
||||
self SetScriptAimPos( vending.origin );
|
||||
|
||||
|
||||
// wait to look at it
|
||||
wait 1;
|
||||
|
||||
|
||||
// press use
|
||||
self thread BotPressUse( 0.15 );
|
||||
wait 0.1;
|
||||
|
||||
|
||||
// ok we pressed use, DONE
|
||||
eObj.sreason = "completed " + perk;
|
||||
eObj.bwassuccessful = true;
|
||||
|
@ -6,14 +6,14 @@
|
||||
Finder( eObj )
|
||||
{
|
||||
answer = [];
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
ents = getentarray( "script_model", "classname" );
|
||||
|
||||
|
||||
for ( i = 0; i < ents.size; i++ )
|
||||
{
|
||||
// not a powerup script_model
|
||||
@ -21,22 +21,22 @@ Finder( eObj )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// can we path to it?
|
||||
if ( GetPathIsInaccessible( self.origin, ents[ i ].origin ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// make sure we are the only one going for it
|
||||
if ( self GetBotsAmountForEntity( ents[ i ] ) >= 1 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
answer[ answer.size ] = self CreateFinderObjectiveEZ( eObj, ents[ i ] );
|
||||
}
|
||||
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
@ -45,12 +45,12 @@ Priority( eObj, eEnt )
|
||||
// TODO: check powerup type
|
||||
base_priority = 0;
|
||||
base_priority += ClampLerp( get_path_dist( self.origin, eEnt.origin ), 300, 700, 2, -2 );
|
||||
|
||||
|
||||
if ( self HasBotObjective() && self GetBotObjectiveEnt() != eEnt )
|
||||
{
|
||||
base_priority -= 1;
|
||||
}
|
||||
|
||||
|
||||
return base_priority;
|
||||
}
|
||||
|
||||
@ -58,25 +58,25 @@ Executer( eObj )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
powerup = eObj.eent;
|
||||
org = powerup.origin;
|
||||
|
||||
|
||||
self thread IncrementBotsForEntity( powerup );
|
||||
self thread WatchForCancel( powerup );
|
||||
|
||||
|
||||
self GoDoPowerup( eObj );
|
||||
|
||||
|
||||
self WatchForCancelCleanup();
|
||||
self DecrementBotsForEntity( powerup );
|
||||
self ClearScriptGoal();
|
||||
|
||||
|
||||
if ( distance( org, self.origin ) <= 64 )
|
||||
{
|
||||
eObj.sreason = "completed";
|
||||
eObj.bwassuccessful = true;
|
||||
}
|
||||
|
||||
|
||||
self CompletedObjective( eObj.bwassuccessful, eObj.sreason );
|
||||
}
|
||||
|
||||
@ -90,17 +90,17 @@ WatchForCancel( powerup )
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "WatchForCancelPowerup" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
self CancelObjective( "self inLastStand()" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( !isdefined( powerup ) )
|
||||
{
|
||||
self CancelObjective( "!isdefined( powerup )" );
|
||||
@ -112,31 +112,31 @@ WatchForCancel( powerup )
|
||||
GoDoPowerup( eObj )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
|
||||
|
||||
powerup = eObj.eent;
|
||||
|
||||
|
||||
// go to it
|
||||
self SetScriptGoal( powerup.origin, 32 );
|
||||
|
||||
|
||||
result = self waittill_any_return( "goal", "bad_path", "new_goal" );
|
||||
|
||||
|
||||
if ( result != "goal" )
|
||||
{
|
||||
eObj.sreason = "didn't go to powerup";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !isdefined( powerup ) || !isdefined( powerup.origin ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( distance( powerup.origin, self.origin ) > 64 )
|
||||
{
|
||||
eObj.sreason = "not touching it";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
eObj.sreason = "completed";
|
||||
eObj.bwassuccessful = true;
|
||||
}
|
||||
|
@ -7,49 +7,49 @@ Finder( eObj )
|
||||
{
|
||||
Players = get_players();
|
||||
Answer = [];
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
return Answer;
|
||||
}
|
||||
|
||||
|
||||
for ( i = 0; i < Players.size; i++ )
|
||||
{
|
||||
Player = Players[ i ];
|
||||
|
||||
|
||||
if ( !isdefined( Player ) || !isdefined( Player.team ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( Player == self )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( Player.sessionstate != "playing" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( !Player inLastStand() || Player.revivetrigger.beingrevived )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( GetPathIsInaccessible( self.origin, Player.origin ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( self GetBotsAmountForEntity( Player ) >= 1 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Answer[ Answer.size ] = self CreateFinderObjectiveEZ( eObj, Player );
|
||||
}
|
||||
|
||||
|
||||
return Answer;
|
||||
}
|
||||
|
||||
@ -57,12 +57,12 @@ Priority( eObj, eEnt )
|
||||
{
|
||||
base_priority = 3;
|
||||
base_priority += ClampLerp( get_path_dist( self.origin, eEnt.origin ), 500, 1200, 2, 0 );
|
||||
|
||||
|
||||
if ( self HasBotObjective() && self GetBotObjectiveEnt() != eEnt )
|
||||
{
|
||||
base_priority -= 1;
|
||||
}
|
||||
|
||||
|
||||
return base_priority;
|
||||
}
|
||||
|
||||
@ -70,20 +70,20 @@ Executer( eObj )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
revivee = eObj.eent;
|
||||
|
||||
|
||||
self thread IncrementBotsForEntity( revivee );
|
||||
self thread WatchForCancelRevive( revivee );
|
||||
|
||||
|
||||
self GoDoRevive( eObj );
|
||||
|
||||
|
||||
self WatchForCancelReviveCleanup();
|
||||
self DecrementBotsForEntity( revivee );
|
||||
self ClearScriptAimPos();
|
||||
self ClearScriptGoal();
|
||||
self ClearPriorityObjective();
|
||||
|
||||
|
||||
self CompletedObjective( eObj.bwassuccessful, eObj.sreason );
|
||||
}
|
||||
|
||||
@ -97,31 +97,31 @@ WatchForCancelRevive( revivee )
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "WatchForCancelRevive" );
|
||||
|
||||
|
||||
org = revivee.origin;
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
self CancelObjective( "self inLastStand()" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( !isdefined( revivee ) || !revivee inLastStand() )
|
||||
{
|
||||
self CancelObjective( "!isdefined( revivee ) || !revivee inLastStand()" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( revivee.revivetrigger.beingrevived && !self isReviving( revivee ) )
|
||||
{
|
||||
self CancelObjective( "revivee.revivetrigger.beingrevived && !self isReviving( revivee )" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( distance( revivee.origin, org ) > 16 )
|
||||
{
|
||||
self CancelObjective( "distance( revivee.origin, org ) > 16" );
|
||||
@ -138,11 +138,11 @@ WatchToGoToGuy( revivee )
|
||||
self endon( "goal" );
|
||||
self endon( "bad_path" );
|
||||
self endon( "new_goal" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 1;
|
||||
|
||||
|
||||
if ( self istouching( revivee.revivetrigger ) )
|
||||
{
|
||||
self notify( "goal" );
|
||||
@ -155,11 +155,11 @@ WatchForSuccessRevive( eObj )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
revivee = eObj.eent;
|
||||
|
||||
|
||||
ret = self waittill_either_return( "cancel_bot_objective", "completed_bot_objective" );
|
||||
|
||||
|
||||
if ( ret == "cancel_bot_objective" && isdefined( revivee ) && !revivee inLastStand() )
|
||||
{
|
||||
eObj.bwassuccessful = true;
|
||||
@ -170,40 +170,40 @@ WatchForSuccessRevive( eObj )
|
||||
GoDoRevive( eObj )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
|
||||
|
||||
revivee = eObj.eent;
|
||||
|
||||
|
||||
// go to guy
|
||||
self thread WatchToGoToGuy( revivee );
|
||||
self SetPriorityObjective();
|
||||
self SetScriptGoal( revivee.origin, 32 );
|
||||
|
||||
|
||||
result = self waittill_any_return( "goal", "bad_path", "new_goal" );
|
||||
|
||||
|
||||
if ( result != "goal" )
|
||||
{
|
||||
eObj.sreason = "didn't go to guy";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !self istouching( revivee.revivetrigger ) )
|
||||
{
|
||||
eObj.sreason = "not touching guy";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ok we are touching guy, lets look at him
|
||||
self SetScriptAimPos( revivee.origin );
|
||||
|
||||
|
||||
// now lets hold use until he is up or otherwise
|
||||
self thread WatchForSuccessRevive( eObj );
|
||||
|
||||
|
||||
while ( self istouching( revivee.revivetrigger ) )
|
||||
{
|
||||
self thread BotPressUse( 0.15 );
|
||||
|
||||
|
||||
wait 0.1;
|
||||
}
|
||||
|
||||
|
||||
eObj.sreason = "not touching guy";
|
||||
}
|
||||
|
@ -6,45 +6,45 @@
|
||||
Finder( eObj )
|
||||
{
|
||||
answer = [];
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
weapons = self getweaponslist();
|
||||
|
||||
|
||||
// TODO check if need a new weapon, rate weapons too is better then current etc
|
||||
chests = level.chests;
|
||||
|
||||
|
||||
if ( !isdefined( chests ) )
|
||||
{
|
||||
chests = getentarray( "treasure_chest_use", "targetname" );
|
||||
}
|
||||
|
||||
|
||||
if ( !isdefined( chests ) || chests.size <= 0 )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
for ( i = 0; i < chests.size; i ++ )
|
||||
{
|
||||
chest = chests[ i ];
|
||||
|
||||
|
||||
// not active chest
|
||||
if ( isdefined( chest.disabled ) && chest.disabled )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// box is waiting for someone to grab weapon
|
||||
if ( isdefined( chest.grab_weapon_hint ) && chest.grab_weapon_hint )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
cost = 950;
|
||||
|
||||
|
||||
if ( isdefined( level.zombie_treasure_chest_cost ) )
|
||||
{
|
||||
cost = level.zombie_treasure_chest_cost;
|
||||
@ -53,44 +53,44 @@ Finder( eObj )
|
||||
{
|
||||
cost = chest.zombie_cost;
|
||||
}
|
||||
|
||||
|
||||
// check cost
|
||||
if ( self.score < cost )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
lid = getent( chest.target, "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( lid ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
weapon_spawn_org = getent( lid.target, "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( weapon_spawn_org ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
org = self getOffset( lid );
|
||||
|
||||
|
||||
if ( GetPathIsInaccessible( self.origin, org ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
answer[ answer.size ] = self CreateFinderObjectiveEZ( eObj, chest );
|
||||
}
|
||||
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
getOffset( model )
|
||||
{
|
||||
org = model get_angle_offset_node( 52, ( 0, 90, 0 ), ( 0, 0, 1 ) );
|
||||
|
||||
|
||||
return org;
|
||||
}
|
||||
|
||||
@ -98,12 +98,12 @@ Priority( eObj, eEnt )
|
||||
{
|
||||
base_priority = 1;
|
||||
base_priority += ClampLerp( get_path_dist( self.origin, eEnt.origin ), 600, 1800, 2, 0 );
|
||||
|
||||
|
||||
if ( self HasBotObjective() && self GetBotObjectiveEnt() != eEnt )
|
||||
{
|
||||
base_priority -= 1;
|
||||
}
|
||||
|
||||
|
||||
return base_priority;
|
||||
}
|
||||
|
||||
@ -111,18 +111,18 @@ Executer( eObj )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
chest = eObj.eent;
|
||||
|
||||
|
||||
self thread WatchForCancel( chest );
|
||||
|
||||
|
||||
self GoDoTreasureChest( eObj );
|
||||
|
||||
|
||||
self WatchForCancelCleanup();
|
||||
self ClearScriptAimPos();
|
||||
self ClearScriptGoal();
|
||||
self ClearPriorityObjective();
|
||||
|
||||
|
||||
self CompletedObjective( eObj.bwassuccessful, eObj.sreason );
|
||||
}
|
||||
|
||||
@ -136,11 +136,11 @@ WatchForCancel( chest )
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "WatchForCancelTreasurechest" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
self CancelObjective( "self inLastStand()" );
|
||||
@ -157,17 +157,17 @@ WatchToGoToChest( chest )
|
||||
self endon( "goal" );
|
||||
self endon( "bad_path" );
|
||||
self endon( "new_goal" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self istouching( chest ) || chest PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
self notify( "goal" );
|
||||
break; // is this needed?
|
||||
}
|
||||
|
||||
|
||||
if ( isdefined( chest.disabled ) && chest.disabled )
|
||||
{
|
||||
self notify( "bad_path" );
|
||||
@ -179,105 +179,105 @@ WatchToGoToChest( chest )
|
||||
GoDoTreasureChest( eObj )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
|
||||
|
||||
chest = eObj.eent;
|
||||
lid = getent( chest.target, "targetname" );
|
||||
weapon_spawn_org = getent( lid.target, "targetname" );
|
||||
org = self getOffset( lid );
|
||||
|
||||
|
||||
weap = self getcurrentweapon();
|
||||
|
||||
|
||||
if ( weap == "none" || !self getammocount( weap ) )
|
||||
{
|
||||
self SetPriorityObjective();
|
||||
}
|
||||
|
||||
|
||||
// go to box
|
||||
self thread WatchToGoToChest( chest );
|
||||
self SetScriptGoal( org, 32 );
|
||||
|
||||
|
||||
result = self waittill_any_return( "goal", "bad_path", "new_goal" );
|
||||
|
||||
|
||||
if ( result != "goal" )
|
||||
{
|
||||
eObj.sreason = "didn't go to chest";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !self istouching( chest ) && !chest PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
eObj.sreason = "not touching chest";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ok we are touching weapon, lets look at it
|
||||
self SetScriptAimPos( chest.origin );
|
||||
|
||||
|
||||
// wait to look at it
|
||||
wait 1;
|
||||
|
||||
|
||||
// press use
|
||||
self thread BotPressUse( 0.15 );
|
||||
wait 0.25;
|
||||
|
||||
|
||||
// ok we pressed use, wait for randomization to complete
|
||||
self ClearScriptAimPos();
|
||||
self ClearPriorityObjective();
|
||||
|
||||
|
||||
// randomization isnt happening...
|
||||
if ( !isdefined( chest.disabled ) || !chest.disabled )
|
||||
{
|
||||
eObj.sreason = "chest isnt randomizing";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ret = weapon_spawn_org waittill_any_timeout( 5, "randomization_done" );
|
||||
|
||||
if (ret == "timeout")
|
||||
|
||||
if ( ret == "timeout" )
|
||||
{
|
||||
eObj.sreason = "randomization_done timed out";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( isdefined( level.flag[ "moving_chest_now" ] ) && flag( "moving_chest_now" ) )
|
||||
{
|
||||
eObj.sreason = "chest is moving!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
waittillframeend;
|
||||
weap = weapon_spawn_org.weapon_string;
|
||||
// weapon is done cooking, grabit!
|
||||
self SetPriorityObjective();
|
||||
|
||||
|
||||
// go to box
|
||||
self thread WatchToGoToChest( chest );
|
||||
self SetScriptGoal( org, 32 );
|
||||
|
||||
|
||||
result = self waittill_any_return( "goal", "bad_path", "new_goal" );
|
||||
|
||||
|
||||
if ( result != "goal" )
|
||||
{
|
||||
eObj.sreason = "didn't go to chest";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !self istouching( chest ) && !chest PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
eObj.sreason = "not touching chest";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ok we are touching weapon, lets look at it
|
||||
self SetScriptAimPos( chest.origin );
|
||||
|
||||
|
||||
// wait to look at it
|
||||
wait 1;
|
||||
|
||||
|
||||
// press use
|
||||
self thread BotPressUse( 0.15 );
|
||||
wait 0.1;
|
||||
|
||||
|
||||
// complete!
|
||||
eObj.sreason = "completed " + weap;
|
||||
eObj.bwassuccessful = true;
|
||||
|
@ -5,15 +5,15 @@
|
||||
CreateObjectiveForManger( sName, fpFinder, fpPriorty, fpExecuter, iProcessRate )
|
||||
{
|
||||
Answer = spawnstruct();
|
||||
|
||||
|
||||
Answer.sname = sName;
|
||||
Answer.fpfinder = fpFinder;
|
||||
Answer.fpexecuter = fpExecuter;
|
||||
Answer.fppriorty = fpPriorty;
|
||||
|
||||
|
||||
Answer.abotprocesstimes = [];
|
||||
Answer.iprocessrate = iProcessRate;
|
||||
|
||||
|
||||
return Answer;
|
||||
}
|
||||
|
||||
@ -25,16 +25,16 @@ CreateFinderObjectiveEZ( eObj, eEnt )
|
||||
CreateFinderObjective( eObj, sName, eEnt, fPriority )
|
||||
{
|
||||
Answer = spawnstruct();
|
||||
|
||||
|
||||
Answer.eparentobj = eObj;
|
||||
Answer.sname = sName;
|
||||
Answer.eent = eEnt;
|
||||
Answer.fpriority = fPriority;
|
||||
Answer.guid = eEnt getentitynumber();
|
||||
|
||||
|
||||
Answer.bwassuccessful = false;
|
||||
Answer.sreason = "canceled";
|
||||
|
||||
|
||||
return Answer;
|
||||
}
|
||||
|
||||
@ -44,18 +44,18 @@ GetBotsAmountForEntity( eEnt )
|
||||
{
|
||||
eEnt.bots = 0;
|
||||
}
|
||||
|
||||
|
||||
return eEnt.bots;
|
||||
}
|
||||
|
||||
IncrementBotsForEntity( eEnt )
|
||||
{
|
||||
self endon( "bots_for_entity_cleanup" );
|
||||
|
||||
|
||||
eEnt.bots++;
|
||||
|
||||
|
||||
self waittill_either( "disconnect", "zombified" );
|
||||
|
||||
|
||||
if ( isdefined( eEnt ) )
|
||||
{
|
||||
eEnt.bots--;
|
||||
@ -65,7 +65,7 @@ IncrementBotsForEntity( eEnt )
|
||||
DecrementBotsForEntity( eEnt )
|
||||
{
|
||||
self notify( "bots_for_entity_cleanup" );
|
||||
|
||||
|
||||
if ( isdefined( eEnt ) )
|
||||
{
|
||||
eEnt.bots--;
|
||||
@ -93,7 +93,7 @@ GetBotObjectiveEnt()
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
return self GetBotObjective().eent;
|
||||
}
|
||||
|
||||
|
@ -6,32 +6,32 @@
|
||||
Finder( eObj )
|
||||
{
|
||||
answer = [];
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
weapon_spawns = getentarray( "weapon_upgrade", "targetname" );
|
||||
|
||||
|
||||
if ( !isdefined( weapon_spawns ) || weapon_spawns.size <= 0 )
|
||||
{
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
weapons = self getweaponslist();
|
||||
|
||||
|
||||
// TODO check if need a new weapon, rate weapons too is better then current etc
|
||||
|
||||
|
||||
for ( i = 0; i < weapon_spawns.size; i++ )
|
||||
{
|
||||
player_has_weapon = false;
|
||||
|
||||
|
||||
if ( !isdefined( weapon_spawns[ i ].zombie_weapon_upgrade ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
for ( h = 0; h < weapons.size; h++ )
|
||||
{
|
||||
if ( weapons[ h ] == weapon_spawns[ i ].zombie_weapon_upgrade )
|
||||
@ -39,13 +39,13 @@ Finder( eObj )
|
||||
player_has_weapon = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
is_grenade = ( weapontype( weapon_spawns[ i ].zombie_weapon_upgrade ) == "grenade" );
|
||||
|
||||
|
||||
if ( !player_has_weapon || is_grenade )
|
||||
{
|
||||
func = BotBuiltinGetFunction( "maps/_zombiemode_weapons", "get_weapon_cost" );
|
||||
|
||||
|
||||
if ( self.score < [[ func ]]( weapon_spawns[ i ].zombie_weapon_upgrade ) )
|
||||
{
|
||||
continue;
|
||||
@ -54,69 +54,69 @@ Finder( eObj )
|
||||
else
|
||||
{
|
||||
func = BotBuiltinGetFunction( "maps/_zombiemode_weapons", "get_ammo_cost" );
|
||||
|
||||
|
||||
if ( self.score < [[ func ]]( weapon_spawns[ i ].zombie_weapon_upgrade ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
model = weapon_spawns[ i ];
|
||||
|
||||
|
||||
if ( isdefined( weapon_spawns[ i ].target ) )
|
||||
{
|
||||
model = getent( weapon_spawns[ i ].target, "targetname" );
|
||||
}
|
||||
|
||||
|
||||
if ( !isdefined( model ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
org = self getOffset( model, weapon_spawns[ i ] );
|
||||
|
||||
|
||||
if ( GetPathIsInaccessible( self.origin, org ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
answer[ answer.size ] = self CreateFinderObjectiveEZ( eObj, weapon_spawns[ i ] );
|
||||
}
|
||||
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
getOffset( model, weapon )
|
||||
{
|
||||
org = model get_angle_offset_node( 40, ( 0, -90, 0 ), ( 0, 0, 1 ) );
|
||||
|
||||
|
||||
test_org = ( org[ 0 ], org[ 1 ], weapon.origin[ 2 ] );
|
||||
|
||||
|
||||
if ( !weapon PointInsideUseTrigger( test_org ) )
|
||||
{
|
||||
org = model get_angle_offset_node( 40, ( 0, 90, 0 ), ( 0, 0, 1 ) );
|
||||
}
|
||||
|
||||
|
||||
return org;
|
||||
}
|
||||
|
||||
Priority( eObj, eEnt )
|
||||
{
|
||||
// TODO: check weallweapon type
|
||||
|
||||
|
||||
base_priority = 0;
|
||||
base_priority += ClampLerp( get_path_dist( self.origin, eEnt.origin ), 0, 800, 1, -2 );
|
||||
|
||||
|
||||
if ( self HasBotObjective() && self GetBotObjectiveEnt() != eEnt )
|
||||
{
|
||||
base_priority -= 1;
|
||||
}
|
||||
|
||||
|
||||
if ( issubstr( eEnt.zombie_weapon_upgrade, "kar98k" ) || issubstr( eEnt.zombie_weapon_upgrade, "type99" ) )
|
||||
{
|
||||
base_priority -= 999;
|
||||
}
|
||||
|
||||
|
||||
return base_priority;
|
||||
}
|
||||
|
||||
@ -124,18 +124,18 @@ Executer( eObj )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
|
||||
|
||||
weapon = eObj.eent;
|
||||
|
||||
|
||||
self thread WatchForCancel( weapon );
|
||||
|
||||
|
||||
self GoDoWallweapon( eObj );
|
||||
|
||||
|
||||
self WatchForCancelCleanup();
|
||||
self ClearScriptAimPos();
|
||||
self ClearScriptGoal();
|
||||
self ClearPriorityObjective();
|
||||
|
||||
|
||||
self CompletedObjective( eObj.bwassuccessful, eObj.sreason );
|
||||
}
|
||||
|
||||
@ -149,11 +149,11 @@ WatchForCancel( weapon )
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "WatchForCancelWallweapon" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
self CancelObjective( "self inLastStand()" );
|
||||
@ -170,11 +170,11 @@ WatchToGoToWeapon( weapon )
|
||||
self endon( "goal" );
|
||||
self endon( "bad_path" );
|
||||
self endon( "new_goal" );
|
||||
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
|
||||
if ( self istouching( weapon ) || weapon PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
self notify( "goal" );
|
||||
@ -186,52 +186,52 @@ WatchToGoToWeapon( weapon )
|
||||
GoDoWallweapon( eObj )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
|
||||
|
||||
weapon = eObj.eent;
|
||||
model = weapon;
|
||||
|
||||
|
||||
if ( isdefined( weapon.target ) )
|
||||
{
|
||||
model = getent( weapon.target, "targetname" );
|
||||
}
|
||||
|
||||
|
||||
org = self getOffset( model, weapon );
|
||||
|
||||
|
||||
weap = self getcurrentweapon();
|
||||
|
||||
|
||||
if ( weap == "none" || !self getammocount( weap ) )
|
||||
{
|
||||
self SetPriorityObjective();
|
||||
}
|
||||
|
||||
|
||||
// go to weapon
|
||||
self thread WatchToGoToWeapon( weapon );
|
||||
self SetScriptGoal( org, 32 );
|
||||
|
||||
|
||||
result = self waittill_any_return( "goal", "bad_path", "new_goal" );
|
||||
|
||||
|
||||
if ( result != "goal" )
|
||||
{
|
||||
eObj.sreason = "didn't go to weapon";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !self istouching( weapon ) && !weapon PointInsideUseTrigger( self.origin ) )
|
||||
{
|
||||
eObj.sreason = "not touching weapon";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ok we are touching weapon, lets look at it
|
||||
self SetScriptAimPos( weapon.origin );
|
||||
|
||||
|
||||
// wait to look at it
|
||||
wait 1;
|
||||
|
||||
|
||||
// press use
|
||||
self thread BotPressUse( 0.15 );
|
||||
wait 0.1;
|
||||
|
||||
|
||||
eObj.sreason = "completed";
|
||||
eObj.bwassuccessful = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user