How to add the Lesser Catapult?


Good Morning

Yet another thing that I am looking at for this game is the addition of a Lesser Catapult unit at an earlier stage of the game. I was thinking that this lesser machine of war would be attached to the Drills tech. Naturally, since it is appearing so early in the game, the unit itself would have to be significantly simplified.

So far, I've pretty much halved the attack and piece damage the catapult does. I've halfed the construction cost too. However, there are still some major questions that I am hoping to have answered in order to make this work:

  • Currently the catapult unit does splash damage. I would like to remove this function, such that the Lesser Catapult only attacks a single tile. Is this possible?
  • How is the Unit_Catapult_Defender added to the city when Siege Weapons is researched? I would like the same for Drills, but do not know how to accomplish that?
  • I don't want two catapults to exist when Siege Weapons is researched. How to I make the Unit_Catapult_Defender a replacement effect for the Unit_Lesser_Catapult_Defender?

Thanks!

edit. Removed the code...

9,802 views 12 replies
Reply #1 Top


Good Morning

Alrighty. I've been struggling through this, but would love a gentle push in figuring this one part out:

To date:

I now have a successful Lesser Catapult Unit.
I now have the Lesser Catapult successfully attacking a single tile with it's basic attack. 
I now can successfully attach any ability I want to that Lesser Catapult Unit and for the most part play with any value. For the most part...

Essentially what I did to accomplish this was to copy the Flamedart_Ability from a staff and rename everything so that it works with the catapult instead...BUT the only left is how to calculate the damage. At the moment, it's pulling from Expression Calculations (shown below). What I would like it to do is pull from the Unit stats (also shown below).

How are these two items linked?

Here is where I would like to pull the attack from the CoreUnits:

    <UnitType InternalName="Unit_Lesser_Catapult">
        <DisplayName>Lesser Catapult</DisplayName>
        <Description>Catapults are devastating on the battle field but are extremely slow and expensive.</Description>
        <CanBeDesigned>1</CanBeDesigned>
        <AdditionalTrainingTurns>120</AdditionalTrainingTurns>
        <IgnoreItemTrainingCosts>1</IgnoreItemTrainingCosts>
        <IsCatapult>1</IsCatapult>
        <IsSovereign>0</IsSovereign>
        <IsUniqueButBuildable>1</IsUniqueButBuildable>
        <AllowGrouping>0</AllowGrouping>
        <TrainUnitIcon>TrainUnitIcon_Catapult.png</TrainUnitIcon>
        <LevelMilestone InternalName="L1">
            <Level>1</Level>
            <UnitStat_Attack_Pierce>14</UnitStat_Attack_Pierce>
            <UnitStat_CombatSpeed>16</UnitStat_CombatSpeed>
            <UnitStat_Defense_Pierce>20</UnitStat_Defense_Pierce>
            <UnitStat_HitPoints>20</UnitStat_HitPoints>
        </LevelMilestone>
more code here...

BUT, here is how it's currently written up:


    <SpellDef InternalName="Lesser_Splash">
        <DisplayName>Lesser Catapult Splash</DisplayName>
        <Description>Extra collateral damage at the enemy</Description>
        <FormattedDescription>Extra collateral damage dealing %d damage to a 3x3 area.</FormattedDescription>
        <IconFG>Action_Catapult.png</IconFG>
        <Cooldown>5</Cooldown>
        <SpellBookSortCategory>Unit</SpellBookSortCategory>
        <SpellBookSortSubCategory>UnitDamage</SpellBookSortSubCategory>
        <SpellType>Tactical</SpellType>
        <SpellClass>Offensive</SpellClass>
        <SpellSubClass>Damage</SpellSubClass>
        <SpellTargetType>EnemyUnit</SpellTargetType>
        <HideInHiergamenon>1</HideInHiergamenon>
        <AllowFriendlyFireInRadius>1</AllowFriendlyFireInRadius>
        <Radius>1</Radius>
        <IsResistable>0</IsResistable>
        <IsSpecialAbility>1</IsSpecialAbility>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>DefendableDamage</Attribute>
            <AttackStat>UnitStat_Attack_Pierce</AttackStat>
            <IsForFormattedDescription>1</IsForFormattedDescription>
            <Calculate InternalName="Calc" ValueOwner="CastingUnit">
                <Expression><![CDATA[[UnitOwner_GetNumFireShards] + [Unit_GetLevel]]]></Expression>
            </Calculate>
            <Calculate InternalName="Calc2" ValueOwner="CastingUnit">
                <Expression><![CDATA[[Calc] * [UnitStat_SpellDamage_Fire]]]></Expression>
            </Calculate>
            <Calculate InternalName="Value">
                <Expression><![CDATA[[Calc2] * 5]]></Expression>
            </Calculate>
            <Calculate InternalName="ValueForFormattedDescription">
                <Expression><![CDATA[[Calc2] * 5]]></Expression>
            </Calculate>
        </GameModifier>
more code here...

I see what it's doing....(Fireshards + Unit's Level) x Fire Damage x Multiplier. It's just not what I want. All I want is to referance the MilestoneLevel damage.

Any pointers would be helpful...

Thanks.

Reply #2 Top

The reference to the level milestone is how the ability is cast. Notice that the catapult attack comes from the ammo. Just like the bow attack. I believe this is where the connection between the unit attack, i.e. the level milestone.

Not exactly sure what you are trying to accomplish here, but I would probably create separate ammo and for the basic catapult attack and one for the lesser catapult. Adding appropriate health modifiers and such to make your lesser catapult. Adding pre-req to the ammo so the unit automatically upgrades to the newer ammo, when reaching the appropriate tech level.

Reply #3 Top

Quoting parrottmath, reply 2
The reference to the level milestone is how the ability is cast. Notice that the catapult attack comes from the ammo. Just like the bow attack. I believe this is where the connection between the unit attack, i.e. the level milestone.

Not exactly sure what you are trying to accomplish here, but I would probably create separate ammo and for the basic catapult attack and one for the lesser catapult. Adding appropriate health modifiers and such to make your lesser catapult. Adding pre-req to the ammo so the unit automatically upgrades to the newer ammo, when reaching the appropriate tech level.

Precisely what I did. I have the Lesser Catapult Unit using the Lesser Catapult Ammo as a weapon and the Lesser Catapult Ammo having the various abilities Lesser Splash, Greater Splash, and Hot Coals. (Currently I have all three attached to the Lesser Catapult Ammo for testing purposes. Once working correctly, the Greater Splash and the Hot Coals will be transferred to the Greater Catapult Ammo for the use of the Greater Catapult.)

The Lesser Splash is simply meant to do a Basic Lesser Catapult Attack, but with 3x3 (ie radius 1) effect (Just like the original Basic Catapult Attack) but with an added 5 turn cooldown.

The Greater Splash is like the above but with a 5x5 affected area (ie radius 2).

The Hot Coals will be a Fire attack, based on Fireshard strength and covers a 3x3 area with 5 turn cooldown.

For all three abilities, I would like the base attack to come for the Milestone L1 unitstat_attack_pierce value. (currently a value of 14). This way, if I choose to, I can later add more level milestones and have the Catapult unit balance itself out.

I didn't bother with adding the code from the LesserCatapultAmmo to this post because it simply bridges the Catapult to use it as a weapon and the abilities were attached to that weapon too.

So, are you saying that the  [Unit_GetLevel] refers to the Unit_Lesser_Catapult -> LevelMilestone InternalName="L1" -> <UnitStat_Attack_Pierce>14</UnitStat_Attack_Pierce> ?? I thought it refered to the unit level... aka "1". Clarification please.

I guess ultimately my question is this: Out of the two 'red' highlighted sections above, I want to delete the code for the Lesser Spash damage caculation and replace it with a referal to the Milestone level damage. I have no idea what code is needed to make this connection. What code is needed? Is that connection possible?

As side notes to the other items I've been tackling: 

Also, I think I've successfully attached the Lesser Catapult and (what I am now calling) the Greater Catapult to the Barracks Improvement and the Weaponsmith Improvement respectively. This is to address the issue of me wanting the greater catapult to replace the lesser catapult. The improvements are not perfect choices. I would have much rathered 'out of the way' techs/improvements that could have used an extra bonus, but there doesn't seem to be many improvements for the Fortress type city. The other option I was considering was Training Grounds // Command Post, but I felt that Command Post was too early in the tree. Your thoughts on it's placement?

Lastly, I've had to butcher the Watertower Improvement to provide that replacement effect, removing the Greater Catapult from it's list. Any recommendations as to what I should give the Watchtower that would be thematic and useful (else no one will ever pick it). One thing I plan to give it is a +1 ZoC. If possible, +1 sight as well (though I'm not sure if that's necessary). Your thoughts?

 

Reply #4 Top


