Upload from upload_mods.ps1
This commit is contained in:
203
Scripts/EAI/EAILeapRebirth.cs
Normal file
203
Scripts/EAI/EAILeapRebirth.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using GamePath;
|
||||
|
||||
public class EAILeapRebirth : EAIBase
|
||||
{
|
||||
public override void Init(EntityAlive _theEntity)
|
||||
{
|
||||
base.Init(_theEntity);
|
||||
this.MutexBits = 3;
|
||||
this.executeDelay = 1f + base.RandomFloat;
|
||||
}
|
||||
|
||||
public override void SetData(DictionarySave<string, string> data)
|
||||
{
|
||||
base.SetData(data);
|
||||
base.GetData(data, "legs", ref this.legCount);
|
||||
}
|
||||
|
||||
public override bool CanExecute()
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute START");
|
||||
|
||||
//Log.Out("EAILeapRebirth-CanExecute RebirthUtilities.IsHordeNight(): " + RebirthUtilities.IsHordeNight());
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute IS NOT HORDE NIGHT");
|
||||
if (!this.theEntity.EntityClass.entityClassName.ToLower().Contains("zombiespider"))
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute entityClassName: " + this.theEntity.EntityClass.entityClassName.ToLower());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.theEntity.IsDancing)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 1");
|
||||
return false;
|
||||
}
|
||||
if (!this.theEntity.GetAttackTarget())
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 2");
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.Jumping)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute IS JUMPING");
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.Climbing || this.theEntity.IsInElevator())
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute IS CLIMBING / IN ELEVATOR");
|
||||
if (!this.theEntity.EntityClass.entityClassName.ToLower().Contains("zombiespider"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((this.legCount <= 2) ? this.theEntity.bodyDamage.IsAnyLegMissing : this.theEntity.bodyDamage.IsAnyArmOrLegMissing)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 4");
|
||||
return false;
|
||||
}
|
||||
if (this.theEntity.moveHelper.IsBlocked)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 5");
|
||||
return false;
|
||||
}
|
||||
|
||||
PathEntity path = this.theEntity.navigator.getPath();
|
||||
if (path == null)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 6");
|
||||
return false;
|
||||
}
|
||||
|
||||
float terrainHeight = this.theEntity.world.GetTerrainHeight((int)path.GetEndPos().x, (int)path.GetEndPos().z);
|
||||
|
||||
if (this.theEntity.position.y < terrainHeight + 2 ||
|
||||
this.theEntity.position.y < terrainHeight - 2
|
||||
)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute terrainHeight: " + terrainHeight);
|
||||
//Log.Out("EAILeapRebirth-CanExecute this.theEntity.position.y: " + this.theEntity.position.y);
|
||||
if (!this.theEntity.EntityClass.entityClassName.ToLower().Contains("zombiespider"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
float jumpMaxDistance = this.theEntity.jumpMaxDistance;
|
||||
this.leapV = path.GetEndPos() - this.theEntity.position;
|
||||
|
||||
//if (this.leapV.y < -5f || this.leapV.y > 15f)
|
||||
if (this.leapV.y < -5f || this.leapV.y > 0.5f + jumpMaxDistance * 0.5f)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 7 jumpMaxDistance: " + jumpMaxDistance);
|
||||
//Log.Out("EAILeapRebirth-CanExecute 7 this.leapV.y: " + this.leapV.y);
|
||||
//Log.Out("EAILeapRebirth-CanExecute 7 0.5f + jumpMaxDistance * 0.5f: " + (0.5f + jumpMaxDistance));
|
||||
|
||||
//Log.Out("EAILeapRebirth-CanExecute 7 this.leapV.y < -5f: " + (this.leapV.y < -5f));
|
||||
//Log.Out("EAILeapRebirth-CanExecute 7 this.leapV.y > 0.5f + jumpMaxDistance: " + (this.leapV.y > 0.5f + jumpMaxDistance));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this.leapDist = Mathf.Sqrt(this.leapV.x * this.leapV.x + this.leapV.z * this.leapV.z);
|
||||
if (this.leapDist < 2.8f || this.leapDist > jumpMaxDistance)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 8 this.leapDist: " + this.leapDist);
|
||||
//Log.Out("EAILeapRebirth-CanExecute 8 jumpMaxDistance: " + jumpMaxDistance);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.theEntity is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX myEntity = (EntityZombieSDX)this.theEntity;
|
||||
if (this.leapDist < myEntity.flLeapMaxDistance || this.leapDist > jumpMaxDistance)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute 9");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EAILeapRebirth-CanExecute PROCEED terrainHeight: " + terrainHeight);
|
||||
//Log.Out("EAILeapRebirth-CanExecute PROCEED this.theEntity.position.y: " + this.theEntity.position.y);
|
||||
|
||||
Vector3 position = this.theEntity.position;
|
||||
position.y += 1.5f;
|
||||
RaycastHit raycastHit;
|
||||
return !Physics.Raycast(position - Origin.position, this.leapV, out raycastHit, this.leapDist - 0.5f, 1082195968);
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
this.abortTime = 5f;
|
||||
this.theEntity.navigator.clearPath();
|
||||
this.theEntity.moveHelper.Stop();
|
||||
this.leapYaw = Mathf.Atan2(this.leapV.x, this.leapV.z) * 57.29578f;
|
||||
}
|
||||
|
||||
public override bool Continue()
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-CanExecute START");
|
||||
|
||||
if (this.theEntity.bodyDamage.CurrentStun != EnumEntityStunType.None)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-Continue 1");
|
||||
return false;
|
||||
}
|
||||
if (this.abortTime <= 0f)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-Continue 2");
|
||||
return false;
|
||||
}
|
||||
EntityMoveHelper moveHelper = this.theEntity.moveHelper;
|
||||
this.theEntity.SeekYaw(this.leapYaw, 0f, 10f);
|
||||
//Log.Out("EAILeapRebirth-Continue this.leapYaw: " + this.leapYaw);
|
||||
//Log.Out("EAILeapRebirth-Continue Utils.FastAbs(Mathf.DeltaAngle(this.theEntity.rotation.y, this.leapYaw)): " + Utils.FastAbs(Mathf.DeltaAngle(this.theEntity.rotation.y, this.leapYaw)));
|
||||
//if (Utils.FastAbs(Mathf.DeltaAngle(this.theEntity.rotation.y, this.leapYaw)) < 1f)
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-Continue this.leapDist: " + this.leapDist);
|
||||
//Log.Out("EAILeapRebirth-Continue this.leapV.y: " + this.leapV.y);
|
||||
|
||||
//moveHelper.CalcIfUnreachablePos();
|
||||
|
||||
//Log.Out("EAILeapRebirth-Continue IsUnreachableSideJump: " + moveHelper.IsUnreachableSideJump);
|
||||
//Log.Out("EAILeapRebirth-Continue IsUnreachableAbove: " + moveHelper.IsUnreachableAbove);
|
||||
//Log.Out("EAILeapRebirth-Continue UnreachablePos: " + moveHelper.UnreachablePos);
|
||||
|
||||
/*this.theEntity.motion = Vector3.zero;
|
||||
this.theEntity.navigator?.clearPath();
|
||||
this.theEntity.moveHelper?.Stop();
|
||||
this.theEntity.speedForward = 0;
|
||||
this.theEntity.speedStrafe = 0;*/
|
||||
|
||||
if (this.theEntity.GetAttackTarget() != null && this.theEntity.CanSee(this.theEntity.GetAttackTarget()))
|
||||
{
|
||||
//Log.Out("EAILeapRebirth-Continue ROTATE TO PLAYER");
|
||||
moveHelper.moveToPos = this.theEntity.GetAttackTarget().position;
|
||||
this.theEntity.RotateTo(moveHelper.moveToPos.x, moveHelper.moveToPos.y, moveHelper.moveToPos.z, 360f, 360f);
|
||||
}
|
||||
|
||||
moveHelper.StartJump(false, this.leapDist, this.leapV.y);
|
||||
return false;
|
||||
}
|
||||
//return true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
this.abortTime -= 0.05f;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
private const int cCollisionMask = 1082195968;
|
||||
private int legCount = 2;
|
||||
private Vector3 leapV;
|
||||
private float leapDist;
|
||||
private float leapYaw;
|
||||
private float abortTime;
|
||||
}
|
||||
Reference in New Issue
Block a user