Author Topic: [in wiki now]looting doesn't seem to work on megaglest/ megaglest-git.  (Read 2204 times)

jammyjamjamman

  • Administrator
  • Horseman
  • ********
  • Posts: 210
    • View Profile
I added looting parameters to various units in tower-defense, so that they released resources when killed. One of these units to get looting parameters, was the drone. Both me (and probably) the cpu had resources. However, when I kill the drone unit I don't receive any resources. No errors or warnings are produced by the parameters. Looting just simply appears not to work. amount-percentage and amount-value both have no effect on the unit's properties.

The xml drone script:

Code: [Select]
<?xml version="1.0" standalone="no"?>

<unit>
<parameters>
<size value="2"/>
<height value="1"/>
<max-hp value="1300" regeneration="3"/>
<max-ep value="200" regeneration="1"/>
<armor value="20"/>
<armor-type value="unit"/>
<sight value="15"/>
<time value="200"/>
<max-unit-count value="2"/>
<multi-selection value="true"/>
<cellmap value="false"/>
<levels>
</levels>
<fields>
<field value="air"/>
</fields>
<properties/>
<light enabled="false"/>
<unit-requirements>
</unit-requirements>
<upgrade-requirements>
</upgrade-requirements>
<resource-requirements>
<resource name="stone" amount="25"/>
<resource name="wood" amount="100"/>
<resource name="gold" amount="225"/>
</resource-requirements>
<resources-stored/>
<image path="images/drone.bmp"/>
<image-cancel path="../../icons/cancel.bmp"/>
<meeting-point value="false"/>
<selection-sounds enabled="true">
<sound path="$COMMONDATAPATH/sounds/horseman_select1.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select2.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select3.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select4.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select5.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select6.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select7.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select8.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select9.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select10.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select11.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select12.wav"/>
</selection-sounds>
<command-sounds enabled="true">
<sound path="$COMMONDATAPATH/sounds/horseman_ack1.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack2.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack3.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack4.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack5.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack6.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack7.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack8.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack9.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack10.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack11.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack12.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack13.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack14.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_ack15.wav"/>
</command-sounds>
                <resources-death>
                        <resource name="wood" amount-percentage="5" loss-percentage="1"/>
                        <resource name="gold" amount-value="1000" loss-percentage="1"/>
                        <resource name="stone" amount-percentage="5" loss-percentage="1"/>
                </resources-death>
</parameters>

<skills>

<skill>
<type value="stop"/>
<name value="stop_skill"/>
<ep-cost value="0"/>
<speed value="1000"/>
<anim-speed value="50"/>
<animation path="models/drone.g3d"/>
<particles value="true">
<particle-file path="jet1.xml"/>
<particle-file path="jet2.xml"/>
</particles>
<sound enabled="false"/>
</skill>

<skill>
<type value="attack"/>
<name value="stop_buff_armor"/>
<ep-cost value="100"/>
<speed value="100"/>
<anim-speed value="100"/>
<animation path="models/drone.g3d"/>
<attack-strenght value="0"/>
<attack-var value="0"/>
<attack-range value="8"/>
<attack-type value="attacker"/>
<attack-fields>
<field value="land"/>
</attack-fields>
<attack-start-time value="0"/>
<projectile value="false"/>
<splash value="false"/>
<particles value="true">
<particle-file path="jet1.xml"/>
<particle-file path="jet2.xml"/>
<particle-file path="front_light.xml"/>
</particles>
<sound enabled="false"/>
<attack-boost>
<allow-multiple-boosts value="true" />
<radius value="12" />
<target value="faction" include-self="false"/>
<armor value="100" value-percent-multipler="false" />
<particles value="false"/>
</attack-boost>
</skill>

