Author Topic: [Done] Allow mods to specify a starting HP and EP value  (Read 3633 times)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
[Done] Allow mods to specify a starting HP and EP value
« on: 6 December 2012, 06:24:21 »
Proposed featureAllow a unit's starting (when produced/built) HP and/or EP to be defined by the unit XML.
PurposeThe ability to set the starting EP is by the far the more useful. Currently, all units start with zero EP. This has some balance issues. For example, if you produce a fresh summoner, they won't have enough EP to perform a single attack for a little while. Long enough that producing a summoner in the heat of a battle will result in their death before they can use a single attack, even if the foe is a single archer. Tech doesn't have this issue as it doesn't use EP. Starting a unit with full (or perhaps half) EP would balance that out a bit without being overpowered. Another example is Magic's golem. It requires EP to move, so on production, it takes ten second to move a single step, or over a minute before it can take the maximum 10 steps (closer to 11 with regeneration) in a row. Starting with EP would make using the golem more convenient without overpowering it in any way.

Specifying a starting HP would be a bit different, but could have its uses. Since HP and EP go hand in hand, if we're going to implement a starting EP, may as well do the same for HP. A good use would be for strategical purposes: you could make a building that is built at 4000 HP, but can be fortified (via a slow repair skill) to a higher HP. Or a unit that starts with a set amount of HP, but can be boosted considerably higher by attack boosts (so in other words, is stronger in a group). If MegaGlest gains support for emanations (basically an always on attack boost), they'd be more useful, as you could have a building for the sole purpose of buffing up a unit before battle (but you can do that with a repair skill as well).
ImplementationSuch a feature would be toggled by modder on the max-hp and max-ep tags as an attribute (perhaps called "starting-hp" and "starting-ep" respectively). The input value is an absolute value of the HP or EP, not a percentage. Negative values are not allowed for starting HP or EP. However, provided it's reasonably possible, values greater than the maximum HP/EP should be allowed (as they open up the possibility of a unit only being "healable" to a certain amount or attacks that require so much EP that they can only be used once).

However, since upgrades can change a unit's max HP/EP, having just an absolute value for the starting HP/EP would prevent us from always being able to give the unit full HP/EP. Thus, for values between 0 and 1 (a decimal), the starting HP/EP would be treated as a percentage. So a starting HP value of 0.5 would start with 50% of their max HP, while a starting HP value of 500 would start with 500 HP. The reason we support both absolute values and percentages is that it allows us to give a specific amount of HP/EP or full HP/EP when there is upgrades in place. Assigning a specific amount of EP, for example, could be used to ensure that the unit is capable of attacking once with a special attack that they don't normally have enough EP for.

When a unit is built (with a build skill), it should be built up to this starting HP. To prevent the possibility of the building burning because it's within the "burnable" threshold, perhaps an optional value on the burnable property should be implemented as well, which would allow it to specify when the building starts burning, as an absolute value. Because burnable is specified with a property element instead of an optional element if its own, it may be cleaner to create a new element for burnable, with a value (boolean toggle for whether or not the unit can catch ablaze) and an option starting value (for at what amount of HP will burning begin). Having its own element would be more versatile as the properties element only has a single attribute, but is also used for things other than "burnable". Can be done either way, though.
Additional notesIf this feature is implemented, I proposal that all units in the MegaPack techtree are given starting EP values equal to their max EP (as a percentage).
« Last Edit: 29 July 2014, 04:20:25 by Omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #1 on: 6 December 2012, 18:04:13 »
You could write your own patch for this pretty easily:

add this to unit_type.h:
line 96     int epStart;
line 153   int getEpStart() const                        {return epStart;}

add this to unit_type.cpp:
line 186  epStart = parametersNode->getChild("max-hp")->getAttribute("start-value")->getFloatValue();

add this to unit.cpp:
line 359    
if (type->getEpStart() >= 1) {
    ep = type->getEpStart();
} else if (type->getEpStart() < 1 && type->getEpStart() > 0) {
    ep = type->getEpStart() * type->getMaxHp();
} else {
    ep = 0;
}

The line numbers may very slightly since I used the source from the last stable release I think. You might also have to do something with ItemVault. Presumably thats like the logger functions in GAE.

You don't really have to have any programming knowledge to edit unit stats. Just copy past the XML parser logic and use some if statements.

FreshDumbledore

  • Guard
  • ***
  • Posts: 61
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #2 on: 23 May 2014, 09:48:56 »
bump want to trigger a one time effect, could do it setting start-ep to 1, skill req to 1 and regeneration to 0, cant do it as there is no start-ep tag.

