[Python] zUnit Enslavement

Wait, no, I don't have it.

I'm trying to combine this with the Inquisition mod.

It features a CvEventManager.py which seems to be the source of my troubles. I have both working on their own, separately, but I can't for the life of me figure out how to merge them.

I think I've got the first part - the import part - right, it's the rest that I can't figure out, where to put the zunitenslavement stuff into the cveventmanager. Since zunit has a CustomEventManager and inquisition has a CvEventManager I thought maybe I could use both without merging anything but I'm getting crashes.

I'm really very new at fooling around with python etc ... could someone either explain this to me step by step, or merge the two for me so I can see how it's done?
 
Lol, ok, I think I have it (again). I had thought that the CvEventManager and CustomEventManager were the same thing sort of, I didn't realize you needed to have both.

So ... question now is ... do I need to define the whole self.addunit thing in both files? That's what I did and it seems to be working. At least, the unit enslavement seems to be working, not sure if the Inquisition python stuff that I merged it with is working or not.
 
And guess what ... no, I don't have it. It seemed to be working then I got a crash and this log:

Traceback (most recent call last):

File "CvEventInterface", line 27, in onEvent

File "CvEventManager", line 216, in handleEvent

File "CustomEventManager", line 58, in onCombatResult

File "zUnitEnslavement", line 367, in doEnslavement

AttributeError: 'NoneType' object has no attribute 'getEnslaveType'

I'm trying to do a mod that focuses on the period from 1450-1750, and religious persecution and slavery are big elements ... someone please help!

EDIT, it does not seem that this is a conflict with Inquisition at all. I'm getting this error in the logs using just zEnslavement as a mod all by itself, without doing any editing other than setting one unit to perform enslavement for test purposes. There's no problem with THAT unit, but the above error comes up every time an undefined unit gets into a fight.

The crash is unrelated. I have got them combined fine now, but I'm still curious because every time I check the logs, in the Python err log there is a huge long list of the above error; it crops up with every combat involving a victorious unit which has not been defined to enslave anything. Is this normal?
 
That would be really great. Just to note, it does work ... it just generates python errors whenever units that have no enslavement ability win a battle. But it doesn't crash. If you have the console going you get about 15 or 20 python error windows per turn, though.

Also the various setAll lines don't work. Only self.addunit seems to work. (Otherwise I would have just gone, self.setAllEnslave("UNIT_WORKER", None, 0, 0) and that would have fixed it)
 
And guess what ... no, I don't have it. It seemed to be working then I got a crash and this log:

Traceback (most recent call last):

File "CvEventInterface", line 27, in onEvent

File "CvEventManager", line 216, in handleEvent

File "CustomEventManager", line 58, in onCombatResult

File "zUnitEnslavement", line 367, in doEnslavement

AttributeError: 'NoneType' object has no attribute 'getEnslaveType'

I'm trying to do a mod that focuses on the period from 1450-1750, and religious persecution and slavery are big elements ... someone please help!

EDIT, it does not seem that this is a conflict with Inquisition at all. I'm getting this error in the logs using just zEnslavement as a mod all by itself, without doing any editing other than setting one unit to perform enslavement for test purposes. There's no problem with THAT unit, but the above error comes up every time an undefined unit gets into a fight.

The crash is unrelated. I have got them combined fine now, but I'm still curious because every time I check the logs, in the Python err log there is a huge long list of the above error; it crops up with every combat involving a victorious unit which has not been defined to enslave anything. Is this normal?

Sorry to jump in here... but I also keep getting the "'NoneType' object has no attribute isAlive" in a different Mod... I don't understand what this error means in general. I'm getting it from code that reads: "if (gc.getPlayer(iCiv).isAlive()):"

What circumstances causes the code to throw this error?

Thanks alot for your attention!
Spocko
 
Well when ever you get an error saying that NoneType doesn't have x attribute it means that some where along the way you asked for a variable object and got a NoneType. Then you took that NoneType that you thought was an object and ask it to do something that only that object can do, then you get that error. Now judging by your code iCiv is either to high or to low. Here's a fix:
Code:
if (iCiv < gc.getMAX_PLAYERS() and iCiv >= 0 and gc.getPlayer(iCiv).isAlive()):
This will make sure that iCiv is within gc.getPlayer's range, because if iCiv player is outside of gc.getPlayer's range you get a NoneType.
 
