Mod-Modders Guide to Fall Further

Two questions.
1)Is it possible to have a unit summoned by a spell that will die if the caster leaves the tile? Basically, what is done for the buildings in a city, but for units instead.
2)I have created diverse lines for the spell spheres. The choice(offensive or normal) is done at level 1. Everything works perfectly, as long as there are no multiple mana for the specific sphere. If there are, e.g. 2 mana sources for fire mana, the newly created adept gets Fire I automatically, and does not allow for Fire I Offensive to be selected... Any suggestions for a way around it?

That's done in Python when the unit's created, as long as it's Arcane. I don't know how to make that selectable, really... You could do it if the Offense/Tactical mage was a different unit though...
 
That's done in Python when the unit's created, as long as it's Arcane. I don't know how to make that selectable, really... You could do it if the Offense/Tactical mage was a different unit though...

It sounds good. If there is no other way I will follow this solution. Another solution would be to make it random, 50% chance each.
I hope there is another solution that can make it selectable without hindering the AI.
 
Any ideas about the first issue? The handling of the Loki puppets should provide something like what I want. Instead of +5 duration out of Loki's tile, a +1 duration. But, I need to know where is this handling taking place...I hope it is not in the dll.
A function similar to haste will be better, though.
 
The method used for Loki's Puppets relies on the fact that there is only one Loki in the game. You could use a similar approach, but that would allow the unit to "Pass the puck" and let another arcane unit tend to his summon for him. There are some tools in the design documents which would make what you want to do quite simple, but I need time to code before those become reality.
 
The method used for Loki's Puppets relies on the fact that there is only one Loki in the game. You could use a similar approach, but that would allow the unit to "Pass the puck" and let another arcane unit tend to his summon for him. There are some tools in the design documents which would make what you want to do quite simple, but I need time to code before those become reality.

What I want to do is implement a "wall of fire" that will do 20% damage to units attacking the stack. That unit("wall of fire") will be held, have blitz and 100% to do a defensive strike for 20% damage. It will have a defence of 0. I want any caster capable of casting this spell to be able to maintain it. Just like a stone wall or hope for cities.
 
I'm searching in vain how the game choose between Korrina or the Risen Emperor as the Scions hero. I looked in XML, python and a bit in dll even though I don't know where to look exactly. So, where should I look?
 
Ok, I take it back, you COULD pull that one off with the current capabilities if you want it to maintain just like Wall of Stone and whatnot.