FreshDumbledore

  • Guard
  • ***
  • Posts: 61
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #3 on: 19 June 2014, 11:13:28 »
optional start-ep tag is in the dev version on github now; this thread could be renamed to solved (if an start EP tag is enough, i didnt bother start HP :D)

winchesther

  • Guest
Re: Allow mods to specify a starting HP and EP value
« Reply #4 on: 23 June 2014, 01:33:46 »
Hello, I'm new here. I would like to clarify one doubt. MegaGlest now downloaded the game and commands are only working through the keyboard. How do I go back to using the mouse during play to select items? Thank Sorry my english, I'm from Brazil and speak Portuguese.   :) :) :)

FreshDumbledore

  • Guard
  • ***
  • Posts: 61
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #5 on: 23 June 2014, 06:37:58 »
I dont understand your question and you should start a new thread for it :)

FreshDumbledore

  • Guard
  • ***
  • Posts: 61
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #6 on: 23 June 2014, 09:48:01 »
Omega do you care for start hp? Would not be much work to implement it.

FreshDumbledore

  • Guard
  • ***
  • Posts: 61
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #7 on: 11 July 2014, 21:52:17 »
so, some more words on this:

the current implementation does not keep any upgrades or anything else in minds. its just a fixed value, no percentage, to define the ep a unit starts with.

thats fine enough? speak up ^^

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Allow mods to specify a starting HP and EP value
« Reply #8 on: 18 July 2014, 00:22:56 »
Omega do you care for start hp? Would not be much work to implement it.
I missed this post. I should note that I am not one of the developers of the game (I mostly just manage the forum, wiki, and some miscellaneous web stuff). I keep telling myself that I should contribute, but I'm kind of a snob when it comes to programming style (never liked C++'s disregard for safety and the "older style" of C++ code used in MG).

EDIT: But you know what, I just might take a look into it. I'll be slow though. My C++ is rusty and I'm not familiar with the code base.

EDIT2: I've taken a look, but I got some fucky stuff going on with my distro, so can't build. I'm going to take the cheap route and just install the newer version. Given the size of the download and my shitty internet, this is going to take a while. I'll come back to this. I have a fair idea of how to implement this to fix the issue of upgrades not being taken into account as well as to implement starting HP and percentage based values.

However, I'm thinking it'd be best to use a different attribute for percentage values. My opinion on this has changed since I first created this feature request. I no longer like the idea of one attribute doing two things.
« Last Edit: 18 July 2014, 02:19:59 by Omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

FreshDumbledore

  • Guard
  • ***
  • Posts: 61
    • View Profile
Re: Allow mods to specify a starting HP and EP value
« Reply #9 on: 18 July 2014, 09:34:51 »
Sorry for being unclear, i meant the 'care' like in 'do you care ABOUT ..' :-)
but nice if you took a look yourself ;)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Allow mods to specify a starting HP and EP value
« Reply #10 on: 19 July 2014, 15:08:53 »
I just realized that Tiger's implementation introduced a new tag for start-ep (eg, use <start-ep value="500" /> as a child of the parameters tag).

It's not documented anywhere, and I don't believe it's been released yet (given that the last release was in January). I propose that we instead use arguments of the existing hp and ep tags, eg:

Code: [Select]
<parameters>
    <!-- ... -->
    <max-hp value="500" regeneration="1" start-value="500" />
    <max-ep value="500" regeneration="1" start-percent="0.5" />
    <!-- ... -->
</parameters>

I think this does a better job of putting related values together while being more consistent (why should the starting value be on its own tag if regeneration isn't)?
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Allow mods to specify a starting HP and EP value
« Reply #11 on: 19 July 2014, 17:28:49 »
It's done.
Code: [Select]
[url]Here's the pull request[/url]. Below is the full summary of changes (taken from the pull request):

Quote
The absolute or percentage starting value can now be set for either HP or EP.

Setting the absolute value is done with `start-value`, while setting the percentage is done with start-percentage. Both of these are attributes of the max-hp and max-ep tags (different from Tiger's changes, which had the starting EP a tag of its own).

The starting percentages are always a percentage of the upgraded max value. Thus, if a unit normally has 1000 max HP and an upgrade is in effect that increases its HP by 500, then setting the max hp to have a starting percentage of 0.5 will result in the unit starting with 750 HP (the result of (1000 + 500) * 0.5).

This is particularly useful because the default behavior is to have units start with their max HP, even if they have upgrades that boost HP. Thus, if you want your units to be created with a starting HP equal to their true max HP (with upgrades), set the percentage starting value to 1.0.

Note that `start-value` and `start-percentage` are mutually exclusive. You cannot use both at the same time. Attempting to do so will cause a runtime error.

I have tested various combinations of starting values and percentages with and without upgrades.

Example:

Code: [Select]
<!-- ... -->
<max-hp value="500" start-percentage="1.0" />
<max-ep value="1000" regeneration="5" start-value="500" />
<!-- ... -->

Known issues

  • Setting the starting HP to 0 causes the unit to be immortal. This actually may be a feature.

I wasn't able to make it so that you can start with greater than max HP/EP (a starting boost), as somewhere else in the code seems to be checking that current HP does not exceed max HP. I'll probably look into whether or not that can be feasibly changed (it's pretty common in various games, eg, Deus Ex HR, to be able to temporarily boost above max HP, but can only regenerate up to max HP).

EDIT: As mentioned in the original post, I've Created another pull request for making all units start with full HP and EP. Pull request message:

Quote
This differs in two ways:

  • Units that have upgrades that boost health take effect from that upgrade immediately, instead of having to regenerate the difference.
  • Units with EP start with full EP instead of none. Thus, a newly created mage can head straight into battle instead of having to wait for their EP to regenerate. This may impact balance. On one hand, EP using units were at a disadvantage because of this need to wait. On the other hand, this makes them slightly more potent, off the bat. It shouldn't make a difference when attacking, though, and only a minor difference for defenders.
« Last Edit: 4 April 2016, 08:56:51 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
O a new developer  ;D ...
The EP startValue makes sense for sure. Maybe not to use it directly with MegagGlest data, but in general for other Mods, like the tower defense mod it makes sense.  I personally don't like the idea too much, that the units start with full EP in the MegaPack. As you already mentioned this will change the balance in the MegaPack and I am afraid maybe a bit more then we thought.

About EP boosts and HP boosts there were some discussions lately ( EP discussion was here: https://forum.megaglest.org/index.php?topic=9414.0 )
Another one was about HP boosts. I think HP-boosts don't really make any sense in MegagGlest, as they would have a VERY similar effect like boosting the armor for a while so everything regarding this does not make a lot of sense.

HP start value: I don't really get the need for a HP start value, so can you explain what this should be good for ?

In general: Please try to discuss things first if possible in IRC chat. I also do this a lot and I get many ideas/hints which I did not think about. I myself will also try to reply more to your forum posts now I know there is a chance that you suddenly start working on it.

« Last Edit: 19 July 2014, 23:27:40 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
The EP startValue makes sense for sure. Maybe not to use it directly with MegagGlest data, but in general for other Mods, like the tower defense mod it makes sense.
Good point. I wasn't sure whether or not to include the EP start value change. Perhaps just the HP fix (which ensures units start with full HP, including upgrades) should be used for now. The EP change would likely need balance testing.

My main reason for including it was because I find it very frustrating if Magic is attacked and needs to spit out emergency units. The units are created and cannot immediately attack (which Tech's units can). In fact, magic doesn't really have *any* way to immediately attack after their units are created. The EP still serves the purpose of preventing the unit from attacking too often.

I think HP-boosts don't really make any sense in MegagGlest, as they would have a VERY similar effect like boosting the armor for a while so everything regarding this does not make a lot of sense.
Good point. I'm not going to bother looking for a way to boost stats above the max (at least not at the moment).

HP start value: I don't really get the need for a HP start value, so can you explain what this should be good for ?
Above all, it allows us to fix the issue that units spawn with their "default" max HP. Upgrades to the max HP are not included. So if a unit normally has 1000 max HP and an upgraded boosts that to 1500, then they spawn with 1000/1500. This seems unintended. Also, if the unit has no HP regen, it can't actually access its max HP. It's also useful for mods that may want to force the unit to regenerate itself to max HP (eg, a unit that starts weak by spawning with low HP, but gets stronger over time as its HP slowly regenerates).

In general: Please try to discuss things first if possible in IRC chat. I also do this a lot and I get many ideas/hints which I did not think about. I myself will also try to reply more to your forum posts now I know there is a chance that you suddenly start working on it.
Sure, great.
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
This is in develop branch now for some days, anyone tested this already ?

If you don't know how to compile for yourself, here you can find test binary/exe files http://snapshots.megaglest.org/
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

 

anything