From 6110da1ef45575c8fe27ac51e7f436fdb2ab4c00 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 16 Feb 2008 20:42:11 +0100 Subject: [PATCH] Fix mobility cost for marines assaulting from non-landing ships Always charge land units at least as much mobility for assaulting from non-landing ships as for landing ships. Before, marines lost all mobility when assaulting from a non-landing ship, which could be less than what the same assault costs from a landing ship (half an update's worth). --- info/Attacking.t | 23 +++++++++++------------ info/assault.t | 14 ++++++-------- src/lib/subs/attsub.c | 20 +++++++++++++++----- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/info/Attacking.t b/info/Attacking.t index 45ccdfd3..18a139ed 100644 --- a/info/Attacking.t +++ b/info/Attacking.t @@ -307,18 +307,17 @@ If the combat was an assault, paradrop, board or lboard, then all victorious mil and units are automatically moved into the target. The mil are moved in with no mobility charge. If the combat is assault, then the mil will take an amount of food with them proportional to the -number of people leaving the ship. The mobility cost to land units is -as follows: -.NF -Assault: If the land units are attacking from a ship with "land" capability, - then land units are charged (update mob) mobility, except for - "marine" units which are only charged half of that. For all - other kinds of ships, land units go to -(update mob), except for - "marine" units which go to zero. Here, (update mob) refers to - the amount of mobility that units gain at the update. -Board: Marine units are charged 10 mobility and other land units are - charged 40. -.FI +number of people leaving the ship. +.s1 +Assaulting units pay one update's worth of mobility, except for +"marine" units, which pay only half of that. Unless assaulting from a +ship with "land" capability, mobility is further decreased to one +update's worth of mobility negated (so that the unit will have zero +mobility after the update), except for "marine" units, whose mobility +is decreased to zero instead. +.s1 +For boarding, "marine" units are charged 10 mobility and other land +units are charged 40. .s1 In the case of attack, the aggressor is asked what they'd like to move in as follows: First, the aggressor is asked how many mil diff --git a/info/assault.t b/info/assault.t index d6f0fbf7..e8c8a027 100644 --- a/info/assault.t +++ b/info/assault.t @@ -20,14 +20,12 @@ semi-lander flag, which allows them to land 25% of their troops. If you have land units with the 'assault' ability aboard the ship assaulting, you will be asked if you wish them to join in the assault as well. -Assaulting land units go to negative mobility when assaulting. -(by an amount equal to the mobility gain per update) -Marine units go to 0 mobility instead. -If assaulting from a ship with the landing ability, a normal unit -pays only mob equal to 1 update's worth of mobility. A marine unit -pays 1/2 that amount. (Example: in a game where land units gain 32 -mobility per update, a non-marine unit would pay 32 mobility to assault -from a landing ship. A marine unit would pay only 16 mobility) +Assaulting units pay one update's worth of mobility, except for marine +units, which pay only half of that. Unless assaulting from a ship +with landing capability, mobility is further decreased to one update's +worth of mobility negated (so that the unit will have zero mobility +after the update), except for marine units, whose mobility is +decreased to zero instead. .s1 .L NOTE This mobility loss for units happens whether or not you diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index 03d1cc3c..1284a143 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -2525,7 +2525,7 @@ take_move_in_mob(int combat_mode, struct ulist *llp, struct combat *off, { double mob = llp->unit.land.lnd_mobil; double gain = etu_per_update * land_mob_scale; - double mobcost; + double mobcost, moblim; switch (combat_mode) { case A_ATTACK: @@ -2534,10 +2534,20 @@ take_move_in_mob(int combat_mode, struct ulist *llp, struct combat *off, lnd_mobtype(&llp->unit.land))); break; case A_ASSAULT: - if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE) - mobcost = off->shp_mcp->m_flags & M_LAND ? gain / 2.0 : mob; - else - mobcost = off->shp_mcp->m_flags & M_LAND ? gain : mob + gain; + /* + * Set mobcost to basic assault cost, moblim to maximum + * mobility to keep when assaulting from non-landing ship + */ + if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE) { + mobcost = gain / 2.0; + moblim = 0; + } else { + mobcost = gain; + moblim = -gain; + } + if (!(off->shp_mcp->m_flags & M_LAND)) + /* Not a landing ship, ensure we go to or below moblim */ + mobcost = MAX(mobcost, mob - moblim); break; case A_BOARD: if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)