FYI. Now that I am in front of my home computer, here is the code for the LesserCatapultAmmo from the CoreWeapons.xml

    <GameItemType InternalName="LesserCatapultAmmo">
        <DisplayName>Catapult Ammo</DisplayName>
        <Description>Heavy shot suitable for smashing walls or unprotected foes.</Description>
        <Type>Weapon</Type>
        <CanBeEquipped>1</CanBeEquipped>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>UnlockCombatAbility</Attribute>
                <StrVal>Lesser_Splash</StrVal>
                <Provides>Extra collateral damage at the enemy</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>UnlockCombatAbility</Attribute>
                <StrVal>Greater_Splash</StrVal>
                <Provides>Extra collateral damage at the enemy</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>UnlockCombatAbility</Attribute>
                <StrVal>Hot_Coals</StrVal>
                <Provides>Launches hot coals at the enemy</Provides>
            </GameModifier>
            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>UnlockRangedAction</Attribute>
                <StrVal>BasicLesserCatapultAttack</StrVal>
                <Provides>Ranged attack</Provides>
            </GameModifier>
        <IsAvailableForSovereignCustomization>0</IsAvailableForSovereignCustomization>
        <RarityDisplay>Common</RarityDisplay>
        <TacticalRange>9</TacticalRange>
        <SupportUnitType>Unit_Catapult</SupportUnitType>
        <IsAvailableForUnitDesign>0</IsAvailableForUnitDesign>
        <ArtDef>CatapultAmmo_ArtDef</ArtDef>
        <GameItemTypeArtDef InternalName="CatapultAmmo_ArtDef">
            <GameItemTypeModelPack InternalName="CatapultAmmo_Default">
                <IconFile>Caravan1_Medallion.png</IconFile>
                <TintR>0</TintR>
                <TintG>0</TintG>
                <TintB>0</TintB>
                <AttackSFX>CatapultToss1_M</AttackSFX>
            </GameItemTypeModelPack>
        </GameItemTypeArtDef>
    </GameItemType>

 

The abilities in red will ultimately be moved to the Greater Catapult unit once I've determined them working properly.

Reply #5 Top


Good Morning

Okay....I THINK I've got it working right. Would love some confirmation on that though. This is what I've done:

For the code for the Lesser_Spash ability (shown above) I've simply REMOVED the part in 'red'. Ran the game.

Seemed to work..gave damges of 6, 8, and 9 against a bunch of skeletons.

Now my question: Does removing that part simply tell the spell to look at the unit's Pierce attack to obtain it's damage value, aka the 14 shown above in red from the Unit's code ??

 

Reply #6 Top


One more question. Forgive me if Heavenfall has already answered this question twice already, but I can't seem to get my head around it so I'll ask it again just to be sure:

It would seem that the only left for me to do to make my catapult additons into a standalone mod is to remove the Gamemodifier from the CoreImprovements that attach the catapult defender to the Watchtower Improvement. Is there a way to obtain this objective through the mod directory only??

(if so, then I think I can package all this catapult working into a standalone mod)

??

Reply #7 Top

Quoting GFireflyE, reply 6

One more question. Forgive me if Heavenfall has already answered this question twice already, but I can't seem to get my head around it so I'll ask it again just to be sure:

It would seem that the only left for me to do to make my catapult additons into a standalone mod is to remove the Gamemodifier from the CoreImprovements that attach the catapult defender to the Watchtower Improvement. Is there a way to obtain this objective through the mod directory only??

(if so, then I think I can package all this catapult working into a standalone mod)

??

lolz. I think I answered my own question. I remembered a trick that Parrotmath did while I was perusing through his wonderbase mod...basically negating the old improvement with a tech prereq "you can't get this" and replacing the code with an identical+changes in the mod.

Woo Hoo! I think I'm good to go now. All I need to make sure is that I understand how the damage is being done correctly. However, I think I'm at the stage to start up an emod thread....

Reply #8 Top

Nice to see that my tricks are paying off... Heavenfall uses that trick in a few places as well. It's rather useful when you want your mod to be modular. Mild issue is that others may not know it and if done too often it may lead to compatibility problems with other mods. Something to be aware of when playing with these tricks.

Reply #9 Top

Quoting parrottmath, reply 8
Nice to see that my tricks are paying off... Heavenfall uses that trick in a few places as well. It's rather useful when you want your mod to be modular. Mild issue is that others may not know it and if done too often it may lead to compatibility problems with other mods. Something to be aware of when playing with these tricks.

Quite true. I thought of that going in. However, I didn't think anyone had come close to thinking about moddinging the Watertower Improvement. XD

 

Reply #10 Top


K, this is frustrating.

I replace the Watertower Improvement with a watchtower_new improvement the same way as Parrotmath replaced IronMine, Smelter, Foundry, etc in his wondersbase mode:

Thing is, when the Watchtower comes up for level 3 upgrade on my fortress....NONE of my changes take effect. It's correct in the hiergermemnon....just no where else.

