Upload from upload_mods.ps1
This commit is contained in:
680
Scripts/EAI/EAISetNearestEntityAsTargetZombieRebirth.cs
Normal file
680
Scripts/EAI/EAISetNearestEntityAsTargetZombieRebirth.cs
Normal file
@@ -0,0 +1,680 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
public class EAISetNearestEntityAsTargetZombieRebirth : EAITarget
|
||||
{
|
||||
public override void Init(EntityAlive _theEntity)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-Init START");
|
||||
base.Init(_theEntity, 25f, true);
|
||||
this.MutexBits = 1;
|
||||
this.sorter = new EAISetNearestEntityAsTargetSorter(_theEntity);
|
||||
}
|
||||
|
||||
private bool bNeedToSee;
|
||||
|
||||
public override void SetData(DictionarySave<string, string> data)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-SetData START");
|
||||
base.SetData(data);
|
||||
this.targetClasses = new List<EAISetNearestEntityAsTargetZombieRebirth.TargetClass>();
|
||||
string text;
|
||||
if (data.TryGetValue("class", out text))
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-SetData text: " + this.theEntity.EntityClass.entityClassName);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-SetData text: " + text);
|
||||
|
||||
string[] array = text.Split(',', (char)StringSplitOptions.None);
|
||||
for (int i = 0; i < array.Length; i += 3)
|
||||
{
|
||||
EAISetNearestEntityAsTargetZombieRebirth.TargetClass targetClass;
|
||||
targetClass.type = EntityFactory.GetEntityType(array[i]);
|
||||
targetClass.hearDistMax = 0f;
|
||||
if (i + 1 < array.Length)
|
||||
{
|
||||
targetClass.hearDistMax = StringParsers.ParseFloat(array[i + 1], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (targetClass.hearDistMax == 0f)
|
||||
{
|
||||
targetClass.hearDistMax = 50f;
|
||||
}
|
||||
targetClass.seeDistMax = 0f;
|
||||
if (i + 2 < array.Length)
|
||||
{
|
||||
targetClass.seeDistMax = StringParsers.ParseFloat(array[i + 2], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (targetClass.type == typeof(EntityPlayer))
|
||||
{
|
||||
this.playerTargetClassIndex = this.targetClasses.Count;
|
||||
}
|
||||
this.targetClasses.Add(targetClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanExecute()
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-CanExecute START");
|
||||
if (this.theEntity.distraction != null)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-CanExecute 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity.Buffs.GetCustomVar("$eventSpawn") == 1f)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-CanExecute EVENT SPAWN");
|
||||
if (this.theEntity.GetAttackTarget() != null)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-CanExecute ALREADY HAS A TARGET");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.foundDecoy = false;
|
||||
|
||||
if (!this.closeTargetEntity)
|
||||
{
|
||||
this.FindTarget();
|
||||
}
|
||||
|
||||
if (!this.closeTargetEntity)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-CanExecute 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
this.targetEntity = this.closeTargetEntity;
|
||||
this.targetPlayer = (this.closeTargetEntity as EntityPlayer);
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-CanExecute this.targetEntity: " + this.targetEntity.EntityClass.entityClassName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void FindTarget()
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget START");
|
||||
this.closeTargetDist = float.MaxValue;
|
||||
this.closeTargetEntity = null;
|
||||
|
||||
float seeDistance = this.theEntity.GetSeeDistance();
|
||||
|
||||
for (int i = 0; i < this.targetClasses.Count; i++)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget this.targetClasses[" + i + "]: " + this.targetClasses[i].type);
|
||||
EAISetNearestEntityAsTargetZombieRebirth.TargetClass targetClass = this.targetClasses[i];
|
||||
|
||||
float num = seeDistance;
|
||||
if (targetClass.seeDistMax > 0f)
|
||||
{
|
||||
num = Utils.FastMin(num, targetClass.seeDistMax * this.theEntity.senseScale);
|
||||
}
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget Distance1: " + num);
|
||||
|
||||
ulong worldTime = GameManager.Instance.World.worldTime;
|
||||
ValueTuple<int, int, int> valueTuple = GameUtils.WorldTimeToElements(worldTime);
|
||||
|
||||
num = (int)(valueTuple.Item1 * 1.5) + 20;
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget Distance2: " + num);
|
||||
|
||||
if (this.theEntity.HasAnyTags(FastTags<TagGroup.Global>.Parse("event")))
|
||||
{
|
||||
num = 200;
|
||||
}
|
||||
|
||||
bool bMindControlled = this.theEntity.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1") || this.theEntity.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2") || this.theEntity.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3");
|
||||
|
||||
if (bMindControlled || this.theEntity.Buffs.GetCustomVar("$eventSpawn") == 1f)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 1");
|
||||
num = 200;
|
||||
this.theEntity.SetMaxViewAngle(360);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 2");
|
||||
num = 50;
|
||||
this.theEntity.SetMaxViewAngle(180);
|
||||
}
|
||||
|
||||
string rebirthFeralSense = RebirthVariables.customFeralSense;
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
bool randomValid = rebirthFeralSense == "random" &&
|
||||
currentDay == RebirthManager.nextFeralSenseDay;
|
||||
|
||||
if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
randomValid;
|
||||
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (isValidFeralSense || (this.theEntity.IsSleeper && POISense))
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-checkEntity FERAL SENSE ON");
|
||||
num = 200;
|
||||
this.theEntity.SetMaxViewAngle(360);
|
||||
}
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget bMindControlled: " + bMindControlled);
|
||||
|
||||
if (!foundDecoy && targetClass.type == typeof(EntityPlayer) && !bMindControlled)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 3");
|
||||
this.FindTargetPlayer(num);
|
||||
if (this.theEntity.noisePlayer && this.theEntity.noisePlayer != this.closeTargetEntity)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 4");
|
||||
if (this.closeTargetEntity)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 5");
|
||||
if (this.theEntity.noisePlayerVolume >= this.theEntity.noiseWake)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 6");
|
||||
Vector3 position = this.theEntity.noisePlayer.position;
|
||||
float magnitude = (this.theEntity.position - position).magnitude;
|
||||
if (magnitude < this.closeTargetDist)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 7");
|
||||
this.closeTargetDist = magnitude;
|
||||
this.closeTargetEntity = this.theEntity.noisePlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!this.theEntity.IsSleeping)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 8");
|
||||
this.SeekNoise(this.theEntity.noisePlayer);
|
||||
}
|
||||
}
|
||||
if (this.closeTargetEntity is EntityPlayer)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 9");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget this.theEntity.IsSleeping: " + this.theEntity.IsSleeping);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget this.theEntity.HasInvestigatePosition: " + this.theEntity.HasInvestigatePosition);
|
||||
|
||||
if (!this.theEntity.IsSleeping && !this.theEntity.HasInvestigatePosition)
|
||||
//if (!this.theEntity.IsSleeping)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10");
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget targetClass: " + targetClass);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget targetClass.type: " + targetClass.type);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget this.theEntity.boundingBox: " + this.theEntity.boundingBox);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget BoundsUtils.ExpandBounds(this.theEntity.boundingBox, num, 4f, num): " + BoundsUtils.ExpandBounds(this.theEntity.boundingBox, num, 4f, num));
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget EAISetNearestEntityAsTargetZombieRebirth.list.Count: " + EAISetNearestEntityAsTargetZombieRebirth.list.Count);
|
||||
|
||||
bool foundTarget = false;
|
||||
|
||||
if (!bMindControlled)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10A");
|
||||
this.theEntity.world.GetEntitiesInBounds(typeof(EntitySurvivor), BoundsUtils.ExpandBounds(this.theEntity.boundingBox, num, 4f, num), EAISetNearestEntityAsTargetZombieRebirth.list);
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Sort(this.sorter);
|
||||
int j = 0;
|
||||
while (j < EAISetNearestEntityAsTargetZombieRebirth.list.Count)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10B, j: " + j);
|
||||
EntityAlive entityAlive = (EntityAlive)EAISetNearestEntityAsTargetZombieRebirth.list[j];
|
||||
|
||||
bool isValid = true;
|
||||
|
||||
if (!entityAlive.IsAlive())
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
else if (!RebirthUtilities.VerifyFactionStanding(this.theEntity, entityAlive))
|
||||
{
|
||||
if (RebirthVariables.noHit && this.theEntity != entityAlive)
|
||||
{
|
||||
Log.Out($"EAISetNearestEntityAsTargetZombieRebirth-FindTarget NO HIT, should attack is false source: {this.theEntity}, target {entityAlive}");
|
||||
}
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10C, isValid: " + isValid);
|
||||
|
||||
//if (isValid && !(entityAlive is EntityDrone) && base.check(entityAlive))
|
||||
if (isValid && !(entityAlive is EntityDrone) && (base.check(entityAlive) || entityAlive.CanSee(this.theEntity)))
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10D");
|
||||
float distance = this.theEntity.GetDistance(entityAlive);
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10D, distance: " + distance);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10D, this.closeTargetDist: " + this.closeTargetDist);
|
||||
|
||||
/*if (this.closeTargetEntity != null)
|
||||
{
|
||||
Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget this.closeTargetEntity: " + this.closeTargetEntity.EntityName);
|
||||
}*/
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget this.closeTargetEntity is EntityPlayer: " + (this.closeTargetEntity is EntityPlayer));
|
||||
|
||||
if (distance < this.closeTargetDist || this.closeTargetEntity is EntityPlayer)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10E");
|
||||
this.closeTargetDist = distance;
|
||||
this.closeTargetEntity = entityAlive;
|
||||
this.lastSeenPos = entityAlive.position;
|
||||
foundTarget = true;
|
||||
foundDecoy = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 10F: " + entityAlive.EntityClass.entityClassName);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Clear();
|
||||
}
|
||||
|
||||
if (!foundTarget && !foundDecoy)
|
||||
{
|
||||
|
||||
|
||||
this.theEntity.world.GetEntitiesInBounds(targetClass.type, BoundsUtils.ExpandBounds(this.theEntity.boundingBox, num, 4f, num), EAISetNearestEntityAsTargetZombieRebirth.list);
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Sort(this.sorter);
|
||||
int j = 0;
|
||||
while (j < EAISetNearestEntityAsTargetZombieRebirth.list.Count)
|
||||
{
|
||||
EntityAlive entityAlive = (EntityAlive)EAISetNearestEntityAsTargetZombieRebirth.list[j];
|
||||
|
||||
bool isValid = true;
|
||||
|
||||
if (bMindControlled)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 11a");
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget entityAlive is entityAlive: " + entityAlive.EntityClass.entityClassName);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget entityAlive is EntityPlayer: " + (entityAlive is EntityPlayer));
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget entityAlive is EntityAliveSDXExtended: " + (entityAlive is EntityAliveSDXExtended));
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse(survivor)): " + (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("survivor"))));
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse(allyanimal)): " + (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("allyanimal"))));
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget VERIFY: " + (entityAlive is EntityPlayer || (entityAlive is EntityAliveSDXExtended && (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("survivor")) || entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("ally"))))));
|
||||
|
||||
if (entityAlive is EntityPlayer || entityAlive is EntitySurvivor ||
|
||||
(entityAlive is EntityNPCRebirth && (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("survivor")) || entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("ally")))))
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget entity: " + entityAlive.EntityClass.entityClassName);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 11b");
|
||||
isValid = false;
|
||||
this.theEntity.attackTarget = (EntityAlive) null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RebirthUtilities.VerifyFactionStanding(this.theEntity, entityAlive))
|
||||
{
|
||||
if (RebirthVariables.noHit && this.theEntity != entityAlive)
|
||||
{
|
||||
Log.Out($"EAISetNearestEntityAsTargetZombieRebirth-FindTarget NO HIT, should attack is false source: {this.theEntity}, target {entityAlive}");
|
||||
}
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthVariables.noHit && this.theEntity != entityAlive)
|
||||
{
|
||||
Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget target: " + entityAlive.EntityClass.entityClassName);
|
||||
Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget isValid: " + isValid);
|
||||
Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget base.check(entityAlive): " + base.check(entityAlive));
|
||||
Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget should attack: " + RebirthUtilities.VerifyFactionStanding(this.theEntity, entityAlive));
|
||||
}
|
||||
|
||||
if (isValid && !(entityAlive is EntityDrone) && base.check(entityAlive))
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 11d");
|
||||
float distance = this.theEntity.GetDistance(entityAlive);
|
||||
if (distance < this.closeTargetDist)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 12");
|
||||
this.closeTargetDist = distance;
|
||||
this.closeTargetEntity = entityAlive;
|
||||
this.lastSeenPos = entityAlive.position;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTarget 13: " + entityAlive.EntityClass.entityClassName);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SeekNoise(EntityPlayer player)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-SeekNoise START");
|
||||
float num = (player.position - this.theEntity.position).magnitude;
|
||||
if (this.playerTargetClassIndex >= 0)
|
||||
{
|
||||
float num2 = this.targetClasses[this.playerTargetClassIndex].hearDistMax;
|
||||
num2 *= this.theEntity.senseScale;
|
||||
num2 *= player.DetectUsScale(this.theEntity);
|
||||
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;
|
||||
}
|
||||
|
||||
string rebirthFeralSense = RebirthVariables.customFeralSense;
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
bool randomValid = rebirthFeralSense == "random" &&
|
||||
currentDay == RebirthManager.nextFeralSenseDay;
|
||||
|
||||
if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
randomValid;
|
||||
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (isValidFeralSense || (this.theEntity.IsSleeper && POISense))
|
||||
{
|
||||
num = 200;
|
||||
}
|
||||
|
||||
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 FindTargetPlayer(float seeDist)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer START");
|
||||
if (this.theEntity.IsSleeperPassive)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer this.theEntity.IsSleeperPassive: " + this.theEntity.IsSleeperPassive);
|
||||
return;
|
||||
}
|
||||
|
||||
string rebirthFeralSense = RebirthVariables.customFeralSense;
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
bool randomValid = rebirthFeralSense == "random" &&
|
||||
currentDay == RebirthManager.nextFeralSenseDay;
|
||||
|
||||
if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
randomValid;
|
||||
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (isValidFeralSense || this.theEntity.Buffs.GetCustomVar("$eventSpawn") == 1f || (this.theEntity.IsSleeper && POISense))
|
||||
{
|
||||
seeDist = 200;
|
||||
this.theEntity.SetMaxViewAngle(360);
|
||||
}
|
||||
|
||||
this.theEntity.world.GetEntitiesInBounds(typeof(EntityPlayer), BoundsUtils.ExpandBounds(this.theEntity.boundingBox, seeDist, seeDist, seeDist), EAISetNearestEntityAsTargetZombieRebirth.list);
|
||||
if (!this.theEntity.IsSleeping)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 1");
|
||||
for (int i = 0; i < EAISetNearestEntityAsTargetZombieRebirth.list.Count; i++)
|
||||
{
|
||||
Entity target = EAISetNearestEntityAsTargetZombieRebirth.list[i];
|
||||
|
||||
if (target is EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)EAISetNearestEntityAsTargetZombieRebirth.list[i];
|
||||
if (entityPlayer.IsAlive() && !entityPlayer.IsIgnoredByAI() && !entityPlayer.IsSpectator)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 2");
|
||||
float distance = this.theEntity.GetDistance(entityPlayer);
|
||||
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer distance: " + distance);
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer this.theEntity.CanSee(entityPlayer): " + this.theEntity.CanSee(entityPlayer));
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer this.theEntity.CanSeeStealth(distance, entityPlayer.Stealth.lightLevel): " + this.theEntity.CanSeeStealth(distance, entityPlayer.Stealth.lightLevel));
|
||||
|
||||
if (distance < this.closeTargetDist && this.theEntity.CanSee(entityPlayer) && this.theEntity.CanSeeStealth(distance, entityPlayer.Stealth.lightLevel))
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 3");
|
||||
this.closeTargetDist = distance;
|
||||
this.closeTargetEntity = entityPlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Sort(this.sorter);
|
||||
EntityPlayer x = null;
|
||||
float num = float.MaxValue;
|
||||
bool flag = false;
|
||||
if (this.theEntity.noisePlayer != null)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 5");
|
||||
if (this.theEntity.noisePlayerVolume >= this.theEntity.noiseWake)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 6");
|
||||
x = this.theEntity.noisePlayer;
|
||||
num = this.theEntity.noisePlayerDistance;
|
||||
}
|
||||
else if (this.theEntity.noisePlayerVolume >= this.theEntity.noiseGroan)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 7");
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < EAISetNearestEntityAsTargetZombieRebirth.list.Count; j++)
|
||||
{
|
||||
Entity target = EAISetNearestEntityAsTargetZombieRebirth.list[j];
|
||||
|
||||
if (target is EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityPlayer2 = (EntityPlayer)EAISetNearestEntityAsTargetZombieRebirth.list[j];
|
||||
if (this.theEntity.CanSee(entityPlayer2) && !entityPlayer2.IsIgnoredByAI())
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 8");
|
||||
float distance2 = this.theEntity.GetDistance(entityPlayer2);
|
||||
int sleeperDisturbedLevel = this.theEntity.GetSleeperDisturbedLevel(distance2, entityPlayer2.Stealth.lightLevel);
|
||||
if (sleeperDisturbedLevel >= 2)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 9");
|
||||
if (distance2 < num)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 10");
|
||||
x = entityPlayer2;
|
||||
num = distance2;
|
||||
}
|
||||
}
|
||||
else if (sleeperDisturbedLevel >= 1)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 11");
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EAISetNearestEntityAsTargetZombieRebirth.list.Clear();
|
||||
if (x != null)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 12");
|
||||
this.closeTargetDist = num;
|
||||
this.closeTargetEntity = x;
|
||||
return;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer 13");
|
||||
this.theEntity.Groan();
|
||||
return;
|
||||
}
|
||||
this.theEntity.Snore();
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-FindTargetPlayer END");
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-Start START");
|
||||
this.theEntity.SetAttackTarget(this.targetEntity, 200);
|
||||
this.theEntity.ConditionalTriggerSleeperWakeUp();
|
||||
base.Start();
|
||||
}
|
||||
|
||||
public override bool Continue()
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-Continue START");
|
||||
if (this.targetEntity.IsDead() || this.theEntity.distraction != null)
|
||||
{
|
||||
if (this.theEntity.GetAttackTarget() == this.targetEntity)
|
||||
{
|
||||
this.theEntity.attackTarget = (EntityAlive) null;
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-Continue REMOVE ATTACK TARGET 1");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.findTime += 0.05f;
|
||||
if (this.findTime > 2f)
|
||||
{
|
||||
this.findTime = 0f;
|
||||
this.FindTarget();
|
||||
if (this.closeTargetEntity && this.closeTargetEntity != this.targetEntity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.theEntity.GetAttackTarget() != this.targetEntity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (base.check(targetEntity) && (this.targetPlayer == null || this.theEntity.CanSeeStealth(this.theEntity.GetDistance(this.targetEntity), this.targetPlayer.Stealth.lightLevel)))
|
||||
{
|
||||
this.theEntity.SetAttackTarget(this.targetEntity, 600);
|
||||
this.lastSeenPos = this.targetEntity.position;
|
||||
return true;
|
||||
}
|
||||
if (this.theEntity.GetDistanceSq(this.lastSeenPos) < 2.25f)
|
||||
{
|
||||
this.lastSeenPos = Vector3.zero;
|
||||
}
|
||||
this.theEntity.attackTarget = (EntityAlive) null;
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-Continue REMOVE ATTACK TARGET 2");
|
||||
int num = this.theEntity.CalcInvestigateTicks(Constants.cEnemySenseMemory * 20, this.targetEntity);
|
||||
if (this.lastSeenPos != Vector3.zero)
|
||||
{
|
||||
this.theEntity.SetInvestigatePosition(this.lastSeenPos, num, true);
|
||||
}
|
||||
if (this.targetPlayer)
|
||||
{
|
||||
if (this.theEntity.entityType == EntityType.Zombie)
|
||||
{
|
||||
num /= 6;
|
||||
}
|
||||
this.theEntity.SetAlertTicks(num);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
//Log.Out("EAISetNearestEntityAsTargetZombieRebirth-Reset START");
|
||||
this.targetEntity = null;
|
||||
this.targetPlayer = null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}, {1}", base.ToString(), this.targetEntity ? this.targetEntity.EntityName : "");
|
||||
}
|
||||
|
||||
private List<EAISetNearestEntityAsTargetZombieRebirth.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 bool foundDecoy = false;
|
||||
|
||||
private struct TargetClass
|
||||
{
|
||||
public Type type;
|
||||
public float hearDistMax;
|
||||
public float seeDistMax;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user