{"action":"created","issue":{"url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/issues/699","labels_url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/issues/699/labels{/name}","comments_url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/issues/699/comments","events_url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/issues/699/events","html_url":"https://github.com/LoneGazebo/Community-Patch-DLL/issues/699","id":111289365,"number":699,"title":"On Piety","user":{"login":"JFDaly","id":11897580,"avatar_url":"https://avatars.githubusercontent.com/u/11897580?v=3","gravatar_id":"","url":"https://api.github.com/users/JFDaly","html_url":"https://github.com/JFDaly","followers_url":"https://api.github.com/users/JFDaly/followers","following_url":"https://api.github.com/users/JFDaly/following{/other_user}","gists_url":"https://api.github.com/users/JFDaly/gists{/gist_id}","starred_url":"https://api.github.com/users/JFDaly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JFDaly/subscriptions","organizations_url":"https://api.github.com/users/JFDaly/orgs","repos_url":"https://api.github.com/users/JFDaly/repos","events_url":"https://api.github.com/users/JFDaly/events{/privacy}","received_events_url":"https://api.github.com/users/JFDaly/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/labels/Feature%20Request","name":"Feature Request","color":"0052cc"},{"url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/labels/Fixed%20in%20upcoming%20version","name":"Fixed in upcoming version","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-10-13T23:02:19Z","updated_at":"2015-10-18T01:56:41Z","closed_at":null,"body":"I've given your offer some thought, and tbh, I don't think I need anything AI-wise for Piety, or at least I think it would be too complicated. This is what I'd like ideally for the AI's decision to adopt/change a State Religion:\r\n* they have researched tech X (Priesthood in my mod, but I'd use a tech tag to mark it, as I remove Priesthood in CBP)\r\n* the religion is the majority in their empire and they have met the founder\r\n* they have not founded their own religion\r\n* they have not changed their State Religion within the past X turns (this last part is something I can't really simulate in Lua). \r\n* If all these are true, the chance to adopt would be based on the leader's religious intolerance flavour (a custom one that I've made: 'FLAVOR_JFD_RELIGIOUS_INTOLERANCE'), and increased by if they desire friendly relations with the founder of that religion (again, something I can't simulate in Lua).\r\n\r\nHowever, most of this can be simulated in Lua, and probably works good enough (only missing the once in every X turns and favouring friendly relations). But what would be useful is a **player:GetMajorityReligion()** function to return the religion which has the most cities to its name in the given player's empire. This would at least streamline the above assessment in Lua, so that it wouldn't need to loop every city and calculate from that.\r\n\r\nI'd also like to ask - not having done so before because I assume it's a bit too much, so feel free to reject it - if some of the Piety related functions could be pushed into the DLL. At the moment, I rely upon Pazyryk's TableSaverLoaded in order to cache the player's state religion ID and their piety value, but I feel as though pushing it into the DLL would be much more stable. Basically, I'd be looking for some if not all of the following functions, grouped by what I feel is least of an ask to most:\r\n\r\n* **player:SetStateReligion(religionID)**\r\n* **player:GetStateReligion()**\r\n* **player:GetNumCitiesWithStateReligion(religionID)** - would return the number of cities where the state religion is the majority\r\n\r\nI would need a **GameEvents.StateReligionChanged(playerID, religionID)** and a **GameEvents.StateReligionAdopted(playerID)** in order to catch these in Lua, however, so that I could still pass all the notifications and sound effects. The difference between the two would be that StateReligionAdopted only fires if the AI has never had a State Religion before (i.e. GetStateReligion() is at -1).\r\n\r\nThere are actually a few methods in the DLL/CvGameCoreDLL/CvPlayer.h already that relate to StateReligion (\"GetNumCitiesWithStateReligion\", \"SetHasAdoptedStateReligion\", \"IsHasAdoptedStateReligion\"), which I presume to be dormant from CivIV, but perhaps could be hijacked for my needs above.\r\n\r\n* **player:SetPiety(value)**\r\n* **player:ChangePiety(value)**\r\n* **player:GetPiety()**\r\nI would need a **GameEvents.PietyChanged(playerID, value)** in order to catch when a piety level changes (which sends a notification, amongst other things).\r\n\r\n* **player:GetPietyRate(value)**\r\n----To make this work, I'd need something like **GameEvents.GetPietyRate(playerID)** or something, so that I can tell the DLL what the actual piety rate is, which is why it's last on this list.\r\n----And with this, perhaps it could fire each turn from within the DLL to ChangePiety() based on the GetPietyRate() value, if GetStateReligion() > -1, so that I didn't have to handle it in Lua.\r\n\r\nBut like I said, I don't wish to ask for more than you'd like to work on (especially when I can be little help coding-wise), and you've already done so much to help this mod, so I have absolutely no expectations and am already awed by your generosity. In addition, I would certainly wait as long as needed for (if) anything you decided to do.\r\n\r\nIncidentally, does the AI already take into consideration policies, buildings, etc. which have a negative value? Or, at least, would it take into account if something had a negative flavour? This could be useful in helping the AI understand my Sovereignty reform system (the bulk of which consist of 'dummy policies' that have a positive effect in one area in exchange for a negative in another)."},"comment":{"url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/issues/comments/148966617","html_url":"https://github.com/LoneGazebo/Community-Patch-DLL/issues/699#issuecomment-148966617","issue_url":"https://api.github.com/repos/LoneGazebo/Community-Patch-DLL/issues/699","id":148966617,"user":{"login":"JFDaly","id":11897580,"avatar_url":"https://avatars.githubusercontent.com/u/11897580?v=3","gravatar_id":"","url":"https://api.github.com/users/JFDaly","html_url":"https://github.com/JFDaly","followers_url":"https://api.github.com/users/JFDaly/followers","following_url":"https://api.github.com/users/JFDaly/following{/other_user}","gists_url":"https://api.github.com/users/JFDaly/gists{/gist_id}","starred_url":"https://api.github.com/users/JFDaly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JFDaly/subscriptions","organizations_url":"https://api.github.com/users/JFDaly/orgs","repos_url":"https://api.github.com/users/JFDaly/repos","events_url":"https://api.github.com/users/JFDaly/events{/privacy}","received_events_url":"https://api.github.com/users/JFDaly/received_events","type":"User","site_admin":false},"created_at":"2015-10-18T01:56:41Z","updated_at":"2015-10-18T01:56:41Z","body":"Ran just this version of the CP; still crashes on trying to load. I ran a quick 100 turn game and then made a manual save to be certain. Here's the [mini dump](https://www.dropbox.com/s/007rcyut1f7hvqw/CvMiniDump.dmp?dl=0) and the [save file](https://www.dropbox.com/s/l5set79do7b91tm/Oda%20Nobunaga_0100%20BC-0375.Civ5Save?dl=0). Fully exited out of the game before loading, too, and deleted the cache before this test. I also tried a 1 turn save, and the same issue [mini dump](https://www.dropbox.com/s/z1l4mq4uqecs2hm/CvMiniDump1.dmp?dl=0) [save] (https://www.dropbox.com/s/yyomejrjyyrpkz7/Alexander_0000%20BC-4000.Civ5Save?dl=0).\r\n\r\nOn a more positive note, PietyMin/Max work perfectly :)"}}