Jump to content
  • 0

L2OFF Exp loss formula


Question

Posted

Anyone can tips me the formula for calculate death Exp loss for players? Or decompiled functions, or place where it calculates in L2OFF (L2Server.exe, CacheD.exe)?

 

Thanks in advance.

Recommended Posts

  • 1
Posted (edited)
double __cdecl GetExpDiePenalty(int level)
{
  double levelFactor; // st7@1

  levelFactor = 10.0 - (double)(level - 1) * 0.125;
  if ( levelFactor <= 4.0 )
  {
    levelFactor = 4.0;
  }
  return -((double)(g_expPenalty[level + 1] - g_expPenalty[level]) * (levelFactor * 0.01));
}
int g_expPenalty = {
0, // 0
0, // 1
68, // 2
363, // 3
1168, // 4
2884, // 5
6038, // 6
11287, // 7
19423, // 8
31378, // 9
48229, // 10
71202, // 11
101677, // 12
141193, // 13
191454, // 14
254330, // 15
331867, // 16
426288, // 17
540000, // 18
675596, // 19
835862, // 20
1023784, // 21
1242546, // 22
1495543, // 23
1786379, // 24
2118876, // 25
2497077, // 26
2925250, // 27
3407897, // 28
3949754, // 29
4555796, // 30
5231246, // 31
5981576, // 32
6812513, // 33
7730044, // 34
8740422, // 35
9850166, // 36
11066072, // 37
12395215, // 38
13844951, // 39
15422929, // 40
17137087, // 41
18995665, // 42
21007203, // 43
23180550, // 44
25524868, // 45
28049635, // 46
30764654, // 47
33680052, // 48
36806289, // 49
40154162, // 50
45525133, // 51
51262490, // 52
57383988, // 53
63907911, // 54
70853089, // 55
80700831, // 56
91162654, // 57
102265881, // 58
114038596, // 59
126509653, // 60
146308200, // 61
167244337, // 62
189364894, // 63
212717908, // 64
237352644, // 65
271975263, // 66
308443198, // 67
346827154, // 68
387199547, // 69
429634523, // 70
474207979, // 71
532694979, // 72
606322775, // 73
696381369, // 74
804225364, // 75
931275828, // 76
1108571463, // 77
1309482881, // 78
1535687304, // 79
1788937098, // 80
2071061777, // 81
0, // 82
};

C1 code right from IDA, for PvE. For PvP/PK/Sieges it's 1/4 of calculated value

Edited by MasterToma
  • 0
Posted

Hello, i try to help you

 

You can put it on a player action or creature action like "on die" and play with mathematics for the value of nExpDec

int User::ExpDown(int nExpDec)
{
	typedef int (*f)(User*, int);
	return f(0x8040F0L)(this, nExpDec);
}

void User::SetExpDown(int nExpDec)
{
	try
	{
		expDrop = nExpDec;
	}
	catch(...)
	{
		return;
	}
}

 

Dont let L2 OFF/PTS die!

  • 0
Posted
6 hours ago, Rootware said:

@Nevermind25 me need an formula, like baseLevelLossExp +levelLossModifier - skillLuckyExpPenaltyModifier .... Bla_Bla_BLa.

hmm if you think, the loss of experience is about a 4%. Then the calc must be down = 0.96 * Exp_of_the_current_level ? 

in the extenders, lin2panel and in other places you can find the exp table for each level. 

  • 0
Posted
7 hours ago, pada said:

i think Function User::GetDefaultExpDownValue Is what you are looking for

 

Where locates this function? L2Server.exe, CacheD.exe?

 

3 hours ago, Nevermind25 said:

hmm if you think, the loss of experience is about a 4%. Then the calc must be down = 0.96 * Exp_of_the_current_level ? 

in the extenders, lin2panel and in other places you can find the exp table for each level. 

 

At this moment, after L2OFF tests, i know what loss experience not static value and calculates from many conditions. I asked about formula for calculate this. I know what for exp loss also affected from clan wars, sieges, level loss %, clan skills, etc.

  • 0
Posted

L2Server.exe -> User::Die -> look for call to User::ExpDown and work your way back from there, you'd need to know asm pretty well and have a spare few days to figure it out, I don't have the time for academic endeavors such as that these days or I'd attempt it

 

If you're friendly with the advext guys you can bet they've already rewrote the whole User::Die func in a few of their exts (never been a fan of that style of working, porting whole func to C++ just for a small fix but hey to each their own), if they feeling nice maybe they'll give some info to you

  • 0
Posted

In C4 exe....


0x545280

double __fastcall GetExpDiePenalty(int level)
{
  double levelFactor; // xmm2_8

  levelFactor = 10.0 - (double)(level - 1) * 0.125;
  if ( levelFactor <= 4.0 )
    levelFactor = 4.0;
  return 0.0 - (double)(g_expPenalty[level] - g_expPenalty[level - 1]) * (levelFactor / 100.0);
}

 

  • 0
Posted (edited)

