Page 5 of 5

Re: Patch to add fall damage.

Posted: Sun Dec 28, 2014 9:53 pm
by zozooo
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;
                    }
                }
                
                ...
                ...
         }

Re: Patch to add fall damage.

Posted: Sun Dec 28, 2014 9:58 pm
by Tesq
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!!

Re: Patch to add fall damage.

Posted: Thu Jan 01, 2015 4:27 am
by chaoscode
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.

Re: Patch to add fall damage.

Posted: Thu Jan 01, 2015 4:33 am
by xitroxas
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.