public bool IsVisibleStanding(BasePlayer player) { Vector3 vector3 = this.eyes.worldStandingPosition; if (!player.IsVisible(vector3, player.CenterPoint(), Single.PositiveInfinity) && !player.IsVisible(vector3, player.transform.position, Single.PositiveInfinity) && !player.IsVisible(vector3, player.eyes.position, Single.PositiveInfinity)) { return(false); } if (!base.IsVisible(player.CenterPoint(), vector3, Single.PositiveInfinity) && !base.IsVisible(player.transform.position, vector3, Single.PositiveInfinity) && !base.IsVisible(player.eyes.position, vector3, Single.PositiveInfinity)) { return(false); } return(true); }
public override float GetScore(BaseContext c) { if (c.AIAgent.AttackTarget == null) { return(0f); } BasePlayer attackTarget = c.AIAgent.AttackTarget as BasePlayer; if (!attackTarget) { if (this.Cover == CoverPoint.CoverType.Full) { if (!c.AIAgent.AttackTarget.IsVisible(c.AIAgent.AttackPosition, Single.PositiveInfinity)) { return(0f); } return(1f); } if (!c.AIAgent.AttackTarget.IsVisible(c.AIAgent.CrouchedAttackPosition, Single.PositiveInfinity)) { return(0f); } return(1f); } Vector3 attackPosition = c.AIAgent.AttackPosition; if ((attackTarget.IsVisible(attackPosition, attackTarget.CenterPoint(), Single.PositiveInfinity) || attackTarget.IsVisible(attackPosition, attackTarget.eyes.position, Single.PositiveInfinity) ? false : !attackTarget.IsVisible(attackPosition, attackTarget.transform.position, Single.PositiveInfinity))) { return(0f); } return(1f); }
public static void spawnlootfrom(Arg args) { BasePlayer basePlayer = ArgEx.Player(args); string @string = args.GetString(0, string.Empty); int @int = args.GetInt(1, 1); Vector3 vector = args.GetVector3(1, basePlayer ? basePlayer.CenterPoint() : Vector3.zero); if (string.IsNullOrEmpty(@string)) { return; } BaseEntity baseEntity = GameManager.server.CreateEntity(@string, vector); if (baseEntity == null) { return; } baseEntity.Spawn(); basePlayer.ChatMessage("Contents of " + @string + " spawned " + @int + " times"); LootContainer component = baseEntity.GetComponent <LootContainer>(); if (component != null) { for (int i = 0; i < @int * component.maxDefinitionsToSpawn; i++) { component.lootDefinition.SpawnIntoContainer(basePlayer.inventory.containerMain); } } baseEntity.Kill(); }
public static void spawnlootfrom(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); string str = args.GetString(0, string.Empty); int num = args.GetInt(1, 1); Vector3 vector3 = args.GetVector3(1, (basePlayer ? basePlayer.CenterPoint() : Vector3.zero)); if (string.IsNullOrEmpty(str)) { return; } GameManager gameManager = GameManager.server; Quaternion quaternion = new Quaternion(); BaseEntity baseEntity = gameManager.CreateEntity(str, vector3, quaternion, true); if (baseEntity == null) { return; } baseEntity.Spawn(); basePlayer.ChatMessage(string.Concat(new object[] { "Contents of ", str, " spawned ", num, " times" })); LootContainer component = baseEntity.GetComponent <LootContainer>(); if (component != null) { for (int i = 0; i < num * component.maxDefinitionsToSpawn; i++) { component.lootDefinition.SpawnIntoContainer(basePlayer.inventory.containerMain); } } baseEntity.Kill(BaseNetworkable.DestroyMode.None); }
public override float GetScore(BaseContext c) { if (Object.op_Equality((Object)c.AIAgent.AttackTarget, (Object)null)) { return(0.0f); } BasePlayer attackTarget = c.AIAgent.AttackTarget as BasePlayer; if (Object.op_Implicit((Object)attackTarget)) { Vector3 attackPosition = c.AIAgent.AttackPosition; return((attackTarget.IsVisible(attackPosition, attackTarget.CenterPoint(), float.PositiveInfinity) || attackTarget.IsVisible(attackPosition, attackTarget.eyes.position, float.PositiveInfinity) ? 1 : (attackTarget.IsVisible(attackPosition, ((Component)attackTarget).get_transform().get_position(), float.PositiveInfinity) ? 1 : 0)) == 0 ? 0.0f : 1f); } if (this.Cover == CoverPoint.CoverType.Full) { return(!c.AIAgent.AttackTarget.IsVisible(c.AIAgent.AttackPosition, float.PositiveInfinity) ? 0.0f : 1f); } return(!c.AIAgent.AttackTarget.IsVisible(c.AIAgent.CrouchedAttackPosition, float.PositiveInfinity) ? 0.0f : 1f); }
public override void DoExecute(BaseContext c) { if (BaseEntity.Query.Server == null) { return; } int inSphere = BaseEntity.Query.Server.GetInSphere(c.Position, c.AIAgent.GetStats.VisionRange, this.Results, new Func <BaseEntity, bool>(ScanForEntities.AiCaresAbout)); if (inSphere == 0) { return; } for (int i = 0; i < inSphere; i++) { BaseEntity results = this.Results[i]; if (!(results == null) && !(results == c.Entity) && results.isServer && ScanForEntities.WithinVisionCone(c.AIAgent, results)) { BasePlayer basePlayer = results as BasePlayer; if (basePlayer != null && !results.IsNpc) { if (!ConVar.AI.ignoreplayers) { Vector3 attackPosition = c.AIAgent.AttackPosition; if ((basePlayer.IsVisible(attackPosition, basePlayer.CenterPoint(), Single.PositiveInfinity) || basePlayer.IsVisible(attackPosition, basePlayer.eyes.position, Single.PositiveInfinity) ? false : !basePlayer.IsVisible(attackPosition, basePlayer.transform.position, Single.PositiveInfinity))) { goto Label0; } } else { goto Label0; } } c.Memory.Update(results, 0f); } Label0: } c.Memory.Forget((float)this.forgetTime); }
public override void DoExecute(BaseContext c) { if (BaseEntity.Query.Server == null) { return; } int inSphere = BaseEntity.Query.Server.GetInSphere(c.Position, c.AIAgent.GetStats.VisionRange, this.Results, new Func <BaseEntity, bool>(ScanForEntities.AiCaresAbout)); if (inSphere == 0) { return; } for (int index = 0; index < inSphere; ++index) { BaseEntity result = this.Results[index]; if (!Object.op_Equality((Object)result, (Object)null) && !Object.op_Equality((Object)result, (Object)c.Entity) && (result.isServer && ScanForEntities.WithinVisionCone(c.AIAgent, result))) { BasePlayer basePlayer = result as BasePlayer; if (Object.op_Inequality((Object)basePlayer, (Object)null) && !result.IsNpc) { if (!ConVar.AI.ignoreplayers) { Vector3 attackPosition = c.AIAgent.AttackPosition; if ((basePlayer.IsVisible(attackPosition, basePlayer.CenterPoint(), float.PositiveInfinity) || basePlayer.IsVisible(attackPosition, basePlayer.eyes.position, float.PositiveInfinity) ? 1 : (basePlayer.IsVisible(attackPosition, ((Component)basePlayer).get_transform().get_position(), float.PositiveInfinity) ? 1 : 0)) == 0) { continue; } } else { continue; } } c.Memory.Update(result, 0.0f); } } c.Memory.Forget((float)this.forgetTime); }
private bool AnyPartVisible(BasePlayer localPlayer, BasePlayer targetPlayer) { Vector3 position = localPlayer.eyes.position; Vector3 a = localPlayer.eyes.HeadRight(); Vector3 vector = targetPlayer.CenterPoint(); if (targetPlayer.IsSleeping()) { vector += new Vector3(0f, 1f, 0f); } float dist = Vector3.Distance(position, vector); bool flag = this.PointSeePoint(position, vector, dist, true); if (targetPlayer.IsSleeping()) { return(flag); } if (!flag && PlayerCulling.visQuality > 0) { Vector3 position2 = targetPlayer.eyes.position; flag = PointSeePoint(position, position2, dist, false); } if (!flag && PlayerCulling.visQuality > 1) { Vector3 origin = vector + a * 0.25f; flag = PointSeePoint(position, origin, dist, false); if (!flag) { Vector3 origin2 = vector + a * -0.25f; flag = PointSeePoint(position, origin2, dist, false); } } if (!flag && PlayerCulling.visQuality > 2) { flag = PointSeePoint(position, targetPlayer.transform.position + new Vector3(0f, 0.1f, 0f), dist, false); } return(flag); }
public void PlayerAttack(RPCMessage msg) { BasePlayer player = msg.player; if (!VerifyClientAttack(player)) { SendNetworkUpdate(); return; } using (TimeWarning.New("PlayerAttack", 50)) { using (PlayerAttack playerAttack = ProtoBuf.PlayerAttack.Deserialize(msg.read)) { if (playerAttack == null) { return; } HitInfo hitInfo = Facepunch.Pool.Get <HitInfo>(); hitInfo.LoadFromAttack(playerAttack.attack, true); hitInfo.Initiator = player; hitInfo.Weapon = this; hitInfo.WeaponPrefab = this; hitInfo.Predicted = msg.connection; hitInfo.damageProperties = damageProperties; if (Interface.CallHook("OnMeleeAttack", player, hitInfo) != null) { return; } if (hitInfo.IsNaNOrInfinity()) { string shortPrefabName = base.ShortPrefabName; AntiHack.Log(player, AntiHackType.MeleeHack, "Contains NaN (" + shortPrefabName + ")"); player.stats.combat.Log(hitInfo, "melee_nan"); return; } BaseEntity hitEntity = hitInfo.HitEntity; BasePlayer basePlayer = hitInfo.HitEntity as BasePlayer; bool flag = basePlayer != null; bool flag2 = flag && basePlayer.IsSleeping(); bool flag3 = flag && basePlayer.IsWounded(); bool flag4 = flag && basePlayer.isMounted; bool flag5 = flag && basePlayer.HasParent(); bool flag6 = hitEntity != null; bool flag7 = flag6 && hitEntity.IsNpc; if (ConVar.AntiHack.melee_protection <= 0) { goto IL_0903; } bool flag8 = true; float num = 1f + ConVar.AntiHack.melee_forgiveness; float melee_clientframes = ConVar.AntiHack.melee_clientframes; float melee_serverframes = ConVar.AntiHack.melee_serverframes; float num2 = melee_clientframes / 60f; float num3 = melee_serverframes * Mathx.Max(UnityEngine.Time.deltaTime, UnityEngine.Time.smoothDeltaTime, UnityEngine.Time.fixedDeltaTime); float num4 = (player.desyncTimeClamped + num2 + num3) * num; int layerMask = (ConVar.AntiHack.melee_terraincheck ? 10551296 : 2162688); if (flag && hitInfo.boneArea == (HitArea)(-1)) { string shortPrefabName2 = base.ShortPrefabName; string shortPrefabName3 = basePlayer.ShortPrefabName; AntiHack.Log(player, AntiHackType.MeleeHack, "Bone is invalid (" + shortPrefabName2 + " on " + shortPrefabName3 + " bone " + hitInfo.HitBone + ")"); player.stats.combat.Log(hitInfo, "melee_bone"); flag8 = false; } if (ConVar.AntiHack.melee_protection >= 2) { if (flag6) { float num5 = hitEntity.MaxVelocity() + hitEntity.GetParentVelocity().magnitude; float num6 = hitEntity.BoundsPadding() + num4 * num5; float num7 = hitEntity.Distance(hitInfo.HitPositionWorld); if (num7 > num6) { string shortPrefabName4 = base.ShortPrefabName; string shortPrefabName5 = hitEntity.ShortPrefabName; AntiHack.Log(player, AntiHackType.MeleeHack, "Entity too far away (" + shortPrefabName4 + " on " + shortPrefabName5 + " with " + num7 + "m > " + num6 + "m in " + num4 + "s)"); player.stats.combat.Log(hitInfo, "melee_target"); flag8 = false; } } if (ConVar.AntiHack.melee_protection >= 4 && flag8 && flag && !flag7 && !flag2 && !flag3 && !flag4 && !flag5) { float magnitude = basePlayer.GetParentVelocity().magnitude; float num8 = basePlayer.BoundsPadding() + num4 * magnitude + ConVar.AntiHack.tickhistoryforgiveness; float num9 = basePlayer.tickHistory.Distance(basePlayer, hitInfo.HitPositionWorld); if (num9 > num8) { string shortPrefabName6 = base.ShortPrefabName; string shortPrefabName7 = basePlayer.ShortPrefabName; AntiHack.Log(player, AntiHackType.ProjectileHack, "Player too far away (" + shortPrefabName6 + " on " + shortPrefabName7 + " with " + num9 + "m > " + num8 + "m in " + num4 + "s)"); player.stats.combat.Log(hitInfo, "player_distance"); flag8 = false; } } } if (ConVar.AntiHack.melee_protection >= 1) { if (ConVar.AntiHack.melee_protection >= 4) { float magnitude2 = player.GetParentVelocity().magnitude; float num10 = player.BoundsPadding() + num4 * magnitude2 + num * maxDistance; float num11 = player.tickHistory.Distance(player, hitInfo.HitPositionWorld); if (num11 > num10) { string shortPrefabName8 = base.ShortPrefabName; string text = (flag6 ? hitEntity.ShortPrefabName : "world"); AntiHack.Log(player, AntiHackType.MeleeHack, "Initiator too far away (" + shortPrefabName8 + " on " + text + " with " + num11 + "m > " + num10 + "m in " + num4 + "s)"); player.stats.combat.Log(hitInfo, "melee_initiator"); flag8 = false; } } else { float num12 = player.MaxVelocity() + player.GetParentVelocity().magnitude; float num13 = player.BoundsPadding() + num4 * num12 + num * maxDistance; float num14 = player.Distance(hitInfo.HitPositionWorld); if (num14 > num13) { string shortPrefabName9 = base.ShortPrefabName; string text2 = (flag6 ? hitEntity.ShortPrefabName : "world"); AntiHack.Log(player, AntiHackType.MeleeHack, "Initiator too far away (" + shortPrefabName9 + " on " + text2 + " with " + num14 + "m > " + num13 + "m in " + num4 + "s)"); player.stats.combat.Log(hitInfo, "melee_initiator"); flag8 = false; } } } if (ConVar.AntiHack.melee_protection >= 3) { if (flag6) { Vector3 pointStart = hitInfo.PointStart; Vector3 vector = hitInfo.HitPositionWorld + hitInfo.HitNormalWorld.normalized * 0.001f; Vector3 center = player.eyes.center; Vector3 position = player.eyes.position; Vector3 vector2 = pointStart; Vector3 vector3 = hitInfo.PositionOnRay(vector); Vector3 vector4 = vector; bool num15 = GamePhysics.LineOfSight(center, position, vector2, vector3, vector4, layerMask); if (!num15) { player.stats.Add("hit_" + hitEntity.Categorize() + "_indirect_los", 1, Stats.Server); } else { player.stats.Add("hit_" + hitEntity.Categorize() + "_direct_los", 1, Stats.Server); } if (!num15) { string shortPrefabName10 = base.ShortPrefabName; string shortPrefabName11 = hitEntity.ShortPrefabName; AntiHack.Log(player, AntiHackType.MeleeHack, string.Concat("Line of sight (", shortPrefabName10, " on ", shortPrefabName11, ") ", center, " ", position, " ", vector2, " ", vector3, " ", vector4)); player.stats.combat.Log(hitInfo, "melee_los"); flag8 = false; } } if (flag8 && flag && !flag7) { Vector3 vector5 = hitInfo.HitPositionWorld + hitInfo.HitNormalWorld.normalized * 0.001f; Vector3 position2 = basePlayer.eyes.position; Vector3 vector6 = basePlayer.CenterPoint(); if ((!GamePhysics.LineOfSight(vector5, position2, layerMask, 0f, ConVar.AntiHack.losforgiveness) || !GamePhysics.LineOfSight(position2, vector5, layerMask, ConVar.AntiHack.losforgiveness, 0f)) && (!GamePhysics.LineOfSight(vector5, vector6, layerMask, 0f, ConVar.AntiHack.losforgiveness) || !GamePhysics.LineOfSight(vector6, vector5, layerMask, ConVar.AntiHack.losforgiveness, 0f))) { string shortPrefabName12 = base.ShortPrefabName; string shortPrefabName13 = basePlayer.ShortPrefabName; AntiHack.Log(player, AntiHackType.MeleeHack, string.Concat("Line of sight (", shortPrefabName12, " on ", shortPrefabName13, ") ", vector5, " ", position2, " or ", vector5, " ", vector6)); player.stats.combat.Log(hitInfo, "melee_los"); flag8 = false; } } } if (flag8) { goto IL_0903; } AntiHack.AddViolation(player, AntiHackType.MeleeHack, ConVar.AntiHack.melee_penalty); goto end_IL_0031; IL_0903: player.metabolism.UseHeart(heartStress * 0.2f); using (TimeWarning.New("DoAttackShared", 50)) { DoAttackShared(hitInfo); } end_IL_0031 :; } } }
public static void spawnlootfrom(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); string strPrefab = args.GetString(0, string.Empty); int num = args.GetInt(1, 1); Vector3 vector3 = args.GetVector3(1, Object.op_Implicit((Object)basePlayer) ? basePlayer.CenterPoint() : Vector3.get_zero()); if (string.IsNullOrEmpty(strPrefab)) { return; } BaseEntity entity = GameManager.server.CreateEntity(strPrefab, vector3, (Quaternion)null, true); if (Object.op_Equality((Object)entity, (Object)null)) { return; } entity.Spawn(); basePlayer.ChatMessage("Contents of " + strPrefab + " spawned " + (object)num + " times"); LootContainer component = (LootContainer)((Component)entity).GetComponent <LootContainer>(); if (Object.op_Inequality((Object)component, (Object)null)) { for (int index = 0; index < num * component.maxDefinitionsToSpawn; ++index) { component.lootDefinition.SpawnIntoContainer(basePlayer.inventory.containerMain); } } entity.Kill(BaseNetworkable.DestroyMode.None); }
public bool IsVisibleStanding(BasePlayer player) { Vector3 standingPosition = this.eyes.worldStandingPosition; return((player.IsVisible(standingPosition, player.CenterPoint(), float.PositiveInfinity) || player.IsVisible(standingPosition, ((Component)player).get_transform().get_position(), float.PositiveInfinity) || player.IsVisible(standingPosition, player.eyes.position, float.PositiveInfinity)) && (this.IsVisible(player.CenterPoint(), standingPosition, float.PositiveInfinity) || this.IsVisible(((Component)player).get_transform().get_position(), standingPosition, float.PositiveInfinity) || this.IsVisible(player.eyes.position, standingPosition, float.PositiveInfinity))); }
public bool IsVisibleCrouched(BasePlayer player) { Vector3 crouchedPosition = this.eyes.worldCrouchedPosition; return((player.IsVisible(crouchedPosition, player.CenterPoint(), float.PositiveInfinity) || player.IsVisible(crouchedPosition, ((Component)player).get_transform().get_position(), float.PositiveInfinity) || player.IsVisible(crouchedPosition, player.eyes.position, float.PositiveInfinity)) && (this.IsVisible(player.CenterPoint(), crouchedPosition, float.PositiveInfinity) || this.IsVisible(((Component)player).get_transform().get_position(), crouchedPosition, float.PositiveInfinity) || this.IsVisible(player.eyes.position, crouchedPosition, float.PositiveInfinity))); }