Upload from upload_mods.ps1
This commit is contained in:
87
Scripts/EAI/EAISetAsTargetIfHurtRebirth.cs
Normal file
87
Scripts/EAI/EAISetAsTargetIfHurtRebirth.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class EAISetAsTargetIfHurtRebirth : EAISetAsTargetIfHurt
|
||||
{
|
||||
public override bool CanExecute()
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute START, source: " + this.theEntity.EntityName);
|
||||
EntityAlive revengeTarget = this.theEntity.GetRevengeTarget();
|
||||
|
||||
bool bIsValidTarget = true;
|
||||
|
||||
if (revengeTarget)
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute revengeTarget.EntityName: " + revengeTarget.EntityName);
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute revengeTarget.entityType: " + revengeTarget.entityType);
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute this.theEntity.entityType: " + this.theEntity.entityType);
|
||||
|
||||
bIsValidTarget = RebirthUtilities.VerifyFactionStanding(this.theEntity, revengeTarget, true); //revengeTarget.entityType != this.theEntity.entityType;
|
||||
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute bIsValidTarget: " + bIsValidTarget);
|
||||
}
|
||||
|
||||
if (revengeTarget && revengeTarget != this.theEntity.GetAttackTarget() && bIsValidTarget)
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute 1");
|
||||
if (this.targetClasses != null)
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute 2");
|
||||
bool flag = false;
|
||||
Type type = revengeTarget.GetType();
|
||||
for (int i = 0; i < this.targetClasses.Count; i++)
|
||||
{
|
||||
EAISetAsTargetIfHurtRebirth.TargetClass targetClass = this.targetClasses[i];
|
||||
if (targetClass.type != null && targetClass.type.IsAssignableFrom(type))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.theEntity.GetAttackTarget() != null && base.GetRandom(3) != 0)
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute 3");
|
||||
this.theEntity.SetRevengeTarget((EntityAlive) null);
|
||||
return false;
|
||||
}
|
||||
if (base.check(revengeTarget))
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute 4");
|
||||
return true;
|
||||
}
|
||||
Vector3 vector = this.theEntity.position - revengeTarget.position;
|
||||
float searchRadius = EntityClass.list[this.theEntity.entityClass].SearchRadius;
|
||||
vector = revengeTarget.position + vector.normalized * (searchRadius * 0.35f);
|
||||
Vector3 vector2 = this.manager.random.RandomOnUnitSphere * searchRadius;
|
||||
vector.x += vector2.x;
|
||||
vector.z += vector2.z;
|
||||
Vector3i vector3i = World.worldToBlockPos(vector);
|
||||
int height = (int)this.theEntity.world.GetHeight(vector3i.x, vector3i.z);
|
||||
if (height > 0)
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute 5");
|
||||
vector.y = (float)height;
|
||||
}
|
||||
int num2 = this.theEntity.CalcInvestigateTicks(1200, revengeTarget);
|
||||
this.theEntity.SetInvestigatePosition(vector, num2, true);
|
||||
if (this.theEntity.entityType == EntityType.Zombie)
|
||||
{
|
||||
//Log.Out("EAISetAsTargetIfHurtRebirth-CanExecute 6");
|
||||
num2 /= 6;
|
||||
}
|
||||
this.theEntity.SetAlertTicks(num2);
|
||||
this.theEntity.SetRevengeTarget((EntityAlive) null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<EAISetAsTargetIfHurtRebirth.TargetClass> targetClasses;
|
||||
private struct TargetClass
|
||||
{
|
||||
public Type type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user