Author Topic: Experience-based leveling  (Read 3176 times)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Experience-based leveling
« on: 20 December 2011, 22:47:33 »
This has definitely been requested in the past, but was unable to find a ticket nor a thread, so we'll repost for that purpose, along with beautiful elaboration.

As we all (should) know, units can be given levels, which they can access by reaching a certain number of kills. These levels allow you to raise stats by either multipliers or static amounts. We've long since filled up the bug with killing your own units for free kills.

However, the weakness with kill-count based leveling is that you could kill 5 pigs, or you could kill 5 airships to still count for the same level. This feature request specifies an optional system which would replace that, using a very simple experience based concept. Units would have a defined amount of experience rewarded for killing them. Levels would need a certain amount of experience to level up. However, working with both kill-count based leveling and experience based leveling at the same time is almost impossible. A unit can level up between one or the other, never both.

Currently, the XML syntax for levels is like this:
Code: (Current system) [Select]
<levels>
<level name="elite" kills="5"/>
</levels>

To state the type of leveling system, either experience or kill-count based, we'd add a new parameter to <levels>, system (either kills or experience, with kills being the default system), and the <level /> tag would replace the kills attribute with a more accurate experience attribute:
Code: (Syntax) [Select]
<levels system="experience">
<level name="elite" experience="4000"/>
</levels>

For better accuracy, units could also be given a new <experience /> tag, which would define how much experience the killer gets. If an experience tag is not specified, the max-HP of the killed unit becomes the experience (so a swordman would be worth 700 experience, and by default, an archmage would be worth 450, though you could use the <experience /> tag to up the archmage to, say, 1000).
Code: (Syntax) [Select]
<experience amount="1000" />
As it is, the unit who gets the last hit gets the kill. That's fine for a basic implementation, but a refined method I'd like to see is the kill going to whichever unit did the most damage to the killed unit. So if my horseman took of 90% of the foe's health and my swordman just happened to get the last, killing blow, the horseman will get the kill/experience, not the swordman, as it currently is. If the unit who did the most damage is dead, it would go to the one that dealt the second most. If it's dead too, well, we know how that works. This would ideally apply to both the kill and experience based leveling systems, as it would not break any mods nor have any major impact on gameplay. Of course, it could be a lot more work, since the engine would have to keep tabs on who did every hit to a unit.

Edit 2012-05-23: Experience would be gained as a percentage of damage dealt, rather than based on who got that "killing blow". So if a unit's attack knocks off 50% of their foe's health, they'd gain 50% of that foe's experience value.

On a side note, the kill based and experience based systems are not meant to function together. It's one or the other. If you use the experience based system, you'd have to use it for every unit that has a <level /> tag. Trying to get them to play nice with each other at the same time would be unnecessary and a headache. I'm not even wasting time proposing a workaround for such instances, just throw an error so the modder won't distribute their bad version.

Advantages of an experience based system:
  • More accurate in terms of effort: killing an airship is vastly more difficult than killing a pig. In an experience based system, a pig might only be worth 100 experience, but an airship could be 2000, 20 times more valuable, despite being the same in a kill based system.
  • Experience points and leveling go hand in hand. Sure first person shooters might use kill based systems, but many RPGs, RTSs, etc, would use experience. Players are used to it, and know exactly how it works.
Advantages of a kill based system:
  • Simplicity, easier to remember; "I have to kill two more dudes to level up".
  • No extra work for modders (on a rebuttal, you'd need, at a bare minimum, to add 20 characters to each unit XML, find and replace friendly).
Disadvantages of giving a choice:
  • None. :)
« Last Edit: 24 May 2012, 04:20:34 by Omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Bloodwurm

  • Guest
Re: Experience-based leveling
« Reply #1 on: 21 December 2011, 03:12:46 »
I find this to be awesome!

But yeah, there are some really annoying drawbacks:

- (The biggest in my opinion) Getting all units from all factions modified will be a challenge, past, current and future. Sure the HP thing could be used but then your example of the archmage just shows my point (if it's not modified, then it's XP value would be lower than a simple guard ). Everytime a new faction would get created, especially by a new modder, then things would become hectic when playing against it...

- Not only does every unit need to keep track of their damage on other units, but what happens when that unit retreats and heals up (or simply heals up through a support caster or whatever)? This kind of things could quickly become a can of worms of bugs.... Some intelligent damage management and timers would need to be put in place to make it rock solid.

