Need creative solution(s) to "wonder unit" problem

Herostratus

Grim Harbinger of Things to Come
Joined
Jul 24, 2009
Messages
116
OK, so I've figured out how to add a unit to Civ4 :D ...but there's an effect I was shooting for that I can't figure out how to achieve.

Essentially, I want to add some "wonder units" that a civ gets for building certain wonders. The first one I'm working on is the Crusader, a buffed-up version of the Swordsman with a few free promotions, which comes with Hagia Sophia.

What I can't figure out is
#1 - whether it's possible for the Crusader to simply "spawn" once the Hagia Sophia is built,
and if not, and if the unit has to be built rather than spawned,
#2 - how to enforce a build limit on the Crusader unit, like the missionaries', only ideally just 1 instead of 3.

Judging from previous threads, it looks like #2 would have to involve Python, and I'd prefer to avoid that. Is there another way?

I also can't rely on custom events to achieve #1 because I play my mod in multiplayer, and we have to turn off random events or else we get OOS errors.

I am willing to be flexible about how all this turns out--in Civ 2, our wonder units *were* dependent on events, were spawned rather than built, and could not be replaced if they were destroyed. Now, I'd be content to allow players to "rebuild" a lost wonder unit, provided that ONLY that player could build them, and provided that the player could not build tons of them.

Thanks for whatever feedback you can provide. Please remember, I am still a beginning modder :blush:
 
Yes, I've been wondering this, too. Monasteries need to be built to make missionaries, so shouldn't we be able to make a world wonder that allows a certain kind of unit?

Don' mean to hijack OPs thread, but would it be possible to only allow one of a certain kind of unit per city in the empire?
 
OK, so I've figured out how to add a unit to Civ4 :D ...but there's an effect I was shooting for that I can't figure out how to achieve.

Essentially, I want to add some "wonder units" that a civ gets for building certain wonders. The first one I'm working on is the Crusader, a buffed-up version of the Swordsman with a few free promotions, which comes with Hagia Sophia.

What I can't figure out is
#1 - whether it's possible for the Crusader to simply "spawn" once the Hagia Sophia is built,
and if not, and if the unit has to be built rather than spawned,
#2 - how to enforce a build limit on the Crusader unit, like the missionaries', only ideally just 1 instead of 3.

Judging from previous threads, it looks like #2 would have to involve Python, and I'd prefer to avoid that. Is there another way?

I also can't rely on custom events to achieve #1 because I play my mod in multiplayer, and we have to turn off random events or else we get OOS errors.

I am willing to be flexible about how all this turns out--in Civ 2, our wonder units *were* dependent on events, were spawned rather than built, and could not be replaced if they were destroyed. Now, I'd be content to allow players to "rebuild" a lost wonder unit, provided that ONLY that player could build them, and provided that the player could not build tons of them.

Thanks for whatever feedback you can provide. Please remember, I am still a beginning modder :blush:
#1 is possible by scripting via python. You'll have to add an entry to the CvEventManager.py in the event "onBuildingBuilt".

#2 is much easier to imply, you can define a limit in the CIV4UnitClassInfos.xml. For example, the entry for an Executive looks like this:
Code:
		<UnitClassInfo>
			<Type>UNITCLASS_EXECUTIVE_1</Type>
			<Description>TXT_KEY_UNIT_EXECUTIVE_1</Description>
			<iMaxGlobalInstances>-1</iMaxGlobalInstances>
			<iMaxTeamInstances>-1</iMaxTeamInstances>
			<iMaxPlayerInstances>5</iMaxPlayerInstances>
			<iInstanceCostModifier>0</iInstanceCostModifier>
			<DefaultUnit>UNIT_EXECUTIVE_1</DefaultUnit>
		</UnitClassInfo>
As you can see, the iMaxPlayerInstances defines the number of units one player can build at a time. iMaxTeamInstances is the same for all player of the same team together and iMaxGlobalInstances for all players in the game together. An entry of -1 means no limit.
 
*headsmack* Of course, the class. Thanks Saibot.

I'm pleased to report that it works after setting iMaxPlayerInstances to 1. Once you build one, the Crusader disappears from the city's buildable-stuff-list (it's not even greyed out) until you get it killed. It reappears in the list immediately upon its death :cool:

A few other things I learned, which might be useful to someone in the future:
- my Crusader wonder unit shows up, greyed out, in all cities' buildable-stuff-list from the beginning of the game unless I give it a prereq tech. So I just picked Theology, which is also Hagia Sophia's prereq.
- the Crusader can only be built in the same *city* that contains Hagia Sophia. I suppose this means if someone captured that city, they could build their own Crusader :cry:
- though it is just a beefed-up version of the Swordsman, it HAS TO HAVE ITS OWN CLASS or else bad things happen.
 
- the Crusader can only be built in the same *city* that contains Hagia Sophia. I suppose this means if someone captured that city, they could build their own Crusader :cry:
I'm not quite sure I follow. What seems to be the problem? :confused: Or, what do you need?

Did you manage to spawn the unit with the wonder, by the way?
 
I'm not quite sure I follow. What seems to be the problem? Or, what do you need?
It's not a problem, actually. I was just pointing it out.

Did you manage to spawn the unit with the wonder, by the way?
No, I skipped the python approach. Instead, you have to build the unit.

There has been a modcomp for 'Kind Richard's Crusade' made by tsentom1.
Looks interesting... and a good deal more relevant to the unit than the Hagia Sophia!

I have a new problem with this unit, actually :rolleyes: ...the barbarians are getting them. Is there a way to prevent that? "Barbarian Crusaders" just doesn't quite work.
 
I have a new problem with this unit, actually :rolleyes: ...the barbarians are getting them. Is there a way to prevent that? "Barbarian Crusaders" just doesn't quite work.
You'll have to add an entry to the CIV4CivilizationInfos.xml's Barbarian section. There is an subsection called units where you can define unique units or no units for a certain unitclass. For example, the entry
Code:
				<Unit>
					<UnitClassType>UNITCLASS_SETTLER</UnitClassType>
					<UnitType>NONE</UnitType>
				</Unit>
makes sure that the Barbarians can build no settler.
 
What about this for Hagia Sofia?
Spoiler :
Once built, the Wonder spawns a Crusader unit.
Any time the unit dies, a new one is automatically spawned (free-of-charge) at the Wonder's location. (It might even retain the previous unit's attributes, like XP/promotions.)
 
Back
Top Bottom