Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Figuring out WDEF
#1
Here's the formula. I'm still trying to figure out the variables:

 adjust_base_dispense

[spoiler=CalcDamage:TongueDamage]
Code:
int __thiscall CalcDamage__PDamage(void *this, int MobData, __int64 CharacterData, int BasicStat, int MobAttackInfo, unsigned int a6, char a7, int a8, int a9, unsigned int MobID, int a11, int a12)
{
  int v12; // edx@1
  int v13; // ecx@1
  int result; // eax@6
  double v15; // st7@10
  double v16; // st7@11
  signed __int64 v17; // qax@13
  int v18; // eax@15
  signed int v19; // ecx@19
  unsigned int RandNum; // eax@23
  double mob_base_damage; // ST3C_8@23
  int charLevel; // ST28_4@23
  int mobLevel; // ST24_4@23
  __int32 basePDD; // eax@23
  signed int SecondaryStat:GetPDD; // eax@23
  double v26; // ST3C_8@23
  double v27; // ST3C_8@23
  double damage; // st7@27
  double v29; // [sp+24h] [bp-20h]@23
  int v30; // [sp+2Ch] [bp-18h]@1
  int v31; // [sp+30h] [bp-14h]@1
  void *v32; // [sp+34h] [bp-10h]@1
  signed int v33; // [sp+50h] [bp+Ch]@26
  signed int mobAttack; // [sp+5Ch] [bp+18h]@21
  signed int v35; // [sp+60h] [bp+1Ch]@7

  v32 = this;
  v13 = 0;
  v12 = 0;
  v30 = 0;
  v31 = 0;
  if ( a8 )
  {
    v12 = *(a8 + 28);
    v30 = *(a8 + 32);
    v13 = *(a8 + 20);
    v31 = *(a8 + 40);
  }
  if ( CalcDamage__CheckPDamageMiss(MobData, CharacterData, HIDWORD(CharacterData), BasicStat, a6, v13, v12) )
  {
    if ( a8 )
      ZRef_PassiveSkillData____ReleaseRaw(0);
    result = 0;
  }
  else
  {
    _ZtlSecureFuse((HIDWORD(CharacterData) + 24), *(HIDWORD(CharacterData) + 32));
    v35 = *(MobData + 40);
    if ( *(MobData + 40) && *(MobData + 44) == 1201006 && MobID / 0x2710 != 882 ) // 1201006 = Threaten... The 882 check is to see if the mobID is Pink Bean
    {
      v15 = v35 * 0.01 + 1.0;
      if ( MobAttackInfo )
        v16 = v15 * *(MobAttackInfo + 24);
      else
        v16 = v15 * *(MobData + 36);
      v17 = v16;
    }
    else
    {
      if ( MobAttackInfo )
        v18 = *(MobAttackInfo + 24);
      else
        v18 = *(MobData + 36);
      LODWORD(v17) = v35 + v17;
    }
    if ( v17 <= 0 )
      v19 = 0;
    else
      v19 = v17;
    mobAttack = v19;
    if ( v19 >= 29999 )
      mobAttack = 29999;
    _ZtlSecureFuse((HIDWORD(CharacterData) + 12), *(HIDWORD(CharacterData) + 20));
    RandNum = CRand32__Random(v32 + 160);
    mob_base_damage = _calc_mob_base_damamge(mobAttack, RandNum);
    charLevel = _ZtlSecureFuse((HIDWORD(CharacterData) + 12), *(HIDWORD(CharacterData) + 20));
    mobLevel = *MobData;
    basePDD = BasicStat__CalcBasePDD(HIDWORD(CharacterData));
    SecondaryStat:GetPDD = SecondaryStat__GetPDD(BasicStat, basePDD, CharacterData, v30, 0, a11, a12);
    v26 = _adjust_base_depense(mob_base_damage, SecondaryStat:GetPDD, mobLevel, charLevel, v31);
    v27 = v26 - _ZtlSecureFuse((BasicStat + 780), *(BasicStat + 788)) * v26 * 0.01;
    v29 = v27 - _ZtlSecureFuse((BasicStat + 4360), *(BasicStat + 4368)) * v27 * 0.01;
    if ( _ZtlSecureFuse((BasicStat + 1260), *(BasicStat + 1268)) )
    {
      if ( a9 )
        *a9 = CalcDamage__GetMesoGuardReduce(CharacterData, v29);
    }
    v33 = *(MobData + 212);
    if ( v33 )
      damage = v33 * v29 * 0.01;
    else
      damage = v29;
    if ( damage <= 1.0 )
      damage = 1.0;
    if ( damage >= 999999.0 )
      damage = 999999.0;
    if ( a8 )
      ZRef_PassiveSkillData____ReleaseRaw(0);
    result = damage;
  }
  return result;
}
[/spoiler]

 adjust_mob_damamge
