mirror of
https://github.com/JezuzLizard/t4sp_bot_warfare.git
synced 2025-09-18 14:17:27 +00:00
cleanup
This commit is contained in:
214
maps/bots/objectives/_wallweapon.gsc
Normal file
214
maps/bots/objectives/_wallweapon.gsc
Normal file
@@ -0,0 +1,214 @@
|
||||
#include common_scripts\utility;
|
||||
#include maps\_utility;
|
||||
#include maps\bots\_bot_utility;
|
||||
#include maps\bots\objectives\_utility;
|
||||
|
||||
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 )
|
||||
{
|
||||
player_has_weapon = true;
|
||||
}
|
||||
}
|
||||
|
||||
is_grenade = ( WeaponType( weapon_spawns[i].zombie_weapon_upgrade ) == "grenade" );
|
||||
|
||||
if ( !player_has_weapon || is_grenade )
|
||||
{
|
||||
func = GetFunction( "maps/_zombiemode_weapons", "get_weapon_cost" );
|
||||
|
||||
if ( self.score < [[func]]( weapon_spawns[i].zombie_weapon_upgrade ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
func = GetFunction( "maps/_zombiemode_weapons", "get_ammo_cost" );
|
||||
|
||||
if ( self.score < [[func]]( weapon_spawns[i].zombie_weapon_upgrade ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
model = getEnt( weapon_spawns[ i ].target, "targetname" );
|
||||
|
||||
if ( !isDefined( model ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
org = self getOffset( model );
|
||||
|
||||
if ( GetPathIsInaccessible( self.origin, org ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
answer[answer.size] = self CreateFinderObjective( eObj, eObj.sName + "_" + weapon_spawns[i] GetEntityNumber(), weapon_spawns[i], self Priority( eObj, weapon_spawns[i] ) );
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
getOffset( model )
|
||||
{
|
||||
// some weapons have 90 offset... how to handle this??
|
||||
angle_off = -90;
|
||||
|
||||
org = model get_angle_offset_node( 40, ( 0, angle_off, 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, 2, -2 );
|
||||
|
||||
if ( self HasBotObjective() )
|
||||
{
|
||||
base_priority -= 1;
|
||||
}
|
||||
|
||||
if ( eEnt.zombie_weapon_upgrade == "zombie_kar98k" )
|
||||
{
|
||||
base_priority -= 99;
|
||||
}
|
||||
|
||||
return base_priority;
|
||||
}
|
||||
|
||||
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 CompletedObjective( eObj.bWasSuccessful, eObj.sReason );
|
||||
}
|
||||
|
||||
WatchForCancelCleanup()
|
||||
{
|
||||
self notify( "WatchForCancelWallweapon" );
|
||||
}
|
||||
|
||||
WatchForCancel( weapon )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "WatchForCancelWallweapon" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
if ( self inLastStand() )
|
||||
{
|
||||
self CancelObjective( "self inLastStand()" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WatchToGoToWeapon( weapon )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
self endon( "disconnect" );
|
||||
self endon( "zombified" );
|
||||
self endon( "goal" );
|
||||
self endon( "bad_path" );
|
||||
self endon( "new_goal" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
wait 0.05;
|
||||
|
||||
if ( self IsTouching( weapon ) )
|
||||
{
|
||||
self notify( "goal" );
|
||||
break; // is this needed?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GoDoWallweapon( eObj )
|
||||
{
|
||||
self endon( "cancel_bot_objective" );
|
||||
|
||||
weapon = eObj.eEnt;
|
||||
model = getEnt( weapon.target, "targetname" );
|
||||
org = self getOffset( model );
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// istouching use triggers doesnt work well
|
||||
if ( !self IsTouching( weapon ) && false )
|
||||
{
|
||||
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