public DamageResponse Defend(DamageResponse damage) { List <DamageResponse> allDamageResponses = new List <DamageResponse>(); foreach (var defenseItem in DefensiveItems) { allDamageResponses.Add(defenseItem.Defend(damage)); } var successValues = from damageResponse in allDamageResponses where damage.SuccessValue == false select damageResponse.SuccessValue; bool successValue = !successValues.Any(); var totalDamageDealt = from damageResponse in allDamageResponses select damageResponse.Damage; double damageDealt = totalDamageDealt.Average(); damageDealt = damageDealt > 0 ? damageDealt : 0; return(new DamageResponse( "Average effort of the composite defend items", successValue, damageDealt, damage.Origin, damage.DamageSource)); }
/// <summary> /// Causes the user's character to die /// </summary> public void Kill() { var entity = GameManager.Instance.World.GetEntity(client.entityId); entity.Kill(DamageResponse.New(new DamageSource(EnumDamageSourceType.Undef), true)); //entity.DamageEntity(new DamageSource(EnumDamageSourceType.Bullet), 99999, false); }
private IEnumerator Explode() { Vector3 pos = this.GetPosition(); Vector3i where = V3i(pos); World world = GameManager.Instance.World; SpawnItem(pos, "thrownAmmoMolotovCocktail", new Vector3(0f, -0.1f, 0f)); // world.SetBlockRPC(0, where, BlockValue.Air); /// Fails to oestroy crate - matter of V3/V3i conversion ? this.Kill(DamageResponse.New(true)); GameRandom random = AIAirDrop.controller.Random; for (int k = 0; k < 10; k++) { SpawnItem( pos + new Vector3(random.RandomRange(-3f, 3f), random.RandomRange(1f, 3f), random.RandomRange(-3f, 3f)), "rockBomb", new Vector3(random.RandomRange(-5f, 5f), random.RandomRange(-2f, 2f), random.RandomRange(-5f, 5f)) ); yield return(new WaitForSeconds(0.2f)); SpawnItem( pos + new Vector3(random.RandomRange(-3f, 3f), random.RandomRange(1f, 3f), random.RandomRange(-3f, 3f)), "thrownAmmoMolotovCocktail", new Vector3(random.RandomRange(-5f, 5f), random.RandomRange(2f, 4f), random.RandomRange(-5f, 5f)) ); float dt = AIAirDrop.controller.Random.RandomRange(0.1f, 1f); yield return(new WaitForSeconds(dt)); } }
private void OnEntityDeath(Entity entity, DamageResponse dmgResponse) { HookCalled("OnEntityDeath"); var source = (EntityFightable)entity.fd0005.GetEntity(dmgResponse.Source.mdv0007()); var entityFightable = entity as EntityFightable; PrintWarning($"{entityFightable.EntityName}"); }
public override IResponse ReceiveHit(DamageResponse hit) { IDefenseItem defenseItem = PickDefenseItem(); DamageResponse defended = defenseItem.Defend(hit); int damageRoundedUp; if (defended.SuccessValue) { damageRoundedUp = Convert.ToInt32(Math.Ceiling(defended.Damage)); } else { return(new FailureResponse("A defense Item failed")); } if (damageRoundedUp > 0) { Hitpoints = Hitpoints - damageRoundedUp; if (Hitpoints == 0) { return(Death()); } return(new SuccessResponse($"{Name} of type {GetType().Name} took {damageRoundedUp} points of damage from {hit.Origin.Name}.")); } return(new SuccessResponse($"{Name} blocked the damage from {hit.Origin.Name}'s attack.")); }
protected override DamageResponse damageEntityLocal(DamageSource _damageSource, int _strength, bool _criticalHit, float impulseScale) { this.Health -= _strength; DamageResponse ret = base.damageEntityLocal(_damageSource, _strength, _criticalHit, impulseScale); // Debug.Log("Response: " + ret.ToString() + " strength: " + _strength + " type: " + _damageSource.GetName().ToString() + " health: " + this.Health); return(ret); }
public override void ProcessDamageResponseLocal(DamageResponse _dmResponse) { if (ProccessCommands(_dmResponse)) { return; } base.ProcessDamageResponseLocal(_dmResponse); }
public static bool Prefix([NotNull] EntityAlive __instance, DamageResponse _dmResponse) { Log.Debug($"Executing patch prefix for {nameof(EntityDamaged)} ..."); ScriptEvent eventType; if (__instance is EntityPlayer) { eventType = ScriptEvent.playerDamaged; } else if (__instance is EntityAnimal || __instance is EntityZombieDog || __instance is EntityEnemyAnimal || __instance is EntityHornet) { eventType = ScriptEvent.animalDamaged; } else if (__instance is EntityZombie) { eventType = ScriptEvent.zombieDamaged; } else { return(true); } CommandTools.InvokeScriptEvents(eventType, () => { var sourceEntity = GameManager.Instance.World?.GetEntity(_dmResponse.Source?.getEntityId() ?? -1) as EntityAlive; var targetClientInfo = ConnectionManager.Instance?.GetClientInfoForEntityId(__instance.entityId); var sourceClientInfo = ConnectionManager.Instance?.GetClientInfoForEntityId(sourceEntity?.entityId ?? -1); return(new EntityDamagedEventArgs { position = __instance.GetBlockPosition(), entityId = __instance.entityId, entityName = __instance.EntityName, entitySteamId = targetClientInfo?.playerId, sourceEntityId = sourceEntity?.entityId, sourceEntityName = sourceEntity?.EntityName, sourceEntitySteamId = sourceClientInfo?.playerId, damageType = _dmResponse.Source?.GetName().ToString(), hitBodyPart = _dmResponse.HitBodyPart.ToString(), hitDirection = _dmResponse.HitDirection.ToString(), damage = _dmResponse.Strength, armorDamage = _dmResponse.ArmorDamage, armorSlot = _dmResponse.ArmorSlot.ToString(), stunType = _dmResponse.Stun.ToString(), stunDuration = _dmResponse.StunDuration, critical = _dmResponse.Critical, fatal = _dmResponse.Fatal, crippleLegs = _dmResponse.CrippleLegs, dismember = _dmResponse.Dismember, turnIntoCrawler = _dmResponse.TurnIntoCrawler, painHit = _dmResponse.PainHit, }); }); return(true); }
public override void ProcessDamageResponseLocal(DamageResponse _dmResponse) { // If we are being attacked, let the state machine know it can fight back emodel.avatarController.SetBool("IsBusy", false); // Turn off the trader ID while it deals damage to the entity ToggleTraderID(false); base.ProcessDamageResponseLocal(_dmResponse); ToggleTraderID(true); }
public static bool DamageResponse_Prefix(EntityAlive __instance, ref DamageResponse _dmResponse) { try { return(DamageDetector.ProcessPlayerDamage(__instance, _dmResponse)); } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Injections.DamageResponse_Prefix: {0}.", e.Message)); } return(true); }
public static bool DamageResponse_Prefix(EntityAlive __instance, DamageResponse _dmResponse) { try { //Log.Out("DamageResponse_Prefix"); return(false); } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Injections.DamageResponse_Prefix: {0}", e.Message)); } return(true); }
/** * When the player activates this entityclass with an empty hand, try to pick it up. */ public override void Kill(DamageResponse _dmgResponse) { if (_dmgResponse.Source.getEntityId() == -1) { base.Kill(_dmgResponse); Log.Warning("Killer was not a player."); return; } EntityPlayerLocal entityPlayerLocal = GameManager.Instance.World.GetLocalPlayerFromID(_dmgResponse.Source.getEntityId()) as EntityPlayerLocal; if (!(entityPlayerLocal is EntityPlayerLocal)) { base.Kill(_dmgResponse); Log.Warning("Killer was an entity, but not a player."); return; } LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal); if (uiforPlayer.xui.isUsingItemActionEntryUse) { base.Kill(_dmgResponse); Log.Warning("XUI interfering."); return; } ItemStack pickup = new ItemStack(this.itemReturned, 1); if (!entityPlayerLocal.inventory.CanTakeItem(pickup) & !entityPlayerLocal.bag.CanTakeItem(pickup)) { base.Kill(_dmgResponse); Log.Warning("Canot take item - no room in inventory."); return; } Log.Out("Player is holding: " + entityPlayerLocal.inventory.holdingItem.GetItemName()); if (entityPlayerLocal.inventory.holdingItem.GetItemName() == "meleeHandPlayer") { Log.Out("Server, despawn the entity."); GameManager.Instance.World.RemoveEntity(this.entityId, EnumRemoveEntityReason.Killed); Log.Out("Player, add the item."); entityPlayerLocal.inventory.AddItem(pickup); return; } Log.Warning("Cannot activate."); base.Kill(_dmgResponse); return; }
public static bool DamageResponse_Prefix(EntityAlive __instance, DamageResponse _dmResponse) { try { if (ProcessDamage.Damage_Detector || Zones.IsEnabled || Lobby.IsEnabled) { return(ProcessDamage.ProcessPlayerDamage(__instance, _dmResponse)); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Injections.DamageResponse_Prefix: {0}", e.Message)); } return(true); }
public override void ProcessDamageResponseLocal(DamageResponse _dmResponse) { if (EntityUtilities.GetBoolValue(entityId, "Invulnerable")) { return; } if (this.Buffs.HasBuff("buffInvulnerable")) { return; } // If we are being attacked, let the state machine know it can fight back emodel.avatarController.SetBool("IsBusy", false); // Turn off the trader ID while it deals damage to the entity ToggleTraderID(false); base.ProcessDamageResponseLocal(_dmResponse); ToggleTraderID(true); }
public static DamageResponse TransformDamage(DamageResponse attack, double efficiency) { Random random = new Random(DateTime.Now.Millisecond); var allAttackTypes = from attackTypes in attack.DamageSource.DamageTypes select attackTypes; var physicalTypes = from attackTypes in attack.DamageSource.DamageTypes where TypeComparer.IsSameOrVariant(typeof(PhysicalDamageType), attackTypes.GetType()).SuccessValue select attackTypes; double physicalPercent = (from weights in physicalTypes select weights.Weight).Sum() / (from weights in allAttackTypes select weights.Weight).Sum(); if (physicalPercent == 0) { return(attack); } //todo damage skal regnes så plate fjerne noget af physical skaden. if (physicalPercent > random.NextDouble()) { } attack.Damage = (attack.Damage * physicalPercent) + (attack.Damage * (1 - physicalPercent)); return(null); }
public DamageResponse Defend(DamageResponse damage) { double newDamage = damage.Damage; double totalWeight = (from types in damage.DamageSource.DamageTypes select types.Weight).Sum(); foreach (var damageType in damage.DamageSource.DamageTypes) { foreach (var defendDamageType in Types) { double weightShare = damageType.Weight / totalWeight; newDamage = newDamage * (damageType.Modifier(defendDamageType) * weightShare); } } newDamage = newDamage - Defense; if (newDamage < 0) { newDamage = 0; } return(new DamageResponse("Damage was successfully defended", true, newDamage, damage.Origin, damage.DamageSource)); }
public void ExecuteCommand(Response R) { switch (R.CMD) { case CommandType.Movement: MoveResponse MovRes = (MoveResponse)R; transform.position = MovRes.getNewPosition(); break; case CommandType.TargetAbility: DamageResponse DamRes = (DamageResponse)R; PM.HP += DamRes.HPChange; if (PM.HP < 0) { Destroy(this.gameObject); return; } break; } //And anything else we need to apply }
private bool ProccessCommands(DamageResponse _dmResponse) { if (_dmResponse.Source.GetName() == EnumDamageSourceType.Disease) { if (_dmResponse.Strength >= 1000 && _dmResponse.Strength < 2000) { // it's a command, i take out 1000 from it to obtain the command "bits" var commands = _dmResponse.Strength - 1000; if (commands == 1) { // return to player callBack(); } else if (commands == 2) { // despawn the entity, captured MarkToUnload(); } else if (commands == 3) { // start taming TameBird(); } else if (commands == 4) { // failed taming, wild bird ownerID = 0; SetRevengeTarget(null); } return(true); } } return(false); }
public static void Kill(EntityAlive entity) { entity.Kill(DamageResponse.New(true)); // entity.SetDead(); // entity.DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.None), 99999, false, 1f); }
// The Update route protected virtual void LateUpdate() { try { // If a critical error is thrown in this method, flag it to be true, so we don't get into a spaming loop. if (CriticalError) { return; } // Delay the updating of hte indexes by the CheckDelay, which is 5seconds by default. if (nextCheck == 0.0f || nextCheck < Time.time) { nextCheck = Time.time + CheckDelay; SetRandomIndex("RandomIndex"); SetRandomIndex("WalkIndex"); SetRandomIndex("RunIndex"); SetRandomIndex("IdleIndex"); } if (this.entityAlive == null) { Log("The entity is null!"); CriticalError = true; } ActionTime -= Time.deltaTime; if (bipedTransform == null || !bipedTransform.gameObject.activeInHierarchy) { Log("Biped Transform was null!"); CriticalError = true; return; } if (anim == null || anim.avatar == null) { Log(string.Format("Animator or Animator Avatar is Null for {0}", modelTransform.name)); CriticalError = true; return; } if (anim.avatar.isValid && anim.enabled) { if (entityAlive.IsBreakingBlocks && !anim.GetBool(IsBreakingBlocks)) { anim.SetBool(IsBreakingBlocks, true); } else { anim.SetBool(IsBreakingBlocks, false); } if (entityAlive.IsBreakingDoors && !anim.GetBool(IsBreakingDoors)) { anim.SetBool(IsBreakingDoors, true); } else { anim.SetBool(IsBreakingDoors, false); } UpdateCurrentState(); if (this.timeSpecialAttackPlaying > 0f) { // it's playing special attack this.timeSpecialAttackPlaying -= Time.deltaTime; return; } // Test condition while we evaluate the effectiveness of using encroachment for state machine triggers. if (true) { if (this.timeSpecialAttackPlaying > 0f) { // it's playing special attack this.timeSpecialAttackPlaying -= Time.deltaTime; return; } Log("Last Distance: " + this.lastDistance); float playerDistanceX = 0.0f; float playerDistanceZ = 0.0f; float encroached = this.lastDistance; // Calculates how far away the entity is playerDistanceX = Mathf.Abs(this.entityAlive.position.x - this.entityAlive.lastTickPos[0].x) * 6f; playerDistanceZ = Mathf.Abs(this.entityAlive.position.z - this.entityAlive.lastTickPos[0].z) * 6f; if (!this.entityAlive.isEntityRemote) { if (Mathf.Abs(playerDistanceX - this.lastPlayerX) > 0.00999999977648258 || Mathf.Abs(playerDistanceZ - this.lastPlayerZ) > 0.00999999977648258) { encroached = Mathf.Sqrt(playerDistanceX * playerDistanceX + playerDistanceZ * playerDistanceZ); this.lastPlayerX = playerDistanceX; this.lastPlayerZ = playerDistanceZ; this.lastDistance = encroached; } } else if (playerDistanceX <= this.lastPlayerX && playerDistanceZ <= this.lastPlayerZ) { this.lastPlayerX *= 0.9f; this.lastPlayerZ *= 0.9f; this.lastDistance *= 0.9f; } else { encroached = Mathf.Sqrt((playerDistanceX * playerDistanceX + playerDistanceZ * playerDistanceZ)); this.lastPlayerX = playerDistanceX; this.lastPlayerZ = playerDistanceZ; this.lastDistance = encroached; } Log("LastPlayerX: " + this.lastPlayerX); Log("LastPlayerZ: " + this.lastPlayerZ); Log("Last Distance:" + this.lastDistance); Log("Encroachment: " + encroached); // if the entity is in water, flag it, so we'll do the swiming conditions before the movement. this.anim.SetBool("IsInWater", entityAlive.IsInWater()); Log("Entity is in Water: " + entityAlive.IsInWater()); Log("Movement State on Animation: " + this.anim.GetInteger("MovementState")); // this.entityAlive.world.IsMaterialInBounds(BoundsUtils.ExpandBounds(this.entityAlive.boundingBox, -0.1f, -0.4f, -0.1f), MaterialBlock.water); if (entityAlive.Electrocuted) { StartAnimationElectrocuted(); } else { this.IsElectrocuting = false; } if (entityAlive.HarvestingAnimation) { StartAnimationHarvesting(); } else { this.IsHarvesting = false; } if (entityAlive.IsEating) { StartEating(); } else { this.isEating = false; } if (encroached > 0.150000005960464) { // Running if above 1.0 if (encroached > 1.0) { this.anim.SetInteger(MovementState, 2); } else { this.anim.SetInteger(MovementState, 1); } } else { this.anim.SetInteger(MovementState, 0); } Log("Movement State on Animation: " + this.anim.GetInteger("MovementState")); } else { // this code uses a newer version of logic, but seems to be inconsistent var num = 0f; var num2 = 0f; if (!entityAlive.IsFlyMode.Value) { num = entityAlive.speedForward; num2 = entityAlive.speedStrafe; } var num3 = num2; if (num3 >= 1234f) { num3 = 0f; } anim.SetFloat(Forward, num); anim.SetFloat(Strafe, num3); var num4 = num * num + num3 * num3; if (!entityAlive.IsDead()) { anim.SetInteger(MovementState, num4 <= entityAlive.speedApproach * entityAlive.speedApproach ? (num4 <= entityAlive.speedWander * entityAlive.speedWander ? (num4 <= 0.001f ? 0 : 1) : 2) : 3); } if (Mathf.Abs(num) <= 0.01f && Mathf.Abs(num2) <= 0.01f) { anim.SetBool(IsMoving, false); } else { idleTime = 0f; anim.SetBool(IsMoving, true); } } var flag = false; if (anim != null && isInDeathAnim && !anim.IsInTransition(0) ) // this.DeathHash.Contains(this.currentBaseState.fullPathHash) ) { flag = true; } if (anim != null && isInDeathAnim && flag && (currentBaseState.normalizedTime >= 1f || anim.IsInTransition(0))) { isInDeathAnim = false; if (entityAlive.HasDeathAnim) { entityAlive.emodel.DoRagdoll(DamageResponse.New(true)); } } anim.SetFloat(IdleTime, idleTime); idleTime += Time.deltaTime; } } catch (Exception ex) { // Because errors in the LateUpdate are pretty fatal, we'll flag it as Critical so things won't get stuck in a spam update, and // the debug log will display all the time. Debug.Log(string.Format("Error in LateUpdate for {0} : {1}", this.modelTransform.name, ex.ToString())); CriticalError = true; } }
public static bool ProcessPlayerDamage(EntityAlive __instance, DamageResponse _dmResponse) { try { if (__instance != null && __instance is EntityPlayer && _dmResponse.Source != null) { int _sourceId = _dmResponse.Source.getEntityId(); if (_sourceId > 0) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromEntityId(_sourceId); if (_cInfo != null) { EntityPlayer _player2 = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player2 != null) { if (Damage_Detector) { ItemValue _itemValue = ItemClass.GetItem(_player2.inventory.holdingItem.Name, true); if (_itemValue != null) { int _distance = (int)_player2.GetDistance(__instance); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} {2} hit {3} with entity id {4} using {5} for {6} damage @ {7}. Distance: {8}", DateTime.Now, _cInfo.playerId, _cInfo.playerName, __instance.EntityName, __instance.entityId, _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(), _dmResponse.Strength, __instance.position, _distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (_dmResponse.Strength >= Entity_Damage_Limit && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Admin_Level) { string _message = "[FF0000]{PlayerName} has been banned for using damage manipulation."; _message = _message.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for using damage manipulation. Damage recorded: {1}\"", _cInfo.playerId, _dmResponse.Strength), (ClientInfo)null); using (StreamWriter sw = new StreamWriter(_detectionFilepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, using damage manipulation @ {2}. Damage recorded: {3}", _cInfo.playerName, _cInfo.playerId, __instance.position, _dmResponse.Strength)); sw.WriteLine(); sw.Flush(); sw.Close(); } return(false); } } } if (Zones.IsEnabled) { if (Zones.ZonePvE.Contains(__instance.entityId) || Zones.ZonePvE.Contains(_cInfo.entityId)) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Do not attack players inside a pve zone or while standing in one!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); EntityPlayer _player1 = (EntityPlayer)__instance; if (_player1 != null) { if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo.entityId, out int _flags); _flags++; if (PersistentOperations.Jail_Violation > 0 && _flags >= PersistentOperations.Jail_Violation) { Jail(_cInfo, __instance); } if (PersistentOperations.Kill_Violation > 0 && _flags >= PersistentOperations.Kill_Violation) { Kill(_cInfo); } if (PersistentOperations.Kick_Violation > 0 && _flags >= PersistentOperations.Kick_Violation) { Kick(_cInfo); } if (PersistentOperations.Ban_Violation > 0 && _flags >= PersistentOperations.Ban_Violation) { Ban(_cInfo); } } else { PersistentOperations.PvEViolations.Add(_cInfo.entityId, 1); } } } return(false); } } if (Lobby.IsEnabled && Lobby.PvE && Lobby.LobbyPlayers.Contains(__instance.entityId) || Market.IsEnabled && Market.PvE && Market.MarketPlayers.Contains(__instance.entityId)) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Do not attack players inside the lobby or market!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); EntityPlayer _player1 = (EntityPlayer)__instance; if (_player1 != null) { if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo.entityId, out int _violations); _violations++; if (PersistentOperations.Jail_Violation > 0 && _violations >= PersistentOperations.Jail_Violation) { Jail(_cInfo, __instance); } if (PersistentOperations.Kill_Violation > 0 && _violations >= PersistentOperations.Kill_Violation) { Kill(_cInfo); } if (PersistentOperations.Kick_Violation > 0 && _violations >= PersistentOperations.Kick_Violation) { Kick(_cInfo); } else if (PersistentOperations.Ban_Violation > 0 && _violations >= PersistentOperations.Ban_Violation) { Ban(_cInfo); } } else { PersistentOperations.PvEViolations.Add(_cInfo.entityId, 1); } } } return(false); } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessPlayerDamage: {0}", e.Message)); } return(true); }
// Had to over-ride LateUpdate because it was making a direct call to the second animation layer. we don't support that. protected override void LateUpdate() { if (this.entity == null || this.bipedTransform == null || !this.bipedTransform.gameObject.activeInHierarchy) { return; } if (!(this.anim == null) && this.anim.enabled) { // Allows for the entity to be registered as local, so that the animations can be synced. this.updateLayerStateInfo(); if (this.entity.inventory.holdingItem.Actions[0] != null) { this.entity.inventory.holdingItem.Actions[0].UpdateNozzleParticlesPosAndRot(this.entity.inventory.holdingItemData.actionData[0]); } if (this.entity.inventory.holdingItem.Actions[1] != null) { this.entity.inventory.holdingItem.Actions[1].UpdateNozzleParticlesPosAndRot(this.entity.inventory.holdingItemData.actionData[1]); } int shortNameHash = this.currentBaseState.shortNameHash; bool flag; if (!(flag = this.anim.IsInTransition(0))) { if (shortNameHash == this.jumpState || shortNameHash == this.fpvJumpState) { this.SetBool("Jump", false); } if (this.deathStates.Contains(shortNameHash)) { this.SetBool("IsDead", false); } if (this.anim.GetBool("Reload") && this.reloadStates.Contains(this.currentWeaponHoldLayer.fullPathHash)) { this.SetBool("Reload", false); } } if (this.anim.GetBool("ItemUse") && --this.itemUseTicks <= 0) { this.SetBool("ItemUse", false); } //float num = 0f; //float num2 = 0f; //if (!this.entity.IsFlyMode.Value) //{ // num = this.entity.speedForward; // num2 = this.entity.speedStrafe; //} //float num3 = num2; //if (num3 >= 1234f) //{ // num3 = 0f; //} //float num4 = num * num + num3 * num3; //this.SetInt("MovementState", (num4 <= this.entity.moveSpeedAggro * this.entity.moveSpeedAggro) ? ((num4 <= this.entity.moveSpeed * this.entity.moveSpeed) ? ((num4 <= 0.001f) ? 0 : 1) : 2) : 3); ////Log("Last Distance: " + this.lastDistance); ////float playerDistanceX = 0.0f; //float playerDistanceZ = 0.0f; //float encroached = this.lastDistance; //// Calculates how far away the entity is //playerDistanceX = Mathf.Abs(this.entity.position.x - this.entity.lastTickPos[0].x) * 6f; //playerDistanceZ = Mathf.Abs(this.entity.position.z - this.entity.lastTickPos[0].z) * 6f; //if (!this.entity.isEntityRemote) //{ // if (Mathf.Abs(playerDistanceX - this.lastPlayerX) > 0.00999999977648258 || // Mathf.Abs(playerDistanceZ - this.lastPlayerZ) > 0.00999999977648258) // { // encroached = // Mathf.Sqrt(playerDistanceX * playerDistanceX + playerDistanceZ * playerDistanceZ); // this.lastPlayerX = playerDistanceX; // this.lastPlayerZ = playerDistanceZ; // this.lastDistance = encroached; // } //} //else if (playerDistanceX <= this.lastPlayerX && playerDistanceZ <= this.lastPlayerZ) //{ // this.lastPlayerX *= 0.9f; // this.lastPlayerZ *= 0.9f; // this.lastDistance *= 0.9f; //} //else //{ // encroached = Mathf.Sqrt((playerDistanceX * playerDistanceX + playerDistanceZ * playerDistanceZ)); // this.lastPlayerX = playerDistanceX; // this.lastPlayerZ = playerDistanceZ; // this.lastDistance = encroached; //} //Log("LastPlayerX: " + this.lastPlayerX); //Log("LastPlayerZ: " + this.lastPlayerZ); //Log("Last Distance:" + this.lastDistance); //Log("Encroachment: " + encroached); //if (encroached > 0.150000005960464) //{ // // Running if above 1.0 // if (encroached > 1.0) // { // SetInt(MovementState, 2); // } // else // { // SetInt(MovementState, 1); // } //} //else //{ // SetInt(MovementState, 0); //} if (this.isInDeathAnim) { if ((this.currentBaseState.tagHash == deathTag || this.deathStates.Contains(shortNameHash)) && this.currentBaseState.normalizedTime >= 1f && !flag) { this.isInDeathAnim = false; if (this.entity.HasDeathAnim) { this.entity.emodel.DoRagdoll(DamageResponse.New(true), 999999f); } } if (this.entity.HasDeathAnim && this.entity.RootMotion && this.entity.isCollidedHorizontally) { this.isInDeathAnim = false; this.entity.emodel.DoRagdoll(DamageResponse.New(true), 999999f); } } return; } if (this.anim.GetInteger("HitBodyPart") != 0 && this.IsAnimationHitRunning()) { this.SetInt("HitBodyPart", 0); this.SetBool("isCritical", false); this.bBlockLookPosition = false; } this.currentLookWeight = Mathf.Lerp(this.currentLookWeight, this.lookWeightTarget, Time.deltaTime); if (this.bBlockLookPosition || !this.isAllowLookPosition()) { this.currentLookWeight = 0f; } }
void OnDamageRequestSuccess(DamageResponse response) { Debug.Log("Take damage command succeeded; dealt damage: " + response.dealtDamage); }
/// <summary> /// Causes the player's character to die /// </summary> public void Kill() { EntityPlayer entity = Object as EntityPlayer; entity?.Kill(DamageResponse.New(new DamageSource(EnumDamageSource.External, EnumDamageTypes.None), true)); }
public override DamageResponse Defend(DamageResponse damage) { damage = PlateDefense.TransformDamage(damage, Efficiency); return(base.Defend(damage)); }
private void OnEntityDeath(Entity entity, DamageResponse response) { HookCalled("OnEntityDeath"); }
/// <summary> /// Causes the user's character to die /// </summary> public void Kill() { var entity = GameManager.Instance.World.GetEntity(client.entityId) as EntityAlive; entity?.Kill(DamageResponse.New(new DamageSource(EnumDamageSourceType.Undef), true)); }
public static bool Prefix(EModelBase __instance, DamageResponse dr, float stunTime = 999999f) { float strength = dr.Strength; DamageSource source = dr.Source; var _difficultyModifiers = new Dictionary <int, float>() { { 0, 0.5f }, { 1, 0.75f }, { 3, 1.5f }, { 4, 2.0f }, { 5, 2.5f }, }; if (strength > 0.0 && source != null) { float angle = GameManager.Instance.World.GetGameRandom().RandomRange(-20f, 50f); float num1 = strength * 0.5f; if (source.damageType == EnumDamageTypes.Bashing) { num1 *= 2.5f; } if (dr.Critical) { angle += 25f; num1 *= 2f; } if (dr.HitBodyPart == EnumBodyPartHit.Head) { num1 *= 0.45f; } float num2 = Utils.FastMin(20f + num1, 500f); Vector3 direction = source.getDirection(); Vector3 axis = Vector3.Cross(direction, Vector3.up); Vector3 forceVec = Quaternion.AngleAxis(angle, axis) * direction * num2; var damageSourceEntity = GameManager.Instance.World.GetEntity(source.getEntityId()); if (damageSourceEntity != null && dr.Fatal) // only run this logic if the hit was a kill { var localPlayer = (damageSourceEntity as EntityPlayerLocal); if (localPlayer != null && localPlayer.inventory != null) // there appears to be a strange timing issue when the inventory is null and throws an exception { var multiplier = 0.0f; var holdingItem = localPlayer.inventory.holdingItem; if (holdingItem.Properties.Contains("DeathForceMultiplier")) { var itemMultiplierString = holdingItem.Properties.GetString("DeathForceMultiplier"); if (!string.IsNullOrEmpty(itemMultiplierString)) { var split = itemMultiplierString.Split(','); if (split.Length > 1) { multiplier = UnityEngine.Random.Range(float.Parse(split[0]), float.Parse(split[1])); Debug.Log(multiplier); } else { multiplier = float.Parse(split[0]); } } } if (multiplier > 0) { var difficulty = GameStats.GetInt(EnumGameStats.GameDifficulty); forceVec *= multiplier * _difficultyModifiers[difficulty]; } } } __instance.DoRagdoll(stunTime, dr.HitBodyPart, forceVec, source.getHitTransformPosition(), false); } else { __instance.DoRagdoll(stunTime, dr.HitBodyPart, Vector3.zero, Vector3.zero, false); } return(false); }
public static bool ProcessEntityDamage(EntityAlive __instance, DamageResponse _dmResponse) { try { if (__instance != null && _dmResponse.Source != null && _dmResponse.Strength > 1) { if (__instance is EntityPlayer player) { EntityPlayer _player1 = player; int _sourceId = _dmResponse.Source.getEntityId(); if (_sourceId > 0 && _player1.entityId != _sourceId) { ClientInfo _cInfo2 = PersistentOperations.GetClientInfoFromEntityId(_sourceId); if (_cInfo2 != null) { EntityPlayer _player2 = PersistentOperations.GetEntityPlayer(_cInfo2.playerId); if (_player2 != null) { if (IsEnabled) { ItemValue _itemValue = ItemClass.GetItem(_player2.inventory.holdingItem.Name, false); if (_itemValue != null) { int _distance = (int)_player2.GetDistance(__instance); using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: {1} \"{2}\" hit \"{3}\" with entity id {4} using {5} for {6} damage @ {7}. Distance: {8}", DateTime.Now, _cInfo2.playerId, _cInfo2.playerName, __instance.EntityName, __instance.entityId, _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(), _dmResponse.Strength, __instance.position, _distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (_dmResponse.Strength >= Player_Damage_Limit && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo2) > Admin_Level) { Phrases.Dict.TryGetValue(952, out string _phrase952); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1} {2}\"", _cInfo2.playerId, _phrase952, _dmResponse.Strength), null); using (StreamWriter sw = new StreamWriter(detectionFilepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("Detected \"{0}\" Steam Id {1}, exceeded damage limit @ {2}. Damage: {3}", _cInfo2.playerName, _cInfo2.playerId, __instance.position, _dmResponse.Strength)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue(951, out string _phrase951); _phrase951 = _phrase951.Replace("{PlayerName}", _cInfo2.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase951 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); return(false); } } } if (Zones.IsEnabled && (Zones.ZonePvE.Contains(__instance.entityId) || Zones.ZonePvE.Contains(_cInfo2.entityId))) { Phrases.Dict.TryGetValue(323, out string _phrase323); ChatHook.ChatMessage(_cInfo2, Config.Chat_Response_Color + _phrase323 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo2.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo2.entityId, out int _violations); _violations++; PersistentOperations.PvEViolations[_cInfo2.entityId] = _violations; if (PersistentOperations.Jail_Violation > 0 && _violations == PersistentOperations.Jail_Violation) { Jail(_cInfo2, __instance); } if (PersistentOperations.Kill_Violation > 0 && _violations == PersistentOperations.Kill_Violation) { Kill(_cInfo2); } if (PersistentOperations.Kick_Violation > 0 && _violations == PersistentOperations.Kick_Violation) { Kick(_cInfo2); } if (PersistentOperations.Ban_Violation > 0 && _violations == PersistentOperations.Ban_Violation) { Ban(_cInfo2); } } else { PersistentOperations.PvEViolations.Add(_cInfo2.entityId, 1); } } return(false); } if ((Lobby.IsEnabled && Lobby.PvE && Lobby.LobbyPlayers.Contains(__instance.entityId)) || (Market.IsEnabled && Market.PvE && Market.MarketPlayers.Contains(__instance.entityId))) { Phrases.Dict.TryGetValue(260, out string _phrase260); ChatHook.ChatMessage(_cInfo2, Config.Chat_Response_Color + _phrase260 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo2.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo2.entityId, out int _violations); _violations++; PersistentOperations.PvEViolations[_cInfo2.entityId] = _violations; if (PersistentOperations.Jail_Violation > 0 && _violations == PersistentOperations.Jail_Violation) { Jail(_cInfo2, __instance); } if (PersistentOperations.Kill_Violation > 0 && _violations == PersistentOperations.Kill_Violation) { Kill(_cInfo2); } if (PersistentOperations.Kick_Violation > 0 && _violations == PersistentOperations.Kick_Violation) { Kick(_cInfo2); } else if (PersistentOperations.Ban_Violation > 0 && _violations == PersistentOperations.Ban_Violation) { Ban(_cInfo2); } } else { PersistentOperations.PvEViolations.Add(_cInfo2.entityId, 1); } } return(false); } if (KillNotice.IsEnabled && KillNotice.Show_Damage && KillNotice.PvP) { if (KillNotice.Damage.ContainsKey(_player1.entityId)) { KillNotice.Damage[_player1.entityId] = _dmResponse.Strength; } else { KillNotice.Damage.Add(_player1.entityId, _dmResponse.Strength); } } } } } } else if (IsEnabled && __instance is EntityZombie) { int _sourceId = _dmResponse.Source.getEntityId(); if (_sourceId > 0) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromEntityId(_sourceId); if (_cInfo != null) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { ItemValue _itemValue = ItemClass.GetItem(_player.inventory.holdingItem.Name, false); if (_itemValue != null) { int _distance = (int)_player.GetDistance(__instance); using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: {1} \"{2}\" hit \"{3}\" with entity id {4} using {5} for {6} damage @ {7}. Distance: {8}", DateTime.Now, _cInfo.playerId, _cInfo.playerName, __instance.EntityName, __instance.entityId, _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(), _dmResponse.Strength, __instance.position, _distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (_dmResponse.Strength >= Entity_Damage_Limit && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Admin_Level) { Phrases.Dict.TryGetValue(952, out string _phrase952); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1} {2}\"", _cInfo.playerId, _phrase952, _dmResponse.Strength), null); using (StreamWriter sw = new StreamWriter(detectionFilepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("Detected \"{0}\" Steam Id {1}, exceeded damage limit @ {2}. Damage: {3}", _cInfo.playerName, _cInfo.playerId, __instance.position, _dmResponse.Strength)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue(951, out string _phrase951); _phrase951 = _phrase951.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase951 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); return(false); } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessEntityDamage: {0}", e.Message)); } return(true); }
// Token: 0x060000A9 RID: 169 RVA: 0x00007612 File Offset: 0x00006612 public override void ProcessDamageResponseLocal(DamageResponse _dmResponse) { }