more general changes to targeting

This commit is contained in:
jenzur 2020-10-02 22:42:53 +02:00
parent 4fdd1670a1
commit 21b8c8c933
2 changed files with 11 additions and 8 deletions

View File

@ -75,8 +75,8 @@ def bot_process_movement(input_line):
strInput += "use weapon_p90; wait 3; " strInput += "use weapon_p90; wait 3; "
elif targeteam == 2: elif targeteam == 2:
strInput += "use weapon_knife; wait 5; " strInput += "use weapon_knife; wait 5; "
#print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman, print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman,
# ' dist_target: ', dist_target) ' dist_target: ', dist_target)
strInput = strinput_append(strInput, 2) strInput = strinput_append(strInput, 2)
#print('strInput final:', strInput) #print('strInput final:', strInput)
writeCfgInput(strInput) writeCfgInput(strInput)
@ -183,9 +183,9 @@ if __name__ == '__main__':
if hull_info == "jump": if hull_info == "jump":
strInput += "+jump; wait 5; -jump; +duck; wait 50; -duck; wait 5; " strInput += "+jump; wait 5; -jump; +duck; wait 50; -duck; wait 5; "
elif hull_info == "crouch": elif hull_info == "crouch":
strInput += "+duck; wait 250; -duck; wait 5; " strInput += "+duck; wait 50; -duck; wait 5; "
writeCfgInput(strInput) writeCfgInput(strInput)
print(colored_text) #print(colored_text)
time.sleep(0.1) time.sleep(0.1)
writeCfgInput("") writeCfgInput("")
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -15,6 +15,7 @@
//#pragma newdecls required //#pragma newdecls required
int present = 0; int present = 0;
int targethuman = 0; int targethuman = 0;
int target_enemy = 0;
int buttons_old; int buttons_old;
int flags_old; int flags_old;
bool surf_cooldown = false; bool surf_cooldown = false;
@ -56,6 +57,7 @@ public void OnPluginStart()
chat_cooldown = false; chat_cooldown = false;
reset_target_human_tp_coord(); reset_target_human_tp_coord();
targethuman = 0; targethuman = 0;
target_enemy = 0;
} }
public void reset_target_human_tp_coord() public void reset_target_human_tp_coord()
@ -171,6 +173,7 @@ public Action bot_chat_cooldown(Handle timer, any data)
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
{ {
targethuman = 0; targethuman = 0;
target_enemy = 0;
reset_target_human_tp_coord(); reset_target_human_tp_coord();
} }
@ -178,7 +181,7 @@ public void OnMapStart()
{ {
//0.2 too spammmy, 1.5 too slow //0.2 too spammmy, 1.5 too slow
chat_cooldown = false; chat_cooldown = false;
CreateTimer(0.60, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(0.30, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
} }
@ -265,7 +268,7 @@ public Action recursive_pressing(Handle timer, any data)
} }
targethuman = GetClosestClient_option1(targeteam == 2 ? 2 : 3); targethuman = GetClosestClient_option1(targeteam == 2 ? 2 : 3);
float enemy_distance = -1.0; float enemy_distance = -1.0;
int target_enemy = GetClosestClient_option1(targeteam == 2 ? 3 : 2); target_enemy = GetClosestClient_option1(targeteam == 2 ? 3 : 2);
float dist_target = -1.0; float dist_target = -1.0;
float pos[3]; float pos[3];
if (IsValidClient(targethuman)) if (IsValidClient(targethuman))
@ -424,7 +427,7 @@ public void face_call(int client)
public void faceclient(int target_human) public void faceclient(int target_human)
{ {
if (IsValidClient(present) && IsValidClient(target_human) && GetEntityMoveType(present) != MOVETYPE_LADDER) if (IsValidClient(present) && IsValidClient(target_human))
{ {
float TargetPos[3]; float TargetPos[3];
float ClientPos[3]; float ClientPos[3];
@ -466,7 +469,7 @@ public int GetClosestClient_option1(int targeteam)
float pos[3]; float pos[3];
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos); GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
float dist_target = get_power_distance(present, pos); float dist_target = get_power_distance(present, pos);
if (admins[i] || vips[i]) if (admins[i] || vips[i] || i == targethuman || i == target_enemy)
dist_target /= 5; dist_target /= 5;
if (nearestdistance < 0 || dist_target < nearestdistance) if (nearestdistance < 0 || dist_target < nearestdistance)
{ {