using Audio; using System.Collections.Generic; using System.Globalization; using Random = System.Random; public class EntityMeleeCyborgRebirth : EntityEnemyRebirthSDX { public float flEyeHeight = -1f; public Random random = new Random(); /*public ulong timeToDie;*/ private bool bPlayHurtSound; public float StaticSizeScale = 1; public bool hasNotified = false; public List generatedNumbers = new List(); public bool NanoCyborgFuriousRamsayStage1 = false; public bool NanoCyborgFuriousRamsayStage2 = false; public bool NanoCyborgFuriousRamsayStage3 = false; public string lootDropEntityClass = ""; public string otherTags = ""; public override void CopyPropertiesFromEntityClass() { base.CopyPropertiesFromEntityClass(); EntityClass entityClass = EntityClass.list[this.entityClass]; if (entityClass.Properties.Values.ContainsKey("StaticSizeScale")) { this.StaticSizeScale = StringParsers.ParseFloat(entityClass.Properties.Values["StaticSizeScale"], 0, -1, NumberStyles.Any); //Log.Out("CopyPropertiesFromEntityClass-StaticSizeScale: " + StaticSizeScale); } else { //Log.Out("NO StaticSizeScale FOUND"); } } public override void fallHitGround(float _distance, Vector3 _fallMotion) { this.SetScale(this.StaticSizeScale); //Log.Out("fallHitGround-StaticSizeScale: " + StaticSizeScale); base.fallHitGround(_distance, _fallMotion); if (_distance > 2f) { int num = (int)((-_fallMotion.y - 0.85f) * 160f); if (num > 0) { this.DamageEntity(DamageSource.fall, num, false, 1f); } } } public override void OnUpdateLive() { if (this.bDead) { if (this.lootContainer != null) { if (this.lootContainer.bTouched && this.lootContainer.IsEmpty()) { this.MarkToUnload(); this.KillLootContainer(); } } } try { base.OnUpdateLive(); } catch (Exception ex) { Log.Out("EntityMeleeCyborgRebirth-OnUpdateLive ERROR: " + ex.Message); } if (!this.bDead) { float flNotified = this.Buffs.GetCustomVar("$FR_ENTITY_NotifiedEvent"); if (flNotified == 1) { hasNotified = true; } if (this.attackTarget && !hasNotified && this.HasAllTags(FastTags.Parse("boss,eventspawn"))) { hasNotified = true; this.Buffs.SetCustomVar("$FR_ENTITY_NotifiedEvent", 1); this.attackTarget.Buffs.AddBuff("FuriousRamsayEventTrigger"); } if (this.ticksUntilVisible > 0) { this.ticksUntilVisible--; } if (!this.isEntityRemote) { if (!this.IsDead() && this.world.worldTime >= this.timeToDie && !this.attackTarget) { this.Kill(DamageResponse.New(true)); } } } } /*public override bool CanDamageEntity(int _sourceEntityId) { return true; }*/ public override int DamageEntity(DamageSource _damageSource, int _strength, bool _criticalHit, float _impulseScale = 1f) { if ((_damageSource.GetDamageType() == EnumDamageTypes.Falling)) { if (this.GetWeight() == 69) { return 0; } else { _strength = (_strength + 1) / 2; int num = (this.GetMaxHealth() + 2) / 3; if (_strength > num) { _strength = num; } } } EntityAlive entityAlive = this.world.GetEntity(_damageSource.getEntityId()) as EntityAlive; //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 0: " + entityAlive.EntityName); EnumDamageSource source = _damageSource.GetSource(); if (_damageSource.IsIgnoreConsecutiveDamages() && source != EnumDamageSource.Internal) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 0a"); if (this.damageSourceTimeouts.ContainsKey(source) && GameTimer.Instance.ticks - this.damageSourceTimeouts[source] < 30UL) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 0b"); return 0; } this.damageSourceTimeouts[source] = GameTimer.Instance.ticks; } //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 1"); if (!this.FriendlyFireCheck(entityAlive)) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 1a"); return 0; } bool flag = _damageSource.GetDamageType() == EnumDamageTypes.Heat; //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 2"); if (!flag && entityAlive is EntityMeleeCyborgRebirth && this is EntityMeleeCyborgRebirth) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 2a"); return 0; } if (this.IsGodMode.Value) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 2b"); return 0; } bool flagSuicide = _damageSource.GetDamageType() == EnumDamageTypes.Suicide; bool shouldAttack = RebirthUtilities.VerifyFactionStanding(this, entityAlive, true); //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 3"); if (!flagSuicide && !shouldAttack/*myRelationship == FactionManager.Relationship.Love*/) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 3a"); return 0; } if (!flagSuicide && !shouldAttack/*myRelationship == FactionManager.Relationship.Like*/) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 3b"); return 0; } if (entityAlive != null) { if (!flagSuicide && !shouldAttack /*myRelationship == FactionManager.Relationship.Neutral*/ && (this.entityClass == entityAlive.entityClass)) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 3c"); return 0; } } //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 4"); if (!this.IsDead() && entityAlive) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 4a"); float value = EffectManager.GetValue(PassiveEffects.DamageBonus, null, 0f, entityAlive, null, new FastTags(), true, true, true, true, true, 1); if (value > 0f) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 4b"); _damageSource.DamageMultiplier = value; _damageSource.BonusDamageType = EnumDamageBonusType.Sneak; } } DamageResponse damageResponse = this.damageEntityLocal(_damageSource, _strength, _criticalHit, _impulseScale); if (this.EntityTags.Test_AnySet(FastTags.Parse("nanospawnerevent"))) { bool isHordeNight = RebirthUtilities.IsHordeNight(); bool NanoCyborgFuriousRamsayStage1Spawns = !NanoCyborgFuriousRamsayStage1 && !isHordeNight && (this.Health / this.Stats.Health.ModifiedMax) < .8f; bool NanoCyborgFuriousRamsayStage2Spawns = !NanoCyborgFuriousRamsayStage2 && !isHordeNight && (this.Health / this.Stats.Health.ModifiedMax) < .55f; bool NanoCyborgFuriousRamsayStage3Spawns = !NanoCyborgFuriousRamsayStage3 && !isHordeNight && (this.Health / this.Stats.Health.ModifiedMax) < .3f; EntityAlive entityplayer = null; if (entityAlive is EntityPlayer) { entityplayer = entityAlive; } if (NanoCyborgFuriousRamsayStage1Spawns) { NanoCyborgFuriousRamsayStage1 = true; Manager.BroadcastPlay(this.position, "FuriousRamsayNanoSpawn"); generatedNumbers.Clear(); RebirthUtilities.SpawnEntity(this.entityId, "NanoCyborg002_FR", 2, "", "", "2", "dynamic", "20", "", 1, -1, true, false, true, entityplayer.entityId); } else if (NanoCyborgFuriousRamsayStage2Spawns) { NanoCyborgFuriousRamsayStage2 = true; Manager.BroadcastPlay(this.position, "FuriousRamsayNanoSpawn"); generatedNumbers.Clear(); RebirthUtilities.SpawnEntity(this.entityId, "NanoCyborg003_FR", 2, "", "", "2", "dynamic", "20", "", 1, -1, true, false, true, entityplayer.entityId); } else if (NanoCyborgFuriousRamsayStage3Spawns) { NanoCyborgFuriousRamsayStage3 = true; Manager.BroadcastPlay(this.position, "FuriousRamsayNanoSpawn"); generatedNumbers.Clear(); RebirthUtilities.SpawnEntity(this.entityId, "NanoCyborg004_FR", 2, "", "", "2", "dynamic", "20", "", 1, -1, true, false, true, entityplayer.entityId); } } else if (this.EntityTags.Test_AnySet(FastTags.Parse("nanospawnerboss"))) { bool isHordeNight = RebirthUtilities.IsHordeNight(); bool NanoCyborgFuriousRamsayStage1Spawns = !NanoCyborgFuriousRamsayStage1 && !isHordeNight && (this.Health / this.Stats.Health.ModifiedMax) < .8f; bool NanoCyborgFuriousRamsayStage2Spawns = !NanoCyborgFuriousRamsayStage2 && !isHordeNight && (this.Health / this.Stats.Health.ModifiedMax) < .55f; bool NanoCyborgFuriousRamsayStage3Spawns = !NanoCyborgFuriousRamsayStage3 && !isHordeNight && (this.Health / this.Stats.Health.ModifiedMax) < .3f; EntityAlive entityplayer = null; if (entityAlive is EntityPlayer) { entityplayer = entityAlive; } if (NanoCyborgFuriousRamsayStage1Spawns) { NanoCyborgFuriousRamsayStage1 = true; Manager.BroadcastPlay(this.position, "FuriousRamsayNanoSpawn"); generatedNumbers.Clear(); RebirthUtilities.SpawnEntity(this.entityId, "NanoCyborg002_FREvent", 2, "", "", "2", "dynamic", "20", "", 1, -1, true, false, true, entityplayer.entityId); } else if (NanoCyborgFuriousRamsayStage2Spawns) { NanoCyborgFuriousRamsayStage2 = true; Manager.BroadcastPlay(this.position, "FuriousRamsayNanoSpawn"); generatedNumbers.Clear(); RebirthUtilities.SpawnEntity(this.entityId, "NanoCyborg003_FREvent", 2, "", "", "2", "dynamic", "20", "", 1, -1, true, false, true, entityplayer.entityId); } else if (NanoCyborgFuriousRamsayStage3Spawns) { NanoCyborgFuriousRamsayStage3 = true; Manager.BroadcastPlay(this.position, "FuriousRamsayNanoSpawn"); generatedNumbers.Clear(); RebirthUtilities.SpawnEntity(this.entityId, "NanoCyborg004_FREvent", 2, "", "", "2", "dynamic", "20", "", 1, -1, true, false, true, entityplayer.entityId); } } NetPackage package = NetPackageManager.GetPackage().Setup(this.entityId, damageResponse); //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 5"); if (this.world.IsRemote()) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 5a"); SingletonMonoBehaviour.Instance.SendToServer(package, false); } else { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 5b"); int excludePlayer = -1; if (!flag && _damageSource.CreatorEntityId != -2) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 5c"); excludePlayer = _damageSource.getEntityId(); if (_damageSource.CreatorEntityId != -1) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 5d"); Entity entity = this.world.GetEntity(_damageSource.CreatorEntityId); if (entity && !entity.isEntityRemote) { //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 5e"); excludePlayer = -1; } } } this.world.entityDistributer.SendPacketToTrackedPlayersAndTrackedEntity(this.entityId, excludePlayer, package); } //Log.Out("EntityMeleeCyborgRebirth-DamageEntity 6"); return damageResponse.ModStrength; } public override void OnAddedToWorld() { base.OnAddedToWorld(); this.timeToDie = this.world.worldTime + 1800UL + (ulong)(22000f * this.rand.RandomFloat); if (this.IsFeral && base.GetSpawnerSource() == EnumSpawnerSource.Biome) { int num = (int)SkyManager.GetDawnTime(); int num2 = (int)SkyManager.GetDuskTime(); int num3 = GameUtils.WorldTimeToHours(this.WorldTimeBorn); if (num3 < num || num3 >= num2) { int num4 = GameUtils.WorldTimeToDays(this.world.worldTime); if (GameUtils.WorldTimeToHours(this.world.worldTime) >= num2) { num4++; } this.timeToDie = GameUtils.DayTimeToWorldTime(num4, num, 0); } } } public override bool IsSavedToFile() { // If they have a cvar persist, keep them around. if (Buffs.HasCustomVar("Persist")) return true; // If its dynamic spawn, don't let them stay. if (GetSpawnerSource() == EnumSpawnerSource.Dynamic) return false; return true; } public override Ray GetLookRay() { Ray result; if (base.IsBreakingBlocks) { result = new Ray(this.position + new Vector3(0f, this.GetEyeHeight(), 0f), this.GetLookVector()); } else if (base.GetWalkType() == 8) { result = new Ray(this.getHeadPosition(), this.GetLookVector()); } else { result = new Ray(this.getHeadPosition(), this.GetLookVector()); } return result; } public override Vector3 GetLookVector() { if (this.lookAtPosition.Equals(Vector3.zero)) { return base.GetLookVector(); } return this.lookAtPosition - this.getHeadPosition(); } public override bool IsRunning { get { EnumGamePrefs eProperty = EnumGamePrefs.ZombieMove; if (this.IsBloodMoon) { eProperty = EnumGamePrefs.ZombieBMMove; } else if (this.IsFeral) { eProperty = EnumGamePrefs.ZombieFeralMove; } else if (this.world.IsDark()) { eProperty = EnumGamePrefs.ZombieMoveNight; } return GamePrefs.GetInt(eProperty) >= 2; } } public override float GetMoveSpeedAggro() { EnumGamePrefs eProperty = EnumGamePrefs.ZombieMove; if (this.IsBloodMoon) { eProperty = EnumGamePrefs.ZombieBMMove; } else if (this.IsFeral) { eProperty = EnumGamePrefs.ZombieFeralMove; } else if (this.world.IsDark()) { eProperty = EnumGamePrefs.ZombieMoveNight; } int @int = GamePrefs.GetInt(eProperty); float num = moveSpeeds[@int]; if (this.moveSpeedRagePer > 1f) { num = moveSuperRageSpeeds[@int]; } else if (this.moveSpeedRagePer > 0f) { float num2 = moveRageSpeeds[@int]; num = num * (1f - this.moveSpeedRagePer) + num2 * this.moveSpeedRagePer; } if (num < 1f) { num = this.moveSpeedAggro * (1f - num) + this.moveSpeedAggroMax * num; } else { num = this.moveSpeedAggroMax * num; } return EffectManager.GetValue(PassiveEffects.RunSpeed, null, num, this, null, new FastTags(), true, true, true, true, true, 1); } public override float getNextStepSoundDistance() { if (!this.IsRunning) { return 0.5f; } return 1.5f; } public override void MoveEntityHeaded(Vector3 _direction, bool _isDirAbsolute) { if (this.walkType == 4 && this.Jumping) { this.motion = this.accumulatedRootMotion; this.accumulatedRootMotion = Vector3.zero; this.IsRotateToGroundFlat = true; if (this.moveHelper != null) { Vector3 vector = this.moveHelper.JumpToPos - this.position; if (Utils.FastAbs(vector.y) < 0.2f) { this.motion.y = vector.y * 0.2f; } if (Utils.FastAbs(vector.x) < 0.3f) { this.motion.x = vector.x * 0.2f; } if (Utils.FastAbs(vector.z) < 0.3f) { this.motion.z = vector.z * 0.2f; } if (vector.sqrMagnitude < 0.010000001f) { if (this.emodel && this.emodel.avatarController) { this.emodel.avatarController.StartAnimationJump(AnimJumpMode.Land); } this.Jumping = false; } } this.entityCollision(this.motion); return; } base.MoveEntityHeaded(_direction, _isDirAbsolute); } public override void UpdateJump() { if (this.walkType == 4 && !this.isSwimming) { base.FaceJumpTo(); this.jumpState = EntityAlive.JumpState.Climb; if (!this.emodel.avatarController || !this.emodel.avatarController.IsAnimationJumpRunning()) { this.Jumping = false; } if (this.jumpTicks == 0 && this.accumulatedRootMotion.y > 0.005f) { this.jumpTicks = 30; } return; } base.UpdateJump(); if (this.isSwimming) { return; } this.accumulatedRootMotion.y = 0f; } public override void EndJump() { base.EndJump(); this.IsRotateToGroundFlat = false; } public override bool ExecuteFallBehavior(EntityAlive.FallBehavior behavior, float _distance, Vector3 _fallMotion) { if (behavior == null || !this.emodel) { return false; } AvatarController avatarController = this.emodel.avatarController; if (!avatarController) { return false; } avatarController.UpdateInt("RandomSelector", this.rand.RandomRange(0, 64)); switch (behavior.ResponseOp) { case EntityAlive.FallBehavior.Op.None: avatarController.UpdateInt(AvatarController.jumpLandResponseHash, -1); break; case EntityAlive.FallBehavior.Op.Land: avatarController.UpdateInt(AvatarController.jumpLandResponseHash, 0); break; case EntityAlive.FallBehavior.Op.LandLow: avatarController.UpdateInt(AvatarController.jumpLandResponseHash, 1); break; case EntityAlive.FallBehavior.Op.LandHard: avatarController.UpdateInt(AvatarController.jumpLandResponseHash, 2); break; case EntityAlive.FallBehavior.Op.Stumble: avatarController.UpdateInt(AvatarController.jumpLandResponseHash, 3); break; case EntityAlive.FallBehavior.Op.Ragdoll: this.emodel.DoRagdoll(this.rand.RandomFloat * 2f, EnumBodyPartHit.None, _fallMotion * 20f, Vector3.zero, false); break; } if (this.attackTarget != null && behavior.RagePer.IsSet() && behavior.RageTime.IsSet() && this.StartRage(behavior.RagePer.Random(this.rand), behavior.RageTime.Random(this.rand))) { avatarController.StartAnimationRaging(); } return true; } public override bool ExecuteDestroyBlockBehavior(EntityAlive.DestroyBlockBehavior behavior, ItemActionAttack.AttackHitInfo attackHitInfo) { if (behavior == null || attackHitInfo == null || this.moveHelper == null || this.emodel == null || this.emodel.avatarController == null) { return false; } if (this.walkType == 4) { return false; } this.moveHelper.ClearBlocked(); this.moveHelper.ClearTempMove(); this.emodel.avatarController.UpdateInt("RandomSelector", this.rand.RandomRange(0, 64)); switch (behavior.ResponseOp) { case EntityAlive.DestroyBlockBehavior.Op.Ragdoll: this.emodel.avatarController.BeginStun(EnumEntityStunType.StumbleBreakThroughRagdoll, EnumBodyPartHit.LeftLowerLeg, Utils.EnumHitDirection.None, false, 1f); base.SetStun(EnumEntityStunType.StumbleBreakThroughRagdoll); break; case EntityAlive.DestroyBlockBehavior.Op.Stumble: this.emodel.avatarController.BeginStun(EnumEntityStunType.StumbleBreakThrough, EnumBodyPartHit.LeftLowerLeg, Utils.EnumHitDirection.None, false, 1f); base.SetStun(EnumEntityStunType.StumbleBreakThrough); this.bodyDamage.StunDuration = 1f; break; } if (this.attackTarget != null && behavior.RagePer.IsSet() && behavior.RageTime.IsSet()) { this.StartRage(behavior.RagePer.Random(this.rand), behavior.RageTime.Random(this.rand)); } return true; } public override Vector3i dropCorpseBlock() { if (this.lootContainer != null && this.lootContainer.IsUserAccessing()) { return Vector3i.zero; } Vector3i vector3i = base.dropCorpseBlock(); if (vector3i == Vector3i.zero) { return Vector3i.zero; } TileEntityLootContainer tileEntityLootContainer = this.world.GetTileEntity(0, vector3i) as TileEntityLootContainer; if (tileEntityLootContainer == null) { return Vector3i.zero; } if (this.lootContainer != null) { tileEntityLootContainer.CopyLootContainerDataFromOther(this.lootContainer); } else { tileEntityLootContainer.lootListName = this.lootListOnDeath; tileEntityLootContainer.SetContainerSize(LootContainer.GetLootContainer(this.lootListOnDeath, true).size, true); } tileEntityLootContainer.SetModified(); return vector3i; } public override void AnalyticsSendDeath(DamageResponse _dmResponse) { DamageSource source = _dmResponse.Source; if (source == null) { return; } string name; if (source.BuffClass != null) { name = source.BuffClass.Name; } else { if (source.ItemClass == null) { return; } name = source.ItemClass.Name; } GameSparksCollector.IncrementCounter(GameSparksCollector.GSDataKey.ZombiesKilledBy, name, 1, true, GameSparksCollector.GSDataCollection.SessionUpdates); } public override void BuffAdded(BuffValue _buff) { if (_buff.BuffClass.DamageType == EnumDamageTypes.Electrical) { this.Electrocuted = true; } } private int ticksUntilVisible = 2; private float moveSpeedRagePer; private float moveSpeedScaleTime; private float fallTime; private float fallThresholdTime; private static float[] moveSpeeds = new float[] { 0f, 0.35f, 0.7f, 1f, 1.35f }; private static float[] moveRageSpeeds = new float[] { 0.75f, 0.8f, 0.9f, 1.15f, 1.7f }; private static float[] moveSuperRageSpeeds = new float[] { 0.88f, 0.92f, 1f, 1.2f, 1.7f }; private static float[] rageChances = new float[] { 0f, 0.15f, 0.3f, 0.35f, 0.4f, 0.5f }; private static float[] superRageChances = new float[] { 0f, 0.01f, 0.03f, 0.05f, 0.08f, 0.15f }; private void ApplyLocalBodyDamage(DamageResponse _dmResponse) { if (_dmResponse.Dismember) { switch (_dmResponse.HitBodyPart) { case EnumBodyPartHit.Head: this.bodyDamage.Flags = (this.bodyDamage.Flags | 1U); break; case EnumBodyPartHit.LeftUpperArm: this.bodyDamage.Flags = (this.bodyDamage.Flags | 2U); break; case EnumBodyPartHit.RightUpperArm: this.bodyDamage.Flags = (this.bodyDamage.Flags | 8U); break; case EnumBodyPartHit.LeftUpperLeg: this.bodyDamage.Flags = (this.bodyDamage.Flags | 32U); this.bodyDamage.ShouldBeCrawler = true; break; case EnumBodyPartHit.RightUpperLeg: this.bodyDamage.Flags = (this.bodyDamage.Flags | 128U); this.bodyDamage.ShouldBeCrawler = true; break; case EnumBodyPartHit.LeftLowerArm: this.bodyDamage.Flags = (this.bodyDamage.Flags | 4U); break; case EnumBodyPartHit.RightLowerArm: this.bodyDamage.Flags = (this.bodyDamage.Flags | 16U); break; case EnumBodyPartHit.LeftLowerLeg: this.bodyDamage.Flags = (this.bodyDamage.Flags | 64U); this.bodyDamage.ShouldBeCrawler = true; break; case EnumBodyPartHit.RightLowerLeg: this.bodyDamage.Flags = (this.bodyDamage.Flags | 256U); this.bodyDamage.ShouldBeCrawler = true; break; } } if (_dmResponse.TurnIntoCrawler) { this.bodyDamage.ShouldBeCrawler = true; } if (_dmResponse.CrippleLegs) { if (_dmResponse.HitBodyPart.IsLeftLeg()) { this.bodyDamage.Flags = (this.bodyDamage.Flags | 4096U); } else if (_dmResponse.HitBodyPart.IsRightLeg()) { this.bodyDamage.Flags = (this.bodyDamage.Flags | 8192U); } } this.bodyDamage.damageType = _dmResponse.Source.damageType; this.bodyDamage.bodyPartHit = _dmResponse.HitBodyPart; } }