Opened 11 years ago

Closed 11 years ago

Last modified 23 months ago

#1718 closed enhancement (fixed)

Packing and Unpacking siege weapons

Reported by: Pureon Owned by: ben
Priority: Should Have Milestone: Alpha 12
Component: UI & Simulation Keywords: packing unpacking siege
Cc: Patch:

Description (last modified by Pureon)

Immobile siege weapons, such as the Roman Ballista and Greek Bolt Shooter, should be transformed from their mobile defenseless form (packed) into their immobile attack form (unpacked).

Most of the immobile siege weapons will have unique packed mobile versions. See units/hellenes/siege_rock_packed.xml and units/hellenes/siege_rock.xml as an example of packed/unpacked siege units.

Whenever the immobile siege weapon is tasked to move to a new location, or ordered to attack an object outside of it's weapon range, the immobile unit will transform into the mobile packed form (such as a horse drawn cart). If the unit has been given an attack order and reaches its attacking range, it will unpack into its immobile attacking form. If a unit is asked to simply to move to a new location, it will move but not unpack when it reaches the location.

A button in the UI should toggle packed/unpacked. This will be used when setting up defenses etc.

Animations for the packing/unpacking transformations can be added at a later stage.

Change History (18)

comment:1 by Pureon, 11 years ago

Description: modified (diff)

comment:2 by Kieran P, 11 years ago

Milestone: BacklogAlpha 13
Type: taskenhancement

comment:3 by historic_bruno, 11 years ago

Keywords: packing, unpacking, siege → packing unpacking siege

Actually I was looking into this task a few months ago. I wasn't completely satisfied with where it ended up, but the idea was to have separate entity templates for packed/unpacked units, which are created/destroyed when the transformation finishes. The benefit of that is it means less special cases throughout the simulation code, but also we can have different properties for packed vs. unpacked units, like armor values and vision range, to name a few. The drawback is twice as many siege templates.

The hardest part of this task IMO is getting it to work nicely with UnitAI which is tightly coupled with unit movement. So for example, UnitAI does range checks for attack that depend on the pathfinder. I opted to create a non-moving motion component for the case of an unpacked siege unit which does a simple linear distance check for range (the normal pathfinder range is far more complicated). I basically got all of it working except animations (obviously) and making the unit auto-pack if tasked to move/attack out of range.

I can clean up the patch I had, test some more, and then post it for review.

Last edited 11 years ago by historic_bruno (previous) (diff)

comment:4 by Pureon, 11 years ago

Sounds like an excellent start historic_bruno. Having separate entities for the packed and unpacked units would also be my choice.

comment:5 by historic_bruno, 11 years ago

What I've got so far: http://www.youtube.com/watch?v=o58aYttbZjw&feature=plcp

There are some problems with formations, but mostly it works as described. They auto-pack and auto-unpack when tasked to move or attack something out of range.

I could use some clarification as to what should happen if an order is given to the unit while it's packing or unpacking - should it simply ignore them, or stop packing/unpacking for certain types of orders? I also think there should be a "Cancel (un)packing" button in the UI, where the pack/unpack buttons are shown in the video.

comment:6 by Pureon, 11 years ago

The functionality looks like it's working really well. Great to see the progress bar working too.

I'm not sure what should happen if a new order is given whilst it's packing/unpacking. I'm thinking either the packing/unpacking process starts again, or it ignores them until it's packed/unpacked. What do you think?

I like the idea of a cancel (un)packing button.

I've created a new packed wagon model and texture which I'm about the animate now. I'll post an update on the forum at some stage later this week.

comment:7 by Amish Coelho, 11 years ago

So this is basically a 'morph' function and could also be used for things like converting cavalry to infantry, theoretically speaking?

comment:8 by historic_bruno, 11 years ago

It's fairly specific to siege engines. Not so much the transforming/morphing function, all that does is set a timer and at the end, replace the old entity with a new one specified in the template. But all the logic around it in UnitAI and the UI are siege specific. There might be ways of making it more generic (like allowing arbitrary states instead of only packed/unpacked, these could be read from JSON files or similar and referenced by name).

comment:9 by Pureon, 11 years ago

I've committed icons for the pack, unpack, and cancel buttons

comment:10 by ben, 11 years ago

Owner: set to ben
Resolution: fixed
Status: newclosed

In 12904:

Implements siege packing. Closes #1718.
Adds templates for packed and unpacked siege units - needs stat tweaking.

comment:11 by historic_bruno, 11 years ago

Some notes:

  • The unpacked siege units still have UnitMotion, but a very small almost-zero speed, and UnitAI doesn't allow them to move without packing anyway. This has some mostly visual side effects in formations, because the formation moves at the speed of its slowest member (it goes very slow until the packing unit is done).
    • I scrapped the idea of a new component for this because it's too difficult copying the target range logic precisely. A better solution might be to allow actual zero movement speed or add logic for static units in UnitMotion.
  • I scrapped the idea of relying on stances for siege engine attack and movement behavior, the current system just isn't flexible enough to handle the subtle but important differences between packed/unpacked siege and normal human units. I left TODOs in UnitAI.js related to this. Consider stances to be a useless feature for siege engines, until further notice.
  • There is some duplication with the Promotion component, conceptually and technically, but as discussed with leper on IRC, I wasn't convinced that making a generic "Transform" component would help us at all.
    • It sounds nice, but I'd rather wait until we actually want another transforming behavior before going that route (It seems like a more generic Transform component means more very specific pack logic in UnitAI).
    • But we should at least consider factoring out whatever they share into global helper functions.
  • There is also duplication in the siege entity templates, which is mostly unavoidable since the templates don't allow multiple inheritance. For instance, packed entities duplicate the Attack stats of their unpacked counterparts because they need to know a.) if they can attack, b.) the target range, etc. If we update one, we have to remember to update the other.
    • One slight way of improving this: have a single generic siege template for each type, then have a civ-specific "common" template inherit from that, and then packed/unpacked templates inherit from the common template. Attack stats, etc would go in the common template. Like this:
                                                                                            /-- athen_mechanical_siege_oxybeles_packed
         template_unit_mechanical_siege_ballista --> athen_mechanical_siege_oxybeles_common |
                                                                                            \-- athen_mechanical_siege_oxybeles_unpacked
      
Version 2, edited 11 years ago by historic_bruno (previous) (next) (diff)

in reply to:  6 comment:12 by historic_bruno, 11 years ago

Replying to Pureon:

I've created a new packed wagon model and texture which I'm about the animate now. I'll post an update on the forum at some stage later this week.

We tracked down the mysterious silhouettes problem :) One of the models, props/special/rome_rock_packed.dae has an unpacked mesh combined with it, underground and to one side. Perhaps it was accidentally selected when exporting the model from Blender?

comment:13 by historic_bruno, 11 years ago

Other reported bugs:

  • Siege units don't work with garrisoning
    • Need to add garrison transition order
    • Partly related to the size of the units causing them to be outside garrison range
  • Some weirdness when giving orders while packing/unpacking, it wastes time re-packing:
    • If ordered to move while unpacking, it should perhaps cancel unpacking and move
    • If ordered to attack in-range targets while packing, it should perhaps cancel packing and attack
Last edited 11 years ago by historic_bruno (previous) (diff)

in reply to:  11 comment:14 by leper, 11 years ago

Milestone: Alpha 13Alpha 12

Replying to historic_bruno:

  • The unpacked siege units still have UnitMotion, but a very small almost-zero speed, and UnitAI doesn't allow them to move without packing anyway. This has some mostly visual side effects in formations, because the formation moves at the speed of its slowest member (it goes very slow until the packing unit is done).

I think this can be done by adding a Pack order in front of the other orders (for formations), but that could cause the units to stay where they are atm.

comment:15 by ben, 11 years ago

In 12935:

Adds garrison auto-packing for siege units, refs #1718

comment:16 by ben, 11 years ago

In 12937:

Factors out common properties from siege templates, refs #1718. Simplifies pack-related tooltips.

comment:17 by fatherbushido, 7 years ago

In 20215:

Get rid of special_units templates for packable siege units. Refs #1718.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D925

comment:18 by Freagarach, 23 months ago

In 26877:

Some fixes for the Han stone thrower.

A.k.a. Mangonel.
Adds UnitMotion. Refs. #1718
Adjust footprint.
Rearrange parents.

Patch by: @Langbart
Differential revision: https://code.wildfiregames.com/D4608

Note: See TracTickets for help on using tickets.