Author Topic: [done] Looting  (Read 3565 times)

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
[done] Looting
« on: 25 March 2014, 20:38:47 »
I was surprised to hear this doesn't exist yet, since it's a rather basic feature and needed for many ideas. If it's not too difficult, please consider adding it soon!

I'd like a new function in the faction XML to specify a list of resources that destroying an unit will give the attacker. If a value is specified, that amount of the resource is given, whereas specifying a percentage gives that amount from what the faction which owns it has. If specifying a negative value, the attacker would actually lose that resource when destroying an enemy building, although that would make little sense. A flag should specify if to also deduct that amount from the owner faction and how much, or if to just make those resources appear to the attacker. If the attacking faction does not use the resource or have where to store it, there's no effect. The function I have in mind would be something like this:

Code: [Select]
<resources-death><resource name, amount, loss/></resources-death>
Example 1: A faction has a building which can be looted of half of the resources it was build with. It costs 100 gold and 50 stone to build. When it comes to the gold, the owning faction will also lose half of what's being looted. Also, 5% of the faction's entire wood stock will be taken away entirely. The code would be:

Code: [Select]
<resources-death>
<resource name="gold" amount="50" loss="50%"/>
<resource name="stone" amount="25" loss="0%"/>
<resource name="wood" amount="5%" loss="100%"/>
</resources-death>

Example 2: The attacking faction uses an unique resource called X, which is optional and can only be extracted by destroying a certain building from another faction. That faction however doesn't use the X resource in any way itself. Implicitly, the resource can only be obtained if the attacker is playing against this faction so they have the building to destroy. The victim faction's building would have this code:

Code: [Select]
<resources-death>
<resource name="X" amount="50" loss="0%"/>
</resources-death>

Before anyone asks, yes, I'm aware this is already possible in Lua for scenarios. To properly do it as part of a faction however, it must also be possible within the XML files of units, otherwise it will not be consistent and won't work in normal battles.
« Last Edit: 6 October 2015, 10:19:05 by titi »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Looting
« Reply #1 on: 25 March 2014, 22:15:49 »
Good idea. However, the use of percentage signs is very inconsistent with the rest of the XMLs. Rather, we should be using a probability (ie, a number between 0.0 and 1.0) to represent percentages.

To do so in a reasonable manner, we'd need an additional parameter. Probably separate parameters for absolute numbers vs percentages.

Eg,

Code: [Select]
<!-- Get 50 children's tears and the player who just lost their unit loses 50 -->
<resource name="children's_tears" amount="50" loss="50" />

<!-- Get 500% of the faction's stock of printer_ink, but they only actually lose 50% of their stock -->
<!-- If this was real life, you'd be a billionaire overnight. This stuff's like unicorn blood -->
<resource name="printer_ink" amount-percentage="5.0" loss-percentage="0.5" />

The last example is slightly different from your proposal. Instead of loss-percentage defining how much the opponent loses as a percentage of what we took, it defines how much the opponent loses as a percentage of their total. Thus, if we want to take 5% of the opponents resource and they lose all of that 5%, we'd simply set amount-percentage and loss-percentage both to be 0.05.
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Looting
« Reply #2 on: 26 March 2014, 02:51:30 »
Makes sense. The percentages aren't a feature I care very much about, I only mentioned them because they might be helpful and I remember seeing them in other XML functions. The part I consider really important is adding an XML function to units so they can give the attacker which destroys them a certain amount of resources... allowing for looting or harvesting your enemies (sometimes for unique resources).

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Looting
« Reply #3 on: 26 March 2014, 23:07:22 »
This would all a whole new level of depth to the game. It would be an exciting new feature to play with.
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Looting
« Reply #4 on: 19 July 2014, 23:11:20 »
Done! See the pull request for details.

EDIT: Gah, I have some minor compilation errors that appear to be platform dependent (no errors in my build). I'll try and get these fixed, but it's gonna be a pain in the ass when I'm not getting the errors locally (TravisCI takes like 10 minutes to let me know if the build passed).

EDIT2: Fixed. Turns out Windows overrides a standard library function with a macro somewhere in its headers (which are presumably included by some library).
« Last Edit: 20 July 2014, 00:19:39 by Omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: [Awaiting pull] Looting
« Reply #5 on: 19 July 2014, 23:27:21 »
Awesome! Thank you for adding this great feature... it will likely be a lot of fun :O

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: [Awaiting pull] Looting
« Reply #6 on: 20 July 2014, 01:59:53 »
Titi, the "issue" of looting faction specific resources that I mentioned in the IRC is actually non-existent. There's no issues here. The resources are correctly ignored and are not displayed. It turns out I was modified the wrong part of the XML when editing it (creating a resource requirement instead). As far as I can tell, there's no issues with this change. I also played a full game to make sure that the AI wouldn't go wonky or anything.

As we discussed, all percentages are now integers (also applies to the starting HP/EP change). This is done in hopes of avoiding possible multiplayer out of sync errors caused by clients calculating floating point numbers in different ways.
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Re: [Awaiting pull] Looting
« Reply #7 on: 28 July 2014, 00:33:36 »
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

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: [Done] Looting
« Reply #8 on: 2 August 2014, 18:36:36 »
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/

Will test asap!
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Re: [Done] Looting
« Reply #9 on: 19 May 2015, 08:59:35 »
Anyone tested this yet and is willing to add this in the Wiki ? ( the change was this: https://github.com/MegaGlest/megaglest-source/commit/082f3472ee2f4e58cd1379030dfacdafd5682e23)
and more Details here: https://github.com/MegaGlest/megaglest-source/pull/17
« Last Edit: 19 May 2015, 09:05:48 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios