Upload from upload_mods.ps1
This commit is contained in:
129
Scripts/EAI/NPCs/EAIWanderCompanion.cs
Normal file
129
Scripts/EAI/NPCs/EAIWanderCompanion.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class EAIWanderCompanion : EAIBase
|
||||
{
|
||||
public const float cLookTimeMax = 3f;
|
||||
public Vector3 position;
|
||||
public float time;
|
||||
|
||||
public override void Init(EntityAlive _theEntity)
|
||||
{
|
||||
base.Init(_theEntity);
|
||||
this.MutexBits = 1;
|
||||
}
|
||||
|
||||
public override void Update() => this.time += 0.05f;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-Reset START");
|
||||
//Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
this.manager.lookTime = this.RandomFloat * 3f;
|
||||
this.theEntity.moveHelper.Stop();
|
||||
}
|
||||
|
||||
public bool NPCEAICanProceed(bool skipTargetVerification = false)
|
||||
{
|
||||
if (this.theEntity.Buffs.GetCustomVar("$Leader") > 0f)
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.Buffs.GetCustomVar("CurrentOrder") > 0)
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 1a");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.Buffs.GetCustomVar("onMission") == 1f ||
|
||||
this.theEntity.Buffs.GetCustomVar("$FR_NPC_Respawn") == 1f ||
|
||||
this.theEntity.Buffs.GetCustomVar("$FR_NPC_Hidden") == 1f
|
||||
)
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 1b");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.GetAttackTarget() != null)
|
||||
{
|
||||
//Log.Out($"EAIWanderCompanion-NPCEAICanProceed theEntity.GetAttackTarget() != null: {theEntity.GetAttackTarget()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.Buffs.HasBuff("buffTalkingTo"))
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.sleepingOrWakingUp)
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 4");
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.GetTicksNoPlayerAdjacent() >= 120)
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 5");
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.bodyDamage.CurrentStun != EnumEntityStunType.None)
|
||||
{
|
||||
//Log.Out("EAIWanderCompanion-NPCEAICanProceed 6");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanExecute()
|
||||
{
|
||||
if (!NPCEAICanProceed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.sleepingOrWakingUp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.GetTicksNoPlayerAdjacent() >= 120)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.bodyDamage.CurrentStun != EnumEntityStunType.None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = (int)(200f * this.executeWaitTime);
|
||||
if (base.GetRandom(1000) >= num)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
int num = 10;
|
||||
this.theEntity.FindPath(RandomPositionGenerator.Calc(this.theEntity, num, num), this.theEntity.GetMoveSpeed(), false, this);
|
||||
}
|
||||
|
||||
public override bool Continue()
|
||||
{
|
||||
if (!NPCEAICanProceed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("EAIWanderCompanion-Continue this.theEntity.bodyDamage.CurrentStun == EnumEntityStunType.None: " + (this.theEntity.bodyDamage.CurrentStun == EnumEntityStunType.None));
|
||||
//Log.Out("EAIWanderCompanion-Continue this.theEntity.moveHelper.BlockedTime <= 0.3f: " + (this.theEntity.moveHelper.BlockedTime <= 0.3f));
|
||||
//Log.Out("EAIWanderCompanion-Continue !this.theEntity.navigator.noPathAndNotPlanningOne(): " + !this.theEntity.navigator.noPathAndNotPlanningOne());
|
||||
|
||||
bool result = this.theEntity.bodyDamage.CurrentStun == EnumEntityStunType.None && this.theEntity.moveHelper.BlockedTime <= 0.3f && !this.theEntity.navigator.noPathAndNotPlanningOne();
|
||||
|
||||
//Log.Out("EAIWanderCompanion-Continue result: " + result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user