HomeWildfire Games

Move "IsInRange" family of functions to the Obstruction Manager and make the…

Description

Move "IsInRange" family of functions to the Obstruction Manager and make the commutative.

These functions were placed in UnitMotion, which had nothing to do with range checks and made them available only to moving entities for no particular reason.

This patch also adds support for square-square range checks and shape-shape distance checks.

Modified from a patch by bb on top of work from wraitii.

Differential Revision: https://code.wildfiregames.com/D981

Event Timeline

Angen added a subscriber: Angen.Sun, Jun 9, 9:20 AM

I am not sure if it was this but some commit with unitmotion and range check.
When any unit is tasked to attack animal which flee (or anything which will flee) it follows it but does not stop to attack when target is in range but keeps following until target does not stop and then attacks.

I am not sure if it was this but some commit with unitmotion and range check.
When any unit is tasked to attack animal which flee (or anything which will flee) it follows it but does not stop to attack when target is in range but keeps following until target does not stop and then attacks.

Ah yeah, I saw that behaviour as well this morning! It was strange to have a ranged unit run towards a melee unit when chasing,,,

Angen added a comment.Sun, Jun 9, 9:55 AM

next:
animals walking on place after feeling
ranged units not responding on attack commands

Stan added a subscriber: Stan.Sun, Jun 9, 11:22 AM

I think i encountered the latter when playing with turrets.

Animals not playing walk animation when moving (randomly).

I am not sure if it was this but some commit with unitmotion and range check.
When any unit is tasked to attack animal which flee (or anything which will flee) it follows it but does not stop to attack when target is in range but keeps following until target does not stop and then attacks.

Ah yeah, I saw that behaviour as well this morning! It was strange to have a ranged unit run towards a melee unit when chasing,,,

Yeah we're in the middle of the "worse before it gets better" of my unit motion-related changes. The problem here is that unitMotion no longer sends so many redundant "MoveCompleted" messages and so unitAI doesn't realise they are in range.
I intend to go back and fix these quirks correctly once I've committed the rest of the patches, but the worst ones I might have to fix straight away, perhaps this is part of that.

@wraitii, do you want us to continue summing up situations in which movement fails (either here on in a different centralised location)? Or leave it untill you've commited the rest?

gameboy added a subscriber: gameboy.Sun, Jun 9, 3:35 PM

@wraitii My friend, my army can't board the warships. Can you let them board the warships?

wraitii added a comment.EditedSun, Jun 9, 4:32 PM

@wraitii, do you want us to continue summing up situations in which movement fails (either here on in a different centralised location)? Or leave it untill you've commited the rest?

Nah if you noticed oddities I'd rather you still report them, I'll be centralising them on my own and coming back to them after.

However I would distinguish:

  • Movement fails when it should succeed (gameboy's report above falls into this I think)
  • Movement doesn't fail (aka units keeps trying to move / moving forever) when it probably should
  • Movement is unexpected or suboptimal.

I'll update the report here: https://trac.wildfiregames.com/ticket/4420

  • Grazing animals turn often and strangly. Steps to recreate bug:
    • Start map.
    • Look at gaia animals.
  • On the fleeing: both the chasing and the fleeing are off. They seem to stop randomly.
    • Steps to recreate bug:
      • Take two units of opposing teams, set one or both to flee-behaviour.
      • Attack (with A) the unit (B) with flee-behaviour.
    • Witnessed behaviour:
      • Unit B starts fleeing
      • After about a second unit B stays in running animation but stops moving.
      • Shortly therafter unit A stops moving but keeps running animation.
      • Then Unit B starts moving again and quickly therafter unit A starts moving also.
      • When the units have stopped moving at the same time they stay in running animation at the same position forever (at least a minute).
    • Unit A stops moving and goes to Idle properly when target dies.
    • Manually moving unit B sends unit A into moving again.
      • When A catches up with B they gently walk side by side.
      • When B stops because targetpos (or is halted by player) is reached, unit A stays in walking animation but doesn't move.
      • Sending unit B to another location continues infinitely as above. Unless the unit B is tasked to the direction unit A is, when unit B is then close enough unit A starts attacking but above behaviour sets in therafter.
    • Manually moving unit A from the nonmoving stalemate sets unit B loose from invisible rope and unit B starts routing.
      • When unit B has routen far enoug it stops moving but still uses walking animation.
      • When unit A reenters LOS of unit B unit B starts moving again (fleeing with run animation) but this is rather inconsistent behaviour.
  • An animal moved from foundation stays in "WALKING"-state with order "LeaveFoundation".
    • Steps to recreate bug:
      • Build a building over an animal.
      • Display selection state.
      • When trying to build a building over the animal again it will not move. (It does respond to attacks, though.)
  • When unit B is attacked by a ranged unit A and the unit B moves out of range the unit A will not move into attack-range but goes to walk next to the attacked unit B. (Like in the earlier bug.)
    • Steps to recreate bug:
      • Let ranged unit A attack unit B.
      • Move unit B out of attack range.
    • Witnessed behaviour:
      • Unit A does not stops to attack when in range but rather keeps walking towards unit B.
      • When arrived unit A stays in walking animation but does not move.
      • Unit A does not care at all if unit B stops and turns to attack and will just stop moving but stay in walking animIation.
    • Unit A stops moving and goes to Idle properly when target dies.

I hope this helps.

Angen added a comment.EditedSun, Jun 9, 9:03 PM

@Freagarach see D1964, some bugs may be resolved

Thanks for the reports @Freagarach , very helpful. The animation thing will fix itself upstream (latest by D1901, possibly earlier) but the rest are likely legitimate issues that will need to be fixed, as Angen did there.

@Freagarach see D1964, some bugs may be resolved

Yeah, I just saw that when I posted this ;)
I directly tested it. The attacking is good again, so the last bug is solved indeed. And the second one partially. Indeed the attacker now keeps moving towards the chased unit. However both the unit (being chased and chasing) still randomly stop moving whilst keeping the running animation.

@Freagarach rP22367 should have improved many/all of the above. Chasing can still exhibit the "unit stops" behaviour - that's a unitMotion issue, which I will fix later.

@Freagarach rP22367 should have improved many/all of the above. Chasing can still exhibit the "unit stops" behaviour - that's a unitMotion issue, which I will fix later.

Yeah, I saw your hard work on it, thank you! That means my testing of other stuff should go easier as well :)
I am patient, dont rush ;)