MantisBT - VCMI
View Issue Details
0000792VCMIMechanics - Battlespublic2011-08-31 13:332014-05-30 17:40
Zamolxis 
Warmonger 
normaltweakalways
closedfixed 
0.85c 
0.87 
0000792: Cerberi's 3-headed attack should only hit up to 3 creatures "in front" of it (not any creatures around)
Unlike the 3-headed Hydra, the Cerberus cannot hit in just any hex around it. It should be able to hit the target hex, and together with that, only whatever enemy creatures are in the hexes adjacent to both the Cerberus and the target creatures. Creatures in any other hexes around the Cerberus should remain unharmed.
No tags attached.
related to 0000797closed Warmonger 2-hex breath attack seems to work only for human player and fail for the computer player 
related to 0000830closed Warmonger Wrong Hydra attack: only three targets and can reach enemies which are not adjacent 
gif grid01.gif (12,417) 2011-09-03 16:13
https://bugs.vcmi.eu/file_download.php?file_id=797&type=bug
gif
Issue History
2011-08-31 13:33ZamolxisNew Issue
2011-08-31 13:33ZamolxisStatusnew => assigned
2011-08-31 13:33ZamolxisAssigned To => Tow dragon
2011-08-31 13:34ZamolxisSummaryCerberus' 3-headed attack should only hit up to 3 creatures "in front" of it (not any creatures around) => Cerberi's 3-headed attack should only hit up to 3 creatures "in front" of it (not any creatures around)
2011-09-03 16:09WarmongerAssigned ToTow dragon => Warmonger
2011-09-03 16:13WarmongerNote Added: 0001979
2011-09-03 16:13WarmongerFile Added: grid01.gif
2011-09-03 16:14WarmongerNote Edited: 0001979bug_revision_view_page.php?bugnote_id=1979#r1382
2011-09-03 16:15WarmongerRelationship addedrelated to 0000797
2011-09-03 16:16WarmongerNote Edited: 0001979bug_revision_view_page.php?bugnote_id=1979#r1383
2011-09-04 01:20ZamolxisNote Added: 0001983
2011-09-04 01:23ZamolxisNote Edited: 0001983bug_revision_view_page.php?bugnote_id=1983#r1387
2011-09-04 01:32ZamolxisNote Edited: 0001983bug_revision_view_page.php?bugnote_id=1983#r1388
2011-09-05 18:15WarmongerNote Added: 0001996
2011-09-05 18:15WarmongerStatusassigned => resolved
2011-09-05 18:15WarmongerFixed in Version => 0.89
2011-09-05 18:15WarmongerResolutionopen => fixed
2011-11-08 08:25WarmongerRelationship addedrelated to 0000830
2014-05-30 17:40beegeeStatusresolved => closed

Notes
(0001979)
Warmonger   
2011-09-03 16:13   
(edited on: 2011-09-03 16:16)
Could you please give any details about which hexes are affected and which not? Hex-handling in heroes is quite complex and possibly I just missed one case, but it should work in general.

Attached hex grid, it may be helpful. Notice that odd and even rows may behave different. Though you don't need to deduce the formulas once again ;P

(0001983)
Zamolxis   
2011-09-04 01:20   
(edited on: 2011-09-04 01:32)
Okay, get ready for a long one. ;-)

Odd or even rows make a difference only in the arithmetic formulas (see below).

But first of all, a clarification to my report above: I made a comparison with the 3-headed Hydra, which may be misleading. The 3-headed Hydra doesn't really have a 3-headed attack, but can actually hit up to 8 enemies around (a 2-hex creature is surrounded by 8 hexes). Personally I don't like the way NWC did it. It would have made more sense for it to be able to hit only max.3 hexes, but that's another story. And same goes for Gorynych (which is basically just a flying Hydra;)

