Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Healing system AlterEmu

Initiate Mage
Joined
May 20, 2017
Messages
2
Reaction score
1
Dear (hopefully) helpers,

I'm digging in the server files of AlterEmu v5 and I noticed in-game that the healing system isn't working.

I also saw this thread where DarkRaptor fixed the healing system but he didn't release it, or deleted it.

Someone able to help me? Or someone that still has the fix available?

With regards,

Jochem



I've but the code from the heal.cs system below.

Code:
namespace Game.Handlers.Game.Ingame{    class Heal : Networking.GameDataHandler    {        protected override void Handle()        {            if (Room.State == Enums.RoomState.Playing)            {                byte targetSlot = GetByte(2); // The target                 bool heal = GetBool(5); // If user needed to be healed or killed                bool isBoxStation = false; // If it's an medic station or just normal healing                ushort healing = 0;                //if (heal)                {                    if (targetSlot >= 0 && targetSlot <= Room.MaximumPlayers)                    {                        Entities.Player p = null;                        try                        {                            Room.Players.TryGetValue(targetSlot, out p);                        }                        catch { p = null; }                        if (p != null)                        {                            if (isBoxStation)                            {                                p.Health += 500;                            }                            else                            {                                switch (Player.Weapon)                                {                                    case 94: // medic kit                                        {                                            if (p.Health < 1000)                                                p.Health += 300;                                            break;                                        }                                    case 99: // adrenaline                                        {                                            if (p.Health < 300)                                                p.Health += 300;                                            else                                                p.Health += 100;                                            break;                                        }                                }                            }                            p.Health += healing;                            if (p.Health > 1000)                                p.Health = 1000;                            respond = true;                            Set(3, Player.Health);                        }                    }                }            }        }    }}
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
The healing system was implemented incorrectly. I re-wrote the handler based on the incoming data from the client. This re-work misses a few checks but it should work for healing and adrenaline.

Code:
namespace Game.Handlers.Game.Ingame{    class Heal : Networking.GameDataHandler    {        protected override void Handle()        {            if (Room.State != Enums.RoomState.Playing) return;            var targetSlot = GetByte(2); // The target             var unitHandle = GetByte(4); // The Type of healing.            if (targetSlot > Room.MaximumPlayers)            {                // Disconnect the player due to faulty packet.                Player.User.Disconnect();                return;            }            if (Player.Health >= 1000)                return; // Ignore the packet since we are full health.            switch (unitHandle)            {                case 0: // Heal                    Player.Health += 300;                    break;                case 1: // Water Warning                    Player.Health -= 100;                    break;                case 2: // Adrenaline                    if (Player.Health > 300)                    {                        Player.Health += 100;                    }                    else                    {                        Player.Health = 300;                    }                    break;                case 4: // Stamina?                    break;            }            if (Player.Health > 1000)            {                Player.Health = 1000;            }            else if (Player.Health < 0)            {                Player.Health = 0;            }             /* Response Info             *              * 2: iReserve0 == PInfo.Session             * 3: iReserve1 == HealthPoint             * 4: iReserve2 == Type             */            respond = true;            Set(3, Player.Health);        }    }}

 
Initiate Mage
Joined
May 20, 2017
Messages
2
Reaction score
1
CodeDragon the hero again... Thank you! Completely working now :)
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
899
Here is some more info that I grabbed from the PDB while I was researching this to fix it for you.

Code:
CreateRoomInProtocol_HealingPlayer(    result,    Client->PInfo.Tag.PC_Idx,    Client->PInfo.RoomNum,    Client->PInfo.Session,    iReserve0_SessionReceivingHeal,    iReserve1,    iReserve2,    iReserve3);CreateRoomInProtocol_HealingPlayer(boost::shared_ptr<room_in_protocol> *result, NSockClient *Client, int iReserve0_SessionReceivingHeal, int iReserve1, int iReserve2, int iReserve3)CreateRoomInProtocol_HealingPlayer(&result, Client, Client->PInfo.Session, 0, 4, 0) // StaminaCreateRoomInProtocol_HealingPlayer(&result, Client, Client->PInfo.Session, 0, 1, 0); // WaterCreateRoomInProtocol_HealingPlayer(&v20, Client, Client->PInfo.Session, 1, 0, 0); // Healing Box

Code Tags seem to be broken so here is a pastebin link:
 
Back
Top