mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-06-19 21:19:07 +00:00
Kopion fix
This commit is contained in:
parent
b99965d245
commit
8d634dd20f
1 changed files with 172 additions and 163 deletions
|
@ -205,186 +205,195 @@ function Read-LogEntry {
|
||||||
$weapon = $matches['Weapon']
|
$weapon = $matches['Weapon']
|
||||||
$damageType = $matches['DamageType']
|
$damageType = $matches['DamageType']
|
||||||
$ship = $global:loadOut
|
$ship = $global:loadOut
|
||||||
|
|
||||||
If ($enemyShip -eq $global:lastKill){
|
|
||||||
$enemyShip = "Passenger"
|
|
||||||
} Else {
|
|
||||||
$global:lastKill = $enemyShip
|
|
||||||
}
|
|
||||||
|
|
||||||
If (($player -eq $global:userName -and $enemyPilot -ne $global:userName) -and ($enemyPilot -notlike "PU_*" -and $enemyPilot -notlike "NPC_*")){
|
Try {
|
||||||
If ($enemyShip -match $cleanupPattern){
|
|
||||||
$enemyShip = $matches[1]
|
|
||||||
}
|
|
||||||
If ($weapon -match $cleanupPattern){
|
|
||||||
$weapon = $matches[1]
|
|
||||||
}
|
|
||||||
If ($weapon -eq "KLWE_MassDriver_S10"){
|
|
||||||
$global:loadOut = "AEGS_Idris"
|
|
||||||
$ship = "AEGS_Idris"
|
|
||||||
}
|
|
||||||
if ($damageType -like "*bullet*") {
|
|
||||||
$ship = "Player"
|
|
||||||
}
|
|
||||||
If ($ship -match $cleanupPattern){
|
|
||||||
$ship = $matches[1]
|
|
||||||
}
|
|
||||||
if ($ship -notmatch $shipManPattern){
|
|
||||||
$ship = "Player"
|
|
||||||
}
|
|
||||||
If ($enemyShip -notmatch $shipManPattern) {
|
|
||||||
$enemyShip = "Player"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Repeatedly remove all suffixes
|
|
||||||
while ($enemyShip -match '_(PU|AI|CIV|MIL|PIR)$') {
|
|
||||||
$enemyShip = $enemyShip -replace '_(PU|AI|CIV|MIL|PIR)$', ''
|
|
||||||
}
|
|
||||||
# Repeatedly remove all suffixes
|
|
||||||
while ($ship -match '_(PU|AI|CIV|MIL|PIR)$') {
|
|
||||||
$ship = $ship -replace '_(PU|AI|CIV|MIL|PIR)$', ''
|
|
||||||
}
|
|
||||||
|
|
||||||
$KillTime = (Get-Date).ToUniversalTime().ToString("d MMM yyyy H:mm 'UTC'")
|
|
||||||
$page1 = Invoke-WebRequest -uri "https://robertsspaceindustries.com/citizens/$enemyPilot"
|
$page1 = Invoke-WebRequest -uri "https://robertsspaceindustries.com/citizens/$enemyPilot"
|
||||||
|
} Catch {
|
||||||
# Get Enlisted Date
|
$page1 = $null
|
||||||
if ($($page1.content) -match $joinDatePattern) {
|
}
|
||||||
$joinDate = $matches[1]
|
|
||||||
$joinDate2 = $joinDate -replace ',', ''
|
|
||||||
} else {
|
|
||||||
$joinDate2 = "-"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if there are any matches
|
If ($null -ne $page1){
|
||||||
$enemyOrgs = $page1.links[3].innerHTML
|
|
||||||
|
If ($enemyShip -eq $global:lastKill){
|
||||||
if ($null -eq $enemyOrgs) {
|
$enemyShip = "Passenger"
|
||||||
$enemyOrgs = "-"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get UEE Number
|
|
||||||
if ($($page1.content) -match $ueePattern) {
|
|
||||||
# The matched UEE Citizen Record number is in $matches[1]
|
|
||||||
$citizenRecord = $matches[1]
|
|
||||||
} else {
|
|
||||||
$citizenRecord = "-"
|
|
||||||
}
|
|
||||||
If ($citizenRecord -eq "n/a") {
|
|
||||||
$citizenRecordAPI = "-1"
|
|
||||||
$citizenRecord = "-"
|
|
||||||
} Else {
|
} Else {
|
||||||
$citizenRecordAPI = $citizenRecord
|
$global:lastKill = $enemyShip
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get PFP
|
If ($player -eq $global:userName -and $enemyPilot -ne $global:userName){
|
||||||
$victimPFP = "https://robertsspaceindustries.com$($page1.images[0].src)"
|
If ($enemyShip -match $cleanupPattern){
|
||||||
|
$enemyShip = $matches[1]
|
||||||
Write-Output "NewKill=throwaway,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate2,$citizenRecord,$killTime,$victimPFP"
|
|
||||||
|
|
||||||
$GameMode = $GameMode.ToLower()
|
|
||||||
# Send to API
|
|
||||||
# Define the data to send
|
|
||||||
If ($null -ne $apiUrl -and $offlineMode -eq $false){
|
|
||||||
$data = @{
|
|
||||||
victim_ship = $enemyShip
|
|
||||||
victim = $enemyPilot
|
|
||||||
enlisted = $joinDate
|
|
||||||
rsi = $citizenRecordAPI
|
|
||||||
weapon = $weapon
|
|
||||||
method = $damageType
|
|
||||||
loadout_ship = $ship
|
|
||||||
game_version = $GameVersion
|
|
||||||
gamemode = $GameMode
|
|
||||||
trackr_version = $TrackRver
|
|
||||||
}
|
}
|
||||||
|
If ($weapon -match $cleanupPattern){
|
||||||
# Headers which may or may not be necessary
|
$weapon = $matches[1]
|
||||||
$headers = @{
|
|
||||||
"Authorization" = "Bearer $apiKey"
|
|
||||||
"Content-Type" = "application/json"
|
|
||||||
"User-Agent" = "AutoTrackR2"
|
|
||||||
}
|
}
|
||||||
|
If ($weapon -eq "KLWE_MassDriver_S10"){
|
||||||
try {
|
$global:loadOut = "AEGS_Idris"
|
||||||
# Send the POST request with JSON data
|
$ship = "AEGS_Idris"
|
||||||
Invoke-RestMethod -Uri $apiURL -Method Post -Body ($data | ConvertTo-Json -Depth 5) -Headers $headers
|
}
|
||||||
$logMode = "API"
|
if ($damageType -like "*bullet*") {
|
||||||
} catch {
|
$ship = "Player"
|
||||||
# Catch and display errors
|
}
|
||||||
$apiError = $_
|
If ($ship -match $cleanupPattern){
|
||||||
# Add to output file
|
$ship = $matches[1]
|
||||||
$logMode = "Err-Local"
|
}
|
||||||
|
if ($ship -notmatch $shipManPattern){
|
||||||
|
$ship = "Player"
|
||||||
|
}
|
||||||
|
If ($enemyShip -notmatch $shipManPattern) {
|
||||||
|
$enemyShip = "Player"
|
||||||
}
|
}
|
||||||
} Else {
|
|
||||||
$logMode = "Local"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Define the output CSV path
|
# Repeatedly remove all suffixes
|
||||||
$csvPath = "$scriptFolder\Kill-log.csv"
|
while ($enemyShip -match '_(PU|AI|CIV|MIL|PIR)$') {
|
||||||
|
$enemyShip = $enemyShip -replace '_(PU|AI|CIV|MIL|PIR)$', ''
|
||||||
|
}
|
||||||
|
# Repeatedly remove all suffixes
|
||||||
|
while ($ship -match '_(PU|AI|CIV|MIL|PIR)$') {
|
||||||
|
$ship = $ship -replace '_(PU|AI|CIV|MIL|PIR)$', ''
|
||||||
|
}
|
||||||
|
|
||||||
# Create an object to hold the data
|
$KillTime = (Get-Date).ToUniversalTime().ToString("d MMM yyyy H:mm 'UTC'")
|
||||||
$killData = [PSCustomObject]@{
|
|
||||||
KillTime = $killTime
|
|
||||||
EnemyPilot = $enemyPilot
|
|
||||||
EnemyShip = $enemyShip
|
|
||||||
Enlisted = $joinDate2
|
|
||||||
RecordNumber = $citizenRecord
|
|
||||||
OrgAffiliation = $enemyOrgs
|
|
||||||
Player = $player
|
|
||||||
Weapon = $weapon
|
|
||||||
Ship = $ship
|
|
||||||
Method = $damageType
|
|
||||||
Mode = $GameMode
|
|
||||||
GameVersion = $GameVersion
|
|
||||||
TrackRver = $TrackRver
|
|
||||||
Logged = $logMode
|
|
||||||
}
|
|
||||||
|
|
||||||
# Export to CSV
|
|
||||||
if (-Not (Test-Path $csvPath)) {
|
|
||||||
# If file doesn't exist, create it with headers
|
|
||||||
$killData | Export-Csv -Path $csvPath -NoTypeInformation
|
|
||||||
} else {
|
|
||||||
# Append data to the existing file
|
|
||||||
$killData | Export-Csv -Path $csvPath -Append -NoTypeInformation
|
|
||||||
}
|
|
||||||
|
|
||||||
$sleeptimer = 10
|
|
||||||
|
|
||||||
# VisorWipe
|
|
||||||
If ($visorwipe -eq $true -and $enemyShip -ne "Passenger" -and $damageType -notlike "*Bullet*"){
|
|
||||||
# send keybind for visorwipe
|
|
||||||
start-sleep 1
|
|
||||||
$sleeptimer = $sleeptimer -1
|
|
||||||
&"$scriptFolder\visorwipe.ahk"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Record video
|
|
||||||
if ($recording -eq $true -and $enemyShip -ne "Passenger"){
|
# Get Enlisted Date
|
||||||
# send keybind for windows game bar recording
|
if ($($page1.content) -match $joinDatePattern) {
|
||||||
Start-Sleep 2
|
$joinDate = $matches[1]
|
||||||
$sleeptimer = $sleeptimer -9
|
$joinDate2 = $joinDate -replace ',', ''
|
||||||
&"$scriptFolder\videorecord.ahk"
|
} else {
|
||||||
Start-Sleep 7
|
$joinDate2 = "-"
|
||||||
|
}
|
||||||
|
|
||||||
$latestFile = Get-ChildItem -Path $videoPath | Where-Object { -not $_.PSIsContainer } | Sort-Object CreationTime -Descending | Select-Object -First 1
|
# Check if there are any matches
|
||||||
# Check if the latest file is no more than 10 seconds old
|
$enemyOrgs = $page1.links[3].innerHTML
|
||||||
if ($latestFile) {
|
|
||||||
$fileAgeInSeconds = (New-TimeSpan -Start $latestFile.CreationTime -End (Get-Date)).TotalSeconds
|
if ($null -eq $enemyOrgs) {
|
||||||
if ($fileAgeInSeconds -le 10) {
|
$enemyOrgs = "-"
|
||||||
# Generate a timestamp in ddMMMyyyy-HH:mm format
|
}
|
||||||
$timestamp = (Get-Date).ToString("ddMMMyyyy-HHmm")
|
|
||||||
|
# Get UEE Number
|
||||||
|
if ($($page1.content) -match $ueePattern) {
|
||||||
|
# The matched UEE Citizen Record number is in $matches[1]
|
||||||
|
$citizenRecord = $matches[1]
|
||||||
|
} else {
|
||||||
|
$citizenRecord = "-"
|
||||||
|
}
|
||||||
|
If ($citizenRecord -eq "n/a") {
|
||||||
|
$citizenRecordAPI = "-1"
|
||||||
|
$citizenRecord = "-"
|
||||||
|
} Else {
|
||||||
|
$citizenRecordAPI = $citizenRecord
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get PFP
|
||||||
|
$victimPFP = "https://robertsspaceindustries.com$($page1.images[0].src)"
|
||||||
|
|
||||||
|
Write-Output "NewKill=throwaway,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate2,$citizenRecord,$killTime,$victimPFP"
|
||||||
|
|
||||||
|
$GameMode = $GameMode.ToLower()
|
||||||
|
# Send to API
|
||||||
|
# Define the data to send
|
||||||
|
If ($null -ne $apiUrl -and $offlineMode -eq $false){
|
||||||
|
$data = @{
|
||||||
|
victim_ship = $enemyShip
|
||||||
|
victim = $enemyPilot
|
||||||
|
enlisted = $joinDate
|
||||||
|
rsi = $citizenRecordAPI
|
||||||
|
weapon = $weapon
|
||||||
|
method = $damageType
|
||||||
|
loadout_ship = $ship
|
||||||
|
game_version = $GameVersion
|
||||||
|
gamemode = $GameMode
|
||||||
|
trackr_version = $TrackRver
|
||||||
|
}
|
||||||
|
|
||||||
|
# Headers which may or may not be necessary
|
||||||
|
$headers = @{
|
||||||
|
"Authorization" = "Bearer $apiKey"
|
||||||
|
"Content-Type" = "application/json"
|
||||||
|
"User-Agent" = "AutoTrackR2"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Send the POST request with JSON data
|
||||||
|
Invoke-RestMethod -Uri $apiURL -Method Post -Body ($data | ConvertTo-Json -Depth 5) -Headers $headers
|
||||||
|
$logMode = "API"
|
||||||
|
} catch {
|
||||||
|
# Catch and display errors
|
||||||
|
$apiError = $_
|
||||||
|
# Add to output file
|
||||||
|
$logMode = "Err-Local"
|
||||||
|
}
|
||||||
|
} Else {
|
||||||
|
$logMode = "Local"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define the output CSV path
|
||||||
|
$csvPath = "$scriptFolder\Kill-log.csv"
|
||||||
|
|
||||||
|
# Create an object to hold the data
|
||||||
|
$killData = [PSCustomObject]@{
|
||||||
|
KillTime = $killTime
|
||||||
|
EnemyPilot = $enemyPilot
|
||||||
|
EnemyShip = $enemyShip
|
||||||
|
Enlisted = $joinDate2
|
||||||
|
RecordNumber = $citizenRecord
|
||||||
|
OrgAffiliation = $enemyOrgs
|
||||||
|
Player = $player
|
||||||
|
Weapon = $weapon
|
||||||
|
Ship = $ship
|
||||||
|
Method = $damageType
|
||||||
|
Mode = $GameMode
|
||||||
|
GameVersion = $GameVersion
|
||||||
|
TrackRver = $TrackRver
|
||||||
|
Logged = $logMode
|
||||||
|
}
|
||||||
|
|
||||||
|
# Export to CSV
|
||||||
|
if (-Not (Test-Path $csvPath)) {
|
||||||
|
# If file doesn't exist, create it with headers
|
||||||
|
$killData | Export-Csv -Path $csvPath -NoTypeInformation
|
||||||
|
} else {
|
||||||
|
# Append data to the existing file
|
||||||
|
$killData | Export-Csv -Path $csvPath -Append -NoTypeInformation
|
||||||
|
}
|
||||||
|
|
||||||
|
$sleeptimer = 10
|
||||||
|
|
||||||
|
# VisorWipe
|
||||||
|
If ($visorwipe -eq $true -and $enemyShip -ne "Passenger" -and $damageType -notlike "*Bullet*"){
|
||||||
|
# send keybind for visorwipe
|
||||||
|
start-sleep 1
|
||||||
|
$sleeptimer = $sleeptimer -1
|
||||||
|
&"$scriptFolder\visorwipe.ahk"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Record video
|
||||||
|
if ($recording -eq $true -and $enemyShip -ne "Passenger"){
|
||||||
|
# send keybind for windows game bar recording
|
||||||
|
Start-Sleep 2
|
||||||
|
$sleeptimer = $sleeptimer -9
|
||||||
|
&"$scriptFolder\videorecord.ahk"
|
||||||
|
Start-Sleep 7
|
||||||
|
|
||||||
|
$latestFile = Get-ChildItem -Path $videoPath | Where-Object { -not $_.PSIsContainer } | Sort-Object CreationTime -Descending | Select-Object -First 1
|
||||||
|
# Check if the latest file is no more than 10 seconds old
|
||||||
|
if ($latestFile) {
|
||||||
|
$fileAgeInSeconds = (New-TimeSpan -Start $latestFile.CreationTime -End (Get-Date)).TotalSeconds
|
||||||
|
if ($fileAgeInSeconds -le 10) {
|
||||||
|
# Generate a timestamp in ddMMMyyyy-HH:mm format
|
||||||
|
$timestamp = (Get-Date).ToString("ddMMMyyyy-HHmm")
|
||||||
|
|
||||||
# Extract the file extension to preserve it
|
# Extract the file extension to preserve it
|
||||||
$fileExtension = $latestFile.Extension
|
$fileExtension = $latestFile.Extension
|
||||||
|
|
||||||
# Rename the file, preserving the original file extension
|
# Rename the file, preserving the original file extension
|
||||||
Rename-Item -Path $latestFile.FullName -NewName "$enemyPilot.$enemyShip.$timestamp$fileExtension"
|
Rename-Item -Path $latestFile.FullName -NewName "$enemyPilot.$enemyShip.$timestamp$fileExtension"
|
||||||
|
} else {}
|
||||||
} else {}
|
} else {}
|
||||||
} else {}
|
}
|
||||||
|
Start-Sleep $sleeptimer
|
||||||
}
|
}
|
||||||
Start-Sleep $sleeptimer
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue