2017-11-02 12:49:45 -04:00
|
|
|
#include maps\mp\_utility;
|
|
|
|
#include maps\mp\gametypes\_hud_util;
|
|
|
|
#include common_scripts\utility;
|
|
|
|
|
|
|
|
init()
|
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
SetDvarIfUninitialized( "sv_customcallbacks", true );
|
|
|
|
SetDvarIfUninitialized( "sv_framewaittime", 0.05 );
|
2019-09-09 18:40:04 -04:00
|
|
|
SetDvarIfUninitialized( "sv_additionalwaittime", 0.1 );
|
|
|
|
SetDvarIfUninitialized( "sv_maxstoredframes", 12 );
|
2020-01-11 21:32:27 -05:00
|
|
|
SetDvarIfUninitialized( "sv_printradarupdates", 0 );
|
2019-08-12 20:04:25 -04:00
|
|
|
SetDvarIfUninitialized( "sv_printradar_updateinterval", 500 );
|
|
|
|
SetDvarIfUninitialized( "sv_iw4madmin_url", "http://127.0.0.1:1624" );
|
2018-10-25 09:14:39 -04:00
|
|
|
|
2018-05-21 17:09:27 -04:00
|
|
|
level thread onPlayerConnect();
|
2019-08-12 20:04:25 -04:00
|
|
|
if (getDvarInt("sv_printradarupdates") == 1)
|
|
|
|
{
|
|
|
|
level thread runRadarUpdates();
|
|
|
|
}
|
2018-10-25 09:14:39 -04:00
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
level waittill( "prematch_over" );
|
2017-11-02 12:49:45 -04:00
|
|
|
level.callbackPlayerKilled = ::Callback_PlayerKilled;
|
2018-05-21 17:09:27 -04:00
|
|
|
level.callbackPlayerDamage = ::Callback_PlayerDamage;
|
2018-10-25 09:14:39 -04:00
|
|
|
level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
onPlayerConnect( player )
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
for( ;; )
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
|
|
|
level waittill( "connected", player );
|
2019-12-27 21:37:50 -05:00
|
|
|
player setClientDvar("cl_autorecord", 1);
|
|
|
|
player setClientDvar("cl_demosKeep", 200);
|
2018-05-21 17:09:27 -04:00
|
|
|
player thread waitForFrameThread();
|
2020-01-06 19:43:00 -05:00
|
|
|
player thread waitForAttack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForAttack()
|
|
|
|
{
|
|
|
|
self endon( "disconnect" );
|
|
|
|
|
|
|
|
self.lastAttackTime = 0;
|
|
|
|
|
|
|
|
for( ;; )
|
|
|
|
{
|
|
|
|
self notifyOnPlayerCommand( "player_shot", "+attack" );
|
|
|
|
self waittill( "player_shot" );
|
|
|
|
|
|
|
|
self.lastAttackTime = getTime();
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
2017-11-02 12:49:45 -04:00
|
|
|
}
|
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
getHttpString( url )
|
2018-09-11 15:28:37 -04:00
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
request = httpGet( url );
|
|
|
|
request waittill( "done", success, data );
|
|
|
|
request destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
runRadarUpdates()
|
|
|
|
{
|
|
|
|
interval = int(getDvar("sv_printradar_updateinterval"));
|
|
|
|
|
|
|
|
for ( ;; )
|
2018-09-11 15:28:37 -04:00
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
for ( i = 0; i <= 17; i++ )
|
|
|
|
{
|
|
|
|
player = level.players[i];
|
|
|
|
|
|
|
|
if ( isDefined( player ) )
|
|
|
|
{
|
|
|
|
payload = player.guid + ";" + player.origin + ";" + player getPlayerAngles() + ";" + player.team + ";" + player.kills + ";" + player.deaths + ";" + player.score + ";" + player GetCurrentWeapon() + ";" + player.health + ";" + isAlive(player) + ";" + player.timePlayed["total"];
|
|
|
|
logPrint( "LiveRadar;" + payload + "\n" );
|
|
|
|
}
|
|
|
|
}
|
2018-09-11 15:28:37 -04:00
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
wait( interval / 1000 );
|
|
|
|
}
|
2018-09-11 15:28:37 -04:00
|
|
|
}
|
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
hitLocationToBone( hitloc )
|
2018-03-22 14:50:09 -04:00
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
switch( hitloc )
|
2018-03-22 14:50:09 -04:00
|
|
|
{
|
|
|
|
case "helmet":
|
|
|
|
return "j_helmet";
|
|
|
|
case "head":
|
|
|
|
return "j_head";
|
|
|
|
case "neck":
|
|
|
|
return "j_neck";
|
|
|
|
case "torso_upper":
|
|
|
|
return "j_spineupper";
|
|
|
|
case "torso_lower":
|
|
|
|
return "j_spinelower";
|
|
|
|
case "right_arm_upper":
|
|
|
|
return "j_shoulder_ri";
|
|
|
|
case "left_arm_upper":
|
|
|
|
return "j_shoulder_le";
|
|
|
|
case "right_arm_lower":
|
|
|
|
return "j_elbow_ri";
|
|
|
|
case "left_arm_lower":
|
|
|
|
return "j_elbow_le";
|
|
|
|
case "right_hand":
|
|
|
|
return "j_wrist_ri";
|
|
|
|
case "left_hand":
|
|
|
|
return "j_wrist_le";
|
|
|
|
case "right_leg_upper":
|
|
|
|
return "j_hip_ri";
|
|
|
|
case "left_leg_upper":
|
|
|
|
return "j_hip_le";
|
|
|
|
case "right_leg_lower":
|
|
|
|
return "j_knee_ri";
|
|
|
|
case "left_leg_lower":
|
|
|
|
return "j_knee_le";
|
|
|
|
case "right_foot":
|
|
|
|
return "j_ankle_ri";
|
|
|
|
case "left_foot":
|
|
|
|
return "j_ankle_le";
|
|
|
|
default:
|
|
|
|
return "tag_origin";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-21 17:09:27 -04:00
|
|
|
waitForFrameThread()
|
2018-03-22 14:50:09 -04:00
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
self endon( "disconnect" );
|
2018-05-21 17:09:27 -04:00
|
|
|
|
|
|
|
self.currentAnglePosition = 0;
|
|
|
|
self.anglePositions = [];
|
2019-09-09 18:40:04 -04:00
|
|
|
|
|
|
|
for (i = 0; i < getDvarInt( "sv_maxstoredframes" ); i++)
|
|
|
|
{
|
|
|
|
self.anglePositions[i] = self getPlayerAngles();
|
|
|
|
}
|
2018-05-21 17:09:27 -04:00
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
for( ;; )
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
|
|
|
self.anglePositions[self.currentAnglePosition] = self getPlayerAngles();
|
2019-08-12 20:04:25 -04:00
|
|
|
wait( getDvarFloat( "sv_framewaittime" ) );
|
|
|
|
self.currentAnglePosition = (self.currentAnglePosition + 1) % getDvarInt( "sv_maxstoredframes" );
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
2018-03-22 14:50:09 -04:00
|
|
|
}
|
2017-11-02 12:49:45 -04:00
|
|
|
|
2019-09-09 18:40:04 -04:00
|
|
|
waitForAdditionalAngles( logString, beforeFrameCount, afterFrameCount )
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
2019-09-09 18:40:04 -04:00
|
|
|
currentIndex = self.currentAnglePosition;
|
|
|
|
wait( 0.05 * afterFrameCount );
|
2018-05-21 17:09:27 -04:00
|
|
|
|
|
|
|
self.angleSnapshot = [];
|
|
|
|
|
2019-09-09 18:40:04 -04:00
|
|
|
for( j = 0; j < self.anglePositions.size; j++ )
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
2019-09-09 18:40:04 -04:00
|
|
|
self.angleSnapshot[j] = self.anglePositions[j];
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
anglesStr = "";
|
2019-09-09 18:40:04 -04:00
|
|
|
collectedFrames = 0;
|
|
|
|
i = currentIndex - beforeFrameCount;
|
|
|
|
|
|
|
|
while (collectedFrames < beforeFrameCount)
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
2019-09-09 18:40:04 -04:00
|
|
|
fixedIndex = i;
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
fixedIndex = self.angleSnapshot.size - abs(i);
|
|
|
|
}
|
2020-01-06 19:43:00 -05:00
|
|
|
anglesStr += self.angleSnapshot[int(fixedIndex)] + ":";
|
2019-09-09 18:40:04 -04:00
|
|
|
collectedFrames++;
|
|
|
|
i++;
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
2019-09-09 18:40:04 -04:00
|
|
|
|
|
|
|
if (i == currentIndex)
|
2018-05-21 17:09:27 -04:00
|
|
|
{
|
|
|
|
anglesStr += self.angleSnapshot[i] + ":";
|
2019-09-09 18:40:04 -04:00
|
|
|
i++;
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
2019-09-09 18:40:04 -04:00
|
|
|
|
|
|
|
collectedFrames = 0;
|
|
|
|
|
|
|
|
while (collectedFrames < afterFrameCount)
|
|
|
|
{
|
|
|
|
fixedIndex = i;
|
|
|
|
if (i > self.angleSnapshot.size - 1)
|
|
|
|
{
|
|
|
|
fixedIndex = i % self.angleSnapshot.size;
|
|
|
|
}
|
2020-01-06 19:43:00 -05:00
|
|
|
anglesStr += self.angleSnapshot[int(fixedIndex)] + ":";
|
2019-09-09 18:40:04 -04:00
|
|
|
collectedFrames++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2020-01-06 19:43:00 -05:00
|
|
|
lastAttack = int(getTime()) - int(self.lastAttackTime);
|
|
|
|
isAlive = isAlive(self);
|
|
|
|
|
|
|
|
logPrint(logString + ";" + anglesStr + ";" + isAlive + ";" + lastAttack + "\n" );
|
2018-09-04 13:40:29 -04:00
|
|
|
}
|
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
vectorScale( vector, scale )
|
2018-09-02 17:59:27 -04:00
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
return ( vector[0] * scale, vector[1] * scale, vector[2] * scale );
|
2018-09-02 17:59:27 -04:00
|
|
|
}
|
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
Process_Hit( type, attacker, sHitLoc, sMeansOfDeath, iDamage, sWeapon )
|
2017-11-02 12:49:45 -04:00
|
|
|
{
|
2019-09-09 18:40:04 -04:00
|
|
|
if (sMeansOfDeath == "MOD_FALLING" || !isPlayer(attacker))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-02 12:49:45 -04:00
|
|
|
victim = self;
|
2018-02-08 02:23:45 -05:00
|
|
|
_attacker = attacker;
|
2019-08-12 20:04:25 -04:00
|
|
|
|
|
|
|
if ( !isPlayer( attacker ) && isDefined( attacker.owner ) )
|
|
|
|
{
|
2018-02-27 23:19:54 -05:00
|
|
|
_attacker = attacker.owner;
|
2019-08-12 20:04:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
else if( !isPlayer( attacker ) && sMeansOfDeath == "MOD_FALLING" )
|
|
|
|
{
|
2018-02-08 02:23:45 -05:00
|
|
|
_attacker = victim;
|
2019-08-12 20:04:25 -04:00
|
|
|
}
|
2018-03-26 00:51:25 -04:00
|
|
|
|
2019-08-12 20:04:25 -04:00
|
|
|
location = victim GetTagOrigin( hitLocationToBone( sHitLoc ) );
|
|
|
|
isKillstreakKill = !isPlayer( attacker ) || isKillstreakWeapon( sWeapon );
|
2018-03-22 14:50:09 -04:00
|
|
|
|
2020-01-06 19:43:00 -05:00
|
|
|
logLine = "Script" + type + ";" + _attacker.guid + ";" + victim.guid + ";" + _attacker GetTagOrigin("tag_eye") + ";" + location + ";" + iDamage + ";" + sWeapon + ";" + sHitLoc + ";" + sMeansOfDeath + ";" + _attacker getPlayerAngles() + ";" + int(gettime()) + ";" + isKillstreakKill + ";" + _attacker playerADS() + ";0;0";
|
2019-09-09 18:40:04 -04:00
|
|
|
attacker thread waitForAdditionalAngles( logLine, 2, 2 );
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Callback_PlayerDamage( eInflictor, attacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime )
|
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
if ( self.health - iDamage > 0 )
|
|
|
|
{
|
2020-05-30 14:39:09 -04:00
|
|
|
isFriendlyFire = level.teamBased && isDefined( attacker ) && ( self != attacker ) && isDefined( attacker.team ) && ( self.pers[ "team" ] == attacker.team );
|
|
|
|
|
|
|
|
if ( !isFriendlyFire )
|
|
|
|
{
|
|
|
|
self Process_Hit( "Damage", attacker, sHitLoc, sMeansOfDeath, iDamage, sWeapon );
|
|
|
|
}
|
2019-08-12 20:04:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
self maps\mp\gametypes\_damage::Callback_PlayerDamage( eInflictor, attacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime );
|
2018-05-21 17:09:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Callback_PlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
|
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
Process_Hit( "Kill", attacker, sHitLoc, sMeansOfDeath, iDamage, sWeapon );
|
2017-11-02 12:49:45 -04:00
|
|
|
self maps\mp\gametypes\_damage::Callback_PlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration );
|
2018-10-25 09:14:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Callback_PlayerDisconnect()
|
|
|
|
{
|
2019-08-12 20:04:25 -04:00
|
|
|
level notify( "disconnected", self );
|
2018-10-25 09:14:39 -04:00
|
|
|
self maps\mp\gametypes\_playerlogic::Callback_PlayerDisconnect();
|
2017-11-02 12:49:45 -04:00
|
|
|
}
|