But I'm all for new RPG elements! :)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Experience-based leveling
« Reply #2 on: 21 December 2011, 03:21:54 »
- (The biggest in my opinion) Getting all units from all factions modified will be a challenge, past, current and future. Sure the HP thing could be used but then your example of the archmage just shows my point (if it's not modified, then it's XP value would be lower than a simple guard ). Everytime a new faction would get created, especially by a new modder, then things would become hectic when playing against it...
Since the system is optional, if a modder wishes to add it (were it implemented, I'd add it to AD), it would literally take about 10 minutes to add. For someone who knows their faction (if you made it, you should know it well), balance should be pretty easy.

- Not only does every unit need to keep track of their damage on other units, but what happens when that unit retreats and heals up (or simply heals up through a support caster or whatever)? This kind of things could quickly become a can of worms of bugs.... Some intelligent damage management and timers would need to be put in place to make it rock solid.
Yeah, that's a bit trickier. I did think of that, but considered that whichever unit dealt the most damage to it, period, even if it fully heals itself several times, should just take the experience from it. Seemed like the easiest way to do it. Alternatively, you could reset the recorded damage dealt to the unit the moment its health is fully restored. Of course, bearing in mind that this is actually separate from the experience based leveling, though would compliment the entire leveling system quite well, I would think.

Also, being entirely optional, I imagine one could make some pretty cool RPG-style scenarios with experience based leveling.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Zoythrus

  • Guest
Re: Experience-based leveling
« Reply #3 on: 21 December 2011, 05:36:03 »
if i may contribute an idea, i've seen some games where units gain experience through merely doing damage to an enemy unit. so, here's what i propose: a unit would acquire the percentage of damage dealt to the the enemy's HP as experience. eg. if a unit dealt an attack that drained 10% of the enemy's health, it would gain 10% of the max amount of XP that the attacked unit has (small damage quabbles would be rounded up, for ease of use). now, this system would always apply, even if the unit in question is healed.

also worth noting, this should also create a new tag for units - "xp-gain" which, in short acts like this: in the previous scenario, if the attacking unit had an <xp-gain value ="2"/> somewhere in his parameters, he would receive 20% of the possible xp. (this tag would default to 1, because it's a multiplier)

Bloodwurm

  • Guest
Re: Experience-based leveling
« Reply #4 on: 21 December 2011, 14:33:05 »
I like that! It would simple and effective, though funny to see some unit rank up in XP because it keeps hitting a unit that gets healed all the time :)

And by having this multiplier, effects/emanations could be added to boost the amount of XP gained!

Zoythrus

  • Guest
Re: Experience-based leveling
« Reply #5 on: 21 December 2011, 17:56:12 »
I like that! It would simple and effective, though funny to see some unit rank up in XP because it keeps hitting a unit that gets healed all the time :)

And by having this multiplier, effects/emanations could be added to boost the amount of XP gained!
exactly!

now, about the part of a guy leveling up because of a guy who wont die, it's much the same way in real life. look at a punching bag, you train by hitting it, not "killing" it. the more you punch on this invulnerable target, you get better and better at punching stuff, even though you arent "killing" it.

lastly, one of the benefits of my method is that you cant "kill steal" by swooping in a guy and finishing off the unit that you've been trying to kill for the last minute.

jda

  • Guest
Re: Experience-based leveling
« Reply #6 on: 21 December 2011, 22:04:57 »
if i may contribute an idea, i've seen some games where units gain experience through merely doing damage to an enemy unit. so, here's what i propose: a unit would acquire the percentage of damage dealt to the the enemy's HP as experience. eg. if a unit dealt an attack that drained 10% of the enemy's health, it would gain 10% of the max amount of XP that the attacked unit has (small damage quabbles would be rounded up, for ease of use). now, this system would always apply, even if the unit in question is healed.

