Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#1866 closed defect (fixed)

[PATCH] Unit attack instability

Reported by: zoot Owned by: leper
Priority: Nice to Have Milestone: Alpha 14
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by zoot)

Steps to reproduce:

  1. Start a match on the 'Combat Demo' scenario.

What happens: After a while, a group of your units in the left side of the screen enters an 'unstable' state where they begin attacking an enemy, then return to their previous position, then begin attacking again etc. in an infinite loop.

What I believe would be ideal: Either the unit should attack or not - not vacillate in indecision!

http://trac.wildfiregames.com/raw-attachment/ticket/1866/instability.gif

Attachments (1)

instability.gif (28.7 KB ) - added by zoot 11 years ago.

Download all attachments as: .zip

Change History (8)

by zoot, 11 years ago

Attachment: instability.gif added

comment:1 by zoot, 11 years ago

Description: modified (diff)

comment:2 by mimo, 11 years ago

There is in fact an inconsistency for units in defensive stance like in this demo : the unit starts to attack, but is immediately stopped, so go back to its held position, then starts again to attack, etc

The fix is simple, but there are two possibilities and I'm not sure what is the wanted behaviour when in defensive stance : for such a stance, the attack is done in UnitAI.prototype.AttackEntityInZone and the stop of the attack in UnitAI.prototype.ShouldAbandonChase.

We can prevent it to attack (in cases where it will be stopped by ShouldAbandonChase) by replacing in AttackEntityInZone the line

			this.PushOrderFront("Attack", { "target": target, "force": false, "forceResponse": forceResponse });

by

			if (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
                	{
				this.PushOrderFront("Attack", { "target": target, "force": false, "forceResponse": forceResponse });
				return true;
			}

Or we can prevent it from being stopped in ShouldAbandonChase by replacing the lines

	// Stop if we're in hold-ground mode and it's too far from the holding point
	if (this.GetStance().respondHoldGround)
	{
		if (!this.CheckTargetDistanceFromHeldPosition(target, iid, this.attackType))
			return true;
	}

	// Stop if it's left our vision range, unless we're especially persistent
	if (!this.GetStance().respondChaseBeyondVision)
	{
		if (!this.CheckTargetIsInVisionRange(target))
			return true;
	}

by

	// Stop if we're in hold-ground mode and it's too far from the holding point
	if (this.GetStance().respondHoldGround)
	{ 
		if (!this.CheckTargetDistanceFromHeldPosition(target, iid, this.attackType))
			return true;
	}
	// Stop if it's left our vision range, unless we're especially persistent
	else if (!this.GetStance().respondChaseBeyondVision)
	{
		if (!this.CheckTargetIsInVisionRange(target))
			return true;
	}

The first solution is may-be better.

comment:3 by Markus, 11 years ago

Keywords: patch review added
Milestone: BacklogAlpha 14
Summary: Unit attack instability[PATCH] Unit attack instability

in reply to:  3 ; comment:4 by zoot, 11 years ago

Replying to Markus:

Did you forget to attach the patch?

in reply to:  4 comment:5 by Markus, 11 years ago

mimo already suggested some code changes. The first one being prefered. It changes the behavior in the mentioned demo scenario.

comment:6 by leper, 11 years ago

Owner: set to leper
Resolution: fixed
Status: newclosed

In 13502:

Fix inconsitency between AttackEntityInZone and ShouldAbandonChase for units in defensive stance. Patch by mimo. Fixes #1866.

comment:7 by leper, 11 years ago

Keywords: review removed

Thanks for the patch.

Note: See TracTickets for help on using tickets.