minor updates to outprint and removal of time lockers

This commit is contained in:
jenzur 2020-09-20 19:52:28 +02:00
parent bc813e7ba0
commit 018f5b4d9f
2 changed files with 68 additions and 80 deletions

View File

@ -6,33 +6,28 @@ from threading import Timer
import string import string
import random import random
import signal import signal
import time
import socket import socket
import codecs import codecs
import datetime import datetime
import time
looptestPath = '/home/gameservers/.steam/steam/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg' looptestPath = '/home/gameservers/.steam/steam/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg'
chatmsg = "" chatmsg = ""
ladder_counter = 0 ladder_counter = 0
def writeCfgInput(Input): def writeCfgInput(Input):
with open(looptestPath, 'w') as f: with open(looptestPath, 'w') as f:
f.write(Input) if input == "wait 5;":
time.sleep(1)
f.write(Input)
def resetCfgInputShortWait():
str = "wait 5; "
with open(looptestPath, 'w') as f:
f.write(str)
time.sleep(0.2)
def exit_handler(): def exit_handler():
print('reached exithandler') print('reached exithandler')
resetCfgInputShortWait() writeCfgInput('wait 5;')
def joinTeam(): def joinTeam():
str = "jointeam 2; joinclass 3; zspawn;" str = "jointeam 2; joinclass 3; zspawn;"
writeCfgInput(str) writeCfgInput(str)
time.sleep(4.5)
print('jointeam func: ') print('jointeam func: ')
def bot_process_surf(input_line): def bot_process_surf(input_line):
@ -53,9 +48,8 @@ def bot_process_surf(input_line):
strInput += "+moveleft; wait 3; " strInput += "+moveleft; wait 3; "
elif bot_surf_plane[0] > 0.0: elif bot_surf_plane[0] > 0.0:
strInput += "+moveright; wait 3; " strInput += "+moveright; wait 3; "
print('bot surfing bot_surf_plane: ', bot_surf_plane) print('date: ', datetime.datetime.now().time(),'bot surfing bot_surf_plane: ', bot_surf_plane)
writeCfgInput(strInput) writeCfgInput(strInput)
time.sleep(0.3)
writeCfgInput("wait 5;") writeCfgInput("wait 5;")
def bot_process_keyinput(input_line): def bot_process_keyinput(input_line):
@ -64,8 +58,7 @@ def bot_process_keyinput(input_line):
dist_target = float(dist_target) dist_target = float(dist_target)
strInput = f"""{movement_input}; wait 5; -jump; wait 5; -duck; wait 5; """ strInput = f"""{movement_input}; wait 5; -jump; wait 5; -duck; wait 5; """
writeCfgInput(strInput) writeCfgInput(strInput)
print('MIMIC datetime: ', datetime.datetime.now().time(), ' dist_target: ', dist_target, ' movement strinput: ', strInput) print('MIMIC date: ', datetime.datetime.now().time(), ' dist_target: ', dist_target, ' movement strinput: ', strInput)
time.sleep(0.3)
writeCfgInput("wait 5;") writeCfgInput("wait 5;")
def bot_process_movement(input_line): def bot_process_movement(input_line):
@ -85,17 +78,13 @@ def bot_process_movement(input_line):
targeteam = int(targeteam) targeteam = int(targeteam)
min_distance_target_human = 800.0 min_distance_target_human = 800.0
strInput = "-attack; wait 2; -use; wait 5; -jump; wait 5; -duck; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; +forward; wait 2; " strInput = "-attack; wait 2; -use; wait 5; -jump; wait 5; -duck; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; +forward; wait 2; "
if dot_product > 0.0:
print('dot_product: ', dot_product)
if z_axis > 0.0:
print('z_axis: ', z_axis)
crouch_cap = 5000.0 crouch_cap = 5000.0
jump_cap = 100000.0 jump_cap = 12000.0
if 0.0 < dot_product <= crouch_cap: if 0.0 < dot_product <= crouch_cap:
print('crouching', datetime.datetime.now().time()) #print('crouching', datetime.datetime.now().time())
strInput += "+duck; wait 1500; +jump; -duck; wait 250; -jump; wait 50;" strInput += "+duck; wait 1500; +jump; -duck; wait 250; -jump; wait 50;"
elif 0.0 < dot_product <= jump_cap: elif 0.0 < dot_product <= jump_cap:
print('jumping', datetime.datetime.now().time()) #print('jumping', datetime.datetime.now().time())
strInput += "+jump; wait 350; +duck; wait 250; -jump; -duck; wait 50;" strInput += "+jump; wait 350; +duck; wait 250; -jump; -duck; wait 50;"
if dist_target > min_distance_target_human: if dist_target > min_distance_target_human:
strInput += "use weapon_elite; wait 3; " strInput += "use weapon_elite; wait 3; "
@ -112,7 +101,6 @@ def bot_process_movement(input_line):
ladder_counter = 0 ladder_counter = 0
min_enemy_distance = 100.0 min_enemy_distance = 100.0
if bot_on_type == 3: if bot_on_type == 3:
print('3 = downhill: ', bot_on_type)
for _ in range(5): for _ in range(5):
strInput += "+jump; wait 5;" strInput += "+jump; wait 5;"
if enemy_distance > 0: if enemy_distance > 0:
@ -122,7 +110,6 @@ def bot_process_movement(input_line):
strInput = strinput_append(strInput, 2) strInput = strinput_append(strInput, 2)
#print('strInput final:', strInput) #print('strInput final:', strInput)
writeCfgInput(strInput) writeCfgInput(strInput)
time.sleep(0.4)
writeCfgInput("wait 5;") writeCfgInput("wait 5;")
def strinput_append(strInput, nth): def strinput_append(strInput, nth):
@ -151,66 +138,63 @@ def bot_connect_ze():
strdev = "connect 151.80.230.149:27019/test132;" strdev = "connect 151.80.230.149:27019/test132;"
str1 = "connect 151.80.230.149:27015;" str1 = "connect 151.80.230.149:27015;"
writeCfgInput(str1) writeCfgInput(str1)
time.sleep(0.2)
writeCfgInput("wait 5;")
print('not yet connected') print('not yet connected')
if __name__ == '__main__': if __name__ == '__main__':
atexit.register(exit_handler) atexit.register(exit_handler)
resetCfgInputShortWait()
local_ip = "127.0.0.1" local_ip = "127.0.0.1"
local_port = 48477 local_port = 48477
udp_external_ip = "62.210.110.245" udp_external_ip = "62.210.110.245"
buffer_size = 4096 #potentially not large enough? buffer_size = 4096 #potentially not large enough?
connection_issue_counter = 0; connection_issue_counter = 0;
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock_external: sock_external = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("", local_port)) sock.bind(("", local_port))
print('reached deadlock') print('reached deadlock')
try: try:
while True: while True:
data, addr = sock.recvfrom(buffer_size) data, addr = sock.recvfrom(buffer_size)
databyte = data databyte = data
data = codecs.decode(data, "utf-8", "ignore") data = codecs.decode(data, "utf-8", "ignore")
ip = addr[0] ip = addr[0]
port = addr[1] port = addr[1]
#print('port: ', port, " ip: ", ip) #print('port: ', port, " ip: ", ip)
if not data: if not data:
continue continue
if ip not in [local_ip, udp_external_ip]: if ip not in [local_ip, udp_external_ip]:
continue continue
if ip == udp_external_ip: if ip == udp_external_ip:
print("enabled remote UDP packet") response_msg = f"""say {data}"""
response_msg = f"""say {data}""" print("enabled remote UDP packet response_msg: ", response_msg)
writeCfgInput(response_msg) writeCfgInput(response_msg)
time.sleep(0.5) if data == "autismo connected":
resetCfgInputShortWait() print('Bot connected!')
#print('data: ', data) connection_issue_counter = 0
if data == "autismo connected": joinTeam()
print('Bot connected!') elif data == "bot kicked server full":
connection_issue_counter = 0 print('bot kicked server full: ', datetime.datetime.now().time())
time.sleep(2) elif data == "connect to ze":
joinTeam() if connection_issue_counter == 5:
elif data == "bot kicked server full": kill_css_process()
print('bot kicked server full: ', datetime.datetime.now().time()) connection_issue_counter += 1
elif data == "connect to ze": print('connection_issue_counter: ', connection_issue_counter)
if connection_issue_counter == 5: bot_connect_ze()
kill_css_process() elif "clientmessage:" in data:
connection_issue_counter += 1 sock_external.sendto(databyte, (udp_external_ip, local_port))
print('connection_issue_counter: ', connection_issue_counter) iterator = 3
bot_connect_ze() print('enabled send databyte: ', databyte)
elif "clientmessage:" in data: elif data.startswith("dist_target:"):
sock_external.sendto(databyte, (udp_external_ip, local_port)) bot_process_movement(data)
print('sent databyte: ', databyte) elif data.startswith("surfing:"):
elif data.startswith("dist_target:"): bot_process_surf(data)
bot_process_movement(data) elif data.startswith("keyinput:"):
elif data.startswith("surfing:"): bot_process_keyinput(data)
bot_process_surf(data) except KeyboardInterrupt:
elif data.startswith("keyinput:"): pass
bot_process_keyinput(data) finally:
except KeyboardInterrupt: sock.close()
pass sock_external.close()
#/home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/autoexec.cfg: #/home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/autoexec.cfg:
#alias loop "exec looptest.cfg; wait 5; loop;"; wait 5; loop; #alias loop "exec looptest.cfg; wait 5; loop;"; wait 5; loop;

