Fort Attack

Archid

Warlord
Joined
Oct 30, 2009
Messages
296
Location
North Wales, UK
Free Fort Attack

Synopsis
Allows units in forts, and optionally cities, a free attack against enemies in the surrounding plots

Download
The file is available for download at CF here

Gameplay
Configured units that are stationed in a fort at the end of a turn can perform a free attack against enemy troops in the surrounding squares. The attackers also need some movement points at the end of the turn.

The potential targets of attack varies depending on the ownership of the fort plot. If the fort is on a plot that is owned by a player then only enemies of the owners team are potential targets. If the fort is in neutral territory then all units in surrounding squares are considered potential targets.

At the end of a turn each attacker picks one of its teams enemies at random and performs the attack. The damage that these attacks can give uses a configurable base value (percentage of targets full health) with a multiplier based on the relative strength of the attacker and target. There is a configurable cap on the maximum percentage damage that a target can have at the end of the attack, and any units that have less than this value are not considred potential targets. The attackers are never damaged in a fort attack.

The configurable values are set in the GlobalDefinesAlt file.

Situation before the end of turn
Spoiler :




Catherine & Qin decided on a suicide attack with one of their archers before the fort attack began so the attackers strength had changed before the fort attack began
Spoiler :

Qin gets attacked 3 times and Catherins once



and rinse and repeat
Spoiler :

Both attacked twice this time, Catherine was attacked by SB & Monte who were both damaged during the suicide attackes so you can see the power ratio being applied to the damage



Modders
The types of units who can attack is based on a new optional tag in the UnitCombatInfo type so is fully configurable.

SDK Changes marked with Archid

Added XML tags
-------------------
++ UnitCombatInfo
bFortAttack - If units of this combat type get a free attack from forts. Defaults to 0


Revision History
-------------------
v1.1 Fixed CTD bug if a potential attacker has no UnitCombatType
Added message to players if they are the attackers

v1.0 Initial release
 
Looks very interesting :goodjob:

I'm adding this to my VIP and considering using it for cities as well.
The optimal solution would be if city had XX building (i.e. citywalls and/or castle), but donno how to code.
Guess its around here ? :
PHP:
bool CvPlot::isCanFortAttack() const
{
	return getImprovementType() != NO_IMPROVEMENT && GC.getImprovementInfo(getImprovementType()).isActsAsCity();
}

another thing that would be pure awesome, was if the iAirRange was considered also for landunits. (using airRange for my siegeweapons in VIP).


edit : Also a message when one of your own units have attacked a unit would be nice :D
 
Would be more realistic if only ranged units can perform the free attacks
 
If you want it to act for both forts and cities then the following should work.

PHP:
bool CvPlot::isCanFortAttack() const
{
	return isCity(true);
}

passing true to the method tells it to also check improvements. I am in the middle of helping someone else out with their mod for now so I am a bit busy, but I'll see if I can find some time to code up having a building tag enable cities to have a free attack. It shouldn't be that difficult.
 
Cities can now optionally (GlobalDefinesAlt) attack in the same way as forts. I have also added a message for each attacker when they have damaged an enemy.
 
Top Bottom