Now, with that confusion out of the way, the Cerberus is actually the only creature in H3 (if I'm not missing sth) with a real 3-headed attack. So the below does not risk to get confused with a similar attack from some other creature.

The logic is quite simple, especially if the Cerberus is surrounded by 1-hex creatures only. Before we go into numbers, let's see the basic principle that NWC had in mind when they coded it (unlike the Hydra, they did it perfectly logic here). What's the "lead head" of a Cerberus? The one in the center normally. So if he's charging an enemy, the center head would attack that one, with the side heads biting whoever is just next to the enemy (perhaps) trying to defend it. But what can a Cerberus not do in the same time? While biting an enemy in front of it, it cannot use one of the side heads to defend against another enemy attacking from behind, or even from more to the sides, as all heads are stuck to the same neck.

Now, let's put that in numbers. In H3, the lead (center) head, is the one attacking according to the direction of our sword pointer. So the target hex will always be the center one, and based on that the side hexes are decided. More concrete, let's say we have or move the Cerberus on hexes 20.21, to attack a creature surrounding this 2-hex location. To avoid any confusion, here are all the possibilities:
- if we attack hex 22, then the side hexes around Cerberus' head (hex 21), are hexes 04 & 38
- if we attack 38, then sides are 22 & 37
- if we attack 37, then sides are 38 & 36
- if we attack 36, then sides are 37 & 19
- if we attack 19, then sides are 36 & 02
- if we attack 02, then sides are 19 & 03
- if we attack 03, then sides are 02 & 04
- and if we attack 04, then sides are 03 & 22

That is NWC's logic that would be preferred to reproduce. Unfortunately, it does have a downside, in the sense that if for example you have enemies only in 04 & 38, you can't take them both with the Cerberus as long as you don't have another enemy in 22 to direct the center head to. You have to direct the sword cursor to one of them, 04 for example, but the the game checks for other enemies only in hex 03 & 22, and the one in 38 remains unharmed. But Cerberus is not a weak creature for its tier, so I wouldn't bother complicating the code even further to correct this downside (plus it would not be H3-like anymore, so it could only be done as part of a mod).

So I guess your basic formulas would look something like this:
Odd row: if head in hex X, and target in X+1, then also attack X-16 (if not negative) and X+18 (if not > 186)
Even row: if head in hex Y, and target in Y+1, then also attack Y-17 and Y+17 [no exceptions as there's no out-of-grid risk for even rows]
(and somewhere you need to also add a condition that if the side hex belongs to the same 2-hex creature which is also occupying the main target hex, then the hex is also ignored, to avoid inflicting double damage)

Unfortunately I don't think we can have a general formula, so we'll need 8*2 formulas for each of the 8 possible destination hexes around the Cerberus, for odd & even rows: X+1, X+17, X+16, X+15, X-2, X-19, X-18 & X-17 or Y+1, Y+18, Y+17, Y+16, Y-2, Y-18, Y-17 & Y-16. Or perhaps you could simplify the code to only 2 formulas (for odd & even rows), if for example you appoint values a to h (or 1 to 8) for the 8 possible destination hexes, also establishing a circular hierarchy so that a follows again after h (or 1<2<...<8<1). And then your formula could say that whichever the target hex you have, also the hexes corresponding to previous and following code in the hierarchy should take a hit. But I'm no coder so I don't know if/how that can be exactly done. I can only hope you know. ;)

* * *

And now, the cherry on the top: the above is not all. It seems NWC had a particular logic in case we point the sword vertically up or down (to the middle hexes just above/below the Cerberus' hexes), and in those target hexes we find the front hex of a 2-hex creature. I'll explain below how their logic worked, but I let you choose if you want to follow it or not. The gameplay impact would be minimal so, if the extra coding effort is not worth it, I'd say you can drop it (especially because it was not the most logic way of handling it).

Mind you, some code would be needed in place either way, because we can't attack both hexes of a 2-hex creature in order to inflict double damage (another H3 logic related to area spells I didn't fully agree with, but again - that's another story). But maybe there's an easier (for you) and more logic (for the players) way to implement this.

So this H3 strange logic (or bug?), kicks in only when there's a 2-hex enemy on the row below or above the Cerberus, with the front hex 'between' Cerberus' hexes. For example, a left army Cerberus at 20.21, and a right army Centaur at 03.04 or 37.38 (or 1 hex more to the right for Centaur, if they swap sides). And the rule is that, if we point in the middle, H3 is only considering the back hex of the enemy, that is the hex which is closest to the head of the Cerberus, the way it is facing the battlefield. That means that for a Cerberus belonging to the right army, it's not the same formulas that apply, but they are flipped vertically (if we can call it like this).

More exactly this means:
> For Cerberus of left army at 20.21 and Centaur of right army at 02.03 (and same for 36.37), nothing changes to the way we expect the formula to apply
- if we point the sword cursor at 02, we also hit 19. As expected, according to above formulas.
- if we point the sword at 03, we find the back hex of the Centaur, so agian no exception: we hit 03 and also 04.
> If however the creatures would be in the same places, but belonging to opposite armies, then the sword pointing up to 03 would meet the head of the Centaur so, instead of attacking 03 & 04, the H3 Centaur goes again for 02 (Centur's back) and 19.
And similarly:
> For Cerberus at 20.21 and Centaur at 03.04 (or 37.38). In this case, it's when the Cerberus belongs to the left army, that if we're pointing up (or down), we find the front hex (03 or 37) of the Centaur. So, instead of hitting 02 & 03 (respectively 36 & 37) as expected, we hit 04 & 22 (respectively 38 & 22)

Again, IMO there is no added value to this H3 logic, so my choice would be to not follow it. On the contrary, there is actually a small (but stupid) disadvantage to it, which perhaps NWC didn't realize (maybe because of the low chance of occurrance). The situation is the following:
- Cerberus at 20.21 (left army)
- fire-shielded creatures at 19 & 22
- 1-hex creature at 02
- 2-hex creature at 03.04
Theoretically it should be possible to hit the creatures above only, by pointing at 03 (avoiding to receive damage back from the fire-shielded creatures, which we may want to take down with shooter/casters for example). But that is not the case:
- if we point at 03, it'll take 04 and the fire-shielded creature at 22
- so the only way to take 02, is to point at 02, but then we also take the fire-shielded creature at 19.
I see this as a H3 bug, because if the creatures above would be placed the other way around (2-hex at 02.03 and 1-hex at 04), we wouldn't have this problem. But I'll let you decide if you agree to that or not.

* * *

And now I will take some time to think of a reward for the one who will succeed in reading and also understanding all the above, as I may have overdone it this time. :-P

(0001996)
Warmonger   
2011-09-05 18:15   
Fixed in r2372,

Now Cerberi attacks target creature and creatures on hexes adjacent both to attacked hex and its head. Hopefully that's simple and clear enough.
As to the secondary described issue, I quite don't see the point :P