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

    • what pack you use  send me on discord for it
    • package custom.events.RandomZoneEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.ScheduledFuture; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.commons.time.SchedulingPattern; import org.l2jmobius.commons.time.TimeUtil; import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.gameserver.managers.ZoneManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.quest.Event; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.RandomZone; import org.l2jmobius.gameserver.util.Broadcast; /** * Random Zone Event - Activates one random PvP zone temporarily. No modifica la clase de la zona: usa flags PvP en runtime. * @author Juan */ public class RandomZoneEvent extends Event { private static final String CONFIG_FILE = "data/scripts/custom/events/RandomZoneEvent/config.xml"; private static int EVENT_DURATION_MINUTES = 15; private static boolean _isActive = false; private ScheduledFuture<?> _eventTask = null; private final List<ZoneType> _availableZones = new ArrayList<>(); private ZoneType _activeZone = null; public RandomZoneEvent() { loadConfig(); loadZones(); registerZoneListeners(); } /** * Registra listeners a TODAS LAS ZONAS random */ private void registerZoneListeners() { for (ZoneType zone : _availableZones) { addEnterZoneId(zone.getId()); addExitZoneId(zone.getId()); LOGGER.info("[RandomZoneEvent] Registered listener for zone: " + zone.getName()); } } private void loadConfig() { new IXmlReader() { @Override public void load() { parseDatapackFile(CONFIG_FILE); } @Override public void parseDocument(Document doc, File file) { forEach(doc, "event", eventNode -> { final StatSet att = new StatSet(parseAttributes(eventNode)); final String name = att.getString("name"); for (Node node = eventNode.getFirstChild(); node != null; node = node.getNextSibling()) { if ("schedule".equals(node.getNodeName())) { final StatSet attributes = new StatSet(parseAttributes(node)); final String pattern = attributes.getString("pattern"); final SchedulingPattern schedulingPattern = new SchedulingPattern(pattern); final StatSet params = new StatSet(); params.set("Name", name); params.set("SchedulingPattern", pattern); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer("Schedule_" + name, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Event " + name + " scheduled at " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } }); } }.load(); } private void loadZones() { for (ZoneType zone : ZoneManager.getInstance().getAllZones(RandomZone.class)) { if ((zone.getName() != null) && zone.getName().toLowerCase().startsWith("random_zone")) { _availableZones.add(zone); LOGGER.info("[RandomZoneEvent] Loaded zone: " + zone.getName() + " (id=" + zone.getId() + ")"); } } LOGGER.info("[RandomZoneEvent] Total random zones loaded: " + _availableZones.size()); } @Override public void onTimerEvent(String event, StatSet params, Npc npc, Player player) { if (event.startsWith("Schedule_")) { eventStart(null); final SchedulingPattern schedulingPattern = new SchedulingPattern(params.getString("SchedulingPattern")); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer(event, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Rescheduled for " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } @Override public boolean eventStart(Player eventMaker) { if (_isActive) { if (eventMaker != null) { eventMaker.sendMessage("RandomZoneEvent already active."); } return false; } if (_availableZones.isEmpty()) { Broadcast.toAllOnlinePlayers("[RandomZoneEvent] No zones configured."); return false; } _isActive = true; Broadcast.toAllOnlinePlayers("⚔️ Random Zone Event has started!"); _eventTask = ThreadPool.schedule(this::activateRandomZone, 5_000); return true; } private void activateRandomZone() { _activeZone = _availableZones.get(new Random().nextInt(_availableZones.size())); _activeZone.setEnabled(true); Broadcast.toAllOnlinePlayers("🔥 Random Zone Event: " + _activeZone.getName() + " is now PvP for " + EVENT_DURATION_MINUTES + " minutes!"); _eventTask = ThreadPool.schedule(this::eventStop, EVENT_DURATION_MINUTES * 60 * 1000L); } @Override public boolean eventStop() { if (!_isActive) { return false; } _isActive = false; if (_eventTask != null) { _eventTask.cancel(true); _eventTask = null; } if (_activeZone != null) { _activeZone.setEnabled(false); Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended. " + _activeZone.getName() + " is back to normal."); _activeZone = null; } else { Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended."); } return true; } @Override public void onEnterZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, true); if (creature.isPlayer()) { creature.sendMessage("Esta zona está en modo PvP temporalmente."); } } } @Override public void onExitZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, false); if (creature.isPlayer()) { creature.sendMessage("Abandonaste la zona PvP temporal."); } } } @Override public boolean eventBypass(Player player, String bypass) { return true; } @Override public String onEvent(String event, Npc npc, Player player) { return super.onEvent(event, npc, player); } @Override public String onFirstTalk(Npc npc, Player player) { return null; } public static void main(String[] args) { new RandomZoneEvent(); } } i have this but its not working
    • ZonePvPSpawnBossRadio=0 ZonePvPSpawnBossBarakiel=0 at the Customs.ini in L2Server folder. Im prety sure this is it because i had the same problem with you in cruma 1 floor for example and i couldn't fix it but i fixed it finally by changing these 2 lines
    • Siege Reward Start PM Msg Rework Config root BossDieAnnounce and BossDieSound in the L24Team.properties and Config.java files for global raid boss death notifications and sounds. Adds a new reward_list table to the DB.sql file to track castle rewards. Improves character creation logic for thread safety and validation. Adds extensive state checks to the RequestEnchantItem method to prevent enchantments during inappropriate player states. Fixed auto-attack animation bug (there was no attack animation, only damage animation) Clean Code Other fixes I forgot to list! Java 14 Fixed issue where deleting a character would prevent it from leaving the screen or being removed, or even after a delete CD (it would only exit when re-logging in or creating a new character). Added Premium System from the other C2 project (Needs testing and improvement). Added the "Improved" Community Board (incomplete).
  • 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