View File

@ -180,7 +180,7 @@ public Action permitStuck(Handle timer, any data)
public void OnMapStart() public void OnMapStart()
{ {
//0.2 too spammmy, 1.5 too slow //0.2 too spammmy, 1.5 too slow
CreateTimer(0.50, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(0.25, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(1.0, clients_coordinates, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(1.0, clients_coordinates, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(10.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(10.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
} }
@ -241,7 +241,9 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
float pos[3]; float pos[3];
GetEntPropVector(targethuman, Prop_Send, "m_vecOrigin", pos); GetEntPropVector(targethuman, Prop_Send, "m_vecOrigin", pos);
float dist_target = get_power_distance(present, pos); float dist_target = get_power_distance(present, pos);
float dist_cap = 1500.0; //prior 1500.0
//TODO
float dist_cap = 50000.0;
if (dist_target < dist_cap) if (dist_target < dist_cap)
{ {
Format(keyinput, sizeof(keyinput), "keyinput: %s dist_target: %f", keyinput, dist_target); Format(keyinput, sizeof(keyinput), "keyinput: %s dist_target: %f", keyinput, dist_target);
@ -284,7 +286,8 @@ public Action recursive_pressing(Handle timer, any data)
{ {
if (GetClientTeam(present) == 1 || GetClientTeam(present) == 0) if (GetClientTeam(present) == 1 || GetClientTeam(present) == 0)
{ {
bot_send_connected_msg(); //TODO still stuck in spectate, fuck
ChangeClientTeam(present, 2);
return Plugin_Continue; return Plugin_Continue;
} }
if (IsPlayerAlive(present)) if (IsPlayerAlive(present))
@ -419,7 +422,8 @@ public float wall_circle()
GetClientEyeAngles(present, Angles); GetClientEyeAngles(present, Angles);
Angles[iterator] = AngleRotate; Angles[iterator] = AngleRotate;
GetClientEyePosition(present, StartOrigin); GetClientEyePosition(present, StartOrigin);
TR_TraceRayFilter(StartOrigin, Angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present); //TR_TraceRayFilter(StartOrigin, Angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present);
TR_TraceRayFilter(StartOrigin, Angles, MASK_SHOT, RayType_EndPoint, TraceRayDontHitSelf, present);
if (TR_DidHit()) if (TR_DidHit())
{ {
float EndOrigin[3]; float EndOrigin[3];
@ -430,7 +434,7 @@ public float wall_circle()
float crouch_cap = 5000.0; float crouch_cap = 5000.0;
float jump_cap = 100000.0; float jump_cap = 100000.0;
//TODO maybe 50.0 again //TODO maybe 50.0 again
float distance_cap = 60.0; float distance_cap = 100.0;
if (distance <= distance_cap) if (distance <= distance_cap)
{ {
if (dot_product <= crouch_cap || dot_product <= jump_cap) if (dot_product <= crouch_cap || dot_product <= jump_cap)