Results 1 to 2 of 2
  1. #1
    Invader_Zim's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Location
    Atlas 2
    Posts
    546
    Reputation
    10
    Thanks
    300
    My Mood
    Tired

    [FSoD] Custom Behavior - GivePlayersEffect.cs

    This is a modification from the GivePlayerEffect class that gives the nearest player a status effect. I simply took its original point, and made it apply to all players within the given distance. I also removed the immune checks, since players are normally not immune to status effects.

    All credits go towards The First Sin for the original code. Click here to look at the original, and to thank him.

     
    Code:
    #region
    using System.Linq;
    using wServer.realm;
    using wServer.networking.svrPackets;
    using wServer.realm.entities;
    using wServer.realm.entities.player;
    
    #endregion
    
    namespace wServer.logic.behaviors
    {
        public class GivePlayersEffect : Behavior
        {
            private readonly int dist;
            private readonly int duration;
            private readonly ConditionEffectIndex effect;
    
            public GivePlayersEffect(ConditionEffectIndex effect, int duration, int dist)
            {
                this.dist = dist;
                this.effect = effect;
                this.duration = duration;
            }
    
            protected override void TickCore(Entity host, RealmTime time, ref object state) { }
    
            protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
            {
                if (host.GetNearestEntities(dist, null) == null) return;
                foreach (Entity player in host.GetNearestEntities(dist, null))
                {
                    string effectname = effect.ToString();
                    if (player.HasConditionEffect(ConditionEffectIndex.Invincible)) return;
                    player.ApplyConditionEffect(new ConditionEffect
                    {
                        Effect = effect,
                        DurationMS = duration
                    });
                    player.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Trail,
                        TargetId = host.Id,
                        PosA = new Position { X = player.X, Y = player.Y },
                        Color = new ARGB(0xffff0000)
                    }, null);
                    player.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Potion,
                        TargetId = player.Id,
                        Color = new ARGB(0xffff0000)
                    }, null);
                    player.Owner.BroadcastPacket(new NotificationPacket
                    {
                        ObjectId = player.Id,
                        Color = new ARGB(0xffff0000),
                        Text = "{"key":"blank","tokens":{"data":"" + effectname + ""}}"
                    }, null);
                }
            }
        }
    }

    My weapon is a backpack.

  2. The Following 2 Users Say Thank You to Invader_Zim For This Useful Post:

    HGAEHaeheadhetdhtertherh (09-28-2016),~V~ (09-02-2016)

  3. #2
    MikeRaarupBirk's Avatar
    Join Date
    Mar 2016
    Gender
    male
    Posts
    1,583
    Reputation
    38
    Thanks
    3,775
    My Mood
    Stressed
    but where do i add it? never miiiiiiiiind Ecks dee
    Last edited by MikeRaarupBirk; 09-03-2016 at 07:45 AM.

Similar Threads

  1. [FSOD] Lair of Draconis [MAP][BEHAVIOR][SETPIECES]
    By HGAEHaeheadhetdhtertherh in forum Realm of the Mad God Private Servers Tutorials/Source Code
    Replies: 38
    Last Post: 06-18-2017, 02:53 PM
  2. [FSoD] Conditional Behaviors
    By OmegaBM in forum Realm of the Mad God Private Servers Tutorials/Source Code
    Replies: 13
    Last Post: 09-03-2016, 08:01 AM
  3. [Help Request] [FSoD] Custom Classes + Custom Slottypes
    By Lunacy Gaming in forum Realm of the Mad God Private Servers Help
    Replies: 1
    Last Post: 08-24-2016, 12:30 PM
  4. Custom Enemy Behaviors
    By sadpeanut11 in forum Realm of the Mad God Private Servers Help
    Replies: 3
    Last Post: 02-13-2016, 02:28 AM
  5. Custom Lava Boss behavior...
    By lkdjnfoskjednfblksjdfn in forum Realm of the Mad God Private Servers Tutorials/Source Code
    Replies: 8
    Last Post: 07-27-2015, 12:44 AM