Recent Topics

Ads

Patch to add fall damage.

Talk about the development of the emulator and related services.
Check out new and upcoming features to be implemented onto the server.
Forum rules
Before posting on this forum, be sure to read the Terms of Use
zozooo
Posts: 2

Re: Patch to add fall damage.

Post#41 » Sun Dec 28, 2014 9:53 pm

All you need to check for fall damage is to modify the packet handler for F_PLAYER_STATE2


Here is the code i made on my little debugging emu. You need to change it to work for the big emu :)

Code: Select all


        Stopwatch FallDmgWatch = null;     // .. create a timer in player's class or somewhere

        public static double FallDamagePercent(double durationMS)
        {
            if (durationMS >= 1400) // jumping from east keep in caledor results in 30% falldmg   (live server)
                return 0.3;         // 30%,
            else if (durationMS >= 1200)
                return 0.2;
            else if (durationMS >= 1000)
                return 0.1;
            else if (durationMS >= 800)  
                return 0.05;

            return 0;
        }



        static public void F_PLAYER_STATE2(Connection conn, PacketIn packet)
        {
                ...
                ...
                // ..check for knockback state before doing crazy stuff !

                if (CombatByte < 0x1F)    // this value always decreases on free fall
                {
                    if (FallDmgWatch == null)
                    {
                        FallDmgWatch = Stopwatch.StartNew();      // start timer
                    }
                }
                else
                {
                    if (FallDmgWatch != null)
                    {
                        FallDmgWatch.Stop();                     // stop timer
                        TimeSpan elapsedTime = FallDmgWatch.Elapsed;
                        double fallDmgPct = FallDamagePercent(elapsedTime.TotalMilliseconds);

                        if (fallDmgPct > 0)
                        {
                            // do damage amount = (CurrentHealth * fallDmgPct)
                        }


                        Log.Debug(string.Format("fall durationMS: {0}", elapsedTime.TotalMilliseconds));
                        
                        FallDmgWatch = null;
                    }
                }
                
                ...
                ...
         }

Ads
User avatar
Tesq
Posts: 5704

Re: Patch to add fall damage.

Post#42 » Sun Dec 28, 2014 9:58 pm

zozooo wrote:All you need to check for fall damage is to modify the packet handler for F_PLAYER_STATE2


Here is the code i made on my little debugging emu. You need to change it to work for the big emu :)

Code: Select all


        Stopwatch FallDmgWatch = null;     // .. create a timer in player's class or somewhere

        public static double FallDamagePercent(double durationMS)
        {
            if (durationMS >= 1400) // jumping from east keep in caledor results in 30% falldmg   (live server)
                return 0.3;         // 30%,
            else if (durationMS >= 1200)
                return 0.2;
            else if (durationMS >= 1000)
                return 0.1;
            else if (durationMS >= 800)  
                return 0.05;

            return 0;
        }



        static public void F_PLAYER_STATE2(Connection conn, PacketIn packet)
        {
                ...
                ...
                // ..check for knockback state before doing crazy stuff !

                if (CombatByte < 0x1F)    // this value always decreases on free fall
                {
                    if (FallDmgWatch == null)
                    {
                        FallDmgWatch = Stopwatch.StartNew();      // start timer
                    }
                }
                else
                {
                    if (FallDmgWatch != null)
                    {
                        FallDmgWatch.Stop();                     // stop timer
                        TimeSpan elapsedTime = FallDmgWatch.Elapsed;
                        double fallDmgPct = FallDamagePercent(elapsedTime.TotalMilliseconds);

                        if (fallDmgPct > 0)
                        {
                            // do damage amount = (CurrentHealth * fallDmgPct)
                        }


                        Log.Debug(string.Format("fall durationMS: {0}", elapsedTime.TotalMilliseconds));
                        
                        FallDmgWatch = null;
                    }
                }
                
                ...
                ...
         }
if it's working send a pm to max!!
Image

User avatar
chaoscode
Posts: 202

Re: Patch to add fall damage.

Post#43 » Thu Jan 01, 2015 4:27 am

Due to faggots like Shooterx and Kaika. I am removing my code and would ask it not to be used. Faggots like them should not be on the server.

User avatar
xitroxas
Posts: 92

Re: Patch to add fall damage.

Post#44 » Thu Jan 01, 2015 4:33 am

He's just crying because we lost a scenario match and he chose to blame Kalika for not healing him (a healer). Nothing to see here. And as I told him when he threatened to pull his code (like I matter, so why tell me?) the server was fine without him and will continue on without him.
Bigx - Black orc — Lilx - squig herder
Image

Who is online

Users browsing this forum: No registered users and 46 guests