<skill>
<type value="attack"/>
<name value="stop_buff_dmg"/>
<ep-cost value="100"/>
<speed value="100"/>
<anim-speed value="100"/>
<animation path="models/drone.g3d"/>
<attack-strenght value="0"/>
<attack-var value="0"/>
<attack-range value="8"/>
<attack-type value="attacker"/>
<attack-fields>
<field value="land"/>
</attack-fields>
<attack-start-time value="0"/>
<projectile value="false"/>
<splash value="false"/>
<particles value="true">
<particle-file path="jet1.xml"/>
<particle-file path="jet2.xml"/>
<particle-file path="front_light.xml"/>
</particles>
<sound enabled="false"/>
<attack-boost>
<allow-multiple-boosts value="true" />
<radius value="12" />
<target value="faction" include-self="false"/>
<attack-strenght value="60"/>
<particles value="false"/>
</attack-boost>
</skill>

<skill>
<type value="attack"/>
<name value="stop_buff_range"/>
<ep-cost value="100"/>
<speed value="100"/>
<anim-speed value="100"/>
<animation path="models/drone.g3d"/>
<attack-strenght value="0"/>
<attack-var value="0"/>
<attack-range value="8"/>
<attack-type value="attacker"/>
<attack-fields>
<field value="land"/>
</attack-fields>
<attack-start-time value="0"/>
<projectile value="false"/>
<splash value="false"/>
<particles value="true">
<particle-file path="jet1.xml"/>
<particle-file path="jet2.xml"/>
<particle-file path="front_light.xml"/>
</particles>
<sound enabled="false"/>
<attack-boost>
<allow-multiple-boosts value="true" />
<radius value="12" />
<target value="faction" include-self="false"/>
<attack-range value="4"/>
<particles value="false"/>
</attack-boost>
</skill>

<skill>
<type value="attack"/>
<name value="stop_buff_hp"/>
<ep-cost value="100"/>
<speed value="100"/>
<anim-speed value="100"/>
<animation path="models/drone.g3d"/>
<attack-strenght value="0"/>
<attack-var value="0"/>
<attack-range value="8"/>
<attack-type value="attacker"/>
<attack-fields>
<field value="land"/>
</attack-fields>
<attack-start-time value="0"/>
<projectile value="false"/>
<splash value="false"/>
<particles value="true">
<particle-file path="jet1.xml"/>
<particle-file path="jet2.xml"/>
<particle-file path="front_light.xml"/>
</particles>
<sound enabled="false"/>
<attack-boost>
<allow-multiple-boosts value="true" />
<radius value="12" />
<target value="faction" include-self="false"/>
<max-hp value="400" value-percent-multipler="false" />
<particles value="false"/>
</attack-boost>
</skill>


<skill>
<type value="move"/>
<name value="move_skill"/>
<ep-cost value="0"/>
<speed value="250"/>
<anim-speed value="100"/>
<animation path="models/drone.g3d"/>
<particles value="true">
<particle-file path="jet1.xml"/>
<particle-file path="jet2.xml"/>
</particles>
<sound enabled="true" start-time="0">
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk3.wav"/>
</sound>
</skill>


               
<skill>
<type value="die"/>
<name value="die_skill"/>
<ep-cost value="0"/>
<speed value="60"/>
<anim-speed value="50"/>
<animation path="models/drone.g3d"/>
<particles value="false"/>
<sound enabled="true" start-time="0">
<sound-file path="$COMMONDATAPATH/sounds/horseman_die1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die3.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die4.wav"/>
</sound>
                        <fade value="false"/>
</skill>

</skills>

<commands>

<command>
<type value="stop"/>
<name value="stop"/>
<image path="../../icons/stop.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<stop-skill value="stop_skill"/>
</command>

<command>
<type value="move"/>
<name value="move"/>
<image path="../../icons/move.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
</command>

<command>
<type value="attack"/>
<name value="plus_100_armor"/>
<image path="../../icons/stop.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<attack-skill value="stop_buff_armor"/>
</command>

<command>
<type value="attack"/>
<name value="plus_400_hp"/>
<image path="../../icons/stop.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<attack-skill value="stop_buff_hp"/>
</command>

