Merge pull request #254 from nullifiedcat/walkbot

fix crash
This commit is contained in:
nullifiedcat 2017-08-03 12:19:07 +03:00 committed by GitHub
commit 4c74176fe0
4 changed files with 72 additions and 0 deletions

46
attach-user Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
user=$USER
if [ "$#" == 1 ]; then
user=$1
fi
proc="0"
for pid in $(pidof hl2_linux)
do
if sudo -H -u $user kill -0 $pid
then
proc=$pid
break
fi
done
if [ "$proc" == "0" ]
then
echo "TF2 for $user is not running"
continue
fi
echo Attaching to "$proc"
FILENAME=$(realpath "bin/libcathook.so")
echo loading "$FILENAME" to "$proc"
sudo killall -19 steam
sudo killall -19 steamwebhelper
sudo gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$FILENAME\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"
sudo killall -18 steamwebhelper
sudo killall -18 steam

12
src/headshake.cpp Normal file
View File

@ -0,0 +1,12 @@
/*
* headshake.cpp
*
* Created on: Aug 2, 2017
* Author: nullifiedcat
*/
#include <vector>
const std::vector<float> headshake_pitch_deltas = {
-0.2, 0.8, -1.7, 0.8, -0.8, 0.19, -0.99, 1.9
};

12
src/headshake.hpp Normal file
View File

@ -0,0 +1,12 @@
/*
* headshake.hpp
*
* Created on: Aug 2, 2017
* Author: nullifiedcat
*/
#pragma once

View File

@ -156,6 +156,7 @@ powerup_type GetPowerupOnPlayer(CachedEntity* player) {
// A function to tell if a player is using a specific weapon
bool HasWeapon(CachedEntity* ent, int wantedId) {
if (CE_BAD(ent)) return false;
// Create a var to store the handle
int *hWeapons;
// Grab the handle and store it into the var
@ -172,6 +173,7 @@ bool HasWeapon(CachedEntity* ent, int wantedId) {
}
bool HasDarwins(CachedEntity* ent) {
if (CE_BAD(ent)) return false;
// Check if player is sniper
if (CE_INT(ent, netvar.iClass) != tf_sniper) return false;
// Check if player is using darwins, 231 is the id for darwins danger sheild