Not sure what the problem is....but he's the code I have in place for the watchtower_new:

    <ImprovementType InternalName="Watchtower">
 <HideInHiergamenon>1</HideInHiergamenon>
      <Prereq>
  <Type>Tech</Type>
  <Attribute>YouCantGetThisTech</Attribute>
      </Prereq>
    </ImprovementType>

    <ImprovementType InternalName="Watchtower_New">
        <DisplayName>Watchtower</DisplayName>
       <Description>Watchtowers increase the city's zone of control by +1 and provide two archer units for city defense. In addition, all units trained here start with the Charge trait (+1 Moves and +2 Attack for the first action in combat). </Description>
        <RequiresCity>1</RequiresCity>
        <RequiresForceUnlock>1</RequiresForceUnlock>
        <BarredTerrain>River</BarredTerrain>
        <BarredTerrain>SwampTerrain</BarredTerrain>
        <PreferredTerrain>City</PreferredTerrain>
        <PreferredTerrain>Category:Land</PreferredTerrain>
        <PreferredTerrain>Forest</PreferredTerrain>
        <RequiresCityImprovement>1</RequiresCityImprovement>
        <RequiredImprovement>Fortress</RequiredImprovement>
        <LaborToBuild>0</LaborToBuild>
        <GameModifier>
            <ModType>CityTrainingBonus</ModType>
            <Attribute>TrainingBonus_ApplyAbilityBonus</Attribute>
            <StrVal>Charge</StrVal>
            <Provides>Trained units get +1 Move and +2 Attack on the first action in combat</Provides>
        </GameModifier>
        <GameModifier>
            <Value>1</Value>
            <Provides>+1 Zone of Control</Provides>
            <UpgradeComparisonID>1</UpgradeComparisonID>
            <UpgradeComparisonText>Zone of Control</UpgradeComparisonText>
        </GameModifier>
        <GameModifier>
            <ModType>CityDefenseSummon</ModType>
            <Attribute>SummonUnitByClass</Attribute>
            <Value>2</Value>
            <Multiplier>3</Multiplier>
            <Provides>+2 City Archer Groups</Provides>
            <UnitClass>CityArcher</UnitClass>
        </GameModifier>
        <AIData AIPersonality="AI_General">
            <AIPriority>5</AIPriority>
            <AITag>CommandPost</AITag>
        </AIData>
        <ArtDef>Art_Watchtower</ArtDef>
    </ImprovementType>

Reply #11 Top


Did you forget to change this

<AbilityBonusOption InternalName="UnlockWatchtower">
            <DisplayName>Watchtower</DisplayName>
            <Description>Watchtowers provide a Catapult for city defense all units trained here start with the Charge trait (+1 Move and +2 Attack for the first action in combat).</Description>
            <Icon>K_Watchtower_Thumb_01.png</Icon>
            <GameModifier>
                <ModType>City</ModType>
                <Attribute>UnlockImprovement</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>Watchtower</StrVal>
            </GameModifier>
            <Likelihood>400</Likelihood>
            <RarityDisplay>Common</RarityDisplay>
            <RequiredLevel>3</RequiredLevel>
            <Prereq>
                <Type>AbilityBonusOption</Type>
                <Target>City</Target>
                <Attribute>UnlockFortress</Attribute>
            </Prereq>
            <AIData AIPersonality="AI_General">
                <AIPriority>5</AIPriority>
            </AIData>
        </AbilityBonusOption>

You do not need to add the pre-req to the Watchtower since it won't unlock unless forced through an upgrade on the Fortress. These abilities will override all prereqs.

Reply #12 Top

Quoting parrottmath, reply 11

Did you forget to change this

<AbilityBonusOption InternalName="UnlockWatchtower">
            <DisplayName>Watchtower</DisplayName>
            <Description>Watchtowers provide a Catapult for city defense all units trained here start with the Charge trait (+1 Move and +2 Attack for the first action in combat).</Description>
            <Icon>K_Watchtower_Thumb_01.png</Icon>
            <GameModifier>
                <ModType>City</ModType>
                <Attribute>UnlockImprovement</Attribute>
                <BoolVal1>1</BoolVal1>
                <StrVal>Watchtower</StrVal>
            </GameModifier>
            <Likelihood>400</Likelihood>
            <RarityDisplay>Common</RarityDisplay>
            <RequiredLevel>3</RequiredLevel>
            <Prereq>
                <Type>AbilityBonusOption</Type>
                <Target>City</Target>
                <Attribute>UnlockFortress</Attribute>
            </Prereq>
            <AIData AIPersonality="AI_General">
                <AIPriority>5</AIPriority>
            </AIData>
        </AbilityBonusOption>

You do not need to add the pre-req to the Watchtower since it won't unlock unless forced through an upgrade on the Fortress. These abilities will override all prereqs.

What xml is this located in?

nvm....I found it.