Project_WL/AgentScripts/WL884_Probe.cs

59 lines
3.3 KiB
C#

// WL884_Probe.cs — PD 지시 #884 칼날 폭풍 다듬기 시험(Play 중)
// unity command run_script --file AgentScripts/WL884_Probe.cs --entry WL884_Probe.Run --args '[로그 경로, 이동 시작 s, 이동 길이 s, dx, dz, 슬롯]'
// 시험 시전(쿨 · MP 무시) → 0.25 s(게임 시간)마다 동작 · 상태 · 조이스틱 상태 · 위치 · 회전 투사체 수 · 타격 수를 파일에 적는다(run_script 마다 어셈블리가 새로 생겨 static 으로는 못 넘긴다).
using System.Collections;
using System.Reflection;
using UnityEngine;
public static class WL884_Probe
{
static readonly BindingFlags BF = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
static readonly string[] States = { "twohandskill3", "twohandskill3_loop", "idle", "Idle", "run", "Run", "fatalblow" };
public static object Run(string path, float steerAt, float steerFor, float dx, float dz, int slot)
{
var pc = MyValue.MyPC; if (pc == null) return "PC 없음";
var arr = typeof(PCActor).GetField("arr_magicData", BF).GetValue(pc) as SkillListTableData[];
var data = arr != null && slot >= 0 && slot < arr.Length ? arr[slot] : null;
if (data == null) return "슬롯 비어 있음 " + slot;
System.IO.File.WriteAllText(path, "skill " + data.n_SkillID + " " + data.e_Skill + " anim=" + data.s_Animation + " class=" + data.n_SkillClassID + "\n");
pc.StartCoroutine(Co(pc, data, slot, path, steerAt, steerFor, new Vector3(dx, 0f, dz).normalized));
return "started " + data.n_SkillID;
}
static IEnumerator Co(PCActor pc, SkillListTableData data, int slot, string path, float steerAt, float steerFor, Vector3 dir)
{
int hits0 = WL.Combat.Core.CombatEvents.HitConfirmed.Raised;
bool ok = pc.Use_Skill(data, true, slot, true);
Append(path, "cast=" + ok);
float t = 0f, next = 0f;
while (t < 4.5f && pc != null)
{
if (t >= steerAt && t < steerAt + steerFor) pc.Run_byJoystick(dir);
if (t >= next) { next += 0.25f; Append(path, Line(pc, t, hits0)); }
yield return null;
t += Time.deltaTime;
}
Append(path, "END " + Line(pc, t, hits0));
}
static string Line(PCActor pc, float t, int hits0)
{
var an = pc.m_animation;
string st = "?", clip = "?";
if (an != null)
{
var si = an.GetCurrentAnimatorStateInfo(0);
foreach (var n in States) if (si.IsName(n)) { st = n; break; }
if (an.IsInTransition(0)) { var ni = an.GetNextAnimatorStateInfo(0); foreach (var n in States) if (ni.IsName(n)) { st += ">" + n; break; } }
var ci = an.GetCurrentAnimatorClipInfo(0); clip = ci.Length > 0 ? ci[0].clip.name : "-";
}
int ww = Object.FindObjectsByType<Skill_Whirlwind>(FindObjectsInactive.Exclude, FindObjectsSortMode.None).Length;
var p = pc.transform.position;
return "t=" + t.ToString("F2") + " anim=" + pc.Get_CurAnim() + " state=" + st + " clip=" + clip + " js=" + pc.JoystickStatus
+ " pos=(" + p.x.ToString("F2") + "," + p.z.ToString("F2") + ") whirl=" + ww + " hits+" + (WL.Combat.Core.CombatEvents.HitConfirmed.Raised - hits0);
}
static void Append(string path, string line) { try { System.IO.File.AppendAllText(path, line + "\n"); } catch { } }
}