Temporary Summon, SpecialUnit_Spell (disables enhanced duration and some other things which wouldn't be completely appropriate). Create an AutoAcquire/MustMaintain promotion which has PrereqPromotionsOnTile set to require the enabling spellcaster promotion (ie - Fire II) and grants +1 duration per turn.


Do that and the wall will be set to expire on the next turn, but so long as a viable caster is on the tile, it will be considered permanent.

Opera: The Hero is defined in python, customFunctions.py I believe. Just search for _DONAL and you should find it pretty quickly, nothing else is too special about him that I can think of.
 
I'm searching in vain how the game choose between Korrina or the Risen Emperor as the Scions hero. I looked in XML, python and a bit in dll even though I don't know where to look exactly. So, where should I look?

How the game gives each Scion Leader the proper Hero, and only that Leader?

XML. Umm... lets see:

RE is controlled via BuildingInfos. He requires the Vacant Mausoleum. The VM in turn requires a Leader with the Organized Trait. The RE-Leader doesn't have Organized. Korrina does.

Korrina is controlled via EventTriggers. The event that spawns her only triggers for the RE-Leader. (EVENTRIGGER_POP_KORRINA)

(The function xienwolf mentions is getHero. Which, if I'd known about it when I started, might be how the Scions sort things out.)
 
Thanks for the answers, xienwolf and Tarquelne!
I have what I wanted now! :goodjob:
 
Ok, I take it back, you COULD pull that one off with the current capabilities if you want it to maintain just like Wall of Stone and whatnot.

Temporary Summon, SpecialUnit_Spell (disables enhanced duration and some other things which wouldn't be completely appropriate). Create an AutoAcquire/MustMaintain promotion which has PrereqPromotionsOnTile set to require the enabling spellcaster promotion (ie - Fire II) and grants +1 duration per turn.


Do that and the wall will be set to expire on the next turn, but so long as a viable caster is on the tile, it will be considered permanent.

I have tried to implement the Fire Wall using your instructions, but there are some problems:
1) When you include <Special>SPECIALUNIT_SPELL</Special>, the unit is deleted at the end of your turn, no matter what unit it is. Even with a permanent summon.
2)The Promotion fails to remove when there is no unit with FIRE II on the tile.
In addition, the Durations are not taken in account. I tried with iChangeDuration, and the wall was removed 2 turns later. iDurationAlter did nothing at all.

My best try so far, was to turn it in a permanent summon with a promotion giving it the defensive strike and blitz. However, the promotion is not removed when the prereqs are not met.

Here is the Promotion:

Spoiler :

Code:
<PromotionInfo>		<!-- FIREWALL -->
	<Type>PROMOTION_FIREWALL</Type>
	<Description>TXT_KEY_PROMOTION_FIREWALL</Description>
	<Sound>AS2D_IF_LEVELUP</Sound>
	<bAutoAcquire>1</bAutoAcquire>
	<bMustMaintain>1</bMustMaintain>
	<bNoXP>1</bNoXP>
	<PrereqPromotionsOnTile>
		<Promotion>PROMOTION_FIRE2</Promotion>
	</PrereqPromotionsOnTile>
	<bBlitz>1</bBlitz>
	<UnitCombats>
		<UnitCombat>
			<UnitCombatType>UNITCOMBAT_FIREWALL</UnitCombatType>
			<bUnitCombat>1</bUnitCombat>
		</UnitCombat>
	</UnitCombats>
	<Button>Art/Interface/Buttons/Promotions/BigPinkBox.dds</Button>
	<iDefensiveStrikeChance>100</iDefensiveStrikeChance>
	<iDefensiveStrikeDamage>20</iDefensiveStrikeDamage>
	<bOnlyDefensive>1</bOnlyDefensive>
	<bImmuneToCapture>1</bImmuneToCapture>
	<bImmuneToFear>1</bImmuneToFear>
	<bImmuneToMagic>1</bImmuneToMagic>
	<bNotAlive>1</bNotAlive>
</PromotionInfo>


The spell:

Spoiler :

Code:
<SpellInfo>			<!-- Wall of Fire -->
	<Type>SPELL_WALL_OF_FIRE</Type>
	<Description>TXT_KEY_SPELL_WALL_OF_FIRE</Description>
	<Civilopedia>TXT_KEY_SPELL_WALL_OF_FIRE_PEDIA</Civilopedia>
	<PromotionPrereq1>PROMOTION_FIRE2</PromotionPrereq1>
	<bAllowAI>1</bAllowAI>
	<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
	<bHasCasted>1</bHasCasted>
	<CreateUnitType>UNIT_WALL_OF_FIRE</CreateUnitType>
	<iCreateUnitNum>1</iCreateUnitNum>
	<bPermanentUnitCreate>1</bPermanentUnitCreate>
	<Effect>EFFECT_SPELL1</Effect>
	<Sound>AS3D_SPELL_HOPE</Sound>
	<Button>Art/Interface/Buttons/Buildings/Wall.dds</Button>
</SpellInfo>


The unit:

Spoiler :

Code:
<UnitInfo>		<!-- Fire Wall -->
	<Class>UNITCLASS_FIRE_ELEMENTAL</Class>
	<Type>UNIT_WALL_OF_FIRE</Type>
	<Combat>UNITCOMBAT_FIREWALL</Combat>
	<Domain>DOMAIN_IMMOBILE</Domain>
	<DefaultUnitAI>UNITAI_RESERVE</DefaultUnitAI>
	<Description>TXT_KEY_UNIT_WALL_OF_FIRE</Description>
	<Civilopedia>TXT_KEY_UNIT_WALL_OF_FIRE_PEDIA</Civilopedia>
	<Strategy>TXT_KEY_UNIT_WALL_OF_FIRE_STRATEGY</Strategy>
	<Advisor>ADVISOR_MILITARY</Advisor>
	<UnitAIs>
		<UnitAI>
			<UnitAIType>UNITAI_RESERVE</UnitAIType>
			<bUnitAI>1</bUnitAI>
		</UnitAI>
	</UnitAIs>
	<PrereqTech>TECH_ELEMENTALISM</PrereqTech>
	<iMoves>0</iMoves>
	<iCombat>0</iCombat>
	<iAsset>0</iAsset>
	<iPower>0</iPower>
	<UnitMeshGroups>
		<iGroupSize>1</iGroupSize>
		<iMeleeWaveSize>1</iMeleeWaveSize>
		<iRangedWaveSize>1</iRangedWaveSize>
		<UnitMeshGroup>
			<iRequired>1</iRequired>
			<EarlyArtDefineTag>ART_DEF_UNIT_FIRE_ELEMENTAL</EarlyArtDefineTag>
		</UnitMeshGroup>
	</UnitMeshGroups>
	<FreePromotions>
		<FreePromotion>
			<PromotionType>PROMOTION_ELEMENTAL</PromotionType>
			<bFreePromotion>1</bFreePromotion>
		</FreePromotion>
	</FreePromotions>
	<bNoWarWeariness>1</bNoWarWeariness>
	<iTier>3</iTier>
	<DamageTypeCombats>
		<DamageTypeCombat>
			<DamageType>DAMAGE_FIRE</DamageType>
			<iCombat>0</iCombat>
		</DamageTypeCombat>
	</DamageTypeCombats>
</UnitInfo>


I have added the UNITCOMBAT_FIREWALL in the UnitCombats, to make sure the promotion will only be autogiven to the Firewall.

Am I doing something wrong?

Also, the dummy entries in the Units/Promotions/Spells have many missing fields. For example iDefensiveStrikeChance, iDefensiveStrikeDamage(for both units and promotions) and many other fields in all 3 of them.
 
Yeah, I thought about the auto-delete of SpecialUnit_Spell after I posted that. The function responsible will be deleted for next patch, there is no point in it since SpecialUnit already prevents any enhanced duration.

Why did you invent a new unitcombat? Seems a wasted move, unless you are also creating special promotions for them, or some anti-unitcombat capabilities on other promotions/units to counter them. And I am not sure what the point of assigning it 0 fire damage is, that won't do anything at all.

Not sure why the promotion isn't removing itself, you have the MustMaintain listed, so that should set everything up automatically.

As for Change/Alter Duration working wierd, those ones are a bit strange if you apply them before the spell applies the duration to the unit (ie - have them as a starting promotion for the unit, or have them AutoAcquire with prereqs which are met instantly upon creation). The spell forces a specific duration on the unit, so any altering of their duration done before that will work in reverse (you'll lose the bonus duration when the promotion is removed from the unit without having gained upon application)

ie - Apply AlterDuration -5 to a unit immediately upon summoning, then it is set to a duration of 2 (instantly clicked down by 1). Now you remove the AlterDuration promotion from the unit and the duration bumps up to 6.


Also, MustMaintain won't remove a promotion which is listed as a free promotion in UnitInfos. Did you maybe have it set that way when you tested things?
 
Yeah, I thought about the auto-delete of SpecialUnit_Spell after I posted that. The function responsible will be deleted for next patch, there is no point in it since SpecialUnit already prevents any enhanced duration.

Good. Can you tell me where it is so that I can go and delete it myself for my tests?

Why did you invent a new unitcombat? Seems a wasted move, unless you are also creating special promotions for them, or some anti-unitcombat capabilities on other promotions/units to counter them. And I am not sure what the point of assigning it 0 fire damage is, that won't do anything at all.

The promotion has Autoaquire. So, I have to specify a unitcombat to autoaquire it, right? If I leave it blank, then all default unitcombats will be able to get it(?). This is what I thought.

The Fire damage 0 was just left there when doing some tests with Fire Damage 1, then put it to 0 again...

Not sure why the promotion isn't removing itself, you have the MustMaintain listed, so that should set everything up automatically.

As for Change/Alter Duration working wierd, those ones are a bit strange if you apply them before the spell applies the duration to the unit (ie - have them as a starting promotion for the unit, or have them AutoAcquire with prereqs which are met instantly upon creation). The spell forces a specific duration on the unit, so any altering of their duration done before that will work in reverse (you'll lose the bonus duration when the promotion is removed from the unit without having gained upon application)

ie - Apply AlterDuration -5 to a unit immediately upon summoning, then it is set to a duration of 2 (instantly clicked down by 1). Now you remove the AlterDuration promotion from the unit and the duration bumps up to 6.

The default duration for summons appears to be 1. When used iDurationAlter 1, did not show any change on the unit's duration in game. I hadn't removed or changed anything else at that time, because I was trying to figure out how to make it work, first...

Also, MustMaintain won't remove a promotion which is listed as a free promotion in UnitInfos. Did you maybe have it set that way when you tested things?

I had it at first, removed it later. The unitinfo that I posted here is the one I test with.
The promotion giving 100% defensive strike chance, I guess it means 100% of the already existing. So, if that is 5% it goes to 10%, if it is 0% it stays 0%...Is this correct?

In the meantime, I have also tried to solve the mana bonus issue. It was a tough nut to crack, but I finally did it. Unfortunatelly, I had to add a
Code:
ReportEventToPython(pUpgraded,"UnitUpgradedEvent");
to the Upgrade method of the unit.

There is a report there, but it is only called when unit statistics are enabled.
In order to make it randomly apply the bonuses, I had to pick the unit after it was upgraded. The OnUnitCreated event is called before the old unit copies its promotions to the new one, so it was impossible to correctly upgrade the correct line.
When I set up the OnUnitUpgradedEvent and hooked there the bonus promotions, all went well. Still, the OnUnitCreate event checks the adepts for bonuses, but everything else is covered on the onUnitUpgradedEvent.
Perhaps such an event can be included in the next patch, because it is very useful for modding things that must happen on upgrades.

Hopefully, when you tell me what to delete to have the SPECIALUNIT_SPELL work correctly, I might be able to implement the FireWall as I want it to be(almost. The ideal situation would be to do fire damage to the attacking units, without depriving the archers from the chance to do defensive strikes, but I do not think this is currently doable).
 
The auto-delete is in the DLL, in CvPlayer during doTurn or somesuch. Just search for SpecialUnit_spell and it'll show right up.

You don't need to specify a unitcombat for a promotion if you specify a unit for it.

You don't quite follow me on the DurationAlter bit, but that's ok because it is a bit confusing. Just avoid trying to apply any such effects on a unit the same turn it is created and you'll do fine. What you want to use to make a semi-permanent unit is DurationPerTurn anyway.

100% Defensive Strike chance means it increases whatever the unit's current Def strike chances by 100, to a max of 100. That percent is the chance that this unit will attempt to perform a defensive strike. Setting it at 100 means that unless someone else is going to make a stronger strike, this unit will always make a strike when the tile is attacked. You are right that only one defenesive strike can ever happen with the current setup.
 
The auto-delete is in the DLL, in CvPlayer during doTurn or somesuch. Just search for SpecialUnit_spell and it'll show right up.

Thanks, I'll check it out.
You don't need to specify a unitcombat for a promotion if you specify a unit for it.

And how do I specify a unit for it? I tried the UnitRequired but it didn't work as expected.

You don't quite follow me on the DurationAlter bit, but that's ok because it is a bit confusing. Just avoid trying to apply any such effects on a unit the same turn it is created and you'll do fine. What you want to use to make a semi-permanent unit is DurationPerTurn anyway.

If the promotion is Autoaquired on creation, it is difficult not to apply it on creation.

100% Defensive Strike chance means it increases whatever the unit's current Def strike chances by 100, to a max of 100. That percent is the chance that this unit will attempt to perform a defensive strike. Setting it at 100 means that unless someone else is going to make a stronger strike, this unit will always make a strike when the tile is attacked. You are right that only one defenesive strike can ever happen with the current setup.

The fire walls having the posted promotion, failed to preform a single defensive strike against an attack of 7 beasts of agares...Could it be possible?

Since you didn't comment on the upgrade event, I guess it is not going to be included next patch...
 
UnitRequired is what you would want to use. Should work without issue.

And yes, if you have it autoacquired it is difficult to avoid application on creation unless you set up something in the requirements which will not be met until after creation is completed. That is what I was saying.

I'm not sure how Defensive strikes work, but it might require that the unit striking out has some base strength.

And very little will be included from me in the next patch except minor edits here and there. Quite busy right now, so wouldn't be able to code and debug something completely new.
 
All my tests show that PrereqPromotionsOnTile is being totally ignored.
I have tested whatever you can think of. For the purpose of my tests I have allowed all UnitCombats to get PROMOTION_FIREWALL.
The most evident last test was this:
I checked for PrereqUnitsOnTile, specifying a "WALL_OF_FIRE" to be present. It worked as expected.
Then I deleted this, and asked PrereqPromotionsOnTile, specifying a "PROMOTION_ELEMENTAL". Now, all Firewalls have elemental. But, in game, it was completely ignored. My units can get the promotion without any Elementals being on the tile. And, of course, they can never lose it.

Xienwolf said:
And very little will be included from me in the next patch except minor edits here and there. Quite busy right now, so wouldn't be able to code and debug something completely new.

The ReportToPython I described, is just one line of code.
If you include the python extra coding, is a total of 6 lines(including the def OnUnitUpgradedEvent and the assignments of the units in variables), which only require one execution of the game to make sure the syntax is correct. It does not change anything in the game. It just allows for modders to hook on the OnUnitUpgrade event.

I can post the changes needed, provided that the team is interested in including such an event in the next patch.
 
One more question. The promotion's iDuration. I assume the code checks for a caster having the PrereqPromotion for the promotion in question? That is, for the purposes of the spell reworking, if, lets say, I make the firewall to a promotion instead of a unit, the spell requires Fire2 for the caster, so, if there is a caster with fire2 with the stack the promotion will not expire..Right?
And, if I also set it to be lost on move, the iDuration becomes irrelevant and the promotion is lost as soon as the unit moves?
 
Yes, duration won't count down if there is a viable caster on the tile. Probably ought to write a boolean which allows you to bypass that feature for certain promotions. It isn't that it checks for the prereqs of the promotion though, it checks for someone able to cast a spell to provide that promotion, but that is the example you stated anyway.

Not sure how you would set a promotion to be lost on movement, other than a MustMaintain which is impossible to fulfill, but that a spell can bypass (like prereqLevel).


My main issue with just tossing in the report to python bit is that it is a new function to me, and I am always very wary of anything I haven't used before to check into precisely what/how things are happening. The fact I don't understand that function yet is probably why UnitStats doesn't work right now, because it relies on many of those function calls and something somewhere broke it (I would imagine probably the disabling of the combat log). The method I have used previously to interact with python is more involved since you pass along an argslist and allow a response from python.

I'll check in on PromotionOnTile when I get some spare time and see if I can figure out what broke with it though.
 
If it means anything to you, I got that report working nicely.
I hope you will be able to figuer out why the PrereqPromotionOnTile does not work. I have been looking at the code again and again, but it appears that it should have been working :confused:.

Another thing I noticed is that some promotions do not appear in the promotions list... Perhaps you know why? I have created a Burned promotion that is applied to units attacking a unit that has a Firewall promotion, before combat begins. The system works correctly, but the Burned promotion does not appear in the promotions list.
 
Back
Top Bottom