ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.58k stars 359 forks source link

Hotkeys for moving armies between heroes/castle garrison #4084

Open a1exsh opened 2 years ago

a1exsh commented 2 years ago

Preliminary checks

Describe the problem requiring a solution

One of the annoying parts of the original game is the necessity to manually move each army unit bought in a castle or town to the hero army troops. This requires a lot of clicking and makes the process rather boring.

Describe the possible solution

Newer games in the series (esp. Heroes IV and V) have introduced hotkeys (space, up, down) for solving this issue that we could also use.

I see the following possible setups and propose the following workflows:

  1. A hero and a guardian in a castle:

    • Swap heroes and their armies (unchanged) using space key. This just adds a hotkey for the existing functionality.

    • Move all units from the visiting hero to the guardian using up key. The existing logic from the "meeting heroes" can be used.

    • Move all units from the guardian to the visiting hero using down key. Same logic can be used.

  2. A hero visiting a castle (no active guardian):

    • Make hero a guardian of the castle using space key. Any existing troops in the castle will join hero's army, but the check needs to be made first that all troops will fit, and otherwise — the move should be rejected. This logic already exists, so just a hotkey needs to be added.

    • Move (almost) all units from the visiting hero to the castle using up key. The hero needs to keep at least one troop. Logic exists.

    • Move all units from the castle to the visiting hero using down key.

  3. There is only a guardian in the castle:

    • The guardian may leave the castle together with the army using space key. Just adding a hotkey here as well.
  4. No heroes in the castle: no army can be moved.

Additional info

No response

zenseii commented 2 years ago

I've been wanting this change myself lately since I'm too used to having such a hotkey from the other games and it would hugely improve QoL while playing.

Two notes about the above ideas:

  1. A hero can only be a visitor in a castle, not a guardian, in Heroes 2. This should simplify some of the work needed since you wouldn't need to "move" a hero.

  2. A guardian in a castle garrison can only be a Captain from the Captain's Quarters and this Captain can never leave the garrison - just as a reminder.

a1exsh commented 2 years ago

A hero can only be a visitor in a castle, not a guardian

Castle guardians is an experimental setting in fheroes2 — you need to enable it before starting a new game. ;)

zenseii commented 2 years ago

A hero can only be a visitor in a castle, not a guardian

Castle guardians is an experimental setting in fheroes2 — you need to enable it before starting a new game. ;)

Right! I never use experimental options so I didn't know. In that case I figure what you said should be a possibility, especially if it's an option people actually use.

LeHerosInconnu commented 2 years ago

Related discussion: https://github.com/ihhub/fheroes2/discussions/5432.

zenseii commented 2 years ago

I'm currently looking into this one @LeHerosInconnu, and I've read your suggestions and will keep them in mind.

Also rest assured that I'm also putting a lot of effort into facilitating it for users who only use the mouse. Incidentally, this is also beneficial for players on platforms with only touch input.

Hotkeys will naturally be in place as described by @a1exsh above, since I'm personally of that camp of players. I'll use the exact keys mentioned above, but they will nevertheless be remappable just as all other keys are.

EDIT: My concept is this basically: Keep it as simple as possible - Use the click-and-drag motion down/up from where the captain/heroes portraits are since we already have this way of input present in the engine, which will maintain a consistent system of control and input. Therefore we drop the use of those arrow icons that you mention in the discussion all together.

The reasons are that their functions can easily be accomplished with such simple inputs, they are not very esthetically pleasing, too small for users on something like a smartphone and even for someone using a mouse they will inevitably often lead to misclicks, especially with such close placement as you suggested (and this could send the player straight to the hero screen which is a very annoying detour).

There's also the fact that adding those buttons means we have to do the extra work of implementing a pressed state for each of them which is inefficient use of dev time in my opinion.

We only need two actions: Move and merge entire army down, and swap armies. Both of these can be accomplished with click-and-drag. Moving the entire army up from a hero into the garrison is something you very rarely do from my own experience and so its implementation can be less quick and snappy than the two actions I mentioned first.

As for when guardians are enabled, they can just keep those buttons since it's an experiemental option anyways. I don't think it's necessary to spend much extra time for this case as of now.

EDIT2: Actually I have a better solution than the one proposed above. I'll explain it once I post the PR then we can continue the discussion from that point onwards.

LeHerosInconnu commented 2 years ago

Hello @zenseii,

The use of the buttons is also an indication to the player that actions are possible.

Everything could eventually be done with click and drag. For example:

Switch heroes (with their respective armies): Click and hold on the portrait of one of the two heroes, move the mouse cursor to the portrait of the other hero, release the mouse button. Clic and drag castle window 02 Clic and drag castle window 03

Initiate a meeting with the two heroes: Click and hold on the portrait of one of the two heroes, move the mouse cursor to the portrait of the other hero, without releasing move the mouse cursor back to the portrait of the first hero, release the mouse button. Clic and drag castle window 04 Clic and drag castle window 05

Move the visiting army to the garrisoned army: Click and hold on any of the graphics of one of the troops in the visiting army, move the mouse cursor to the location corresponding to the portrait of the garrisoned hero (can be the captain, or without hero and captain), release the mouse button. Clic and drag castle window 06

Move the garrisoned army to the visiting army: Click and hold on any of the graphics of one of the troops in the garrisoned army, move the mouse cursor to the portrait of the visiting hero, release the mouse button. Clic and drag castle window 07

Switch armies: Click and hold on any of the graphics of one of the troops of the garrisoned army, move the mouse cursor to the location corresponding to the portrait of the garrisoned hero (can be the captain, or without hero and captain), without releasing move the mouse cursor to the portrait of the visiting hero, release the mouse button. Clic and drag castle window 08

Or. Click and hold on any of the graphics of one of the troops of the visiting army, move the mouse cursor to the portrait of the visiting hero, without releasing move the mouse cursor to the location corresponding to the portrait of the garrisoned hero (can be the captain, or without hero and captain), release the mouse button. Clic and drag castle window 09

One of the problems with click and drag is that the user has to memorize the different ways to proceed for each different action.

I think that if it would be possible for the player to choose the buttons or the click and drag it would be ideal (and also depending on the possibilities of the hardware used to play the game).

There's also the fact that adding those buttons means we have to do the extra work of implementing a pressed state for each of them which is inefficient use of dev time in my opinion.

A simple way to do this (for this case or for the case of other buttons in the future) is to change the background color of the button (or possibly to "invert" the color of the graphic used (when the graphic is simple)).

We only need two actions: Move and merge entire army down, and swap armies. Both of these can be accomplished with click-and-drag. Moving the entire army up from a hero into the garrison is something you very rarely do from my own experience and so its implementation can be less quick and snappy than the two actions I mentioned first.

I frequently transfer the visiting hero's army to the garrison (keeping the fastest troop in the army) so that the hero has more movement the next turn. :)

As for when guardians are enabled, they can just keep those buttons since it's an experiemental option anyways. I don't think it's necessary to spend much extra time for this case as of now.

I think the interface should be standardized, either the buttons or the use of click and drag, so as not to confuse the user (part of the actions with buttons only, and part of the actions with click and drag only).

Edit:

EDIT2: Actually I have a better solution than the one proposed above. I'll explain it once I post the PR then we can take the discussion from there.

I'm looking forward to it. :rofl:

shprotru commented 2 years ago

these changes should take into account the possibility of buying a spell book.

zenseii commented 2 years ago

these changes should take into account the possibility of buying a spell book.

I'm not sure I understand what you are referring to @shprotru?

shprotru commented 2 years ago

@zenseii I mean, how should work buying of a spell book in the mage guild, when:

zenseii commented 2 years ago

@zenseii I mean, how should work buying of a spell book in the mage guild, when:

  • both heroes in castle haven't spell book.
  • one of a hero in castle haven't spell book.

This isn't really relevant to this issue as far as I can understand, but the code is already in place for this: If both heroes lack a spell book, then two dialogs will appear - one for each with the Hero's name as the dialog header. image

Note that in this PR I'm not adding the possibility to have Hero guardians in castles, that possibility already exists in the experiemental options.

Branikolog commented 2 years ago

Hi, guys! I mostly agree with @zenseii: making a ton of buttons into this screen makes the game look not so pleasant, turning it into some sort of excel table. :) Not so user-friendly. At the same time, such complex drag-n-drop mechanics could be not obvious for players. So I hardly can imagine any ideal solution here. Probably, a full rearrangement of the GUI will be a solution here: place some nice and easy-to-point well drawn buttons somewhere close to portraits. But this would be applied only on bigger screens. For now and up to the 1.0 release, we can add click+hotkey and simple drag-n-drop, as the majority of players are got used to such behaviour. That's my opinion.

LeHerosInconnu commented 2 years ago

Hello @zenseii and @Branikolog,

There could be a single, fairly unobtrusive button that opens a window with larger buttons to perform all possible actions. The size of this window and its buttons could also possibly be adjusted accordingly to the resolution used.

zenseii commented 2 years ago

Hello @zenseii and @Branikolog,

There could be a single, fairly unobtrusive button that opens a window with larger buttons to perform all possible actions. The size of this window and its buttons could also possibly be adjusted accordingly to the resolution used.

I've already discussed with @ihhub that we will implement object drag and dropping, like imagine dragging the heroes portraits or dragging all icons of all monsters in an army. I have to finish the current PR before I can start looking at that though.

I will need both of your feedbacks later when it comes to merging/moving an army and how to prioritize what creatures to move and what actions to take if there is not room for all or if you need a hero to be left with at least one creature. For example should we make it so that a hero that all creatures are moved from will be left with only 1 of the weakest creatures in the hero's army or is that exagerated and not always preferable? Right now the hero is left with 1 of whatever creature is found in the rightmost creature slot.

LeHerosInconnu commented 2 years ago

Hello @zenseii,

Hello @zenseii and @Branikolog, There could be a single, fairly unobtrusive button that opens a window with larger buttons to perform all possible actions. The size of this window and its buttons could also possibly be adjusted accordingly to the resolution used.

I've already discussed with @ihhub that we will implement object drag and dropping, like imagine dragging the heroes portraits or dragging all icons of all monsters in an army. I have to finish the current PR before I can start looking at that though.

Okay.

For example should we make it so that a hero that all creatures are moved from will be left with only 1 of the weakest creatures in the hero's army or is that exagerated and not always preferable? Right now the hero is left with 1 of whatever creature is found in the rightmost creature slot.

For my part, and for many players I've seen on video, it's best to leave one of the weaker creatures among the faster ones. For example, between a greater druid and a great elf, the great elf is kept in the army, between a minotaur king and a gargoyle, the gargoyle is kept in the army. This is to always give the most movement points for the secondary hero.

zenseii commented 2 years ago

For my part, and for many players I've seen on video, it's best to leave one of the weaker creatures among the faster ones. For example, between a greater druid and a great elf, the great elf is kept in the army, between a minotaur king and a gargoyle, the gargoyle is kept in the army. This is to always give the most movement points for the secondary hero.

Hi @LeHerosInconnu. It is a good point, however I want to point out that in your examples just leaving the lowest tier creature would be get the same result.

I agree that you would want the hero with a faster creature to prioritize movement. I imagine this logic will not be clear to many players because most players I've seen have no idea that movement points for the Hero is in part determined by the speed of the slowest creature, but this is more an issue of explanation of game mechanics and in a perfect world all players would know this and would be happy to be left with one grand elf instead of one sprite.

But I want to stress that the logic needs to be clear and also always valid, which is why something like always leaving the rightmost creature is a predictable logic for all players.

And again leaving a hero with the lowest tier creature might also be what many players want if they intend to gather all their strongest troops on one hero and let the other one go and rest in a castle or just camp somewhere not to be used to walk around. The more I think about this the more I'm convinced that there is not one solution that fits all...

LeHerosInconnu commented 2 years ago

@zenseii.

For my part, and for many players I've seen on video, it's best to leave one of the weaker creatures among the faster ones. For example, between a greater druid and a great elf, the great elf is kept in the army, between a minotaur king and a gargoyle, the gargoyle is kept in the army. This is to always give the most movement points for the secondary hero.

Hi @LeHerosInconnu. It is a good point, however I want to point out that in your examples just leaving the lowest tier creature would be get the same result.

Here is another example, between a power lich, a bone dragon, and a royal mummy, the power lich is kept in the army. :)

I agree that you would want the hero with a faster creature to prioritize movement. I imagine this logic will not be clear to many players because most players I've seen have no idea that movement points for the Hero is in part determined by the speed of the slowest creature, but this is more an issue of explanation of game mechanics and in a perfect world all players would know this and would be happy to be left with one grand elf instead of one sprite.

These are fairly experienced players who keep a quick troop in the secondary hero's army. This would be an opportunity to make sure that even the most novice players get this benefit, even if they don't realize it yet. :)

But I want to stress that the logic needs to be clear and also always valid, which is why something like always leaving the rightmost creature is a predictable logic for all players.

I've seen not-so-experienced players who don't even care about the placement of troops within the hero's army. This ends up with a few grand elves in the leftmost slot of the hero's army, the rest of the army also disordered, and five titans in the rightmost slot of the hero's army. The few grand elves end up playing first and do ridiculous damage while the titans could have done much more damage if they had played first.

So with the above rule, it would be a titan, which is in the rightmost slot of the hero's army, that would be the creature kept in the secondary hero's army, when it could (should) have been a grand elf. Again, with a benefit without the inexperienced player having to worry about it.

And again leaving a hero with the lowest tier creature might also be what many players want if they intend to gather all their strongest troops on one hero and let the other one go and rest in a castle or just camp somewhere not to be used to walk around. The more I think about this the more I'm convinced that there is not one solution that fits all...

I had made a proposal about this so that the troop that is kept can be selected based on a setting, depending on how the player plays.

For example: Keep one creature from the weakest of the fastest creatures. Keep one of the weakest creatures (can be based on the combat value of the troop). Etc.

Edit.

I have found the post with the proposal of the "speed" and "power" setting:

@Branikolog and @ihhub.

the fastest (in priority) AND the weakest.

This means that if two troops are composed of a creature of the same speed the weaker one should be kept.

Here's another, and the most common case: image Do we need to leave fast Liches, rather than skeletons in barbarian Atlas' army? Definitely not.

It depends on the goal, if afterwards Atlas should be as mobile as possible or not, or if Rebbecca should be as powerful as possible or not.

For the selection of the creature/troop to keep, I made an enhancement proposal in this way here: #3742. :)

I definitely agree with your proposal here. I'm sorry I forgot about your thread. My idea 100% coincides with your proposal. :)

Yes. No worries. :)

I feel we have to make it as a discussion as I don't see that we cover 100% of cases with your proposed logic and for players it's not obvious.

I think it is not possible to cover 100% of the cases.

As I said, generally the player wants the secondary hero to have as much mobility as possible. The main hero is there principally to combat, so his army should be strong even if he is a little less mobile. But the main hero, may have to stay very mobile when he is not in a combat situation. It is therefore complicated to determine the player's goal when he transfers his armies between heroes.

So you would have to make a choice in the default action, either to focus on the hero's movement speed, or to focus on the power of the hero's army.

This can eventually be set in the fheroes2.cfg file: "# meeting troops transfer: 1 - 2 (1 for hero speed - 2 for hero power)"

Originally posted by @LeHerosInconnu in https://github.com/ihhub/fheroes2/discussions/4396#discussioncomment-1464406

Branikolog commented 2 years ago

@LeHerosInconnu , @zenseii What if we implement additional and more flexible approach here, when player selects, for instance, the creature he wants to leave, and then proceed with transferring by drag-drop, and this stack will be the last one, that would be transferred, leaving 1 troop (or the whole stack in a case there's not enough room)?

LeHerosInconnu commented 2 years ago

@Branikolog and @zenseii.

@LeHerosInconnu , @zenseii What if we implement additional and more flexible approach here, when player selects, for instance, the creature he wants to leave, and then proceed with transferring by drag-drop, and this stack will be the last one, that would be transferred, leaving 1 troop (or the whole stack in a case there's not enough room)?

Why not. I made a similar proposal for the Heroes Meeting screen here: https://github.com/ihhub/fheroes2/discussions/3742. :)

zenseii commented 2 years ago

@LeHerosInconnu , @zenseii What if we implement additional and more flexible approach here, when player selects, for instance, the creature he wants to leave, and then proceed with transferring by drag-drop, and this stack will be the last one, that would be transferred, leaving 1 troop (or the whole stack in a case there's not enough room)?

I think this is simple enough that it works and there would be some visual feedback to the player so that they better understand what is going on. I will see if I can implement such a thing since it would solve @LeHerosInconnu's dilemma in a more elegant way than giving more options for a player to have to think about.

Also, even though we've decided against this, I just want to note that there would be another problem for prioritizing keeping the fastest creatures when you have creatures of equal speed. And I'm afraid if we being to take into account too many factors we eventually make a simple move logic into a complete optimization of the army formation for a player, which would be overkill.

On a different note, if a player clicks on an empty slot when dragging and dropping they will get the simple move all and leave the right-most troop with one unit.

LeHerosInconnu commented 2 years ago

@zenseii.

Also, even though we've decided against this, I just want to note that there would be another problem for prioritizing keeping the fastest creatures when you have creatures of equal speed. And I'm afraid if we being to take into account too many factors we eventually make a simple move logic into a complete optimization of the army formation for a player, which would be overkill.

If the goal is to keep the fastest creature (so not the strongest creature), and two creatures have the same speed, the weaker of the two is kept in the secondary hero's army (same if there are three creatures with the same speed, etc.). I don't really see the problem, the rule is simple.

On a different note, if a player clicks on an empty slot when dragging and dropping they will get the simple move all and leave the right-most troop with one unit.

I find this logic too arbitrary and without any real "strategic" reasoning.

zenseii commented 2 years ago

If the goal is to keep the fastest creature (so not the strongest creature), and two creatures have the same speed, the weaker of the two is kept in the secondary hero's army (same if there are three creatures with the same speed, etc.). I don't really see the problem, the rule is simple.

And what if the weaker creature is prefered due to it sharing race with all the other creatures and this is better for morale, or a skeleton is faster than dwarves and archers but gives undead penalty? :P I think we need to draw the line at some point and just accept the fact that players will have to use their brain to make a few extra clicks. The main goal of the move command is to reduce the amount of necessary clicks/inputs from the player, but that doesn't mean taking away a part of the gameplay where you decide what troop is best in a certain situation. It is tough to balance this.

I find this logic too arbitrary and without any real "strategic" reasoning.

My general idea is this: move should be a predictable action that moves/merges troops. If a player has no idea about how to best organize their army then that is their problem. The move action should not take away the part of the gameplay where you decide what formation to have your troops in, whether that's a good or a horrible formation. But your point is in the gray zone of this, so the more simple strategic choice would be to leave a single creature according to some absolute simple comparison like tier/speed/attack/hp etc..

"Weakest" and "strongest" are very vague terms in HoMM 2 when you could acheive more with a single sprite than with a single dwarf if up against ranged armies as a basic example. Tier, highest speed, most HP, highest attack etc. are easy comparisons, even in the case of equals.

I think simple and predictable for the majority of the experienced players is what the move command should strive to be. I don't want an experienced player to perform the move command and afterwards sit there and wonder "Why did the game choose this on my behalf?".

Branikolog commented 2 years ago

I mostly agree with @zenseii In my opinion, default moving of all troops will never satisfy all players' needs. On the other hand, I find current implementation of transferring buttons in meeting hero window (which are the same we're discussing here) not very comfortable since the moment they were added into engine. I'm still not used to this logic. The logic is obvious, but it requires rearrangement of troops in the majority of cases. So I prefer leaving the weakest or the fastest troop more. While fastest could be not obvious to the majority of players, I think leaving the weakest is the case everyone understands and the majority of players used to keep exactly the weakest creature, while transferring. All other cases could be handled with select+transfer logic I've described before.

zenseii commented 2 years ago

Thank you for your input @LeHerosInconnu and @Branikolog!

I believe we have found a very simple and useable solution to this and it will definitely improve on the current implementation! Right now I have done most of the work fixing it, but I need to address the logic of leaving one troop and then later on the logic of preservering one unit of the selected troop. You'll have to excuse me if this will take some time to figure out, not to mention optimize.

I look forward to your feedback when it is ready for you to test it.

(I've also peeked at how this works in other later Heroes games and ours will be much better...)

LeHerosInconnu commented 2 years ago

@zenseii.

If the goal is to keep the fastest creature (so not the strongest creature), and two creatures have the same speed, the weaker of the two is kept in the secondary hero's army (same if there are three creatures with the same speed, etc.). I don't really see the problem, the rule is simple.

And what if the weaker creature is prefered due to it sharing race with all the other creatures and this is better for morale, or a skeleton is faster than dwarves and archers but gives undead penalty? :P I think we need to draw the line at some point and just accept the fact that players will have to use their brain to make a few extra clicks. The main goal of the move command is to reduce the amount of necessary clicks/inputs from the player, but that doesn't mean taking away a part of the gameplay where you decide what troop is best in a certain situation. It is tough to balance this.

The reference "to draw the line" is the combat value of the creature. For two creatures of the same speed, the weaker one (in relation to the combat value, all other criteria are ignored) is the one that is kept in the secondary hero's army.

Yes, there is no question here of reorganizing the player's army. The player initiates the action, the troops are exchanged according to the rules, the player adjusts the result with a few clicks, as you said, to perfect the reorganization of the armies.

Here you can see a representation of the ranking of creatures according to their combat value from peasant to black dragon:


Hello everyone,

Hi @eos428 , I don't know the exact formula for campaign score calculation.

@LeHerosInconnu, could you please help to clarify this?

I think that only the number of days is taken into account for the campaigns. The correspondences are indicated here:

Hello @oleg-derevenetz,

That's because here:

https://github.com/ihhub/fheroes2/blob/849fcf7b9e295f176a3f567e968f7712125f2ca7/src/fheroes2/game/game.cpp#L472

is assumed that nk never exceed 200, but in your case it is 264, so we get a negative number which then turns into unsigned. @Branikolog @LeHerosInconnu does anyone know the correct formula?

Maybe this can help you:

Hello @ihhub,

Hi @LeHerosInconnu , do you know the formula for displaying creatures in this window?

dahbk did it!

It's not really a "formula", but the list of creature correspondence according to the "Rating" for "Scenario", and to the number of "Days" for "Campaign".

https://www.gog.com/forum/heroes_of_might_and_magic_series/homm2_rating_corresponding_creatures

I didn't check for all the scores, but it matches the scores I did. I think that should be correct. :)

Scenario.

"Rating", Monster: 0 Peasant 1 Peasant 2 Peasant 3 Peasant 4 Goblin 5 Goblin 6 Goblin 7 Goblin 8 Sprite 9 Sprite 10 Sprite 11 Sprite 12 Halfling 13 Halfling 14 Halfling 15 Halfling 16 Centaur 17 Centaur 18 Centaur 19 Centaur 20 Rogue 21 Rogue 22 Rogue 23 Rogue 24 Skeleton 25 Skeleton 26 Skeleton 27 Skeleton 28 Orc 29 Orc 30 Orc 31 Orc 32 Zombie 33 Zombie 34 Zombie 35 Zombie 36 Archer 37 Archer 38 Archer 39 Archer 40 Ranger 41 Ranger 42 Ranger 43 Ranger 44 Boar 45 Boar 46 Boar 47 Boar 48 Dwarf 49 Dwarf 50 Dwarf 51 Dwarf 52 Mutant zombie 53 Mutant zombie 54 Mutant zombie 55 Mutant zombie 56 Orc Chieftain 57 Orc Chieftain 58 Orc Chieftain 59 Orc Chieftain 60 Elf 61 Elf 62 Elf 63 Elf 64 Gargoyle 65 Gargoyle 66 Gargoyle 67 Gargoyle 68 Pikeman 69 Pikeman 70 Pikeman 71 Pikeman 72 Grand Elf 73 Grand Elf 74 Grand Elf 75 Grand Elf 76 Battle Dwarf 77 Battle Dwarf 78 Battle Dwarf 79 Battle Dwarf 80 Nomad 81 Nomad 82 Nomad 83 Nomad 84 Veteran Pikeman 85 Veteran Pikeman 86 Veteran Pikeman 87 Veteran Pikeman 88 Wolf 89 Wolf 90 Wolf 91 Wolf 92 Mummy 93 Mummy 94 Mummy 95 Mummy 96 Iron Golem 97 Iron Golem 98 Iron Golem 99 Iron Golem 100 Royal Mummy 101 Royal Mummy 102 Royal Mummy 103 Royal Mummy 104 Ogre 105 Ogre 106 Ogre 107 Ogre 108 Griffin 109 Griffin 110 Griffin 111 Griffin 112 Swordsman 113 Swordsman 114 Swordsman 115 Swordsman 116 Druid 117 Druid 118 Druid 119 Druid 120 Steel Golem 121 Steel Golem 122 Steel Golem 123 Steel Golem 124 Master Swordsman 125 Master Swordsman 126 Master Swordsman 127 Master Swordsman 128 Air Elemental 129 Air Elemental 130 Air Elemental 131 Air Elemental 132 Greater Druid 133 Greater Druid 134 Greater Druid 135 Fire Elemental 136 Fire Elemental 137 Fire Elemental 138 Ghost 139 Ghost 140 Ghost 141 Vampire 142 Vampire 143 Vampire 144 Water Elemental 145 Water Elemental 146 Water Elemental 147 Earth Elemental 148 Earth Elemental 149 Earth Elemental 150 Roc 151 Roc 152 Roc 153 Minotaur 154 Minotaur 155 Minotaur 156 Cavalry 157 Cavalry 158 Cavalry 159 Troll 160 Troll 161 Troll 162 Mage 163 Mage 164 Mage 165 Medusa 166 Medusa 167 Medusa 168 Lich 169 Lich 170 Lich 171 Ogre Lord 172 Ogre Lord 173 Ogre Lord 174 Minotaur King 175 Minotaur King 176 Minotaur King 177 Champion 178 Champion 179 Champion 180 War Troll 181 War Troll 182 War Troll 183 Vampire Lord 184 Vampire Lord 185 Vampire Lord 186 Archmage 187 Archmage 188 Archmage 189 Power Lich 190 Power Lich 191 Power Lich 192 Unicorn 193 Unicorn 194 Unicorn 195 Hydra 196 Hydra 197 Hydra 198 Paladin 199 Paladin 200 Paladin 201 Genie 202 Genie 203 Genie 204 Crusader 205 Crusader 206 Crusader 207 Cyclops 208 Cyclops 209 Cyclops 210 Giant 211 Giant 212 Giant 213 Phoenix 214 Phoenix 215 Phoenix 216 Bone Dragon 217 Bone Dragon 218 Bone Dragon 219 Green Dragon 220 Green Dragon 221 Green Dragon 222 Red Dragon 223 Red Dragon 224 Red Dragon 225 Titan 226 Titan 227 Titan 228 Black Dragon

Campaign.

"Days", Monster: 0-300 Black Dragon 301-320 Titan 321-340 Red Dragon 341-360 Green Dragon 361-380 Bone Dragon 381-400 Phoenix 401-420 Giant 421-440 Cyclopse 441-460 Crusader 461-480 Genie 481-500 Paladin 501-520 Hydra 521-540 Unicorn 541-560 Power Lich 561-580 Archmage 581-600 Vampire Lord 601-620 War Troll 621-640 Champion 641-660 Minotaur King 661-680 Ogre Lord 681-700 Lich 701-720 Medusa 721-740 Mage 741-760 Troll 761-780 Cavalry 781-800 Minotaur 801-820 Roc 821-840 Earth Elemental 841-860 Water elemental 861-880 Vampire 881-900 Ghost 901-920 Fire Elemental 921-940 Greater druid 941-960 Air Elemental 961-980 Master Swordsman 981-1000 Steel Golem 1001-1100 Druid 1101-1200 Swordsman 1201-1300 Griffin 1301-1400 Ogre 1401-1500 Royal Mummy 1501-1600 Iron Golem 1601-1700 Mummy 1701-1800 Wolf 1801-1900 Veteran Pikeman 1901-2000 Nomad 2001-2200 Battle Dwarf 2201-2400 Grand Elf 2401-2600 Pikeman 2601-2800 Gargoyle 2801-3000 Elf 3001-3200 Orc Chieftain 3201-3400 Mutant Zombie 3401-3600 Dwarf 3601-3800 Boar 3801-4000 Ranger 4001-4200 Archer 4201-4400 Zombie 4401-4600 Orc 4601-4800 Skeleton 4801-5000 Rogue 5001-5200 Centaur 5201-5400 Halfling 5401-5600 Sprite 5601-5800 Goblin 5801-∞ Peasant

Originally posted by @LeHerosInconnu in https://github.com/ihhub/fheroes2/issues/954#issuecomment-742099166

Originally posted by @LeHerosInconnu in https://github.com/ihhub/fheroes2/issues/3121#issuecomment-815733587

Also, dahbk made a little tool to calculate the score:

@oleg-derevenetz.

Hi @LeHerosInconnu Thank you! However that's just a match table between points and monsters, but there is nothing here about how exactly points are counted :( So far all I've found is the similar formula, but from H3:

http://heroescommunity.com/viewthread.php3?TID=14020&PID=279535#focus

Don't know is this applicable to H2 as well though... It looks like current implementation uses different formula that takes map size into account and with some intricate dependency on mission time.

dahbk made a little tool to calculate the score. Try to contact him on the Gog forum, maybe he knows the exact formula?

https://www.gog.com/forum/heroes_of_might_and_magic_series/homm2_rating_corresponding_creatures/post9

91699aabb7c025e696478c365995948adc16b13b

Originally posted by @LeHerosInconnu in https://github.com/ihhub/fheroes2/issues/3121#issuecomment-815795638

Originally posted by @LeHerosInconnu in https://github.com/ihhub/fheroes2/issues/4166#issuecomment-922469312


I find this logic too arbitrary and without any real "strategic" reasoning.

My general idea is this: move should be a predictable action that moves/merges troops. If a player has no idea about how to best organize their army then that is their problem. The move action should not take away the part of the gameplay where you decide what formation to have your troops in, whether that's a good or a horrible formation. But your point is in the gray zone of this, so the more simple strategic choice would be to leave a single creature according to some absolute simple comparison like tier/speed/attack/hp etc..

"Weakest" and "strongest" are very vague terms in HoMM 2 when you could acheive more with a single sprite than with a single dwarf if up against ranged armies as a basic example. Tier, highest speed, most HP, highest attack etc. are easy comparisons, even in the case of equals.

I think simple and predictable for the majority of the experienced players is what the move command should strive to be. I don't want an experienced player to perform the move command and afterwards sit there and wonder "Why did the game choose this on my behalf?".

When I talk about the "strongest" and "weakest" creature, it is in reference to the combat value of the creature, something that is well determined in the game, the known and used list of creatures from peasant to black dragon, and not about a possible superiority of the grand elf because he can win against a hydra by attacking her from a distance without ever being attacked in close combat by the hydra. There is no equality of creatures in this ranking, which is also why it is a good reference.

LeHerosInconnu commented 2 years ago

@Branikolog.

I mostly agree with @zenseii In my opinion, default moving of all troops will never satisfy all players' needs.

That's why I proposed the availability of a setting for the player to choose between "speed" or "power" of the creature, by default for the action.

On the other hand, I find current implementation of transferring buttons in meeting hero window (which are the same we're discussing here) not very comfortable since the moment they were added into engine. I'm still not used to this logic. The logic is obvious, but it requires rearrangement of troops in the majority of cases. So I prefer leaving the weakest or the fastest troop more. While fastest could be not obvious to the majority of players, I think leaving the weakest is the case everyone understands and the majority of players used to keep exactly the weakest creature, while transferring. All other cases could be handled with select+transfer logic I've described before.

I have made proposals in the forum "Discussions" to improve this, therefore we could have the best of both worlds. :)

zenseii commented 2 years ago

Thank you for taking the time to share this, @LeHerosInconnu. I've looked closer at the code now, and there are some things that I'm sure you'll appreciate.

As far as I can tell, the monster rating, or the monster you get as a score when completing a campaign/scenario, is not used anywhere else than in this context of getting a score, and it is specific and hardcoded in this context. You can think of it like setting up the prizes for a competition:

1st place: A trophy 2nd place: A toy car 3rd place: A pelouche

They are just set like this because something had to be used and not everyone would agree with them (some might prefer the pelouche over the toy car), and I am not conviced the original developers set the list of monsters according to some incredible amount of statistical data, calculations and reasonings they had made. Nevertheless, fheroes2 cannot take this list as absolute fact and the fheroes2 team has to come up with its own logic for how to best compare creatures.

Which moves us to the actual combat value or what is referred to as "strength" in the fheroes2 code. From the bottom code you might be able to understand how the base monster strength is calculated according to many conditions like abilities: https://github.com/ihhub/fheroes2/blob/d94c531872384b6f22c73eec79fa183902aa7394/src/fheroes2/monster/monster_info.cpp#L46-L128

From this it should be obvious that they are made based on assumptions like how much double damage to undead (i.e.DOUBLE_DAMAGE_TO_UNDEAD) should count towards the base monster strength. This is all stuff that if you didn't already know I'm sure you'll find interesting.

However, to me the only interesting thing right now is that all of this could change at a later point because for instance it isn't an objective fact that double damage to undead should account for as much as it currently says in the code - it is an assumption based on a reasoning. I.e. 15% of all Monsters are Undead, deals double dmg.

And so if I implement leaving a single unit of a creature according to its monster strength, then maybe 1 month later a different creature could end up being left when doing the move command on the same army, just because the logic above had adjustments made to it.

This is why I referred to the "absolute" comparisons, which is probably a wrong use of the word, but nevertheless what I mean is that a sprite will always remain a tier 1 and this along with its speed will always remain the same (unless someone casts mass hypnosis on the core team 🤣).

LeHerosInconnu commented 2 years ago

Hello @zenseii,

Thank you for taking the time to share this, @LeHerosInconnu. I've looked closer at the code now, and there are some things that I'm sure you'll appreciate.

As far as I can tell, the monster rating, or the monster you get as a score when completing a campaign/scenario, is not used anywhere else than in this context of getting a score, and it is specific and hardcoded in this context. You can think of it like setting up the prizes for a competition:

1st place: A trophy 2nd place: A toy car 3rd place: A pelouche

I think this creature rating is a good match for the creatures' strength in the game. The black dragon at the top, followed by the titan, then the red dragon, etc., up to the peasant so beloved by necromancers. :)

They are just set like this because something had to be used and not everyone would agree with them (some might prefer the pelouche over the toy car),

The purpose of the list is not for everyone to agree with the creatures' order, but to have a fixed and known list that can be used for reference (like for example the high scores screen).

and I am not conviced the original developers set the list of monsters according to some incredible amount of statistical data, calculations and reasonings they had made.

I don't think the creatures' order is not the result of some thought by the game developers.

Nevertheless, fheroes2 cannot take this list as absolute fact and the fheroes2 team has to come up with its own logic for how to best compare creatures.

Which moves us to the actual combat value or what is referred to as "strength" in the fheroes2 code. From the bottom code you might be able to understand how the base monster strength is calculated according to many conditions like abilities:

https://github.com/ihhub/fheroes2/blob/d94c531872384b6f22c73eec79fa183902aa7394/src/fheroes2/monster/monster_info.cpp#L46-L128

From this it should be obvious that they are made based on assumptions like how much double damage to undead (i.e.DOUBLE_DAMAGE_TO_UNDEAD) should count towards the base monster strength.

I am not a programmer, but from what I could understand, for fheroes2, they decided to have a more precise evaluation of the creatures' strength according to several parameters which evolve during the game. The advantage is that the creatures' strength is updated according to the "environment" where they evolve, and the disadvantage is that it must be recalculated more often. This is in contrast to the original game, where the strength of each creature is fixed (fight-value) and certainly modified by a second value (fight-value-aux) during the combats.

This is all stuff that if you didn't already know I'm sure you'll find interesting.

Yes, that's interesting, I assumed in fheroes2 the creatures had a fixed combat value, as they do in the original game. :)

However, to me the only interesting thing right now is that all of this could change at a later point because for instance it isn't an objective fact that double damage to undead should account for as much as it currently says in the code - it is an assumption based on a reasoning. I.e. 15% of all Monsters are Undead, deals double dmg.

And so if I implement leaving a single unit of a creature according to its monster strength, then maybe 1 month later a different creature could end up being left when doing the move command on the same army, just because the logic above had adjustments made to it.

This is why I referred to the "absolute" comparisons, which is probably a wrong use of the word, but nevertheless what I mean is that a sprite will always remain a tier 1 and this along with its speed will always remain the same (unless someone casts mass hypnosis on the core team rofl).

In the case of army reorganization actions, it is not necessary to have as much precision as during combat for the creature strength value (so the calculated creature strength value is not necessary). All that is needed is a fixed and known list (even if not everyone agrees with the creatures' order) which serves as a reference. And the creature rating list like the one used for the scores is just right for this. So the focus should not be on using the "real" calculated creatures' strength value, which, as you said, can change over time, but rather on using a predefined and fixed list as reference.

And thank you for all your explanations. I understand better why you were reluctant to use the creatures' strength value, which for you was subject to change, and for me was a fixed value. :roll_eyes:

zenseii commented 2 years ago

Hi @LeHerosInconnu !

I don't think the creatures' order is not the result of some thought by the game developers.

I am not a programmer, but from what I could understand, for fheroes2, they decided to have a more precise evaluation of the creatures' strength according to several parameters which evolve during the game. The advantage is that the creatures' strength is updated according to the "environment" where they evolve, and the disadvantage is that it must be recalculated more often. This is in contrast to the original game, where the strength of each creature is fixed (fight-value) and certainly modified by a second value (fight-value-aux) during the combats.

Yes, they obviously put some thought behind it and I'm not discarding this, but sadly we will likely never know how they came up with it and that's why for us those numbers/comparisons, although we can agree with them based on our own reasonings, are essentially "magical numbers" that we have no idea where came from.

For all we know the original devs had a similar setup as we have for calculating strength . Also as far as I understand the fheroes2 code, the strength of a monster is constant throughout the game in fheroes2, it is just that we have the parameters available to change the calculations of this strength. It is indeed possible that the original source code had this too, but we will never know.

For example it is not as if a Black Dragon's base strength will change if it during combat takes 200 damage from my understanding looking briefly at this code. This code is essentially just the mathematical equation that is used to generate something like the xml file you shared. The difference with fheroes2 is that we have the actual calculation behind it, while the xml file only has the results, which we can make some observations on like you mentioned about the aux value, but we cannot know all the logic/code/calculation behind it and at the end of the day this fine because there is no problem with us setting up our own calculations.

Hopefully there is insight of the game that we have been able to acquire by now almost 30 years after the game came out that makes us able to come up with better calculations/comparisons. Of course, there is no problem leaving the high score list the same.

In the case of army reorganization actions, it is not necessary to have as much precision as during combat for the creature strength value (so the calculated creature strength value is not necessary). All that is needed is a fixed and known list (even if not everyone agrees with the creatures' order) which serves as a reference. And the creature rating list like the one used for the scores is just right for this. So the focus should not be on using the "real" calculated creatures' strength value, which, as you said, can change over time, but rather on using a predefined and fixed list as reference.

So, I have looked at where this list is in fheroes2. Look at the two columns on the right in left-right downwards order): https://github.com/ihhub/fheroes2/blob/6323569060738c403d9252bd11edf76f524d3133/src/fheroes2/game/highscores.cpp#L33-L65

The problem with using this list is that it is not accessible from the part of the code where we move troops. Making it accessible is technically possible but would come at the cost of worsening (i.e. slower and bloated) the overall code, and for such a specific single-time use it is very hard to justify. I hope you can understand that this is not worth such a sacrifice.

To me this leaves us with either using the speed or the tier. I'm fine with either of the two, but as @Branikolog said, tier is most likely the most obvious one for most of the experienced players, assuming Branikolog did indeed mean tier when he was talking about weakest and strongest troop, and not the actual monster strength that we have just discussed exhaustively.

Nothing is set in stone and I suggest we go with one and then if we realize it has flaws we try something else.

For example, it is obvious that you would never want to leave an army with just a single peasant, but then again few experienced players would have peasants in their army to begin with.

Also with the option of leaving 1 unit of the troop you have selected before making the move I think all our issues will be solved really.

And thank you for all your explanations. I understand better why you were reluctant to use the creatures' strength value, which for you was subject to change, and for me was a fixed value. 🙄

You're welcome and thank you for taking the time to understand this.

Branikolog commented 2 years ago

Hi, @zenseii

To me this leaves us with either using the speed or the tier. I'm fine with either of the two, but as @Branikolog said, tier is most likely the most obvious one for most of the experienced players, assuming Branikolog did indeed mean tier when he was talking about weakest and strongest troop, and not the actual monster strength that we have just discussed exhaustively.

I was talking about tier, but playing Heroes 2 will almost always come to army of different factions, so, while transferring troops we would come up to transferring, for instance, various 1 troops, where we have to choose weakest one, according to 1vs1 comparison of the same tier. So here we require a special "magical" table where we can store and compare "strength" value of the same tier troops.

ihhub commented 2 years ago

@zenseii and @LeHerosInconnu , the magic value of monster's strength is calculated once at the start of the game. These values must not be hardcoded like in the original game and should be based on rationale behind monster's stats and abilities. Hardcoding values is no go for adding new monsters or supporting modding. fheroes2 values are different from the original. This is the fact. But these values are used by AI only. Since our AI is completely different it is totally fine to have different values. Yes, these values must be adjusted further and we will do it later.

In regards to monster movement: the most simple and logical way is to use from left to right rule. This will be understandable by every player of the game.

LeHerosInconnu commented 2 years ago

Hello @zenseii, @Branikolog and @ihhub,

Nothing is set in stone and I suggest we go with one and then if we realize it has flaws we try something else.

:+1:

Also with the option of leaving 1 unit of the troop you have selected before making the move I think all our issues will be solved really.

:+1:

You're welcome and thank you for taking the time to understand this.

:+1: :smile:

In regards to monster movement: the most simple and logical way is to use from left to right rule. This will be understandable by every player of the game.

Okay, let's try it like that for now and see how it goes in use. :smiley:

zenseii commented 2 years ago

In regards to monster movement: the most simple and logical way is to use from left to right rule. This will be understandable by every player of the game.

It also makes things a lot easier for me to figure out 😂 Left to right is a simple rule with no edge cases - that is one big benefit.

LeHerosInconnu commented 2 years ago

Hello @zenseii, @Branikolog and @ihhub,

Here there are links where you can see an experienced player using the big yellow arrows for troop transfers. Note that the player has chosen to always keep a quick troop in the hero's army with one troop. :)

Related discussions: https://github.com/ihhub/fheroes2/discussions/4396, https://github.com/ihhub/fheroes2/discussions/4327, https://github.com/ihhub/fheroes2/discussions/3742.

ihhub commented 10 months ago

Hi @zenseii , is there any work left to be done for this issue?

zenseii commented 10 months ago

Hi, @ihhub.

There are a few things still needed. Mainly adding a way to do this with a mouse/touch. I have recently gotten some ideas of how to make this match the original UI style of the game, instead of having drag-and-drop functionality because that would look a bit "alien" to the rigid look and feel of the UI of the original game (: very little movement and animation is going on).

Also, we still haven't added army swap function because that needs UI adaptation.

Jojoshua commented 9 months ago

How about a little up/down caret buttons between the hero and town to move all matching units up/down

zenseii commented 9 months ago

Hi, @Jojoshua. I have an idea about expanding the already existing red outlining borders to achieve this. The buttons you descibe were actually tried once in the project when it was possible to garrison heroes, but personally I found them too small to work on a touch screen (which is the main reason to add this), and they invade the original design a bit too much. We also left open the possibility to add hero garrisoning and using this place would interfer with that if such a ui interaction were to be used, which is of course not decided.

Anyways once I have more time I'll try to give a more proper description, or even a PR showing how I think we can quickly and elegantly implement this without meddling too much with the original look.

Jojoshua commented 9 months ago

Thanks for looking into it @zenseii . I'm sure you'll come up with something great.

Just going to throw some more ideas into the mix now that I know what the design goals are.

image