So, as expected - raw penalty formula in C4 is the same as in C1. Trick is, that calculated by GetExpDiePenalty() value is modified later on, taking into account other factors (it's only pve/pvp factors in C1, in C4 might be more)

Edited by MasterToma
  • 0
Posted

I have this in case it helps you.

  pSD = this_->base.d.pSD;
  nRace = pSD->nRace;
  nSex = pSD->nSex;
  nClass = pSD->nClass;
  nLevel = pSD->nLevel;
  nExp = pSD->nExp;
  if ( LOBYTE(this_->base.d.f_height_damage) && !dword_C6B880 )
  {
    if ( BYTE5(this_->base.d.shieldDefenceRate)
      && (v70 = v80, v71 = v81, v72 = v82, (v28 = sub_424B90(&unk_C476F0, &v70, 11)) != 0) )
    {
      ExpP1 = GetExpDiePenalty(this_->base.d.pSD->nLevel) * *(v28 + 432);
      this_->base.d.unk_BA0 = ExpP1;
      nExp = User::ExpDown(this_, ExpP1);
      v66 = *(v28 + 440);
    }
    else if ( v14 )
    {
      if ( v16 )
      {
        this_->base.d.unk_BA0 = 0;
      }
      else
      {
        ExpP2 = GetExpDiePenalty(this_->base.d.pSD->nLevel) * 0.25;
        this_->base.d.unk_BA0 = ExpP2;
        nExp = User::ExpDown(this_, ExpP2);
        if ( pEnemy_ )
        {
          pEnemyUser = (pEnemy_->vtable->base.base.MemoryObject__CastUser)(pEnemy_);
          if ( pEnemyUser )
          {
            pledge = User::GetPledge(pEnemyUser);
            pledge2 = User::GetPledge(this_);
            if ( pledge || pledge2 )
              CPledge::UpdateSiegeKillDeathPoint(pledge, pledge2);
          }
        }
      }
    }
    else
    {
      v34 = GetExpDiePenalty(this_->base.d.pSD->nLevel);
      this_->base.d.unk_BA0 = v34;
      nExp = User::ExpDown(this_, v34);
    }
  }

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Thank you everyone — we're doing our best to deliver the highest quality experience!   ⏳ Less than 2 days left until the L2Elixir Launch! Our team is working nonstop, polishing every little detail to ensure a smooth and exciting opening. A huge thank you to everyone who participated in the Open Beta — your support and feedback have been invaluable. Get ready… the adventure begins soon! ⚔️✨   Launch: November 28 & 21:00 UTC +2   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs  
    • Do you sell interlude interfaces?
    • in conclusion when somebody who has a project for 10+ years still on development writes an e-say to try until you succeed and then advertises his project, one of the reasons is he needs money, so l2j has once more become pure expensive hobby, you wont make money out of it.   You can still use L2jFrozen and get better results for this, i know some people that done it    keep in mind that C in aCis stands for Crappy, and after all these years its not a cool wordplay anymore, its a fact, prove me wrong.
    • First, don't really follow the "main voice", moreover if you consider it an hobby. Simply do what you want, you got only one life so use it as you want. If you make it an hobby, it's exactly like piano, or velo - only practice makes you better.   Secondly, how do you learn things ? It's actually a really important question, since some can simply be scholar, read books (theory) then practice ; and some simply can't read books. I'm the second type, I hated school, I find it boring - my knowledge in Java comes from try-and-fail. You improve your coding style every year or so, I can myself rewrite my own code (which I already considered top-notched) after a while. You always learn something new - even if Java barely evolves. L2J is a fun way to learn programming, it's a giant sandbox where you can edit anything, and I believe it should be taken as it.   My own way of learning was as follow : Add existing customs, no matter what they are : the point is to know main classes used by L2J / customs. L2J is barely Java knowledge ; the true knowledge is to know WHAT to search in WHICH location (what I call, organization). You have to understand than EVERYTHING you think already exists, in a form on another, in the source code. A custom is only the association of the different mechanisms you found "here and there", glued together in a proper goal. Once you know main classes to edit, and the customs you added are compiling fine, the main point is to know WHAT exactly you DID. Try to understand WHY and WHERE you actually copied the code. Third point would be to MANIPULATE the customs you added in order to fit your wish. First edit little values, then logic conditions ; eventually add a new Config, or a new functionality to the custom. Fourth point would be to begin to craft your own ideas. Once again, EVERYTHING already exists, in a form or another. You want a cycled event ? You got Seven Signs main task as exemple. Npc ? Search any type of Npc and figure out what it does. Fifth point would be to understand Java - mostly containers (WHAT and WHERE to use them), variables types and main Java mechanisms (inheritance, static modifier, etc). You should also begin to cut your code into maintainable classes or methods. Java can actually run without optimization, but bigger your ideas, more optimized and well-thought it should be. It's direct saved time in the future, and you would thank yourself doing so. Main tips : ALWAYS use any type of versioning system - GIT or SVN. It allows to save your work, step by step and eventually revert back anytime you want if you terribly messed up. L2J is 80% organization knowledge, and 20% Java knowledge. Basically, if you know WHAT and WHERE to search, if you aren't dumb, it's easy to replicate and re-use things. Cherry on top is to use a already good coded pack to avoid copy-paste crap and get bad habits. Avoid any type of russian or brazilian packs, for exemple - their best ability is to leak someone's else code. Obviously you need some default sense of logic, but Java and programming in general help you to improve it.   Finally, most of your questions could be solved joining related Discord (at least for aCis, I can't speak for others) - from the moment your question was correctly asked (and you seemed to search for the answer). My community (and myself) welcomes newbies, but got some issues with noobies.   The simpliest is to try, fail and repeat until you succeed - it sounds stupid, but that's basically how life works.   PS : about Java ressources, before ChatGPT, it was mostly about stackoverflow website, and site like Baeldung's one. With ChatGPT and alike, you generally double-cross AI output to avoid fucked up answers. Also, care about AI, they are often hallucinating really hard, even today. They can give you complete wrong answer, you tell them they are wrong, and they say "indeed, I suck, sorry - here's a new fucked up answer". You shouldn't 100% rely over AI answer, even if that can give sometimes legit answers, full code or just skeletons of ideas.   PPS : I don't think there are reliable ressources regarding L2J itself, also most of the proposed code decays pretty fast if the source code is actually maintained (at least for aCis). Still, old coded customs for old aCis sources are actually a good beginner challenge to apply on latest source.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock