191 lines
7.6 KiB
C#
191 lines
7.6 KiB
C#
using System.Collections.Generic;
|
|
|
|
public class EAISetAsTargetIfHurtZombieRebirth : EAITarget
|
|
{
|
|
public override void Init(EntityAlive _theEntity)
|
|
{
|
|
base.Init(_theEntity, 0f, false);
|
|
this.MutexBits = 1;
|
|
}
|
|
|
|
public override void SetData(DictionarySave<string, string> data)
|
|
{
|
|
base.SetData(data);
|
|
this.targetClasses = new List<EAISetAsTargetIfHurtZombieRebirth.TargetClass>();
|
|
string text;
|
|
if (data.TryGetValue("class", out text))
|
|
{
|
|
string[] array = text.Split(new char[]
|
|
{
|
|
','
|
|
});
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
EAISetAsTargetIfHurtZombieRebirth.TargetClass item = default(EAISetAsTargetIfHurtZombieRebirth.TargetClass);
|
|
item.type = EntityFactory.GetEntityType(array[i]);
|
|
this.targetClasses.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool CanExecute()
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute START");
|
|
EntityAlive revengeTarget = this.theEntity.GetRevengeTarget();
|
|
|
|
bool bIsValidTarget = true;
|
|
|
|
if (revengeTarget)
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute revengeTarget.EntityName: " + revengeTarget.EntityName);
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute revengeTarget.entityType: " + revengeTarget.entityType);
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute this.theEntity.entityType: " + this.theEntity.entityType);
|
|
|
|
bIsValidTarget = RebirthUtilities.VerifyFactionStanding(this.theEntity, revengeTarget); //revengeTarget.entityType != this.theEntity.entityType;
|
|
|
|
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute bIsValidTarget: " + bIsValidTarget);
|
|
|
|
if (!bIsValidTarget)
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute 0a");
|
|
bool bMindControlled = revengeTarget.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1") ||
|
|
revengeTarget.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2") ||
|
|
revengeTarget.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3");
|
|
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute FuriousRamsayRangedMindControlBuffTier1: " + revengeTarget.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1"));
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute FuriousRamsayRangedMindControlBuffTier2: " + revengeTarget.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2"));
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute FuriousRamsayRangedMindControlBuffTier3: " + revengeTarget.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3"));
|
|
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute bMindControlled: " + bMindControlled);
|
|
|
|
if (!bMindControlled)
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute 0b");
|
|
this.theEntity.SetRevengeTarget((EntityAlive) null);
|
|
revengeTarget = null;
|
|
this.theEntity.attackTarget = (EntityAlive) null;
|
|
this.theEntity.ClearInvestigatePosition();
|
|
}
|
|
else
|
|
{
|
|
this.theEntity.SetAttackTarget(revengeTarget, 60);
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute 0c");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute 0d");
|
|
}
|
|
}
|
|
|
|
if (revengeTarget && revengeTarget != this.theEntity.GetAttackTarget() && bIsValidTarget)
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute 1");
|
|
if (this.targetClasses != null)
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-CanExecute 2");
|
|
bool flag = false;
|
|
Type type = revengeTarget.GetType();
|
|
for (int i = 0; i < this.targetClasses.Count; i++)
|
|
{
|
|
EAISetAsTargetIfHurtZombieRebirth.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("EAISetAsTargetIfHurtZombieRebirth-CanExecute 3");
|
|
this.theEntity.SetRevengeTarget((EntityAlive) null);
|
|
return false;
|
|
}
|
|
if (base.check(revengeTarget))
|
|
{
|
|
//Log.Out("EAISetAsTargetIfHurtZombieRebirth-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("EAISetAsTargetIfHurtZombieRebirth-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("EAISetAsTargetIfHurtZombieRebirth-CanExecute 6");
|
|
num2 /= 6;
|
|
}
|
|
this.theEntity.SetAlertTicks(num2);
|
|
this.theEntity.SetRevengeTarget((EntityAlive) null);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void Start()
|
|
{
|
|
this.theEntity.SetAttackTarget(this.theEntity.GetRevengeTarget(), 400);
|
|
this.viewAngleSave = this.theEntity.GetMaxViewAngle();
|
|
this.theEntity.SetMaxViewAngle(270f);
|
|
this.viewAngleRestoreCounter = 100;
|
|
base.Start();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
if (this.viewAngleRestoreCounter > 0)
|
|
{
|
|
this.viewAngleRestoreCounter--;
|
|
if (this.viewAngleRestoreCounter == 0)
|
|
{
|
|
this.restoreViewAngle();
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool Continue()
|
|
{
|
|
return (!(this.theEntity.GetRevengeTarget() != null) || !(this.theEntity.GetAttackTarget() != this.theEntity.GetRevengeTarget())) && base.Continue();
|
|
}
|
|
|
|
public override void Reset()
|
|
{
|
|
base.Reset();
|
|
this.restoreViewAngle();
|
|
}
|
|
|
|
private void restoreViewAngle()
|
|
{
|
|
if (this.viewAngleSave > 0f)
|
|
{
|
|
this.theEntity.SetMaxViewAngle(this.viewAngleSave);
|
|
this.viewAngleSave = 0f;
|
|
this.viewAngleRestoreCounter = 0;
|
|
}
|
|
}
|
|
|
|
private List<EAISetAsTargetIfHurtZombieRebirth.TargetClass> targetClasses;
|
|
private float viewAngleSave;
|
|
private int viewAngleRestoreCounter;
|
|
private struct TargetClass
|
|
{
|
|
public Type type;
|
|
}
|
|
}
|