Ejemplo n.º 1
0
 public static bool IsOwnerOrFactionOwned(MyCubeGrid grid, long playerId, bool doFactionCheck)
 {
     if (grid.BigOwners.Contains(playerId))
     {
         return(true);
     }
     else
     {
         if (!doFactionCheck)
         {
             return(false);
         }
         long ownerId = GetOwner(grid);
         //check if the owner is a faction member, i honestly dont know the difference between grid.BigOwners and grid.SmallOwners
         return(FacUtils.InSameFaction(playerId, ownerId));
     }
 }
Ejemplo n.º 2
0
        private void DamageCheck(object target, ref MyDamageInformation info)
        {
            if (file != null)
            {
                if (file.LogNeutralsDamagingEachOther || file.ShowFactionTagsOnDamageGrid)
                {
                    try
                    {
                        if (!(target is MySlimBlock block))
                        {
                            return;
                        }
                        long       attackerId = GetAttacker(info.AttackerId);
                        MyIdentity id         = MySession.Static.Players.TryGetIdentity(attackerId);
                        if (id == null)
                        {
                            return;
                        }
                        IMyFaction defender = FacUtils.GetPlayersFaction(FacUtils.GetOwner(block.CubeGrid));
                        IMyFaction attacker = FacUtils.GetPlayersFaction(id.IdentityId);
                        if (file.ShowFactionTagsOnDamageGrid)
                        {
                            if (Sync.Players.TryGetPlayerId(id.IdentityId, out MyPlayer.PlayerId player))
                            {
                                if (MySession.Static.Players.GetPlayerById(player) != null)
                                {
                                    SendAttackNotification(attacker, defender, attackerId, player.SteamId, block.CubeGrid.PositionComp.GetPosition());
                                }
                            }
                        }


                        MyCubeBlock cubeBlock = block.FatBlock;
                        if (cubeBlock == null)
                        {
                            return;
                        }



                        if (cubeBlock as MyTerminalBlock == null)
                        {
                            return;
                        }

                        if (cubeBlock.EntityId == 0L)
                        {
                            return;
                        }

                        if (GetAttacker(info.AttackerId) > 0L)
                        {
                            //this is so messy
                            if (attacker != null && defender != null)
                            {
                                if (attacker.Equals(defender))
                                {
                                    return;
                                }

                                if (MySession.Static.Factions.AreFactionsFriends(attacker.FactionId, defender.FactionId) || MySession.Static.Factions.AreFactionsNeutrals(attacker.FactionId, defender.FactionId))
                                {
                                    if (blockCooldowns.TryGetValue(cubeBlock.EntityId, out DateTime time))
                                    {
                                        if (DateTime.Now < time)
                                        {
                                            return;
                                        }
                                    }
                                    if (file.ShowFactionTagsOnDamageGrid)
                                    {
                                        blockCooldowns.Remove(cubeBlock.EntityId);
                                        blockCooldowns.Add(cubeBlock.EntityId, DateTime.Now.AddSeconds(10));
                                        CrunchUtilitiesPlugin.Log.Info("FACTIONLOG Attacking while not at war " + attackerId + " " + attacker.Tag + " " + attacker.FactionId + " against " + cubeBlock.CubeGrid.DisplayName + ", " + defender.Tag + " " + defender.FactionId);
                                    }
                                }
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error(e, "Error on Checking Damage!");
                    }
                }
            }
        }