Well when ever you get an error saying that NoneType doesn't have x attribute it means that some where along the way you asked for a variable object and got a NoneType. Then you took that NoneType that you thought was an object and ask it to do something that only that object can do, then you get that error. Now judging by your code iCiv is either to high or to low. Here's a fix:
Code:
if (iCiv < gc.getMAX_PLAYERS() and iCiv >= 0 and gc.getPlayer(iCiv).isAlive()):
This will make sure that iCiv is within gc.getPlayer's range, because if iCiv player is outside of gc.getPlayer's range you get a NoneType.

Will this fix my zunitenslavement with BTS problem?

If so, in what file and where do I add this line exactly?
 
Well when ever you get an error saying that NoneType doesn't have x attribute it means that some where along the way you asked for a variable object and got a NoneType. Then you took that NoneType that you thought was an object and ask it to do something that only that object can do, then you get that error. Now judging by your code iCiv is either to high or to low. Here's a fix:
Code:
if (iCiv < gc.getMAX_PLAYERS() and iCiv >= 0 and gc.getPlayer(iCiv).isAlive()):
This will make sure that iCiv is within gc.getPlayer's range, because if iCiv player is outside of gc.getPlayer's range you get a NoneType.

Thanks Zebra 9! I'll put this to good use!

Spocko
 
Your welcome, and I'm going to make a new release soon. Currently I'm very busy with life and the Hand of History.:D

The problem in zUnitEnslavement is similar but not the same.
 
Okay, I'd really appreciate some help here as I just can't get this to work at all. I'm having some trouble figuring out what everything is that's in the python folder. What I've done (which I'm assuming is fine as the help file doesn't say otherwise) is copy everything from zunitenslavement/assets/python into my own mods python directory, which was previosuly empty so now contains the entrypoints and zunitenslavement folders and the customeventmanager.py file. I have edited this file according to the help text and started off with the simplest thing I could think of, getting rid of the initial example definitions and having just

self.setAllLandEnslave("UNIT_WORKER", 100)

If I understand the mod correctly this should make all land units always enslave a worker from succesful combat however nothing is happening, I'm not even getting an error message, it's as if the mod isn't taking effect at all.

BTW I'm using BTS 3.13.
 
Okay, I'd really appreciate some help here as I just can't get this to work at all. I'm having some trouble figuring out what everything is that's in the python folder. What I've done (which I'm assuming is fine as the help file doesn't say otherwise) is copy everything from zunitenslavement/assets/python into my own mods python directory, which was previosuly empty so now contains the entrypoints and zunitenslavement folders and the customeventmanager.py file. I have edited this file according to the help text and started off with the simplest thing I could think of, getting rid of the initial example definitions and having just

self.setAllLandEnslave("UNIT_WORKER", 100)

If I understand the mod correctly this should make all land units always enslave a worker from succesful combat however nothing is happening, I'm not even getting an error message, it's as if the mod isn't taking effect at all.

BTW I'm using BTS 3.13.

Read the thread. It isn't yet updated for BTS. setAll will not work. It sort of works, but not the setall function. It will work if you set a specific unit, but your log will be full of python errors (though it won't crash your game), one for every battle in which a unit that doesn't have the ability is victorious.
 
Read the thread. It isn't yet updated for BTS. setAll will not work. It sort of works, but not the setall function. It will work if you set a specific unit, but your log will be full of python errors (though it won't crash your game), one for every battle in which a unit that doesn't have the ability is victorious.

Thankyou for the reply, although I did read the thread actually and the download section says that this is compatibale with BtS.
 
If I get time today I will work on, at the least, a fix. I really want to make a totally new version that takes advantage of more BtS features. I also want to get the less advanced features out of python, now that I have the ability to read INI files.
 
If you're going to do a whole new version ...

What about adding a sacrifice option? Like in Civ3? Don't know if you're familiar with it, but in civ3 units could feature an option (which could be enabled by a tech) to be sacrificed in a city, which would give it some culture points. Usually it was set to allow sacrifice of captured workers and units enslaved as workers.

What I ideally want to be able to do is set up 3 different types of enslaved units, according to culture. Type 1 will be a low-efficiency worker, type 2 will be able to be sacrificed for culture points, and type 3 will be able to be sacrificed for hammers. Representing, in order, agricultural and other typical forms of slavery, human sacrifice, and forced labour such as used to build major projects.
 
Top Bottom