Skip to content

Commit

Permalink
Update plugin test, and some scanner updates
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed May 26, 2024
1 parent 16a1611 commit 8674225
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 55 deletions.
26 changes: 13 additions & 13 deletions PLUGIN/plugin.sma
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

#define PLUGIN "Unreal Demo Plugin"
#define AUTHOR "karaulov"
#define VERSION "1.55"
#define VERSION "1.56"


new g_iDemoHelperInitStage[33] = {0,...};
new g_iFrameNum[33] = {0,...};
new g_iPbEventCount[33] = {0,...};
new Float:g_flLastEventTime[33] = {0.0,...};

public plugin_init()
{
Expand All @@ -32,7 +32,7 @@ public plugin_init()

public client_disconnected(id)
{
g_iPbEventCount[id] = 0;
g_flLastEventTime[id] = 0.0;
g_iFrameNum[id] = 0;
g_iDemoHelperInitStage[id] = 0;

Expand All @@ -42,9 +42,13 @@ public client_disconnected(id)
/*Server not processed angles. Always empty.*/
public fw_PlaybackEvent( iFlags, id, eventIndex )
{
if(id > 0 && id < 33 && g_iDemoHelperInitStage[id] == -1)
if(id > 0 && id < 33 && g_iDemoHelperInitStage[id] == -1 && iFlags == 1)
{
g_iPbEventCount[id]++;
if (floatabs(get_gametime() - g_flLastEventTime[id]) > 1.0)
{
g_flLastEventTime[id] = get_gametime();
WriteDemoInfo(id, "UDS/EVENT/%i", eventIndex);
}
}

return FMRES_IGNORED;
Expand Down Expand Up @@ -97,22 +101,18 @@ public PM_Move(const id)
{
new button = get_entvar(id, var_button)
new oldbuttons = get_entvar(id, var_oldbuttons)
if (g_iDemoHelperInitStage[id] == -1 && !(button & IN_ATTACK) && (oldbuttons & IN_ATTACK))
if (g_iDemoHelperInitStage[id] == -1 && (button & IN_ATTACK) && !(oldbuttons & IN_ATTACK))
{
new cmdx = get_pmove( pm_cmd );

g_iFrameNum[id]++;
WriteDemoInfo(id, "UDS/XCMD/%i/%i/%i", get_ucmd(cmdx, ucmd_lerp_msec), get_ucmd(cmdx, ucmd_msec),g_iFrameNum[id]);
if (g_iPbEventCount[id] > 0)
WriteDemoInfo(id, "UDS/EVENTS/%i",g_iPbEventCount[id]);
g_iPbEventCount[id] = 0;
g_iFrameNum[id]++;
}
return HC_CONTINUE;
}

public UnrealDemoHelpInitialize(id)
{
g_iPbEventCount[id] = 0;
g_flLastEventTime[id] = 0.0;
g_iFrameNum[id] = 0;
g_iDemoHelperInitStage[id] = 0;
if (is_user_connected(id))
Expand Down Expand Up @@ -155,7 +155,7 @@ public DemoHelperInitializeTask(id)
WriteDemoInfo(id,"UDS/MINUR/%i",get_cvar_num("sv_minupdaterate"));
WriteDemoInfo(id,"UDS/MAXUR/%i",get_cvar_num("sv_maxupdaterate"));

g_iPbEventCount[id] = 0;
g_flLastEventTime[id] = 0.0;
g_iDemoHelperInitStage[id] = -1;
}
}
Expand Down
99 changes: 63 additions & 36 deletions UnrealDemoScanner/UnrealDemoScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public MyTreeNode(string text)
public static int LocalPlayerId = -1;
public static int LocalPlayerUserId = -1;
public static int LocalPlayerUserId2 = -1;
public static int LocalPlayerEntity = -1;
public static int TmpPlayerNum = -1;
public static int TmpPlayerEnt = -1;
public static bool FirstEventShift;
Expand Down Expand Up @@ -3608,13 +3607,20 @@ следующий кадр изменение и 5 кадров нет движ

var eframe = (GoldSource.EventFrame)frame.Value;

//bool found = false;

//foreach (var res in DownloadedResources)
//{
// if (res.res_index == eframe.Index && res.res_type == 5)
// {
// found = true;
// Console.WriteLine("Event:" + res.res_path + " at " + CurrentTimeString);
// }
//}

//if (!found)
// Console.WriteLine("Event:" + "[UNKNOWN]" + " at " + CurrentTimeString);

LastEventId = eframe.Index;

if (abs(LastEventDetectTime) > EPSILON && abs(LastAttackPressed - LastEventDetectTime) > 0.25)
Expand Down Expand Up @@ -3853,7 +3859,8 @@ следующий кадр изменение и 5 кадров нет движ
FirstJump = false;
FirstAttack = false;
SearchJumpBug = false;

TmpPlayerEnt = -1;
TmpPlayerNum = -1;
LocalPlayerId = -1;
fullPlayerList.AddRange(playerList);
playerList.Clear();
Expand Down Expand Up @@ -4146,6 +4153,18 @@ следующий кадр изменение и 5 кадров нет движ
FrameDuplicates++;
}

TmpPlayerNum = nf.RParms.Playernum;
TmpPlayerEnt = nf.RParms.Viewentity;

if (abs(CurrentTime) > EPSILON && CurrentFrameDuplicated <= 1)
{
if (LocalPlayerId < 0)
{
LocalPlayerId = TmpPlayerNum;
//if (DUMP_ALL_FRAMES) subnode.Text += "[HERE PLAYER FOUND]";
//Console.WriteLine(LocalPlayerId.ToString());
}
}

var voice_time = abs(CurrentTime - PreviousTime);
if (voice_time > 1.0f)
Expand Down Expand Up @@ -4191,14 +4210,14 @@ следующий кадр изменение и 5 кадров нет движ
}
if (abs(LastEventDetectTime) > EPSILON && abs(LastAttackPressed - LastEventDetectTime) > 0.25)
{
DemoScanner_AddWarn("[BETA] [TRIGGER TYPE 3 " + CurrentWeapon + "] at (" + CurrentTime + ") " +
DemoScanner_AddWarn("[BETA] [TRIGGER TYPE 3." + (LastEventId < 0 ? 2 : 1) + " " + CurrentWeapon + "] at (" + CurrentTime + ") " +
CurrentTimeString, false);
TriggerAimAttackCount++;
LastTriggerAttack = CurrentTime;

foreach (var res in DownloadedResources)
{
if (res.res_index == LastEventId && res.res_type == 5)
if (res.res_index == Math.Abs(LastEventId) && res.res_type == 5)
{
Console.WriteLine("[Debug] event:" + res.res_path + " at " + CurrentTimeString);
}
Expand Down Expand Up @@ -5987,14 +6006,6 @@ следующий кадр изменение и 5 кадров нет движ
subnode.Text += "RParms.Playernum = " + nf.RParms.Playernum + "\n";
}

TmpPlayerNum = nf.RParms.Playernum;
TmpPlayerEnt = nf.RParms.Viewentity;

if (LocalPlayerId == -1 && TmpPlayerNum == TmpPlayerEnt - 1)
{
LocalPlayerId = TmpPlayerNum;
}

ViewModel = nf.Viewmodel;

if (!UserAlive && ViewEntity == nf.RParms.Viewentity)
Expand Down Expand Up @@ -8342,7 +8353,7 @@ public static void ProcessPluginMessage(string cmd)
PluginVersion = cmdList[1] == "UCMD" ? "< 1.5" : cmdList[2];
DemoScanner_AddWarn("[INFO] Found module version " + PluginVersion, true, false, true,
true);
if (cmdList[1] == "UCMD" || PluginVersion != "1.55")
if (cmdList[1] == "UCMD" || PluginVersion != "1.56")
{
if (IsRussia)
{
Expand Down Expand Up @@ -8384,7 +8395,7 @@ public static void ProcessPluginMessage(string cmd)
var ms = Convert.ToByte(int.Parse(cmdList[3]));
var incomingframenum = int.Parse(cmdList[4]);

if (!IsPlayerBtnAttackedPressed() && abs(CurrentTime - LastLostAttackTime2) < 1.0f &&
if (!IsPlayerBtnAttackedPressed() && /*abs(CurrentTime - LastLostAttackTime2) < 1.0f &&*/
FirstAttack && IsUserAlive() && !DisableJump5AndAim16)
{
DemoScanner_AddWarn(
Expand Down Expand Up @@ -8488,32 +8499,45 @@ public static void ProcessPluginMessage(string cmd)
}
else if (cmdList[1] == "EVENT" && !DisableJump5AndAim16)
{
var events = 1;
if (DUMP_ALL_FRAMES) OutDumpString += "\n{ EVENT PLUGIN }\n";

if (PluginEvents == -1)
var tmpEvent = 0;
if (cmdList.Length > 1)
int.TryParse(cmdList[2], out tmpEvent);
LastEventId = -tmpEvent;

if (abs(LastEventDetectTime) > EPSILON && abs(LastAttackPressed - LastEventDetectTime) > 0.5)
{
CurrentEvents = 0;
PluginEvents = 0;

}
else if (CurrentEvents > 0)
else
{
if (CurrentEvents - PluginEvents > 4)
{
if (PluginEvents != 0)
DemoScanner_AddWarn(
"[EXPERIMENTAL][CMD HACK TYPE 8] at (" + CurrentTime + "):" +
CurrentTimeString, false, true, false, true);
else
BadEvents += 8;

CurrentEvents = 0;
PluginEvents = 0;
FirstEventShift = true;
}

PluginEvents += events;
LastEventDetectTime = 0.0f;
}

//if (PluginEvents == -1)
//{
// CurrentEvents = 0;
// PluginEvents = 0;
//}
//else if (CurrentEvents > 0)
//{
// if (CurrentEvents - PluginEvents > 4)
// {
// if (PluginEvents != 0)
// DemoScanner_AddWarn(
// "[EXPERIMENTAL][CMD HACK TYPE 8] at (" + CurrentTime + "):" +
// CurrentTimeString, false, true, false, true);
// else
// BadEvents += 8;

// CurrentEvents = 0;
// PluginEvents = 0;
// FirstEventShift = true;
// }

// PluginEvents += events;
//}
}
else if (cmdList[1] == "MINR" || cmdList[1] == "MINUR"
|| cmdList[1] == "MAXR" || cmdList[1] == "MAXUR")
Expand Down Expand Up @@ -9670,7 +9694,6 @@ public void MessageUpdateUserInfo()
var tmpconsolecolor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
for (var i = 0; i < 64; i++) Console.Write(" ");

Console.CursorLeft = UserNameAndSteamIDField2;
Console.Write(player.UserName.TrimBad().Trim());
Console.ForegroundColor = ConsoleColor.Cyan;
Expand Down Expand Up @@ -10425,6 +10448,11 @@ private void MessageResourceList()

DownloadedResources = CleanDownloadedResources;

//foreach (var res in DownloadedResources)
//{
// Console.WriteLine(res.ToString() + " at " + CurrentTimeString);
//}

// consistency list
// indices of resources to force consistency upon?
if (BitBuffer.ReadBoolean())
Expand Down Expand Up @@ -10530,7 +10558,6 @@ private void MessageHltv()
LocalPlayerId = 0;
LocalPlayerUserId = 0;
LocalPlayerUserId2 = 0;
LocalPlayerEntity = 0;
AlternativeTimeCounter = 1;
DEMOSCANNER_HLTV = true;
var backcolor = Console.ForegroundColor;
Expand Down
12 changes: 6 additions & 6 deletions UnrealDemoScannerNET48/UnrealDemoScannerNET48.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,24 @@
<Link>Other\Resources.Designer.cs</Link>
</Compile>
<Compile Include="..\UnrealDemoScanner\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\UnrealDemoScanner\UnrealDemoScanner.cs">
</Compile>
<Compile Include="..\UnrealDemoScanner\Parser\BinaryReaderExtension.cs">
<Link>Parser\BinaryReaderExtension.cs</Link>
<Link>Parser\BinaryReaderExtension.cs</Link>
</Compile>
<Compile Include="..\UnrealDemoScanner\Parser\CrossDemoParser.cs">
<Link>Parser\CrossDemoParser.cs</Link>
<Link>Parser\CrossDemoParser.cs</Link>
</Compile>
<Compile Include="..\UnrealDemoScanner\Parser\DemoInfo.cs">
<Link>Parser\DemoInfo</Link>
<Link>Parser\DemoInfo</Link>
</Compile>
<Compile Include="..\UnrealDemoScanner\Parser\GoldSourceParser.cs">
<Link>Parser\GoldSourceParser.cs</Link>
<Link>Parser\GoldSourceParser.cs</Link>
</Compile>
<Compile Include="..\UnrealDemoScanner\Parser\Point3D.cs">
<Link>Parser\Point3D</Link>
<Link>Parser\Point3D</Link>
</Compile>
<EmbeddedResource Include="..\UnrealDemoScanner\EntitiesPreviewWindow.resx">
<DependentUpon>EntitiesPreviewWindow.cs</DependentUpon>
Expand Down

0 comments on commit 8674225

Please sign in to comment.