Reply
#2
At a guess, a5 in the first equation is the random component, so v5 is effectively "def mastery" in some sense. I haven't worked out exactly what sort of values it'll have yet.
Reply
#3
No, I think the random component is taken care of in the _adjust_mob_damamge (sic) function.
Reply
#4
I mean in player def. In the old system, you have (0.5,0.6)*def as well as the 94%~ mastery on the mob's damage itself. It's not quite structured the same though, hmm. Gotta run through this with some numbers to see what it actually does.
Reply
#5
Speaking of the old system, I can pull up that data as well.
Reply
#6
Okay, I've done some further study and found an interesting result:

On very high damage monsters, defense becomes percentage based - roughly half the square root of the defense (as a percent) is used instead of straight up 0.25*def. It basically chooses the best of the 2, in terms of reduction amount.

If you have 400 def for example, you end up with 10% or 100 reduced, whichever is bigger.

a5 is added to the percentage based def reduction - so it only affects damage taken on mobs with higher damage. It's basically another percentage - a value of 200 in a5 means +200% to the percentage based reduction (to 30% in the above example)

I don't know, maybe it is coming from Shield Mastery? If so, PDD around 4500 would be enough to reduce all damage to 1...
Reply
#7
So based on what you say, Stereo, lets see if I got this right..

Given:
10,000 defense
20,000 damage

Result:
Square Root of 10,000 = 100, 100/2 = 50 --> 50%
10,000 Defense x 25% = 2,500

--> damage reduction of 50% = 10,000 damage reduced vs 2,500 damage reduced = it would be reduced by 10,000 damage since it's the larger amount? You would receive 10,000 damage?

EDIT: lol, think I found a miscalc... fixed
Reply
#8
Yeah, it works like that.

You do lose 2% per level below the mob though, so it'll do more damage. But you really can't hit it anyway.
Reply
#9
PDD has a constraint of [0, 30000]
Mob damage has a constraint of [1, 999999]

I threw this at a C compiler btw.

So, calculating defense of 30000 and 999999 damage yields the following:

 oops
Reply
#10
Looks the same as what I got, except I used an excel spreadsheet so I can see directly what the code is doing line by line. For short code it seems to be a decent method, though I cheated a little on the if statements.


Kudos to Nexon for making defense actually useful I guess - on something with 25k damage my Paladin will only take ~16k due to wdef alone.
Reply
#11
I'm coding a calculator like my other ones. I should have it up and ready in a little bit.

EDIT: As a rule of thumb, if you want a mob to do 1 damage to you, you need to have 4x the mob's attack value.
Reply
#12
If you can figure out where a5 came from, it might have an upper bound under 30000 wdef (rather than the impossible 40000 wdef with a5=0) - say you could get a5=150, then you'd only need 6400 wdef to be invincible. For that matter, with a5=17 30000 def would be the same.
Reply
#13
Where are you getting that value from? 6400?
Reply
#14
{[1/(a5+100)*10000]*2}^2 = def

It's basically the equation backwards, with the goal being v11=0, which in turn means v5 = 100, so (PDD*.25)^.5*(1+a5/100) = 100

Since a5 is for some reason a whole number percentage, instead of a decimal fraction, it introduces a lot of extra *100 factors in the equation.
Reply
#15
You're making a lot of assumptions about a5.

If it means anything, the avoid and hit rate formula also has sections which look like a5. I edited them out since they don't seem to apply to regular players or only apply in very specific scenarios.

http://happychinchilla.info/damage.html
Reply
#16
Calculator appears to be non-functional :/

Also,

var v11 = (100 - pddSqrt) * mobAttack * 0.01;

Does this mean with 40,000 defense, nothing will hit you for more than 1 damage? Forgot about the cap.

a5 appears to be nothing more than a % increase to wdef, probably coming from skills like Shield Mastery or equips with +% wdef.
Reply
#17
Dusk, no. If you look further up in the formula the defense is first multiplied by 0.25. So the maximum defense is technically 7500 (30000 * 0.25). The square root of this is about 86%.

The calculator should be fixed. Refresh.
Reply
#18
So I was looking at the wdef formula

WDEF = STR * 1.2 + (DEX + LUK) * 0.5 + INT * 0.4 + [def from equips]?


How about def from equips? that should just be added in after right?
Reply
#19
Correct. That formula is for base WDEF.
Reply
#20
Fiel Wrote:Correct. That formula is for base WDEF.


Figured as much. Thanks for the clarification.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)