mirror of
https://github.com/JezuzLizard/t4sp_bot_warfare.git
synced 2025-09-18 14:17:27 +00:00
fmt
This commit is contained in:
@@ -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