adapt a script

print is it okay to put here?
i have error- attach 2
14:05:00 TRACE: Error in buildingBuilt event handler <function onBuildingBuilt at 0x1E35D2B0>
14:05:00 TRACE: global name 'iPlayer' is not defined
 

Attachments

  • 1.jpg
    1.jpg
    80.9 KB · Views: 11
  • 1s.jpg
    1s.jpg
    60.1 KB · Views: 16
Last edited:
Once more, I saw iPlayer in existing code and assumed that it would be defined. :/
So I guess that's why your code had no effect. Though I think you should've gotten a Python Exception popup from your own use of iPlayer, so it's strange that you had no errors.
Indentation of the print statement looks wrong. Well, perhaps it won't be needed now. Just setting iPlayer = pPlayer.getID() might make your code work.
 
Once more, I saw iPlayer in existing code and assumed that it would be defined. :/
So I guess that's why your code had no effect. Though I think you should've gotten a Python Exception popup from your own use of iPlayer, so it's strange that you had no errors.
Indentation of the print statement looks wrong. Well, perhaps it won't be needed now. Just setting iPlayer = pPlayer.getID() might make your code work.
Now work.

always very kind and helpful
thx
 
Sorry if I always ask for help, I would like to make sense of the inquisitor, so I want to give punishment to a city that has other religions besides the state one, I made a draft phyton script hoping it goes well
 

Attachments

  • 1213.jpg
    1213.jpg
    30.2 KB · Views: 12
The chaining with "and" only works inside conditions. Well, I think, your code is syntactically correct, but only the first call (changeBaseGreatPeopleRate) will get evaluated that way, i.e. the other two will have no effect. With "or" instead of "and" it would probably work, but I'd just put them each on a separate line. And the GP rate is actually supposed to increase ("punishment," you wrote)? For the free specialist, it's probably better to ensure that the specialist count doesn't become negative: -(min(2, pCity.getFreeSpecialistCount(ePriest))) instead of -2 and with ePriest set to getInfoType...
 
The chaining with "and" only works inside conditions. Well, I think, your code is syntactically correct, but only the first call (changeBaseGreatPeopleRate) will get evaluated that way, i.e. the other two will have no effect. With "or" instead of "and" it would probably work, but I'd just put them each on a separate line. And the GP rate is actually supposed to increase ("punishment," you wrote)? For the free specialist, it's probably better to ensure that the specialist count doesn't become negative: -(min(2, pCity.getFreeSpecialistCount(ePriest))) instead of -2 and with ePriest set to getInfoType...
now I have a doubt about this script, I don't know under which event to insert it, perhaps I should put it under 'cityBuilt' to make it work?
 
Seems that there is a 'religionRemove' event. I assume that's what an inquisitor accomplishes. Oh, I guess what you actually want is give players a reason to use the Inquisitor. So the 'religionSpread' event then – when an offending religion spreads to the city, the penalties apply.

But you'll also want to remove the penalties when the religion is removed. So the 'religionRemove' handler is still going to be useful. However, when a religion gets removed, you won't be able to tell whether the city had been penalized at the time that the religion was spread. Because its owner's state religion could have been different at that time. Usually, I think, this problem is addressed by tying the effects to a building. So, upon religion spread, if it's not the state religion, the building gets added. And upon religion removal, the building is removed – which will have no effect if the building isn't there. A building can't remove a Priest specialist, however. I guess you could still do that part through Python; will just need to check whether the building exists when undoing the removal of the Priest in the 'religionRemove' handler.
 
Last edited:
Seems that there is a 'religionRemove' event. I assume that's what an inquisitor accomplishes. Oh, I guess what you actually want is give players a reason to use the Inquisitor. So the 'religionSpread' event then – when an offending religion spreads to the city, the penalties apply.

But you'll also want to remove the penalties when the religion is removed. So the 'religionRemove' handler is still going to be useful. However, when a religion gets removed, you won't be able to tell whether the city had been penalized at the time that the religion was spread. Because its owner's state religion could have been different at that time. Usually, I think, this problem is addressed by tying the effects to a building. So, upon religion spread, if it's not the state religion, the building gets added. And upon religion removal, the building is removed – which will have no effect if the building isn't there. A building can't remove a Priest specialist, however. I guess you could still do that part through Python; will just need to check whether the building exists when undoing the removal of the Priest in the 'religionRemove' handler.
ok so I think it's better to tie it to a building in buildingBuilt, I basically lose the bonuses of religious buildings, until the non-state religion is removed
 