<command>
<type value="attack"/>
<name value="plus_60_dmg"/>
<image path="../../icons/stop.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<attack-skill value="stop_buff_dmg"/>
</command>

<command>
<type value="attack"/>
<name value="plus_4_range"/>
<image path="../../icons/stop.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<attack-skill value="stop_buff_range"/>
</command>

</commands>
</unit>
« Last Edit: 6 October 2015, 10:05:51 by titi »
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #1 on: 25 September 2015, 14:55:43 »
The first problem is it looks like noone was willing to test/describe this feature in the wiki :-(
Maybe someone( you!? ) can do this ?

see here: https://forum.megaglest.org/index.php?topic=9475.msg91844#msg91844

What exactly would you expect to happen in your example?
« Last Edit: 25 September 2015, 15:05:21 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

jammyjamjamman

  • Administrator
  • Horseman
  • ********
  • Posts: 210
    • View Profile
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #2 on: 28 September 2015, 19:37:34 »
The first problem is it looks like noone was willing to test/describe this feature in the wiki :-(
Maybe someone( you!? ) can do this ?

see here: https://forum.megaglest.org/index.php?topic=9475.msg91844#msg91844

What exactly would you expect to happen in your example?

The cost of the drone is as follows:
Code: [Select]
<resource-requirements><resource name="stone" amount="25"/><resource name="wood" amount="100"/><resource name="gold" amount="225"/></resource-requirements>
the looting or resources-death parameters for the drone are:
Code: [Select]
<resources-death>
\t<resource name="wood" amount-percentage="5" loss-percentage="1"/>
\t<resource name="gold" amount-value="1000" loss-percentage="1"/>
\t<resource name="stone" amount-percentage="5" loss-percentage="1"/>
</resources-death>

Quote from: MikeHoffert link=https://github.com/MegaGlest/megaglest-source/pull/17
    amount-value: An absolute amount to give to the killing unit.
    amount-percentage: Percentage of the killed unit to give to the faction that killed it.
    loss-value: An absolute amount of resources that are removed from the faction of the killed unit.
    loss-percentage: Percentage of the resource that are removed from the faction of the killed unit.
    allow-negative: If true, the faction can go into the negatives if they lose more resources than they have. If false, the resource count won't go below 0.

So when I kill the drone, I expect to gain:
  • 5% of the wood that the drone cost, which is 100*0.05 = 5 wood
  • 5% of the stone that the drone cost, which is 25*0.05 = 1 and a quarter stone => 1 stone (code implies ints are used, so truncation must occur)
  • 1000 gold exactly

The information about looting says that the loss-percentage is the
Quote
Percentage of the resource that are removed from the faction of the killed unit.
, but it doesn't say if the percentage of the drone/ player's resources are taken from the player who owns the drone. Looking at the code:
Code: [Select]
attacked->getFaction()->incResourceAmount(resource.getResourceType(), -(factionTotalResource * resource.getLossPercentage() / 100)) (this is if the resources of the player can go negative), it looks like the percentage of the player's (who owns the drone) store of resources is taken.

this means I also expect the enemy player to lose 1% of their store of wood, gold and stone.

I have not seen any resources gained or lost whenever I've killed the drone/ a drone is killed. If I can get to properly understand how this looting works, I'd be happy to write a wiki for it :) . (also apologies for starting a new topic, I should have just posted at https://forum.megaglest.org/index.php?topic=9475.msg91844#msg91844
)
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2

jammyjamjamman

  • Administrator
  • Horseman
  • ********
  • Posts: 210
    • View Profile
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #3 on: 28 September 2015, 20:18:44 »
**EDIT** it appears that the amount-value/ loss-value work perfectly fine. However, amount-percentage/ loss-percentage don't seem to have any effect.
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #4 on: 29 September 2015, 00:08:53 »
it was made long ago,

There are two things that were discussed back then:

1.
 Is it possible that the percentage is maent for the stored resources in a unit and as they are shared the resources  of the faction ? I think I remember it was like this.
SO for example the blacksmith can store wood. So if this has the percentage tag its meant for the wood of the faction.

2.
percentage of unit cost/price

I don't know which one was implemented, can you try to find out ?
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

jammyjamjamman

  • Administrator
  • Horseman
  • ********
  • Posts: 210
    • View Profile
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #5 on: 30 September 2015, 02:53:25 »
it was made long ago,

There are two things that were discussed back then:

1.
 Is it possible that the percentage is maent for the stored resources in a unit and as they are shared the resources  of the faction ? I think I remember it was like this.
SO for example the blacksmith can store wood. So if this has the percentage tag its meant for the wood of the faction.

2.
percentage of unit cost/price

I don't know which one was implemented, can you try to find out ?

looking at the code:
Code: [Select]
attacked->getFaction()->incResourceAmount(resource.getResourceType(), -(factionTotalResource * resource.getLossFactionPercent() / 100));
Answer 1 is (almost) correct! The
Code: [Select]
loss-percentage is apparently referring to the percentage of the resources stored by the player who owns the unit. However, the unit is not required to be able to store any resources.
For example, if the roman general had this variable, it would be possible to kill the roman general, then a percentage of the resources stored by the player who owns the general would be removed from this player. This can happen even if the general doesn't store any resources on his person.

I eventually did get the percentage variables to work. The documentation left by MikeHoffert was not quite correct. The variables
Code: [Select]
loss-percentage and
Code: [Select]
amount-percentage are invalid variables. Looking once again at the code:
Code: [Select]
if(resourceNode->hasAttribute("faction-amount-percentage")) {
-resource.setAmountPercentage(resourceNode->getAttribute("faction-amount-percentage")->getIntValue());
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2

jammyjamjamman

  • Administrator
  • Horseman
  • ********
  • Posts: 210
    • View Profile
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #6 on: 30 September 2015, 03:16:12 »
it was made long ago,

There are two things that were discussed back then:

1.
 Is it possible that the percentage is maent for the stored resources in a unit and as they are shared the resources  of the faction ? I think I remember it was like this.
SO for example the blacksmith can store wood. So if this has the percentage tag its meant for the wood of the faction.

2.
percentage of unit cost/price

I don't know which one was implemented, can you try to find out ?

After finally getting the percentage variables to work, and by looking at the code:
Code: [Select]
attacked->getFaction()->incResourceAmount(resource.getResourceType(), -(factionTotalResource * resource.getLossPercentage() / 100));it appears that your first answer is (almost) correct! The player who owns this unit has the given percentage of their resources taken away from them when this unit is killed.

However, if we have an example, such as a roman general with the variable <resource name="gold" loss-percentage="5"/>. When the general is killed, the player who owns this unit loses 5% of the gold they currently have stored in total, even though the general does not store any gold on his person.

As mentioned earlier, I got the percentage variables to work. But, I found out that amount-percentage and loss-percentage are not meaningful variables. From once again looking at the code:
Code: [Select]
resource.setAmountFactionPercent(resourceNode->getAttribute("amount-faction-percent")->getIntValue());and
Code: [Select]
resource.setLossFactionPercent(resourceNode->getAttribute("loss-faction-percent")->getIntValue());,
it turned out that the correct variable names are amount-faction-percent and loss-faction-percent.

So afaik, everything is working exactly how it should (barring the 2 incorrect variable names) :D
I'll try to document this on the wiki soon :)
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #7 on: 30 September 2015, 08:18:46 »
Cool! Thank you a lot for your work!
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

jammyjamjamman

  • Administrator
  • Horseman
  • ********
  • Posts: 210
    • View Profile
Re: looting doesn't seem to work on megaglest/ megaglest-git.
« Reply #8 on: 30 September 2015, 17:17:03 »
I've written down what I know about looting in the megaglest wiki docs page. Enjoy :)
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2