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());
            }
        }
    }
Example #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;
                 }
             }
         }
     }
 }
Example #3
0
 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;
         }
     }
 }
        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);
        }
Example #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);
        }
Example #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;
         }
     }
 }
Example #7
0
        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!");
                    }
                }
            }
        }
Example #8
0
        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;
                }
            }
        }
Example #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;
         }
     }
 }
Example #10
0
        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;
                }
            }
        }
Example #11
0
 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);
     }
 }
Example #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");
                    }
                }
            }
        }
Example #13
0
 private void EntityHurt(HurtEvent he)
 {
 }
Example #14
0
 private void Update_HitEvent(int hurtIndex, Transform position)
 {
     HurtEvent?.Invoke(hurtIndex, position);
 }
Example #15
0
 public void On_CorpseHurt(HurtEvent he)
 {
     SetHookWorking("On_CorpseHurt");
     Broadcast(he.Attacker.Name + " attacked a corpse with " + he.Weapon.Name);
 }
Example #16
0
 public void OnNPCHurt(HurtEvent evt)
 {
     this.Invoke("On_NPCHurt", new object[] { evt });
 }
Example #17
0
 void EntityHurt(HurtEvent he)
 {
 }
Example #18
0
 public void OnNPCHurt(HurtEvent evt)
 {
     Invoke("On_NPCHurt", evt);
 }
Example #19
0
 public void OnEntityHurt(HurtEvent evt)
 {
     Invoke("On_EntityHurt", evt);
 }
Example #20
0
 public void OnEntityHurt(HurtEvent he)
 {
     this.Invoke("On_EntityHurt", new object[] { he });
 }
Example #21
0
 public void OnPlayerHurt(HurtEvent evt)
 {
     Invoke("On_PlayerHurt", evt);
 }
Example #22
0
 public void OnNPCHurt(HurtEvent he)
 {
     this.Invoke("On_NPCHurt", new object[] { he });
 }
Example #23
0
 void PlayerHurt(HurtEvent he)
 {
 }
Example #24
0
 public void OnPlayerHurt(HurtEvent he)
 {
     this.Invoke("On_PlayerHurt", new object[] { he });
 }
Example #25
0
 public void OnEntityHurt(HurtEvent evt)
 {
     this.Invoke("On_EntityHurt", new object[] { evt });
 }
Example #26
0
 private void GotHurt(int value)
 {
     HurtEvent?.Invoke(this, value);
     Health -= value;
 }
Example #27
0
 public void OnPlayerHurt(HurtEvent evt)
 {
     this.Invoke("On_PlayerHurt", new object[] { evt });
 }
Example #28
0
 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!");
                 }
             }
         }
     }
 }