The event handler needs to be chosen based on the timing that you want for your effect. So, if you want to have an extra building just so long as a city has a non-state religion, the correct time is probably when a religion spreads or gets removed. Choosing an event handler that directly corresponds to your effect, e.g. buildingBuilt for adding a building, does not usually make sense. It's cause and effect, and the cause normally arises by something that happens outside of your control in the DLL. Sorry if this is obvious. I feel that you've tried to use some strange event handlers on a couple of occasions. It's also possible that I'm just misunderstanding your latest post.
 
sorry, I understood how to build a building, how to make it available, and which links the penalties or bonuses depending on the religions present in the city, for example if there are no religions from a bonus, which is deactivated by the presence of a non-state religion in city, like Platy's pantheon, which however gives extra happiness, now works well, I added to that script the possibility of removing the bonus/malus if a religion is removed. What I can't figure out how to do is tell the script that only non-state religions give the penalty( in my test give bonus happy), now all religions give it whether they are state or not. I'm doing some tests with happy, to test. in second attach i try to add the possibility of giving the bonus only to non-state religions in the city, doesn't give me errors but has strange effects, but it still gives the bonus to all religions, both state and non-state

to summarize, I would like the malus/bonus to be given only to non-state religions present in the city
 

Attachments

  • 1.jpg
    1.jpg
    56.4 KB · Views: 13
  • 2.jpg
    2.jpg
    48.1 KB · Views: 15
Last edited:
Not sure I'm understanding all the context, but maybe we can take it a step at a time. Platy's Pantheon gives one happiness for each religion in every city. If you instead want to do something based on the owner's state religion, then the for iReligion loop should be removed and iStateReligion should be the call parameter of isHasReligion. Hm, no, I think you want to do something with every religion that isn't iStateReligion. In that case, keep the religion loop and check iReligion != iStateReligion and pLoopCity.isHasReligion(iReligion).
 
. So, upon religion spread, if it's not the state religion, the building gets added. And upon religion removal, the building is removed – which will have no effect if the building isn't there. A building can't remove a Priest specialist, however. I guess you could still do that part through Python; will just need to check whether the building exists when undoing the removal of the Priest in the 'religionRemove' handler.
I understood by testing the pantheon script that your idea of tying everything to a building is the best, I sketched out a script, let's hope it goes well, obviously I also did religion remove
 

Attachments

  • 1x.jpg
    1x.jpg
    51.2 KB · Views: 14
I take it from the pSpreadCity that this is in the religionSpread handler. Shouldn't that simply add the Tribunal building to the city? I.e. just pSpreadCity.setNumRealBuilding(gc.getInfoType... etc. Well, only if the owner's state religion is not NO_RELIGION and differs from the religion that has just spread. But that's just an "if...and..." beforehand. I don't think the for-iBuilding loop should be needed, nor the check whether the owner already has the Tribunal somewhere. Or at least I don't understand why they're there (same for the building prereq checks).
 
We get this from the arguments of the event handler:
iReligion, iOwner, pSpreadCity = argsList
For the state religion, if that's not already what you have:
iStateReligion = gc.getPlayer(iOwner).getStateReligion()
Then that religion is supposed to be an actual religion and not the same as iReligion:
if iStateReligion != ReligionTypes.NO_RELIGION and iStateReligion != iReligion:
(I use the NO_RELIGION constant for clarity; its value is simply set to -1 in the DLL, so iStateReligion >= 0 would work just as well.)
And then the setHasBuilding is garbled in your screenshot, but I think you know how that works. Needs the number of buildings (1) in the second argument and in the first the building ID (not the building class ID).
And then I assume that all the penalties will come from the building's XML (e.g. -1 happiness).
 
Let's see if I wrote it right.
obviously in removereligion I put -1,
edit: I just wanted to add that the building is only added if a particular technology has been discovered
 

Attachments

  • 2.jpg
    2.jpg
    43.6 KB · Views: 11
The tribunal might be missing an "L" in its type string. The tech ... to be discovered by the city owner? That would be gc.getTeam(pSpreadCity.getTeam()).isHasTech(gc.getInfoTypeForString... etc.
As another precondition for adding the building, i.e. ... and ...
 
Like this?

what I don't understand the building is added whether religion is added by a missionary or whether it is added by influence
 

Attachments

  • 1.jpg
    1.jpg
    57.3 KB · Views: 16
Back
Top Bottom