UU Problem

jhunt1376

Chieftain
Joined
Apr 16, 2011
Messages
31
I posted a question in a different subforum and they directed me here:

I'm trying to make a UU for a civ that would essentially be a non-suicidal missionary. This unit would be similar to a spy in that when its "mission" is over, it would come back to the capital. How would I go about doing that using python, or is there even a way?

Thanks
JAH
 
You need to know programming, for starters. Look in my signature for links on how to get started with Python modding.

Else you need a programmer to do the work for you. If you can't be bothered with learning this stuff yourself I suggest you post the exact specifications for what you need, so that someone in the know would be able to help you out. Like what XML tag the unit concerned has, specifics like that.

If you already know Python, then what you need to do is to intercept the game at the onUnitSpreadReligionAttempt game event in the CvEventManager module. Since the unit has been deleted you need to make another by the same unit type. The methods involved would be CyPlayer.getCapitalCity(), CyCity.getX(), CyCity.getY() and CyPlayer.initUnit(). The CyUnit instance of the expired unit is supplied with the call-up, so you clone its attributes to the new unit with CyUnit.convert() and pass the instance as a parameter in the method invocation.

This is the theory anyway - I haven't tried it myself.
 
hm, I will hafta read through those. Thanks a lot, Baldyr. Do you think, on average, it takes a long while to learn python? I have some C knowledge, if that helps any.
 
If you already know some of the basics of programming, you should pretty much be able to learn the basics of Python in one single sitting. Just read the first 10 or so chapters of the textbook linked in my signature. You should be able to make sense of it immediately.

In order to be able to handle Python modding you really need to understand the concept of Object Oriented Programming, so you need to go back to the textbook and read some additional 4-6 chapters. (Note that you don't even have to finish the whole textbook, knowing about classes and methods i enough.)

Then, you could read through my own Python modding tutorial - if you read the textbook you should be able follow it without any problems. That one is also linked below this post.

So, with your prior experience, you should be able to master Python modding within... a week? There is of course always more to learn and new tricks to pick up, but that is true about anything and everybody.
 
Top Bottom