Ticket #724 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Units should not move out of enemy construction zones

Reported by: k776 Owned by: Stork
Priority: Must Have Milestone: Alpha 6
Component: Core engine Keywords: review
Cc: Stork

Description

When you place a building, enemy units will politely move out of the way so you can build it.

Only ally units and animals should move away.

Attachments

diffContstruction.patch (2.6 KB) - added by Stork 2 years ago.
fixes some issues with diplomacy; units do not move out of the way for their enemies' constructions

Change History

comment:1 Changed 2 years ago by k776

  • Summary changed from Units should be polite in moving out of construction zones that belong to an enemy to Units should not move out of enemy construction zones

comment:2 Changed 2 years ago by k776

  • Milestone changed from Alpha 4 to Alpha 5

Changed 2 years ago by Stork

fixes some issues with diplomacy; units do not move out of the way for their enemies' constructions

comment:3 follow-up: ↓ 6 Changed 2 years ago by Stork

  • Keywords review added

comment:4 Changed 2 years ago by historic_bruno

  • Summary changed from Units should not move out of enemy construction zones to [PATCH] Units should not move out of enemy construction zones

comment:5 Changed 2 years ago by k776

  • Priority changed from Nice to Have to Must Have

comment:6 in reply to: ↑ 3 ; follow-up: ↓ 7 Changed 2 years ago by historic_bruno

Replying to Stork:

About your comment in the patch, in UnitAI.js line 1859. Are you referring to animal corpses? If so, maybe a check for gaia owned units would be enough. I think the order should not even be added to the queue if it's invalid (i.e. non-gaia players who are not friendly to the requesting player).

comment:7 in reply to: ↑ 6 Changed 2 years ago by Stork

Replying to historic_bruno:

I was referring to any corpses. The bodies of invaders should not prevent me from trying to build a wall to keep them out. I wasn't sure how to check for states outside of the state machine to see if it was in a corpse state, and didn't think that it was the proper way of using states anyway.

comment:8 Changed 2 years ago by Philip

Normal unit corpses have their Obstruction component inactivated, so they should never block the foundation (GetConstructionCollisions won't return them) and they don't need to be explicitly ignored. Only animal corpses remain as real obstructions (so you can still gather food from them) and need the special deletion behaviour.

In the current UnitAI, the validity check needs to be done in IDLE and REPAIR states, so it should probably be extracted into a separate method and called from both of them, instead of putting it directly in the IDLE one.

Rather than using the diplomacy array data directly, I think we really need some helper functions to abstract it out. Probably could go in helpers/Player.js with a function like IsOwnedByAlly(this.entity, msg.data.target).

(Instead of using sendingFoundation.entity you can just use msg.data.target directly since that's already the entity ID of the foundation entity.)

The "TODO: we should verify this is a friendly foundation" comment should be removed since it's being verified now. (I think it makes sense to do the check in the FSM like in this patch, not where that comment is, since animal FSM states don't want the check.)

comment:9 Changed 2 years ago by k776

  • Cc Stork added
  • Owner set to Stork

comment:10 Changed 2 years ago by k776

  • Milestone changed from Alpha 5 to Alpha 6

comment:11 Changed 2 years ago by Badmadblacksad

  • Status changed from new to closed
  • Resolution set to fixed

(In [9532]) check that enemy units don't leave foundations. based on patch from Stork. fixes #724

Note: See TracTickets for help on using tickets.