Remove tech using triggers
Hi guys, is there any example where tech is removed using triggers?
What about using tech that only applies on a terrain?
@prussia Total World War does a lot with tech and triggers including adding terrain bonuses when techs are researched: https://github.com/triplea-maps/total_world_war/blob/master/map/games/Total_World_War_Dec1941.xml
Here is an example of increasing alpine unit attack in hills:
<attachment name="triggerAttachmentgermanSW4" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="trigger" value="conditionAttachmentgermanSpecialWarfare"/> <option name="territoryEffects" value="Hills"/> <option name="territoryEffectProperty" value="combatOffenseEffect" count="2:germanAlpineInfantry"/> <option name="when" value="before:germanyCombatMove"/> <option name="uses" value="1"/> </attachment>
Prussia last edited by Prussia
Thanks, Redrum. What about removing a tech using trigger?
@prussia Do you mean removing a tech that is available to research or remove a tech that has already been researched? Can you give an example of how you want to use it?
My units are not differentiated by nation, i.e. all russian and german infantry have "Infantry" type so I can't quite easily use the code you provided. so I have a work around.
I have a tech called "winter equipment" which is used to counter the effects of "winter" terrain.
I code the winter equipment tech with exactly the opposite of the penalties to winter terrain. Therefore whoever has that tech will have advantage in "winter" terrain.
My "Winter" terrain is triggered to apply to territories in round 3, 7, 11, etc. so for the tech to work properly, I need:
Either a) be able to remove the tech on other rounds so that the advantage don't give advantage in other seasons or
b) be able to tell the engine to only apply this tech in a specific terrain.
If you have other simpler codes that would be welcome. If I have to re-code the units by nation then that's basically recoding the entire XML file.
@prussia I'm not aware of any way to remove a tech. I think you'd have to have triggered add/remove the specific terrain bonuses directly not using a tech.
@prussia If you made your "Winter Equipment" Tech that only effects unit values when the Winter terrain is present.... then the tech should not add bonuses when the terrain is not present.
So really I don't think you'd ever need the tech to be removed.
@hepps Good point... not sure why I didn't think of that.
I tried it yesterday but it didn't work out the way i thought it would:
<attachment name="Winter_Equipment_Action_R" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="Winter_Equipment_Condition_R"/> <option name="territoryEffects" value="Moderate.Winter-Climate"/> <option name="territoryEffectProperty" value="combatOffenseEffect" count="0:infantry"/> <option name="territoryEffectProperty" value="combatDefenseEffect" count="0:infantry"/> <option name="when" value="before:russianPurchase"/> </attachment>
What happened: ALL nations's infantry became immume to winter effects, not just russians.
@prussia Yes because you are applying the effect to "Infantry".
So the way it is written is that the Russians initiate and fire a trigger activating "winter_Equipment_Condition_R" that affects the performance of all "Infantry" where there is the presence of "Moderate.Winter-Climate".
You need to specify that it should only affect Russian Infantry.
I'm trying not to define units by nation, like Russian.infantry vs German.infantry because that would basically require me to redo the entire XML =(
Is it possible to code this like any other tech, like this but with additional terrain restrictions?
<attachment name="techAbilityAttachment" attachTo="jetPower" javaClass="games.strategy.triplea.attachments.TechAbilityAttachment" type="technology"> <option name="attackBonus" value="1:fighter"/> <option name="attackBonus" value="1:tactical_bomber"/> <option name="defenseBonus" value="1:fighter"/> <option name="defenseBonus" value="1:tactical_bomber"/> </attachment>
@prussia That would require the addition of the "Winter Equipment" Tech to the Hard coded technologies as part of the Global Properties in the Engine. If I am not mistaken.
But am not sure.
@prussia The other issue is that tech would then apply bonuses universally. Not specific to a terrain type.
@hepps I believe you can define your own custom techs that aren't hardcoded in the engine. An example of this I believe is in Global 40 (Airborne_Forces):
<attachment name="techAbilityAttachment" attachTo="Airborne_Forces" javaClass="games.strategy.triplea.attachments.TechAbilityAttachment" type="technology"> <option name="airborneForces" value="true"/> <option name="airborneCapacity" value="2:airfield"/> <option name="airborneBases" value="airfield"/> <option name="airborneTypes" value="infantry"/> <option name="airborneDistance" value="3"/> <option name="airborneTargettedByAA" value="AA:infantry"/> </attachment>
@prussia For territoryEffects to be different for different nations, you pretty much have to move towards an XML which defines unique units like RussianInfantry, GermanInfantry, etc. Otherwise you can't specify different territoryEffect bonuses per nation.
Correct, best way would be, to create nation specific units. I had to do this with my version winter climate effects. I put my mod on back burner for now. Until I rethink the whole tech model. I think using so much luck in game changing technologies, can be annoying.
I think best way to approach winter climate as a technology for now, is to make it a national advantage only, for Russia. Because Germany will surely research "winter combat training" tech as soon as possible. Especially if it only 5pu per token. Keeping failed tokens only solidifies the decision to try for it.
So with the existing tech model, this method is highly likely to defeat the entire purpose of creating the winter climates and all the hard work of making nation specific units, in the first place. Unless you make some drastic tech model changes, of course.
The method you are trying to use by switching the tech on and off has a terrible side effect. Anyone that uses the battle calculator won't get accurate outcomes while the tech is off. So advance planning will be very difficult.