Coding Lua

Firebug

Not-so Great Engineer
Joined
Sep 25, 2014
Messages
1,271
Location
Clevedon, England
I need some help with how to code a Lua UA.

Gain +1 Faith for every 2 Military units you own. Attacking a city converts 10% of its population to your religion.

I kind of know how to do the first half, but the second is beyond me.

If i could have some help it'd be greaaat
 
The approximate logic flow (pseudocode) would be:


- Get the attacking unit owner, and get the religion (I am unsure if you mean "religion you founded", or "the current religious majority of my empire). You can use
Code:
pPlayer:GetReligionCreatedByPlayer
for the former. For the latter, you will have to loop through all cities and check for the religious majority & tally everything up.
- Get the defending city
- Iterate through all the religion IDs (game classifies this as ReligionTypes eReligion, but you can cast it back and forth to integer), using a for loop and the function
Code:
pCity:IsReligionInCity
. Please note that the enum NO_RELIGION is -1, so you will need to start from -1.
- If the religion is present in the city, then run
Code:
pCity:ConvertPercentFollowers(eToReligion, eFromReligion, iPercent)
 
The real trouble with the stock available game-hooks as provided by Firaxis will be what hook are you going to use that will reliably fire when your unit attacks.

I believe whoward's VMC dll fixes this glaring oversight with the Firaxis code, so 1st you need to decide if your mod is going to be dependant on his or anyone else's DLL mod. I think the Community Unified Yields DLL and the Community Patch are essentially (if not actually) the same as the current version of whoward's VMC in regards to the combat events provided, but you'd have to check to be sure. But making your mod dependant on anyone's DLL, while adding many nice mod features, also means it is instantly incompatible with every other mod needing or using a different DLL.

Without a DLL it is going to be dueced difficult to get any usable info from anything Firaxis-provided that seems like it might be a combat event.
 
Back
Top Bottom