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;
}
}
...
...
}