Slinger withdraw

It can withdraw once every turn, meaning if it were to be melee attacked a 2nd time on the same turn, it will not withdraw. Also keep in mind that if you are trying to keep a civilian unit safe with the Slinger, it will withdraw and the civilian unit will be captured.
 
^^That is annoying when that happens.

But the ability to withdraw has saved a lot of my units :)
 
Yes, it's a pretty good ability. To bad you need construction in a timely manner
for those Terrace farms.

*Still hoping that someone looks the mechanics up in the code :blush:
 
Yes, it's a pretty good ability. To bad you need construction in a timely manner
for those Terrace farms.

*Still hoping that someone looks the mechanics up in the code :blush:

What mechanic?

Getting construction early isn't too bad as long as you don't have multiple tech luxuries in your starting location. Comp bowmen are great for barbs too.
 
What mechanic?

Getting construction early isn't too bad as long as you don't have multiple tech luxuries in your starting location. Comp bowmen are great for barbs too.

Well the unit ability reads:

"Withdraw Before Melee:
Unit will withdraw when faced with melee attack. Chance of withdrawal decreased against fast enemy units
or if there are limited open tiles behind the unit."

I'd like to know the chance for the slinger to withdraw in %.
Is the withdraw chance 100% when there are open tiles behind the unit? Not in my experience (unless i didn't pay attention very well ;/)
And how much does the chance to withdraw decrease against fast enemy units or if there are limited open tiles behind the unit?

I'd like to know my chances :)

it must be somewhere in the code..

hope my question is clear enough? English is not my main language.
 
Well the unit ability reads:

"Withdraw Before Melee:
Unit will withdraw when faced with melee attack. Chance of withdrawal decreased against fast enemy units
or if there are limited open tiles behind the unit."

I'd like to know the chance for the slinger to withdraw in %.
Is the withdraw chance 100% when there are open tiles behind the unit? Not in my experience (unless i didn't pay attention very well ;/)
And how much does the chance to withdraw decrease against fast enemy units or if there are limited open tiles behind the unit?

I'd like to know my chances :)

it must be somewhere in the code..

hope my question is clear enough? English is not my main language.

Your English is good :)
I'm not too sure on the exact % but it's a nice thing too have.
Inca are my favourite civ
 
Slinger withdrawal is a helpful bonus but not necessary. It feels like a privilege rather than a right.
 
If you want someone to quote actual bits of code, I'm more than happy to oblige.

When a unit can retreat from a melee attack, the game first takes the unit's base withdraw chance (80% for Slingers) and then subtracts 20% for each max movement point the attacker has above 2: eg. if a Knight attacks a Slinger, a -40% modifier is applied to the withdraw chance by default because Knights have a max movement range of 4, thus (4 - 2) * -20% = -40%. Note that this means units with a max movement range of 1 actually ADD 20% to the unit's withdraw chance (movement range of 0 wouldn't do anything), provided the unit has some base withdraw chance in the first place. The game then checks whether any of the three hexes on the far side of the attack are blocked (eg. if the attack happens from the NE, the directions checked are SW, SE, and West, in that order) and subtracts another 20% for each blocked hex; if all three hexes are blocked, the unit can never retreat. The game then rolls a random number between 0 and 99 inclusive, and if the roll's result is less than the withdraw chance, the unit withdraws to an adjacent tile by a random left-right bias and a bias to move away from the incoming attack (eg. if the attack happens form the NE, the bias is SW first, then West and SE, then NW and East). Note that even though the game technically lets retreats happen to plots adjacent to the original attacker's, units should never actually retreat to those plots, as they have the lowest priority when other plots are available, and when no other plots are available, the game forces the withdraw to not occur, even if the unit would have a 100% withdraw chance, since all 3 plots on the far side of the attack are blocked.

Forced retreats (from Winged Hussars) happen in a similar fashion, only it happens after the damage calculation goes through with a 100% chance of happening if at least one of the 3 plots on the far side of the attack are available.

I do not see any bit in the code that forces units to only ever withdraw from maximum one attack per turn. Provided all the necessary conditions are met (attacker is always a slow unit, hexes to be retreated to aren't blocked), there should be no reason why a unit with a withdraw chance would not be able to withdraw from multiple melee attacks in a single turn.

Relevant code bits to check are CvUnitCombat::Attack(), CvUnit::CanWithdrawFromMelee(), and CvUnit:: DoWithdrawFromMelee(). The basic structure is that within CvUnitCombat::Attack(), if the CvUnit::CanWithdrawFromMelee(attacker) call on the defender unit returns true, CvUnit:: DoWithdrawFromMelee(attacker) is called on the defender unit, as well as a supplementary CvUnit::UnitMove() call on the attacker unit to move into the vacated plot if it can.

Minor note, but Impis' first strike attack still goes through, even if the defender would withdraw from combat.
 
If you want someone to quote actual bits of code, I'm more than happy to oblige.

When a unit can retreat from a melee attack, the game first takes the unit's base withdraw chance (80% for Slingers) and then subtracts 20% for each max movement point the attacker has above 2: eg. if a Knight attacks a Slinger, a -40% modifier is applied to the withdraw chance by default because Knights have a max movement range of 4, thus (4 - 2) * -20% = -40%. Note that this means units with a max movement range of 1 actually ADD 20% to the unit's withdraw chance (movement range of 0 wouldn't do anything), provided the unit has some base withdraw chance in the first place. The game then checks whether any of the three hexes on the far side of the attack are blocked (eg. if the attack happens from the NE, the directions checked are SW, SE, and West, in that order) and subtracts another 20% for each blocked hex; if all three hexes are blocked, the unit can never retreat. The game then rolls a random number between 0 and 99 inclusive, and if the roll's result is less than the withdraw chance, the unit withdraws to an adjacent tile by a random left-right bias and a bias to move away from the incoming attack (eg. if the attack happens form the NE, the bias is SW first, then West and SE, then NW and East). Note that even though the game technically lets retreats happen to plots adjacent to the original attacker's, units should never actually retreat to those plots, as they have the lowest priority when other plots are available, and when no other plots are available, the game forces the withdraw to not occur, even if the unit would have a 100% withdraw chance, since all 3 plots on the far side of the attack are blocked.

Forced retreats (from Winged Hussars) happen in a similar fashion, only it happens after the damage calculation goes through with a 100% chance of happening if at least one of the 3 plots on the far side of the attack are available.

I do not see any bit in the code that forces units to only ever withdraw from maximum one attack per turn. Provided all the necessary conditions are met (attacker is always a slow unit, hexes to be retreated to aren't blocked), there should be no reason why a unit with a withdraw chance would not be able to withdraw from multiple melee attacks in a single turn.

Relevant code bits to check are CvUnitCombat::Attack(), CvUnit::CanWithdrawFromMelee(), and CvUnit:: DoWithdrawFromMelee(). The basic structure is that within CvUnitCombat::Attack(), if the CvUnit::CanWithdrawFromMelee(attacker) call on the defender unit returns true, CvUnit:: DoWithdrawFromMelee(attacker) is called on the defender unit, as well as a supplementary CvUnit::UnitMove() call on the attacker unit to move into the vacated plot if it can.

Minor note, but Impis' first strike attack still goes through, even if the defender would withdraw from combat.

Thank you good sir for this detailed and understandable answer.
Exactly what i was looking for.

I must say the slinger is even better then i expected.
 
I do not see any bit in the code that forces units to only ever withdraw from maximum one attack per turn. Provided all the necessary conditions are met (attacker is always a slow unit, hexes to be retreated to aren't blocked), there should be no reason why a unit with a withdraw chance would not be able to withdraw from multiple melee attacks in a single turn.

I can confirm through anecdotal evidence that barbarian ships (Caravels?) have retreated from me on consecutive attacks on the same turn :(
 
Top Bottom