public override void OnUpdate() { this.iCounter++; this.iNextHardUpdate--; if (this.bGonnaDie) { this.MoveInDeath(); return; } if (this.enCurrentAction == FrostlingScoundrelAI.Action.GatheringSnow) { if (Utility.IsWithinRange((int)this.xOwner.xRenderComponent.iActiveAnimation, 24, 31)) { return; } this.enCurrentAction = FrostlingScoundrelAI.Action.Chillin; } if (this.iNextHardUpdate <= 0) { float fDistanceToTarget = 100000f; WorldActor xClosestTarget = base.FindTarget(EnemyBehaviour.TargetSearchParameters.Closest, this.fAggroDistance + ((this.xPlayerLockedOnto != null) ? (this.fAggroDistance / 2f) : 0f), true, out fDistanceToTarget); if (xClosestTarget != null) { this.enCurrentAction = FrostlingScoundrelAI.Action.Walkin; } else { if (this.xPlayerLockedOnto != null) { this.v2RandMoveDir = Vector2.Zero; } this.enCurrentAction = FrostlingScoundrelAI.Action.Chillin; } this.xPlayerLockedOnto = xClosestTarget; this.iNextHardUpdate = 20; this.v2RandMoveDir = Vector2.Zero; } if (this.xOwner.xRenderComponent.GetCurrentAnimation().bIsMoveCancellable && this.v2RandMoveDir != Vector2.Zero) { this.xOwner.xTransform.v2Pos += this.v2RandMoveDir * this.xOwner.xBaseStats.fMovementSpeed; if (this.xOwner.xRenderComponent.iActiveAnimation < 8 || Utility.IsWithinRange((int)this.xOwner.xRenderComponent.iActiveAnimation, 16, 23)) { this.xOwner.xRenderComponent.SwitchAnimation((ushort)(4 + Utility.ConvertV2DirectionToClosestByteDirection(this.v2RandMoveDir)), Animation.CancelOptions.IgnoreIfPlaying); } } else if (this.xOwner.xRenderComponent.iActiveAnimation < 8 || Utility.IsWithinRange((int)this.xOwner.xRenderComponent.iActiveAnimation, 16, 23)) { int iBonus = 0; if (!this.bSnowballReady) { iBonus = 16; } else if (this.bSnowballIsBig) { iBonus = 20; } if (this.xPlayerLockedOnto == null) { this.xOwner.xRenderComponent.SwitchAnimation((ushort)(iBonus + (int)this.xOwner.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying); } else { this.xOwner.xRenderComponent.SwitchAnimation((ushort)(iBonus + (int)Utility.ConvertV2DirectionToClosestByteDirection(Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos))), Animation.CancelOptions.IgnoreIfPlaying); } } if (this.xPlayerLockedOnto != null) { float fMaxAttackDistance = 140f; float fMinAttackDistance = 80f; if (this.enCurrentAction == FrostlingScoundrelAI.Action.Walkin && this.xOwner.xRenderComponent.GetCurrentAnimation().bIsMoveCancellable) { float fDistance = Vector2.Distance(this.xOwner.xTransform.v2Pos, this.xPlayerLockedOnto.xTransform.v2Pos); if (fDistance > fMaxAttackDistance) { if (this.v2RandMoveDir == Vector2.Zero) { this.iNextHardUpdate = 60; float fRotMos = -0.7853982f * (float)CAS.RandomInLogic.NextDouble() * 1.57079637f; this.v2RandMoveDir = Utility.RotateDirectionVector(Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos), fRotMos); return; } } else if (fDistance < fMinAttackDistance && !this.bCantFlee) { if (this.v2RandMoveDir == Vector2.Zero) { this.bCantFlee = true; this.iNextHardUpdate = 60; float fRotMos2 = -0.7853982f * (float)CAS.RandomInLogic.NextDouble() * 1.57079637f; this.v2RandMoveDir = -Utility.RotateDirectionVector(Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos), fRotMos2); return; } } else if (!this.bSnowballReady) { if (this.iCounter - this.iCounterAtLastAttack > 180 - CAS.DifficultyModifier * 20) { int iAdd = 24; if (CAS.RandomInLogic.Next(4) == 0) { iAdd = 28; } this.xOwner.xRenderComponent.SwitchAnimation((ushort)(iAdd + (int)this.xOwner.byAnimationDirection), Animation.CancelOptions.IgnoreIfPlaying); this.v2RandMoveDir = Vector2.Zero; this.enCurrentAction = FrostlingScoundrelAI.Action.GatheringSnow; return; } } else { this.bCantFlee = false; if (this.iCounter - this.iCounterAtSnowBallReady < this.iAttackAfterSnowballReady) { if (this.v2RandMoveDir == Vector2.Zero) { this.iNextHardUpdate = 30; this.v2RandMoveDir = Utility.RandomizeVector2Direction(CAS.RandomInLogic); return; } } else { if (!this.bSnowballIsBig) { this.xOwner.xRenderComponent.SwitchAnimation((ushort)(8 + Utility.ConvertV2DirectionToClosestByteDirection(Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos))), Animation.CancelOptions.IgnoreIfPlaying); } else { this.xOwner.xRenderComponent.SwitchAnimation((ushort)(32 + Utility.ConvertV2DirectionToClosestByteDirection(Utility.Normalize(this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos))), Animation.CancelOptions.IgnoreIfPlaying); } this.bSnowballReady = false; this.iCounterAtLastAttack = this.iCounter; } } } } }
public override void OnHitByAttack(AttackCollisionData xAtColData, AttackPhase xAtPhase) { if (xAtPhase.xStats.iBreakingPower >= 0) { this.iNextHardUpdate = 34; this.enCurrentAction = FrostlingScoundrelAI.Action.TakingDamage; } if (!this.bGonnaDie) { this.v2RandMoveDir = Vector2.Zero; } base.OnHitByAttack(xAtColData, xAtPhase); NetworkHelperInterface.NetworkRole arg_49_0 = Program.game.xNetworkInfo.enCurrentRole; }