How to completely swap art for a unit?

Cool. We could finally be in business for Worm Riders in Dune Wars...
 
oooooooooooooooo0000000000000000oooooooooooo YYyyyyyyyyeeeeeeesssssss!
Distended typing FTW
 
Hey davidlallen

Now after your success, could you perhaps make a small turtorial to how you can make a unit change graphics on terrain-change or comand?
I've got a bit difficulty of following your work, only by reading through your thread.:crazyeye:
 
I had unsubscribed this thread some time back, thank you for the additional PM to draw my attention back.

This feature is working in Dune Wars. However, it is not easy to separate out into a separate modcomp. There is an sdk part and an XML part; so unless you can take C++ code out of the Dune Wars sdk files, modify it appropriately, and compile it into your mod, you would not be able to use this. It also re-uses the LateArtStyleTag, so if you had early or late art variants already, you could not use it.

If you are already comfortable with modifying C++ code in the sdk, then please download the latest version of Dune Wars (see the download database; here is a current version but newer versions will replace it.) In the cvgamecoredll directory, search for comments matching "davidlallen.*reuse late art tag". You will find code segments in CvInfos.cpp and CvUnit.cpp. The code in CvInfos.cpp makes the art style tag local to a unit. The code in CvUnit.cpp has a few magic words copied from Kael's code in FFH around reloadEntity, which actually loads and unloads the art.

