Results 1 to 2 of 2
  1. #1
    Sanusei's Avatar
    Join Date
    Aug 2016
    Gender
    male
    Location
    in the oven
    Posts
    36
    Reputation
    22
    Thanks
    810

    [FSOD] SpecificHeal Fix

    As you may know, SpecificHeal doesn't work too nice when it comes to the maximum health of a monster, and will just keep healing away well over the monster's max health. I actually made the SpecificHeal behaviour a long time ago, and as it was rushed and untested, it ended up just healing way too much. This behaviour is also untested but SHOULD work. Notify me if there are any bugs.

    This is also a very simple fix and is surprisingly not fixed in a lot of Fabiano servers, probably due to the lack of SpecificHeal behaviours. Anyway, simply replace the entire 'SpecificHeal.cs' file with the following code:

     

    Code:
    #region
    
    
    using System;
    using System.Linq;
    using wServer.networking.svrPackets;
    using wServer.realm;
    using wServer.realm.entities;
    
    #endregion
    
    namespace wServer.logic.behaviors
    {
        public class SpecificHeal : Behavior
        {
            //State storage: cooldown timer
    
            private readonly string group;
            private readonly int amount;
            private readonly double range;
            private Cooldown coolDown;
    
            public SpecificHeal(double range, int amount, string group, Cooldown coolDown = new Cooldown())
            {
                this.range = (float) range;
                this.amount = amount;
                this.group = group;
                this.coolDown = coolDown.Normalize();
            }
    
            protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
            {
                state = 0;
            }
    
            protected override void TickCore(Entity host, RealmTime time, ref object state)
            {
                int cool = (int) state;
    
                if (cool <= 0)
                {
                    if (group == "Self")
                    {
                        Enemy entity = host as Enemy;
    		    int newHp = entity.HP + amount;
    		    if (newHp <= entity.ObjectDesc.MaxHP)
    		    {
    			     entity.HP = entity.HP + amount;
    			     entity.UpdateCount++;
    			     entity.Owner.BroadcastPacket(new ShowEffectPacket
    			     {
    				     EffectType = EffectType.Potion,
    				     TargetId = entity.Id,
    				     Color = new ARGB(0xffffffff)
    			     }, null);
    			     entity.Owner.BroadcastPacket(new NotificationPacket
    			     {
    				     ObjectId = entity.Id,
    				     Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + amount + "\"}}",
    				     Color = new ARGB(0xff00ff00)
    			     }, null);
    		    }
    		    else
    		    {
    			     int defecitToMaxHp = Convert.ToInt32(entity.ObjectDesc.MaxHP) - entity.HP;
    			     if (defecitToMaxHp <= 0)
    			     {
    			     }
    			     else
    			     {
    				     entity.HP = entity.HP + defecitToMaxHp;
    				     entity.UpdateCount++;
    				     entity.Owner.BroadcastPacket(new ShowEffectPacket
    				     {
    					     EffectType = EffectType.Potion,
    					     TargetId = entity.Id,
    					     Color = new ARGB(0xffffffff)
    				     }, null);
    				     entity.Owner.BroadcastPacket(new NotificationPacket
    				     {
    					     ObjectId = entity.Id,
    					     Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + amount + "\"}}",
    					     Color = new ARGB(0xff00ff00)
    					     }, null);
    				     }
    			}
                    }
                    else
                    {
                        foreach (Enemy entity in host.GetNearestEntitiesByGroup(range, group).OfType<Enemy>())
                        {
                        	int newHp = entity.HP + amount;
    			if (newHp <= entity.ObjectDesc.MaxHP)
    			{
    				entity.HP = entity.HP + amount;
    				entity.UpdateCount++;
    				entity.Owner.BroadcastPacket(new ShowEffectPacket
    				{
    					EffectType = EffectType.Potion,
    					TargetId = entity.Id,
    					Color = new ARGB(0xffffffff)
    				}, null);
    				entity.Owner.BroadcastPacket(new NotificationPacket
    				{
    					ObjectId = entity.Id,
    					Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + amount + "\"}}",
    					Color = new ARGB(0xff00ff00)
    				}, null);
    			}
    			else
    			{
    				int defecitToMaxHp = Convert.ToInt32(entity.ObjectDesc.MaxHP) - entity.HP;
    				if (defecitToMaxHp <= 0)
    				{
    				}
    				else
    				{
    					entity.HP = entity.HP + defecitToMaxHp;
    					entity.UpdateCount++;
    					entity.Owner.BroadcastPacket(new ShowEffectPacket
    					{
    						EffectType = EffectType.Potion,
    						TargetId = entity.Id,
    						Color = new ARGB(0xffffffff)
    					}, null);
    					entity.Owner.BroadcastPacket(new NotificationPacket
    					{
    						ObjectId = entity.Id,
    						Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + amount + "\"}}",
    						Color = new ARGB(0xff00ff00)
    					}, null);
    				}
    			}
                        }
                    }
                    cool = coolDown.Next(Random);
                }
                else
                    cool -= time.thisTickTimes;
    
                state = cool;
            }
        }
    }


    Edit: tried to fix spacing, definitely better than before, but still a bit off
    Last edited by Sanusei; 01-04-2017 at 10:49 AM. Reason: attempted to fix spacing

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

    Invader_Zim (01-10-2017),Twont (07-09-2017),Zxoro (01-04-2017)

  3. #2
    Invader_Zim's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Location
    Atlas 2
    Posts
    546
    Reputation
    10
    Thanks
    300
    My Mood
    Tired
    Saved me some time when doing tomb bosses, the only thing I had to do was add a trail effect whenever the heal is not on self. Other than that, it works great.

    My weapon is a backpack.

Similar Threads

  1. [FSOD] Grenade Fix
    By HGAEHaeheadhetdhtertherh in forum Realm of the Mad God Private Servers Tutorials/Source Code
    Replies: 9
    Last Post: 01-09-2017, 12:12 PM
  2. [FSOD] Davy Jones Fixed.
    By MikeRaarupBirk in forum Realm of the Mad God Private Servers Tutorials/Source Code
    Replies: 13
    Last Post: 10-14-2016, 09:19 AM
  3. [Help Request] How to replace/fix FSOD dungeons?
    By ZombiJordan in forum Realm of the Mad God Private Servers Help
    Replies: 2
    Last Post: 09-02-2016, 05:10 AM
  4. [Help Request] how to fix buy gold FSOD
    By OGgurk in forum Realm of the Mad God Private Servers Help
    Replies: 3
    Last Post: 06-06-2016, 06:36 PM
  5. FSoD Paladin Seal fix
    By Masternx in forum Realm of the Mad God Private Servers Tutorials/Source Code
    Replies: 15
    Last Post: 05-07-2016, 01:29 AM