DataDumper
This commit is contained in:
@ -1,15 +1,154 @@
|
||||
using RageCoop.Core;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data.HashFunction.Jenkins;
|
||||
using Formatting = Newtonsoft.Json.Formatting;
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RageCoop.Client.DataDumper
|
||||
{
|
||||
class WeaponInfo
|
||||
{
|
||||
public WeaponInfo(XmlNode node)
|
||||
{
|
||||
if (node.Attributes["type"].Value != "CWeaponInfo")
|
||||
{
|
||||
throw new Exception("Not a CWeaponInfo node");
|
||||
|
||||
}
|
||||
foreach (XmlNode info in node.ChildNodes)
|
||||
{
|
||||
switch (info.Name)
|
||||
{
|
||||
case "Name":
|
||||
Name = info.InnerText; break;
|
||||
case "Audio":
|
||||
Audio = info.InnerText; break;
|
||||
case "FireType":
|
||||
FireType = info.InnerText; break;
|
||||
case "DamageType":
|
||||
DamageType = info.InnerText; break;
|
||||
case "Damage":
|
||||
Damage = info.GetFloat(); break;
|
||||
case "Speed":
|
||||
Speed = info.GetFloat(); break;
|
||||
}
|
||||
}
|
||||
IsVehicleWeapon = Name.StartsWith("VEHICLE_WEAPON");
|
||||
}
|
||||
public string Name;
|
||||
public string Audio;
|
||||
public string FireType;
|
||||
public string DamageType;
|
||||
public float Damage;
|
||||
public float Speed;
|
||||
public bool IsVehicleWeapon;
|
||||
}
|
||||
public static class Program
|
||||
{
|
||||
|
||||
public static float GetFloat(this XmlNode n)
|
||||
{
|
||||
return float.Parse(n.Attributes["value"].Value);
|
||||
}
|
||||
public static void Main()
|
||||
{
|
||||
Dictionary<uint, WeaponInfo> weapons = new();
|
||||
foreach (var f in Directory.GetFiles("meta", "*.meta"))
|
||||
{
|
||||
Parse(f, weapons);
|
||||
}
|
||||
Directory.CreateDirectory("Weapons");
|
||||
File.WriteAllText("Weapons\\Weapons.json", JsonConvert.SerializeObject(weapons, Formatting.Indented));
|
||||
DumpWeaponHash(weapons, true);
|
||||
}
|
||||
static void Parse(string filename, Dictionary<uint, WeaponInfo> weap)
|
||||
{
|
||||
Console.WriteLine("Parsing " + filename);
|
||||
var doc = new XmlDocument();
|
||||
try
|
||||
{
|
||||
doc.Load(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex); return;
|
||||
}
|
||||
var nodes = doc.ChildNodes.ToList();
|
||||
if (nodes.Any(x => x.Name == "CWeaponInfoBlob"))
|
||||
{
|
||||
var infosNode = doc.GetElementsByTagName("Item");
|
||||
foreach (XmlNode n in infosNode)
|
||||
{
|
||||
if (n.Attributes["type"]?.Value == "CWeaponInfo")
|
||||
{
|
||||
var info = new WeaponInfo(n);
|
||||
if (!info.Name.StartsWith("VEHICLE_WEAPON") && !info.Name.StartsWith("WEAPON"))
|
||||
{ continue; }
|
||||
var hash = Hash(info.Name);
|
||||
if (weap.ContainsKey(hash))
|
||||
{
|
||||
weap[hash] = info;
|
||||
}
|
||||
else
|
||||
{
|
||||
weap.Add(hash, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void DumpWeaponHash(Dictionary<uint, WeaponInfo> weapons, bool sort = false, string path = @"Weapons\WeaponHash.cs")
|
||||
{
|
||||
StringBuilder output = new();
|
||||
List<string> lines = new();
|
||||
var weps = weapons.Where(x => x.Value.Name.StartsWith("WEAPON"));
|
||||
var vehWeaps = weapons.Where(x => x.Value.Name.StartsWith("VEHICLE_WEAPON"));
|
||||
output.Append("public enum WeaponHash : uint\r\n{");
|
||||
foreach (var info in weps)
|
||||
{
|
||||
lines.Add($"{CoreUtils.FormatToSharpStyle(info.Value.Name, 7)} = {info.Key.ToHex()}");
|
||||
}
|
||||
if (sort)
|
||||
{
|
||||
lines.Sort();
|
||||
}
|
||||
foreach (var l in lines)
|
||||
{
|
||||
output.Append($"\r\n\t{l},");
|
||||
}
|
||||
output.AppendLine("\r\n}");
|
||||
output.AppendLine();
|
||||
output.Append("public enum VehicleWeaponHash : uint\r\n{\r\n\tInvalid = 0xFFFFFFFF,");
|
||||
lines = new();
|
||||
foreach (var info in vehWeaps)
|
||||
{
|
||||
lines.Add($"{CoreUtils.FormatToSharpStyle(info.Value.Name)} = {info.Key.ToHex()}");
|
||||
}
|
||||
if (sort)
|
||||
{
|
||||
lines.Sort();
|
||||
}
|
||||
foreach (var l in lines)
|
||||
{
|
||||
output.Append($"\r\n\t{l},");
|
||||
}
|
||||
output.Append("\r\n}");
|
||||
File.WriteAllText(path, output.ToString());
|
||||
|
||||
}
|
||||
static List<XmlNode> ToList(this XmlNodeList l)
|
||||
{
|
||||
var nodes = new List<XmlNode>();
|
||||
foreach(XmlNode n in l)
|
||||
{
|
||||
nodes.Add(n);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
static UInt32 Hash(string key)
|
||||
{
|
||||
key = key.ToLower();
|
||||
int i = 0;
|
||||
uint hash = 0;
|
||||
while (i != key.Length)
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using RageCoop.Core;
|
||||
|
||||
namespace RageCoop.Client
|
||||
{
|
||||
@ -28,16 +29,23 @@ namespace RageCoop.Client
|
||||
World.DrawLine(wb.Position, wb.Position + wb.RightVector, Color.Blue);
|
||||
}
|
||||
if (ToMark == null) return;
|
||||
|
||||
if (WeaponUtil.VehicleWeapons.TryGetValue((uint)(int)ToMark.Model, out var info))
|
||||
{
|
||||
foreach (var ws in info.Weapons)
|
||||
{
|
||||
foreach (var w in ws.Value.Bones)
|
||||
{
|
||||
DrawBone(w.BoneName, ws.Value.Name);
|
||||
DrawBone(w.BoneName, ws.Value.Name+":"+ws.Key.ToHex());
|
||||
}
|
||||
}
|
||||
}
|
||||
var P = Game.Player.Character;
|
||||
var b = ToMark.GetMuzzleBone(P.VehicleWeapon);
|
||||
if (b != null)
|
||||
{
|
||||
World.DrawLine(b.Position, b.Position + b.ForwardVector * 5, Color.Brown);
|
||||
}
|
||||
}
|
||||
void FindAndDraw()
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ using System.Resources;
|
||||
|
||||
|
||||
// Version informationr(
|
||||
[assembly: AssemblyVersion("1.5.6.98")]
|
||||
[assembly: AssemblyFileVersion("1.5.6.98")]
|
||||
[assembly: AssemblyVersion("1.5.6.104")]
|
||||
[assembly: AssemblyFileVersion("1.5.6.104")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||
|
||||
|
@ -327,20 +327,18 @@ namespace RageCoop.Client
|
||||
}
|
||||
public static Vector3 GetAimCoord(this Ped p)
|
||||
{
|
||||
var weapon = p.Weapons.CurrentWeaponObject;
|
||||
Prop weapon;
|
||||
|
||||
var v = p.CurrentVehicle;
|
||||
// Rhino
|
||||
if (v != null && v.Model.Hash == 782665360)
|
||||
{
|
||||
return v.Bones[35].Position + v.Bones[35].ForwardVector * 100;
|
||||
}
|
||||
EntityBone b;
|
||||
if (p.IsOnTurretSeat())
|
||||
{
|
||||
var b = p.CurrentVehicle.GetMuzzleBone(p.VehicleWeapon);
|
||||
return b.Position + b.ForwardVector * 50;
|
||||
if((b = p.CurrentVehicle.GetMuzzleBone(p.VehicleWeapon)) != null)
|
||||
{
|
||||
return b.Position + b.ForwardVector * 50;
|
||||
}
|
||||
return GetLookingCoord(p);
|
||||
}
|
||||
if (weapon != null)
|
||||
if ((weapon= p.Weapons.CurrentWeaponObject) != null)
|
||||
{
|
||||
// Not very accurate, but doesn't matter
|
||||
Vector3 dir = weapon.RightVector;
|
||||
|
@ -281,6 +281,7 @@ namespace RageCoop.Client
|
||||
}
|
||||
public static EntityBone GetMuzzleBone(this Vehicle v, VehicleWeaponHash hash)
|
||||
{
|
||||
if ((uint)hash == 1422046295) { hash = VehicleWeaponHash.WaterCannon; } // Weird...
|
||||
var i = v.GetMuzzleIndex(hash);
|
||||
if (i == -1) { return null; }
|
||||
return v.Bones[i];
|
||||
|
@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RageCoop.Client.DataDumper", "Client\DataDumper\RageCoop.Client.DataDumper.csproj", "{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -68,6 +70,14 @@ Global
|
||||
{FC8CBDBB-6DC3-43AF-B34D-092E476410A5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FC8CBDBB-6DC3-43AF-B34D-092E476410A5}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{FC8CBDBB-6DC3-43AF-B34D-092E476410A5}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F3DFDDC8-D5B1-4E96-959E-492AD7A8BA30}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Reference in New Issue
Block a user