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

View File

@ -180,7 +180,7 @@ public Action permitStuck(Handle timer, any data)
public void OnMapStart()
{
//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(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];
GetEntPropVector(targethuman, Prop_Send, "m_vecOrigin", 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)
{
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)
{
bot_send_connected_msg();
//TODO still stuck in spectate, fuck
ChangeClientTeam(present, 2);
return Plugin_Continue;
}
if (IsPlayerAlive(present))
@ -419,7 +422,8 @@ public float wall_circle()
GetClientEyeAngles(present, Angles);
Angles[iterator] = AngleRotate;
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())
{
float EndOrigin[3];
@ -430,7 +434,7 @@ public float wall_circle()
float crouch_cap = 5000.0;
float jump_cap = 100000.0;
//TODO maybe 50.0 again
float distance_cap = 60.0;
float distance_cap = 100.0;
if (distance <= distance_cap)
{
if (dot_product <= crouch_cap || dot_product <= jump_cap)