1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[MODCOMP] Unit Combat Attack Defense Mod

Discussion in 'Civ4 - Mod Components' started by TheLopez, Sep 9, 2010.

  1. TheLopez

    TheLopez Deity

    Joined:
    Jan 16, 2006
    Messages:
    2,525
    Location:
    Oregon
    Unit Combat Attack Defense Mod v0.1BtS
    By: TheLopez

    Last Update: 09/09/10

    Version: v0.1BtS
    Patch Compatibility: Beyond the Sword v3.19
    MP Compatible: ?
    Download Mod v0.1BtS

    Description:
    This mod adds a couple of new tags that allow the specification of unit combat
    attack and defense modifiers separately instead of as a whole as the existing
    tag <UnitCombatMods> does. What this allows you to do is split up the attack and
    defense percentage modification. For instance the updated warrior definition
    using the new tags looks like:
    Code:
          <UnitCombatAttackMods>
            <UnitCombatAttackMod>
              <UnitCombatType>UNITCOMBAT_MELEE</UnitCombatType>
              <iUnitCombatMod>75</iUnitCombatMod>
            </UnitCombatAttackMod>
          </UnitCombatAttackMods>
          <UnitCombatDefenseMods>
            <UnitCombatDefenseMod>
              <UnitCombatType>UNITCOMBAT_MELEE</UnitCombatType>
              <iUnitCombatMod>50</iUnitCombatMod>
            </UnitCombatDefenseMod>
          </UnitCombatDefenseMods>
    
    -----Notes to Modmakers-----

    If you want to use this mod component in your mod I have tried to make things
    as easy as possible for you. In the XML files I have added
    <!-- Unit Combat Attack Defense Mod Start --> and
    <!-- Unit Combat Attack Defense Mod End --> in all of the places where
    changes were made. In the SDK files I have added
    // < Unit Combat Attack Defense Mod Start > and
    // < Unit Combat Attack Defense Mod End > in all of the places where
    changes were made. In the python files I have added
    # < Unit Combat Attack Defense Mod Start > and
    # < Unit Combat Attack Defense Mod End > in all of the places where changes
    were made.

    -----Version Information-----

    -----v0.1BtS------

    - Setup the Unit Combat Attack Defense Mod infrastructure

    - Added the new <UnitCombatAttackMods> tag that allow specification of percent
    attack bonuses against a particular unit combat type.

    - Added the new <UnitCombatDefenseMods> tag that allow specification of percent
    defense bonuses against a particular unit combat type.

    - As an example of how to use the new tags warriors have been updated in the
    CIV4UnitInfos.xml file.

    -----===Credits & Thanks===-----

    - Exavier - Composite Mod - readme.txt format

    - Cybah - for suggesting this mod
     
  2. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,605
    Location:
    israel
    oh wee theres no stopping you huh?

    thats a very good addtion, it will allow a more detailed warfare system,

    awesome.
     
  3. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,480
    yaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. :D WOHOO! TYVM. :)
     
  4. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    Here's a screenie:
    Spoiler :
     
  5. Mexico

    Mexico TR senior programmer

    Joined:
    Dec 2, 2005
    Messages:
    578
    Location:
    Slovakia, Kosice
    we implemented this mod in our beta Total realism for BtS and we found a bug in combat calculation:
    in CvUnit.cpp, method CvUnit::baseCombatStr, you missed check for combat type NO_COMBAT - in this case if you fight with NO_COMBAT unit like animals, attacker always get combat odds > 99,9% because unitCombatAttackModifier/unitCombatDefenseModifier is not defined for this

    Old code:
    Code:
    // < Unit Combat Attack Defense Mod Start >
    			iExtraModifier = unitCombatDefenseModifier(pAttacker->getUnitCombatType());
    			iTempModifier += iExtraModifier;
    			if (pCombatDetails != NULL)
    			{
    				pCombatDetails->iCombatDefenseModifier = iExtraModifier;
    			}
    
    			iExtraModifier = -pAttacker->unitCombatAttackModifier(getUnitCombatType());
    			iTempModifier += iExtraModifier;
    			if (pCombatDetails != NULL)
    			{
    				pCombatDetails->iCombatAttackModifier = iExtraModifier;
    			}
    			// < Unit Combat Attack Defense Mod End   >
    
    			if (pAttacker->getUnitCombatType() != NO_UNITCOMBAT)
    			{
    				iExtraModifier = unitCombatModifier(pAttacker->getUnitCombatType());
    				iTempModifier += iExtraModifier;
    				if (pCombatDetails != NULL)
    				{
    					pCombatDetails->iCombatModifierA = iExtraModifier;
    				}
    			}
    			if (getUnitCombatType() != NO_UNITCOMBAT)
    			{
    				iExtraModifier = -pAttacker->unitCombatModifier(getUnitCombatType());
    				iTempModifier += iExtraModifier;
    				if (pCombatDetails != NULL)
    				{
    					pCombatDetails->iCombatModifierT = iExtraModifier;
    				}
    			}
    
    
    bugfix:
    Code:
    			UnitCombatTypes eAttackerUnitCombat = pAttacker->getUnitCombatType();
    			if (eAttackerUnitCombat != NO_UNITCOMBAT)
    			{
    				iExtraModifier = unitCombatModifier(eAttackerUnitCombat);
    				iTempModifier += iExtraModifier;
    				if (pCombatDetails != NULL)
    				{
    					pCombatDetails->iCombatModifierA = iExtraModifier;
    				}
    
    				iExtraModifier = unitCombatDefenseModifier(eAttackerUnitCombat);
    				iTempModifier += iExtraModifier;
    				if (pCombatDetails != NULL)
    				{
    					pCombatDetails->iCombatDefenseModifier = iExtraModifier;
    				}
    			}
    
    			UnitCombatTypes eDefenderUnitCombat = getUnitCombatType();
    			if (eDefenderUnitCombat != NO_UNITCOMBAT)
    			{
    				iExtraModifier = -pAttacker->unitCombatModifier(eDefenderUnitCombat);
    				iTempModifier += iExtraModifier;
    				if (pCombatDetails != NULL)
    				{
    					pCombatDetails->iCombatModifierT = iExtraModifier;
    				}
    
    				iExtraModifier = -pAttacker->unitCombatAttackModifier(eDefenderUnitCombat);
    				iTempModifier += iExtraModifier;
    				if (pCombatDetails != NULL)
    				{
    					pCombatDetails->iCombatAttackModifier = iExtraModifier;
    				}
    			}
    
     
  6. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,605
    Location:
    israel
    thank you Mexico for this!
     

Share This Page