also worth noting, this should also create a new tag for units - "xp-gain" which, in short acts like this: in the previous scenario, if the attacking unit had an <xp-gain value ="2"/> somewhere in his parameters, he would receive 20% of the possible xp. (this tag would default to 1, because it's a multiplier)
I agree this is a better method than the one originally proposed by Omega.
Plus: it can be expanded to:
- Healing/Repairing units: XP based on HP given to the target;
- Harvesters (why not? They could harvest faster on account of levelling up, or have a maximum load increase, whatever...): Amount of resource gathered or, preferably, turned in to a storage building.
This could simply be set per skill (and even have several skills give your unit xp), allowing for other types of abilities that might come up to grant XP as well.

Another thought is you could stop the unit counting damage/repairing/harvesting done once it reached the maximum level, easing CPU load. A single table per game could be setup in this way: count for units 1, 2, 5, 13 and so on (negleting units 3, 6, 7. 8 and so on, because they are not on the master-table).

The whole system sounds simpler, more CPU-time efficient and broader / more flexible.
« Last Edit: 21 December 2011, 22:10:49 by jda »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Experience-based leveling
« Reply #7 on: 22 December 2011, 02:46:18 »
if i may contribute an idea, i've seen some games where units gain experience through merely doing damage to an enemy unit. so, here's what i propose: a unit would acquire the percentage of damage dealt to the the enemy's HP as experience. eg. if a unit dealt an attack that drained 10% of the enemy's health, it would gain 10% of the max amount of XP that the attacked unit has (small damage quabbles would be rounded up, for ease of use). now, this system would always apply, even if the unit in question is healed.

also worth noting, this should also create a new tag for units - "xp-gain" which, in short acts like this: in the previous scenario, if the attacking unit had an <xp-gain value ="2"/> somewhere in his parameters, he would receive 20% of the possible xp. (this tag would default to 1, because it's a multiplier)
Me likes. That would be simpler to implement (get the percentage of damage done (damage dealt divided by max HP) and then multiply that to the specified experience (or max HP if none is specified).

To make sure I understand correctly, the xp-gain tag would multiply the amount of experience the unit should have gained. So if they dealt 100 damage to a unit without specified experience tag (first post; no specified experience tag would have the experience given equal the unit's max HP, so the damage you deal is the experience you get). Being a multiplier, having an xp-gain value of 1 would give you 100 xp, whereas having an xp-gain value of 0.5 would only give you 50 xp, and an xp-gain value of 2 would give you 200. However, then your example is incorrect, as "2" would double the xp, "0.2" would give 20%.

If that is what you mean by the tag, then I question the usefulness of this tag, as you can already control the amount of experience needed for the level. So a unit that needs 3000 xp to gain a level and has an xp-gain value of 0.5 would be the same as a unit that needs 6000 xp to gain that level with an xp gain of 1 (the equivalent of no xp gain).

I'm actually having a hard time putting this into (understandable) words, so some quick examples to the extent of my understanding:
Example One:
Swordman has 700 HP, and no specified experience tag, so the experience from defeating it (entirely) would be 700. An opposing guard attacks the swordman dealing 100 damage. Mathmatically, 100 / 700 * 700 = 100 (that is, damage divided by max HP times the experience value), so the guard got 100 xp from that attack.

Example Two:
Swordman has 700 HP, but has an experience tag with the value of 1000. Thus, defeating it would give 1000 xp. An opposing guard attacks the swordman, dealing 100 damage. Mathmatically, 100 / 700 * 1000 = 143, so the guard got 143 xp from that attack (we'll assume we should always be rounding up, or ceiling, the number).

Example Three:
Archmage has 450 HP, but has an experience tag with a hefty 1500. A guard attacks if for 150 damage. Mathmatically, 150 / 450 * 1500 = 500. The guard took off a third of its health, so it gets a third of the experience from defeating the archmage.

Why the math?
The experience value is the total experience gained from the unit if you were to kill them without them healing at all. So if a swordman is worth 1000 xp, and I kill it (miraculously) in a single hit, I should get 1000 xp from that kill. So if I took off half the unit's HP, I should be getting half of the total xp from killing them, namely 1000. If I took off 10% of its HP, I should be getting 10% of the total xp (that is, 100). So dividing the damage dealt by the total HP gives me the percentage of damage done, which we multiply by the experience value, getting the experience that one blow gave us.

On a side note, the whole concept of granted xp based on damage means that units which have an area of effect attack would be gaining xp a lot faster than normal (whatever your normal is), since they can hit a lot of units, which would have to be taken into aspect by modders.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Zoythrus

  • Guest
Re: Experience-based leveling
« Reply #8 on: 22 December 2011, 06:29:51 »
yeah Omega, that's exactly what i was trying to say. one of the bonuses of this setup is that one way to enhance xp-gain is through attack multipliers. if a unit uses an attack that does double damage to a specific unit, he gets twice as much XP.

and about the problem with splash attacks, just as long as all splashes diminish with range, then things should keep one unit from farming massive amounts of XP.

thank you for agreeing with me, now how soon can we get Silnarm or Hailstone to see this?

lazyanttu

  • Guest
Re: Experience-based leveling
« Reply #9 on: 14 January 2012, 23:09:10 »
Hello again, I have not worked over my mod for almost half year... ::) but during last few days I returned to work on it (it is still badly in progress, the first faction is still incompleted as I faced some nasty balance issues).

I'm not sure if this is too off-topic, but there have been one question in my mind about levelling up. Is it anyhow possible to make units (for example, some sort of hero with special abilities) unlock new abilities as they level. Just as there are unit/upgrade requirements, are there any level requirements? Currently, I have done it in a bit clumsy way. I have set that every level increases the max ep of the unit by 50 (having 50 at level 1, 100 at level 2 and 150 at level 3). The level-2 ability cost more than 50 ep and the level-3 ability cost more than 100 ep. I hope you understand what I mean. However that causes two limitations:
1) Higher level abilities must always cost more ep.
2) Higher level heroes have more ep in their storage. This might be a balance issue in some mods.

Well, my mod's first faction does not have heroes, but I made a scenario where I wanted a hero unit when I first came across this problem. Is it somehow possible to make abilities via levels.

I hope this was not too off-topic ::)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Experience-based leveling
« Reply #10 on: 15 January 2012, 00:11:35 »
No, there's no current way to do so, though you could make a feature request for it. Best to keep the request separate, though.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert