 |
|  |
 |
|
Hermann the Lombard
|
|
Hoboken, NJ, USA
Jun 1999 time: 00:21
|
|
quote: Originally posted by mapfi
Now what I'm looking for:
I'd like to replace the "5" with a factor according to the state of the city, unconverted, converted or converted to other faith like in the const.txt.
Any idea where I get the state of the city? |
I like your approach. If we can't get the state of the city, maybe make the const.txt value more important and the city size less important, perhaps zero for Other, five for Unconverted, and ten for Converted, (or even zero, ten, and twenty), and use a factor of "3" (or "2") instead of "5."
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
Hasn't Locutus already worked on the concept of religion for his ctp3-mod?
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
Could you test this code Mapfi or anyone?
It follows the first idea of only changing the money from conversion and sell improvements.
It should add one gold per population of the converted cities to the player who convert these city.
It also re-calculates the sell indulgences. Giving one gold per civ in a city if the city is converted by the cleric owner. And 1 gold for every 5 pop if the city isnt converted. And 1 gold per 10 pop if the city isnt converted.
If it works we can move on to next stage: Giving identity to the religions.
Any comments?
code:
////////////////////////////////////////////////////////////////////////////
// 1) Religion Code
////////////////////////////////////////////////////////////////////////////
city_t ConvertedCity[];
int_t ReligionOwner[];
int_t ReligiousCount;
int_f GetCityConvertor(city_t tmpCity) { // if GetCityConvertor = 0, means city is not converted
int_t tmpPlayer;
int_t i;
if(CityIsValid(tmpCity)) {
for(i = 0; i <= ReligiousCount; i = i + 1) {
if(tmpCity == ConvertedCity[i]) {
tmpPlayer = ReligionOwner[i];
}
}
}
return tmpPlayer;
}
HandleEvent(ConvertCity) 'StoreConvertedCity' pre {
city_t tmpCity;
int_t i;
if(CityIsValid(city[0]) && IsPlayerAlive(player[0])) {
for(i = 0; i <= ReligiousCount; i = i + 1) {
if(city[0] == ConvertedCity[i]) {
ReligionOwner[i] = 0; // Erase old owner
}
}
ConvertedCity[ReligiousCount] = city[0];
ReligionOwner[ReligiousCount] = player[0];
ReligiousCount = ReligiousCount + 1; // Store city and player who converted
}
}
HandleEvent(BeginTurn) 'ConvertorTakesTheMoneyPerTurn' post {
int_t SinfulCiv;
int_t PriestCiv;
int_t theTenth;
int_t i;
SinfulCiv = player[0];
for(i=0; i < player[0].cities; i = i + 1) {
GetCityByIndex(SinfulCiv, i, city[0]);
PriestCiv = GetCityConvertor(city[0]);
if(PriestCiv != 0) {
theTenth = city[0].population; // How much it will be? 1 gold per pop per turn?
AddGold(SinfulCiv, theTenth);
AddGold(PriestCiv, - theTenth);
}
}
}
HandleEvent(SellIndulgencesOrder) 'ConvertorTakesTheMoneyFromIndulgences' pre {
int_t SinfulCiv;
int_t PriestCiv;
int_t ConvertorCiv;
int_t theTenth;
army_t GodsArmy;
location_t tmpLoc;
GetCityByLocation(tmpLoc, city[0]); //
PriestCiv = GodsArmy.owner; //
ConvertorCiv = GetCityConvertor(city[0]);
SinfulCiv = City[0].owner;
if(ConvertorCiv == PriestCiv) { // If city is converted by the cleric owner
theTenth = city[0].population; // How much gold he gets? 1 gold per pop
AddGold(SinfulCiv, theTenth);
AddGold(PriestCiv, - theTenth);
}
elseif(ConvertorCiv == 0) { // if City is not converted
theTenth = 1 + city[0].population/5; // How much gold he gets? 1/10 gold per pop
AddGold(SinfulCiv, theTenth);
AddGold(PriestCiv, - theTenth);
}
elseif(ConvertorCiv != PriestCiv) { // if city is coverted by another civ religion
theTenth = 1 + city[0].population/10; // How much gold he gets? 1/20 gold per pop
AddGold(SinfulCiv, theTenth);
AddGold(PriestCiv, - theTenth);
}
}
EDIT: A small mistake that would ruin everything was find. The code above is now correct.
Teh correct version
Last edited by Pedrunn on 07-08-2002 at 16:32
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
well, you got me started there! I'll list the changes:
- included new function for checking if city is already in the array
- erased validity checks when debugging (i don't know if those are necessary - you tell me - but when I was looking for mistakes they came in my way
- erased counters, because the .# gives the actual size of the array
- took a while till I spotted that: ConvertedCity[ROwnerCounter] = player[0];, should be ReligionOwner of course
- included Reformation of city by owner
- erased the part of the converted cities giving gold, since that is already done by the regular game, we could, however, make adjustements here
- took IndulgenceSaleMade as event
- changed minus signs in sell indulgence, you subtracted gold from the seller
- changed the values in sellindulgences, a tenth of pop is not going to make much difference
It worked in my testing, so far... Thanks a lot for getting me going!
note: we should of course set the values of the sell indulgence event in the const.txt to zero, to make it clearer what the total effect actually is and where it's defined, same if we want to change the converted cities paying gold -> 2nd note: in the game this is 0.2 times the gold production of the city - so not what you had in mind here, but we can easily access the cities gold production via slic if we want to make any changes there
code:
////////////////////////////////////////////////////////////////////////////
// v.1 Religion Code by Pedrunn
// v.2 by mapfi
////////////////////////////////////////////////////////////////////////////
city_t ConvertedCity[];
int_t ReligionOwner[];
int_f GetCityConvertor(city_t tmpCity) { // if GetCityConvertor = 0, means city is not converted
int_t tmpPlayer;
int_t i;
if(CityIsValid(tmpCity)) {
for(i = 0; i < ConvertedCity.#; i = i + 1) {
if(tmpCity == ConvertedCity[i]) {
tmpPlayer = ReligionOwner[i];
}
}
}
return tmpPlayer;
}
int_f CheckforCity(city_t tmpCity) { //if City is already in array returns place, otherwise next free array place
int_t i;
int_t num;
num = ConvertedCity.#;
for(i = 0; i < ConvertedCity.#; i = i + 1) {
if(tmpCity == ConvertedCity[i]) {
i=num;
}
}
return num;
}
HandleEvent(ConvertCity) 'StoreConvertedCity' post {
int_t i;
i = CheckforCity(city[0]);
ConvertedCity[i] = city[0];
ReligionOwner[i] = player[0];
}
HandleEvent(UnconvertCity) 'StoreUncovertedCity' post { //reformation by city owner
int_t i;
i = CheckforCity(city[0]);
ConvertedCity[i] = city[0];
ReligionOwner[i] = 0;
}
HandleEvent(IndulgenceSaleMade) 'ConvertorTakesTheMoneyFromIndulgences' post {
int_t SinfulCiv;
int_t PriestCiv;
int_t ConvertorCiv;
int_t theTenth;
PriestCiv = unit[0].owner;
ConvertorCiv = GetCityConvertor(city[0]);
SinfulCiv = city[0].owner;
if(ConvertorCiv == PriestCiv) { // If city is converted by the cleric owner
theTenth = city[0].population*5; // How much gold he gets? 1 gold per pop times 5
AddGold(SinfulCiv, - theTenth);
AddGold(PriestCiv, theTenth);
}
elseif(ConvertorCiv == 0) { // if City is not converted
theTenth = city[0].population*3; // How much gold he gets? 1 gold per pop times 3
AddGold(SinfulCiv, - theTenth);
AddGold(PriestCiv, theTenth);
}
elseif(ConvertorCiv != PriestCiv) { // if city is coverted by another civ religion
theTenth = city[0].population; // How much gold he gets? 1 gold per pop
AddGold(SinfulCiv, - theTenth);
AddGold(PriestCiv, theTenth);
}
}
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
quote: Originally posted by mapfi
- included new function for checking if city is already in the array
- erased counters, because the .# gives the actual size of the array
|
I dont think this will give any advantage. But for sure you a much experienced programmer than i am (my very first code only has two/three months).
quote: Originally posted by mapfi
- took a while till I spotted that: ConvertedCity[ROwnerCounter] = player[0];, should be ReligionOwner of course
|
You got me few minutes before i had edited that post where i fixed this bug. I also changed the cod in a way that it only has one count (instead of for city and other for the player).
quote: Originally posted by mapfi
- included Reformation of city by owner
|
I did forgot that, dindnt i? 
quote: Originally posted by mapfi
- erased the part of the converted cities giving gold, since that is already done by the regular game, we could, however, make adjustements here
|
Yet i have added that because i plan to pop messages box every turn (without show() function for sure) where it says how much gold was lost/gained by the civ. Yet we didnt made religious so important to have this messaging poping out. (I also plan to add other information in this message box about trade and others features)
quote: Originally posted by mapfi
- took IndulgenceSaleMade as event
|
I hadnt seen this event befor. It sure looks to be trustful to work than SellIndulgences orders. Other than i dont see much of a difference
- changed minus signs in sell indulgence, you subtracted gold from the seller
[/quote]
Ooops 
quote: Originally posted by mapfi
- changed the values in sellindulgences, a tenth of pop is not going to make much difference
|
I was going to start a discussion about that. This value was just temporary (thats why i create a whole new variable in the code so that was easier to edit.
quote: Originally posted by mapfi
It worked in my testing, so far... Thanks a lot for getting me going!
|
Glad to hear this. This is enough for us to work with yor code and to move on to stage two. Although i may need to get used to the .# wich i had never seen it before. ( as i said i am not much of experienced programmer)
quote: Originally posted by mapfi
note: we should of course set the values of the sell indulgence event in the const.txt to zero, to make it clearer what the total effect actually is and where it's defined, same if we want to change the converted cities paying gold
|
Thats what i had in mind
quote: Originally posted by mapfi
-> 2nd note: in the game this is 0.2 times the gold production of the city - so not what you had in mind here, but we can easily access the cities gold production via slic if we want to make any changes there
|
Sure thing. This is also good if we will want to implement the message box idea.
Last edited by Pedrunn on 07-08-2002 at 17:07
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
quote:
I dont think this will give any advantage. But for sure you a much experienced programmer than i am (my very first code only has two/three months).
|
well otherwise the array would get huge when cities are converted a lot and as for the experienced programmer "Errare humanum est" -> I'm not... had a semester of programming C++ two years ago, haven't done any since and just started reading into SLICing a week ago
quote:
Yet i have added that because i plan to pop messages box every turn (without show() function for sure) where it says how much gold was lost/gained by the civ. Yet we didnt made religious so important to have this messaging poping out. (I also plan to add other information in this message box about trade and others features)
|
well if we keep on working on this at the same pace it may soon be important
quote:
I hadnt seen this event befor. It sure looks to be trustful to work than SellIndulgences orders. Other than i dont see much of a difference
|
i'm not sure but maybe you can give the unti the order more than once even it will only execute once - anyhow, this is just to be on the safe side
quote:
This is enough for us to work with yor code and to move on to stage two. Although i may need to get used to the .# wich i had never seen it before.
|
The .# is usually something like .size in other languages, so most common just a strange way of writing it in slic
Stage 2:
quote:
Every time a city is converted the city owner gets a choice to join the convertor religion. If he dont accept he still keeps losing its money (note he can still reform the city). If he accepts all of his cities get converted to the other player religion (this will cause unhapppiness in all cities that werent converted and increase the happiness in those that were converted). The number of gold taken by the other civ drasticly decreases
|
so we'll do that in slic with part of the code I took out, additionally when more than half of the cities are converted there could also be a pop up that the people petitiones the leader to convert all cities.
quote:
and the player with the new religion can sell indulgences to other civs and get the same amout as if it was converted by him.
|
now it's getting complicated - can we unconnect religion and player? The problem is the data shown in the map which specifically connects those two. and i don't think it's possible to have a players city with his religion converted- i'll try that just now
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
well I tried something with what we had with religion and player unconnected, I zipped it, so have a look at it(it hasn't been tested...)
What we need now is the messagebox stuff and of course the new defining of the goldturnover from religious cities - do they all pay in a religion specific pot and whoever has that religion get's a share of it?
And we should beginn to add bonuses for the different religions, for production, gold or science...
edit: added eventhandler for capturing city
Attachment: religion.zip
This has been downloaded 2 time(s).
Last edited by mapfi on 07-08-2002 at 20:43
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
hey thanks!
num = i, yes, i didn't test it as i said
for the other one just bad style, you're right
i'll keep on thinking... and trying out
Last edited by mapfi on 08-08-2002 at 00:01
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
forgot the updated one, hope to have something more tomorrow night
Attachment: religion.zip
This has been downloaded 3 time(s).
|
|
|  |
 |
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
quote:
The bug is in this line.
code: Event: ConvertCity(city[0], PlayerReligion[tmpplayer], 0);
|
Yep, if you look in that little piece of code I wrote you'll find I solved that by using a global variable to count the called events. There might be something better, though
quote: What i aim at is to create religons that do not depend on the civs.
|
That's my aim too, and as I found out, the colored cross can appear at any players city. Just read a few post ahead.
quote: The crosses disapear when enacting new govs? Are you sure?
|
Quite sure, tested it, but try it out in the game yourself.
|
|
|  |
All times are GMT. The time now is 05:21. Apolyton Time is 00:21. |
top of page
|
| archivepost |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|