Opened 11 years ago

Last modified 7 years ago

#1919 closed enhancement

[PATCH] Packing and unpacking units into structure and vice versa — at Initial Version

Reported by: Doménique Owned by:
Priority: Nice to Have Milestone: Alpha 21
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

The attached patch allows units not just to unpack into another unit entity but also into a structure entity. This enables the use of mobile civ centres and other movable structures for future nomadic tribes.

With the current civilisations of 0 A.D. this patch may not be directly useful, so while I assigned it to Alpha 14 it may be better suited for a later point. I implemented it for a mini civ I made some time ago which you can find here for testing purposes: https://github.com/dvangennip/amazones-0AD

The core changes of this patch involve enabling pack/unpack commands for structure entities, plus the transfer of any garrisoned units and production queues from the old entity to the new. So if the old entity can garrison cavalry and infantry units, but packing up into a mobile cart entity which cannot garrison cavalry, the cavalry will ungarrison while infantry may remain garrisoned. A similar eligibility check applies for any production batches. If the new entity also allows a certain batch to be produced, it will transfer, otherwise it will reset (and funds restored, as per the default behaviour).

This patch would thus also allow transforming one building into another, which might be useful if someone wants to implement building upgrades on phase change (or any other cue). For this reason I feel that the Pack component could be renamed to Transform to better capture its usefulness and perhaps unified with unit Promotion (there is similar code in both components), although that is beyond this patch.

Some issues:

  • Checking for allowed territory does not work, so any unit unpacking into a structure could do this on enemy territory. This is due to wrong tileOwner info in the cmpBuildRestrictions.CheckPlacement function (which has not been altered by this patch).

Change History (1)

by Doménique, 11 years ago

Attachment: pack.patch added

Patch for enabling unit and structure packing/unpacking

Note: See TracTickets for help on using tickets.