コード例 #1
0
    public override void OnEvent(HurtEvent evnt)
    {
        if (BoltNetwork.isServer) {
            //TODO damage stats can be recorded here if needed, all HurtEvents pass through here exactly once

            //Direct damage events, either by consuming them here (if they were meant for the server player)
            //Or by redirecting them to the right player

            //if this HurtEvent is targeted at the server itself, apply it directly without forwarding it first
            if (evnt.Target == GameManager.instance.CurrentUserName) {
                GameManager.instance.CurrentPlayer.TakeDamage(evnt.Amount, evnt.Source, evnt.Direction, evnt.WeaponID);
            } else {//this event is not directed at the server player, it needs to be forwarded to the correct player
                BoltConnection destination = PlayerRegistry.GetConnectionFromUserName(evnt.Target);
                if (destination == null) {//quick error check
                    Debug.LogError("The destination connection for a HurtEvent could not be found! "+evnt);
                } else {
                    //forward the event to the player that was actually damaged
                    HurtEvent redir = HurtEvent.Create(destination, Bolt.ReliabilityModes.ReliableOrdered);
                    redir.Amount = evnt.Amount;
                    redir.Target = evnt.Target;
                    redir.Source = evnt.Source;
                    redir.WeaponID = evnt.WeaponID;
                    redir.Direction = evnt.Direction;
                    redir.Send();
                }
            }
        } else { //this is a client
            if (evnt.Target == GameManager.instance.CurrentUserName) { //make sure that this hurtEvent is intended for this client
                GameManager.instance.CurrentPlayer.TakeDamage(evnt.Amount, evnt.Source, evnt.Direction, evnt.WeaponID);
            } else {
                Debug.LogError("Recieved HurtEvent that is not directed to this player! " + evnt.ToString());
            }
        }
    }
