HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...
Figure out unit_can_defend_here() while transported
Should being able to be unloaded by the transport count as being able to defend (like it does now) or should a unit that can't alight be considered useless as a defender? What about a unit that can alight but can't be unloaded?
"Transport Alight" and "Transport Unload" can have ruleset defined side effects from Lua and effects. Should a transported unit be forced to unload before it can defend? What if it becomes unable to defend while performing the exit transport action? What if it becomes a worse defender?
My suspicion is that the answer to these questions should be answered by rule set. A Laser Gun loaded on a ship should be able to defend against an incoming attack while transported. A Legion on a River Boat should have to alight first and suffer the mp punishment from exiting. A unit that is unloaded slowly should not be able to defend.
#2 Updated by Sveinung Kvilhaugsvik over 1 year ago
Related forum thread: http://forum.freeciv.org/f/viewtopic.php?f=13&t=91063
#4 Updated by Sveinung Kvilhaugsvik over 1 year ago
Possible solution (brain storm-level): 2 phases. First prepare each unit to defend. Then check legality / best defender.
Prepare to defend
This makes the ruleset able to force units at a tile under attack to prepare them self. This should put them in a state where they legally can defend. Get a requirement vector and a list of actions from the ruleset. The requirement vector is evaluated against each possible defender unit. If a unit matches the requirement vector it will be forced to perform the first legal action in the action list. (Can probably be implemented as an action auto performer.) Example: Prepare to defend is triggered by a transported unit at a tile it can exist on and does alight in the requirement vector.
May need to special case transports unloading cargo since that is a unit preparing another unit, not a unit preparing it self.
Get another requirement vector from the ruleset. A unit can defend at the tile if this vector is fulfilled (and hard coded limitations are fulfilled). Pick the best defender as normal. Example: the requirement vector forbids units inside transports from defending.