The one nasty bit is the four lines inside CvUnit::move, which is highly specific to Dune Wars:
Code:
	if (pPlot->isWater() != pOldPlot->isWater())
		if (m_pUnitInfo->getLateArtDefineTag(0, (UnitArtStyleTypes) 0))
			if (isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_SANDRIDER")))
				reloadEntity();

This specifically checks for a promotion, by name, and forces an art swap when a unit with that promotion moves in or out of water. For whatever your application may be, you would need to change these lines.

Once you have a cvgamecoredll.dll built with this, then you need to add the artstyles into the xml. This is not hard if you are familiar with writing xml for new units. Basically, you have two artdefines in assets/xml/art/civ4artdefines_unit.xml, one for the land version and one for the sea unit. Then use the EarlyArtDefineTag for the land unit and the LateArtDefineTag for the sea unit. You can search in the Dune Wars assets/xml/units/civ4unitinfos.xml file for "LateArtDefineTag". All the places where this is used are related to the feature. In the Fremen Scout unit, for example, you will see it uses ART_DEF_UNIT_FREMEN_SCOUT on land, but ART_DEF_UNIT_FREMEN_WORM on water.

If you have specific questions about this, I will be happy to answer, but please keep in mind this requires sdk mods and some assumptions, as I have mentioned above.
 
What exactly is sdk and C++code?
 
I had unsubscribed this thread some time back, thank you for the additional PM to draw my attention back.

This feature is working in Dune Wars. However, it is not easy to separate out into a separate modcomp. There is an sdk part and an XML part; so unless you can take C++ code out of the Dune Wars sdk files, modify it appropriately, and compile it into your mod, you would not be able to use this. It also re-uses the LateArtStyleTag, so if you had early or late art variants already, you could not use it.

If you are already comfortable with modifying C++ code in the sdk, then please download the latest version of Dune Wars (see the download database; here is a current version but newer versions will replace it.) In the cvgamecoredll directory, search for comments matching "davidlallen.*reuse late art tag". You will find code segments in CvInfos.cpp and CvUnit.cpp. The code in CvInfos.cpp makes the art style tag local to a unit. The code in CvUnit.cpp has a few magic words copied from Kael's code in FFH around reloadEntity, which actually loads and unloads the art.

The one nasty bit is the four lines inside CvUnit::move, which is highly specific to Dune Wars:
Code:
	if (pPlot->isWater() != pOldPlot->isWater())
		if (m_pUnitInfo->getLateArtDefineTag(0, (UnitArtStyleTypes) 0))
			if (isHasPromotion((PromotionTypes)GC.getInfoTypeForString("PROMOTION_SANDRIDER")))
				reloadEntity();

This specifically checks for a promotion, by name, and forces an art swap when a unit with that promotion moves in or out of water. For whatever your application may be, you would need to change these lines.

Once you have a cvgamecoredll.dll built with this, then you need to add the artstyles into the xml. This is not hard if you are familiar with writing xml for new units. Basically, you have two artdefines in assets/xml/art/civ4artdefines_unit.xml, one for the land version and one for the sea unit. Then use the EarlyArtDefineTag for the land unit and the LateArtDefineTag for the sea unit. You can search in the Dune Wars assets/xml/units/civ4unitinfos.xml file for "LateArtDefineTag". All the places where this is used are related to the feature. In the Fremen Scout unit, for example, you will see it uses ART_DEF_UNIT_FREMEN_SCOUT on land, but ART_DEF_UNIT_FREMEN_WORM on water.

If you have specific questions about this, I will be happy to answer, but please keep in mind this requires sdk mods and some assumptions, as I have mentioned above.

Rather than hardcode a promotion, could you not add a 'bReloadArtOnWater' tag to units/promotions, and check if the unit has that? Less hardcoding is a good thing, IMO.

Also: That same mechanic is possible in FF, without requiring any hardcoding at all. Autoacquire promotions ftw. :p
 
What exactly is sdk and C++code?

This question tells me you are not a good candidate to implement this feature. There are three levels of modding you can do in Civ. The easiest is XML. You can change the movement rate, or combat strength of a unit, or add new units with existing behaviors. The middle level is python. This is a programming language which allows you to add new behaviors. The hardest level is changing the internals of the game engine itself. This third level involves writing C++ code. C++ is a programming language which is harder than python. (Well, some people may debate that. Using C++ in civ is harder than using python in civ, since there is a compile/link step.) To use C++ in civ, you must use the Software Design Kit (sdk) which is supplied by Firaxis.

valkrionn said:
Rather than hardcode a promotion, could you not add a 'bReloadArtOnWater' tag to units/promotions, and check if the unit has that?

Thank you for the suggestion. Of course adding a tag would be cleaner, just more code. Since only one person is using the code, it does not matter much.

That same mechanic is possible in FF, without requiring any hardcoding at all. Autoacquire promotions ftw.

Yes, that was pointed out earlier in the thread. But since FF is a huge customization of its own, unrelated to the huge customization in Dune Wars, merging the two together would be much harder than adding the seven lines of sdk code I actually added.
 
Thank you for the suggestion. Of course adding a tag would be cleaner, just more code. Since only one person is using the code, it does not matter much.

True, it's just a one man thing; But adding a tag would be what, like 10 locations in CvInfos and then a small amount in CvUnit? I just think it's cleaner. Your mod though. :p

Yes, that was pointed out earlier in the thread. But since FF is a huge customization of its own, unrelated to the huge customization in Dune Wars, merging the two together would be much harder than adding the seven lines of sdk code I actually added.

This is true, and I believe I'm the one who pointed out; I just mention it here because it's in the FfH subforum, so most reading it will be interested in using it for an FfH mod, where the code already exists or is far simpler to merge. ;)
 
davidlallen and Valkrionn you are discussing about how it's done in FF and Dune Wars.
Thought, are you discussing the same way of changing a units graphic within the game or are there two different ways?:confused:
 
There is one way. It is implemented in at least two different places, perhaps more. Neither author (including myself) has taken the extra effort to make this particular feature available as a standalone modcomp. I think it would be hard to make in a completely general way.
 
Is is possible to achieve this art swapping using just XML changes in Fall Further?

As an example, if I wanted to make a spell that switched a Dragon from a non-flying to a flying state and back, could that be achieved entirely via XML if I was modding Fall Further? I guess I would need to temporarily add a Flying promotion which would then be associated with the flying NIF somehow.
 
Top Bottom