コード例 #2
0
 public void OnEntityHurt(HurtEvent he)
 {
     if (he.AttackerIsPlayer && he.VictimIsEntity)
     {
         if (he.Attacker != null && he.Entity != null)
         {
             Fougerite.Entity entity = he.Entity;
             if (entity.Name.ToLower().Contains("box") || entity.Name.ToLower().Contains("stash"))
             {
                 if (!he.WeaponName.Contains("explosive") && !he.WeaponName.Contains("grenade") &&
                     !Guns.Contains(he.WeaponName) && !OwnerTimeData.ContainsKey(entity.UOwnerID))
                 {
                     he.DamageAmount = 0f;
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: AdvGod.cs プロジェクト: samvds/CSharp
 public void OnPlayerHurt(HurtEvent he)
 {
     if (he.AttackerIsPlayer && he.VictimIsPlayer)
     {
         Fougerite.Player attacker = (Fougerite.Player)he.Attacker;
         Fougerite.Player victim   = (Fougerite.Player)he.Victim;
         if (DataStore.GetInstance().ContainsKey("hasadvgod", victim.SteamID) || DataStore.GetInstance().ContainsKey("AdvgodOn", victim.SteamID))
         {
             attacker.Notice("✘", victim.Name + " is currently in godmode this means you cant kill him");
             he.DamageAmount = 0f;
         }
         else if (DataStore.GetInstance().ContainsKey("hasadvgod", attacker.SteamID) || DataStore.GetInstance().ContainsKey("AdvgodOn", attacker.SteamID))
         {
             attacker.Notice("✘", "You cannot hurt people while in godmode");
             he.DamageAmount = 0f;
         }
     }
 }
コード例 #4
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            BaseServant servant     = actionParameter.PrimaryCard as BaseServant;
            GameContext gameContext = actionParameter.GameContext;
            Card        triggerCard = actionParameter.SecondaryCard;

            if (servant.HasHolyShield)
            {
                servant.HasHolyShield = false;
            }
            else if (servant.HasPoison)
            {
                servant.IsDeathing = true;
            }
            else
            {
                servant.Life -= actionParameter.DamageOrHeal;
            }

            HurtEvent hurtEvent = new HurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            };

            if (servant.CardAbility.TryCapture(servant, hurtEvent))
            {
                hurtEvent.Parameter.TertiaryCard = servant;
                gameContext.AddActionStatements(servant.CardAbility, hurtEvent.Parameter);
            }

            gameContext.EventQueue.AddLast(new MyServantHurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            gameContext.EventQueue.AddLast(new AnyServantHurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            gameContext.EventQueue.AddLast(new AnyHurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            return(null);
        }
コード例 #5
0
        public static bool IsFriend(HurtEvent e) // ref
        {
            GodModeCommand command = (GodModeCommand)ChatCommand.GetCommand("god");

            Fougerite.Player victim = e.Victim as Fougerite.Player;
            if (victim != null)
            {
                if (command.IsOn(victim.UID))
                {
                    FallDamage dmg = victim.FallDamage;
                    if (dmg != null)
                    {
                        dmg.ClearInjury();
                    }
                    return(true);
                }
                Fougerite.Player attacker = e.Attacker as Fougerite.Player;
                if (attacker != null)
                {
                    FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("amigos");
                    if (command2.ContainsException(attacker.UID) && command2.ContainsException(victim.UID))
                    {
                        return(false);
                    }
                    bool b = Core.config.GetBoolSetting("Settings", "friendly_fire");
                    try
                    {
                        FriendList list = (FriendList)command2.GetFriendsLists()[attacker.UID];
                        if (list == null || b)
                        {
                            return(false);
                        }
                        return(list.isFriendWith(victim.UID));
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
コード例 #6
0
 public void PlayerHurt(HurtEvent he)
 {
     if (he.AttackerIsPlayer && he.VictimIsPlayer)
     {
         Fougerite.Player attacker = (Fougerite.Player)he.Attacker;
         Fougerite.Player victim   = (Fougerite.Player)he.Victim;
         var id  = victim.SteamID;
         var id1 = attacker.SteamID;
         if (Frozen.Contains(id1))
         {
             attacker.Notice("✘", "Player " + victim.Name + " Is frozen you cant kill him");
             he.DamageAmount = 0f;
         }
         else if (Frozen.Contains(id))
         {
             attacker.Notice("✘", "You cant kill while being frozen");
             he.DamageAmount = 0f;
         }
     }
 }
コード例 #7
0
ファイル: RustPPModule.cs プロジェクト: balu92/Fougerite
        void EntityHurt(HurtEvent he)
        {
            if (Core.IsEnabled())
            {
                InstaKOCommand command = ChatCommand.GetCommand("instako") as InstaKOCommand;

                if (!(he.Attacker is Fougerite.Player))
                {
                    return;
                }

                if (command == null)
                {
                    return;
                }

                if (command.IsOn(((Fougerite.Player)he.Attacker).PlayerClient.userID))
                {
                    if (he.Entity != null)
                    {
                        try
                        {
                            if (!he.IsDecay)
                            {
                                he.Entity.Destroy();
                            }
                            else if (Fougerite.Hooks.decayList.Contains(he.Entity))
                            {
                                Fougerite.Hooks.decayList.Remove(he.Entity);
                            }
                        }
                        catch (Exception ex)
                        { Logger.LogDebug("EntityHurt EX: " + ex); }
                    }
                    else
                    {
                        Logger.LogDebug("he.Entity is null!");
                    }
                }
            }
        }
コード例 #8
0
ファイル: BattleRoyaleCore.cs プロジェクト: samvds/CSharp
        public void Hurt(HurtEvent he)
        {
            if (he.AttackerIsNPC && he.VictimIsPlayer)
            {
                if (npcgod)
                {
                    he.DamageAmount = 0f;
                }
                return;
            }
            RoyaleUser attacker = (RoyaleUser)he.Attacker;
            RoyaleUser victim   = (RoyaleUser)he.Victim;

            if (he.AttackerIsPlayer && he.VictimIsPlayer)
            {
                if (inlobby.Contains(attacker.UID) && inlobby.Contains(victim.UID))
                {
                    he.DamageAmount = 0f;
                    return;
                }
            }
        }
コード例 #9
0
 static void OnEntityHurt(HurtEvent he)
 {
     if (he.AttackerIsPlayer && he.Attacker != null)
     {
         Fougerite.Player player = (Fougerite.Player)he.Attacker;
         User             user   = Data.Globals.usersOnline.Find(x => x.Name == player.Name);
         string           lang   = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);
         if (!UserIsLogged(player))
         {
             char ch = '☢';
             player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f);
             he.DamageAmount = 0;
             return;
         }
         if (he.VictimIsPlayer && he.Victim != null)
         {
             Fougerite.Player victim       = (Fougerite.Player)he.Victim;
             User             victimPlayer = Data.Globals.usersOnline.Find(x => x.Name == victim.Name);
             if (!UserIsLogged(victim))
             {
                 char ch = '☢';
                 player.Notice(ch.ToString(), $"Este usuario no esta logueado, no puedes hacerle daño", 4f);
                 he.DamageAmount = 0;
                 return;
             }
         }
     }
     if (he.AttackerIsNPC && he.Attacker != null && he.VictimIsPlayer && he.Victim != null)
     {
         Fougerite.Player player = (Fougerite.Player)he.Attacker;
         User             user   = Data.Globals.usersOnline.Find(x => x.Name == player.Name);
         if (!UserIsLogged(player))
         {
             he.DamageAmount = 0;
             return;
         }
     }
 }
コード例 #10
0
ファイル: Hooks.cs プロジェクト: slavagmail/Fougerite
        public static void NPCHurt(ref DamageEvent e)
        {
            HurtEvent he = new HurtEvent(ref e);

            if ((he.Victim as NPC).Health > 0f)
            {
                NPC victim = he.Victim as NPC;
                victim.Health += he.DamageAmount;
                if (OnNPCHurt != null)
                {
                    OnNPCHurt(he);
                }
                if (((he.Victim as NPC).Health - he.DamageAmount) <= 0f)
                {
                    (he.Victim as NPC).Kill();
                }
                else
                {
                    NPC npc2 = he.Victim as NPC;
                    npc2.Health -= he.DamageAmount;
                }
            }
        }
コード例 #11
0
ファイル: Hooks.cs プロジェクト: balu92/Fougerite
 public static void PlayerHurt(ref DamageEvent e)
 {
     try
     {
         HurtEvent he = new HurtEvent(ref e);
         if (!(he.Attacker is NPC) && !(he.Victim is NPC))
         {
             Fougerite.Player attacker = he.Attacker as Fougerite.Player;
             Fougerite.Player victim   = he.Victim as Fougerite.Player;
             Zone3D           zoned    = Zone3D.GlobalContains(attacker);
             if ((zoned != null) && !zoned.PVP)
             {
                 attacker.Message("You are in a PVP restricted area.");
                 he.DamageAmount = 0f;
                 e = he.DamageEvent;
                 return;
             }
             zoned = Zone3D.GlobalContains(victim);
             if ((zoned != null) && !zoned.PVP)
             {
                 attacker.Message(victim.Name + " is in a PVP restricted area.");
                 he.DamageAmount = 0f;
                 e = he.DamageEvent;
                 return;
             }
         }
         if (OnPlayerHurt != null)
         {
             OnPlayerHurt(he);
         }
         e = he.DamageEvent;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
コード例 #12
0
        public void EntityHurt(HurtEvent he)
        {
            if (he.AttackerIsPlayer)
            {
                Player attacker = (Player)he.Attacker;
                Entity ent      = he.Entity;

                string weapon = he.DamageType;

                if (weapon == "Explosion")
                {
                    Vector3 pos   = (Vector3)ds.Get("jailloc", "location");
                    float   dist  = Vector3.Distance(attacker.Location, pos);
                    int     dist2 = (int)ds.Get("JailRadius", "radius");
                    int     d     = Convert.ToInt32(dist);

                    if (d < dist2)
                    {
                        he.DamageAmount = 0f;
                        attacker.MessageFrom(Name, "Sorry you cant hurt structures within the jail zone");
                    }
                }
            }
        }
コード例 #13
0
ファイル: AnticheatModule.cs プロジェクト: balu92/Fougerite
 private void EntityHurt(HurtEvent he)
 {
 }
コード例 #14
0
ファイル: Hurtbox.cs プロジェクト: SeanTRyan/SR
 private void Update_HitEvent(int hurtIndex, Transform position)
 {
     HurtEvent?.Invoke(hurtIndex, position);
 }
コード例 #15
0
ファイル: HookTester.cs プロジェクト: Notulp/HookTester
 public void On_CorpseHurt(HurtEvent he)
 {
     SetHookWorking("On_CorpseHurt");
     Broadcast(he.Attacker.Name + " attacked a corpse with " + he.Weapon.Name);
 }
コード例 #16
0
 public void OnNPCHurt(HurtEvent evt)
 {
     this.Invoke("On_NPCHurt", new object[] { evt });
 }
コード例 #17
0
 void EntityHurt(HurtEvent he)
 {
 }
コード例 #18
0
 public void OnNPCHurt(HurtEvent evt)
 {
     Invoke("On_NPCHurt", evt);
 }
コード例 #19
0
 public void OnEntityHurt(HurtEvent evt)
 {
     Invoke("On_EntityHurt", evt);
 }
コード例 #20
0
 public void OnEntityHurt(HurtEvent he)
 {
     this.Invoke("On_EntityHurt", new object[] { he });
 }
コード例 #21
0
 public void OnPlayerHurt(HurtEvent evt)
 {
     Invoke("On_PlayerHurt", evt);
 }
コード例 #22
0
 public void OnNPCHurt(HurtEvent he)
 {
     this.Invoke("On_NPCHurt", new object[] { he });
 }
コード例 #23
0
 void PlayerHurt(HurtEvent he)
 {
 }
コード例 #24
0
 public void OnPlayerHurt(HurtEvent he)
 {
     this.Invoke("On_PlayerHurt", new object[] { he });
 }
コード例 #25
0
 public void OnEntityHurt(HurtEvent evt)
 {
     this.Invoke("On_EntityHurt", new object[] { evt });
 }
コード例 #26
0
 private void GotHurt(int value)
 {
     HurtEvent?.Invoke(this, value);
     Health -= value;
 }
コード例 #27
0
 public void OnPlayerHurt(HurtEvent evt)
 {
     this.Invoke("On_PlayerHurt", new object[] { evt });
 }
コード例 #28
0
ファイル: RustPPModule.cs プロジェクト: samvds/RustPP
 void EntityHurt(HurtEvent he)
 {
     if (Core.IsEnabled())
     {
         if (!he.AttackerIsPlayer || he.Attacker == null)
         {
             return;
         }
         InstaKOCommand    command  = ChatCommand.GetCommand("instako") as InstaKOCommand;
         InstaKOAllCommand command2 = ChatCommand.GetCommand("instakoall") as InstaKOAllCommand;
         Fougerite.Player  pl       = (Fougerite.Player)he.Attacker;
         if (command != null)
         {
             if (command.IsOn(pl.UID))
             {
                 if (he.Entity != null)
                 {
                     try
                     {
                         if (!he.IsDecay)
                         {
                             he.Entity.Destroy();
                         }
                         else if (Fougerite.Hooks.decayList.Contains(he.Entity))
                         {
                             Fougerite.Hooks.decayList.Remove(he.Entity);
                         }
                     }
                     catch (Exception ex)
                     {
                         Logger.LogDebug("EntityHurt EX: " + ex);
                     }
                 }
                 else
                 {
                     Logger.LogDebug("he.Entity is null!");
                 }
             }
         }
         if (command2 != null)
         {
             if (command2.IsOn(pl.UID))
             {
                 if (he.Entity != null)
                 {
                     var list = he.Entity.GetLinkedStructs();
                     foreach (var x in list)
                     {
                         try
                         {
                             x.Destroy();
                             if (Fougerite.Hooks.decayList.Contains(x))
                             {
                                 Fougerite.Hooks.decayList.Remove(x);
                             }
                         }
                         catch
                         {
                         }
                     }
                     try
                     {
                         he.Entity.Destroy();
                         if (Fougerite.Hooks.decayList.Contains(he.Entity))
                         {
                             Fougerite.Hooks.decayList.Remove(he.Entity);
                         }
                     }
                     catch (Exception ex)
                     {
                         Logger.LogDebug("EntityHurt EX: " + ex);
                     }
                 }
                 else
                 {
                     Logger.LogDebug("he.Entity is null!");
                 }
             }
         }
     }
 }