Upload from upload_mods.ps1
This commit is contained in:
232
Scripts/EAI/EAISetNearestEntityAsTargetSDX.cs
Normal file
232
Scripts/EAI/EAISetNearestEntityAsTargetSDX.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class EAISetNearestEntityAsTargetSDX : EAISetNearestEntityAsTarget
|
||||
{
|
||||
private void SeekNoise(EntityPlayer player)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetSDX-SeekNoise START");
|
||||
float num = (player.position - this.theEntity.position).magnitude;
|
||||
if (this.playerTargetClassIndex >= 0)
|
||||
{
|
||||
float num2 = this.targetClasses[this.playerTargetClassIndex].hearDistMax;
|
||||
if (num2 > 0f)
|
||||
{
|
||||
num2 *= this.theEntity.senseScale;
|
||||
if (num > num2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
num *= 0.9f;
|
||||
if (num > this.manager.noiseSeekDist)
|
||||
{
|
||||
num = this.manager.noiseSeekDist;
|
||||
}
|
||||
if (this.theEntity.IsBloodMoon)
|
||||
{
|
||||
num = this.manager.noiseSeekDist * 0.25f;
|
||||
}
|
||||
Vector3 breadcrumbPos = player.GetBreadcrumbPos(num * base.RandomFloat);
|
||||
int ticks = this.theEntity.CalcInvestigateTicks((int)(30f + base.RandomFloat * 30f) * 20, player);
|
||||
this.theEntity.SetInvestigatePosition(breadcrumbPos, ticks, true);
|
||||
float time = Time.time;
|
||||
if (this.senseSoundTime - time < 0f)
|
||||
{
|
||||
this.senseSoundTime = time + 10f + base.RandomFloat * 10f;
|
||||
this.theEntity.PlayOneShot(this.theEntity.soundSense, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindTarget()
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetSDX-FindTarget START");
|
||||
this.closeTargetDist = float.MaxValue;
|
||||
this.closeTargetEntity = null;
|
||||
|
||||
float seeDistance = this.theEntity.GetSeeDistance();
|
||||
|
||||
for (int i = 0; i < this.targetClasses.Count; i++)
|
||||
{
|
||||
EAISetNearestEntityAsTargetSDX.TargetClass targetClass = this.targetClasses[i];
|
||||
float num = seeDistance;
|
||||
if (targetClass.seeDistMax > 0f)
|
||||
{
|
||||
num = Utils.FastMin(num, targetClass.seeDistMax * this.theEntity.senseScale);
|
||||
}
|
||||
|
||||
bool bMindControlled = this.theEntity.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1") || this.theEntity.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2") || this.theEntity.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3");
|
||||
|
||||
if (bMindControlled)
|
||||
{
|
||||
this.theEntity.SetMaxViewAngle(360);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.theEntity.SetMaxViewAngle(180);
|
||||
}
|
||||
|
||||
if (targetClass.type == typeof(EntityPlayer) && !bMindControlled)
|
||||
{
|
||||
this.FindTargetPlayer(num);
|
||||
if (this.theEntity.noisePlayer && this.theEntity.noisePlayer != this.closeTargetEntity)
|
||||
{
|
||||
if (this.closeTargetEntity)
|
||||
{
|
||||
if (this.theEntity.noisePlayerVolume >= this.theEntity.noiseWake)
|
||||
{
|
||||
Vector3 position = this.theEntity.noisePlayer.position;
|
||||
float magnitude = (this.theEntity.position - position).magnitude;
|
||||
if (magnitude < this.closeTargetDist)
|
||||
{
|
||||
this.closeTargetDist = magnitude;
|
||||
this.closeTargetEntity = this.theEntity.noisePlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!this.theEntity.IsSleeping)
|
||||
{
|
||||
this.SeekNoise(this.theEntity.noisePlayer);
|
||||
}
|
||||
}
|
||||
if (this.closeTargetEntity)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)this.closeTargetEntity;
|
||||
if (entityPlayer.IsBloodMoonDead && entityPlayer.currentLife >= 0.5f)
|
||||
{
|
||||
Log.Out("Player {0}, living {1}, lost BM immunity", new object[]
|
||||
{
|
||||
entityPlayer.GetDebugName(),
|
||||
entityPlayer.currentLife * 60f
|
||||
});
|
||||
entityPlayer.IsBloodMoonDead = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!this.theEntity.IsSleeping && !this.theEntity.HasInvestigatePosition)
|
||||
{
|
||||
EAISetNearestEntityAsTargetSDX.list = this.theEntity.world.GetEntitiesInBounds(targetClass.type, BoundsUtils.ExpandBounds(this.theEntity.boundingBox, num, 4f, num), EAISetNearestEntityAsTargetSDX.list);
|
||||
EAISetNearestEntityAsTargetSDX.list.Sort(this.sorter);
|
||||
int j = 0;
|
||||
while (j < EAISetNearestEntityAsTargetSDX.list.Count)
|
||||
{
|
||||
EntityAlive entityAlive = (EntityAlive)EAISetNearestEntityAsTargetSDX.list[j];
|
||||
if (!(entityAlive is EntityDrone) && base.check(entityAlive))
|
||||
{
|
||||
float distance = this.theEntity.GetDistance(entityAlive);
|
||||
if (distance < this.closeTargetDist)
|
||||
{
|
||||
this.closeTargetDist = distance;
|
||||
this.closeTargetEntity = entityAlive;
|
||||
this.lastSeenPos = entityAlive.position;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
j++;
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetSDX.list.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FindTargetPlayer(float seeDist)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetSDX-FindTargetPlayer START");
|
||||
if (this.theEntity.IsSleeperPassive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.theEntity.world.GetEntitiesInBounds(typeof(EntityPlayer), BoundsUtils.ExpandBounds(this.theEntity.boundingBox, seeDist, seeDist, seeDist), EAISetNearestEntityAsTargetSDX.list);
|
||||
if (!this.theEntity.IsSleeping)
|
||||
{
|
||||
for (int i = 0; i < EAISetNearestEntityAsTargetSDX.list.Count; i++)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)EAISetNearestEntityAsTargetSDX.list[i];
|
||||
if (entityPlayer.IsAlive() && !entityPlayer.IsIgnoredByAI() && !entityPlayer.IsSpectator)
|
||||
{
|
||||
float distance = this.theEntity.GetDistance(entityPlayer);
|
||||
if (distance < this.closeTargetDist)
|
||||
{
|
||||
this.closeTargetDist = distance;
|
||||
this.closeTargetEntity = entityPlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetSDX.list.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
EAISetNearestEntityAsTargetSDX.list.Sort(this.sorter);
|
||||
EntityPlayer entityPlayer2 = null;
|
||||
float num = float.MaxValue;
|
||||
bool flag = false;
|
||||
if (this.theEntity.noisePlayer != null)
|
||||
{
|
||||
if (this.theEntity.noisePlayerVolume >= this.theEntity.noiseWake)
|
||||
{
|
||||
entityPlayer2 = this.theEntity.noisePlayer;
|
||||
num = this.theEntity.noisePlayerDistance;
|
||||
}
|
||||
else if (this.theEntity.noisePlayerVolume >= this.theEntity.noiseGroan)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < EAISetNearestEntityAsTargetSDX.list.Count; j++)
|
||||
{
|
||||
EntityPlayer entityPlayer3 = (EntityPlayer)EAISetNearestEntityAsTargetSDX.list[j];
|
||||
if (!entityPlayer3.IsIgnoredByAI())
|
||||
{
|
||||
float distance2 = this.theEntity.GetDistance(entityPlayer3);
|
||||
int sleeperDisturbedLevel = this.theEntity.GetSleeperDisturbedLevel(distance2, entityPlayer3.Stealth.lightLevel);
|
||||
if (sleeperDisturbedLevel >= 2)
|
||||
{
|
||||
if (distance2 < num)
|
||||
{
|
||||
entityPlayer2 = entityPlayer3;
|
||||
num = distance2;
|
||||
}
|
||||
}
|
||||
else if (sleeperDisturbedLevel >= 1)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetSDX.list.Clear();
|
||||
if (entityPlayer2 != null)
|
||||
{
|
||||
this.closeTargetDist = num;
|
||||
this.closeTargetEntity = entityPlayer2;
|
||||
return;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.theEntity.Groan();
|
||||
return;
|
||||
}
|
||||
this.theEntity.Snore();
|
||||
}
|
||||
|
||||
private List<EAISetNearestEntityAsTargetSDX.TargetClass> targetClasses;
|
||||
private int playerTargetClassIndex = -1;
|
||||
private float closeTargetDist;
|
||||
private EntityAlive closeTargetEntity;
|
||||
private EntityAlive targetEntity;
|
||||
private EntityPlayer targetPlayer;
|
||||
private Vector3 lastSeenPos;
|
||||
private float findTime;
|
||||
private float senseSoundTime;
|
||||
private EAISetNearestEntityAsTargetSorter sorter;
|
||||
private static List<Entity> list = new List<Entity>();
|
||||
private struct TargetClass
|
||||
{
|
||||
public Type type;
|
||||
public float hearDistMax;
|
||||
public float seeDistMax;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user