 |
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
quote: Originally posted by mapfi
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. |
But i gave a fast look in the code. and i thought i did exacly what you did (unless the captureCity event). But i will do a deeper look into it, now.
quote: Originally posted by mapfi
That's my aim too, |
I have noticed the minute i saw the LeaderReligion[]. Although i have seen those religions listed above.
quote: Originally posted by mapfi
Quite sure, tested it, but try it out in the game yourself. |
I will. sorry, but I still dont believe. . Anyone else has acould share us this information?
I forgot to attach the text (Oops)
Attachment: religion_str.txt
This has been downloaded 5 time(s).
Last edited by Pedrunn on 09-08-2002 at 09:06
|
|
|  |
 |
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
Isn't there a saying that goes like 'Never make promises you can't keep' ?... Looks like I won't have as much time today as I thought, since we didn't get everything we wanted done yesterday (yes, I'm a student, but I work for an insurance company right now).
But let's have a look at the code:
code:
ConvertorCiv[ReligiousCount] = city[0]; // Store the converted city
ConvertedCity[ReligiousCount] = player[0]; // and the player who converted
That's never going to work since you're story cities in the int array and vice versa - just switch the two
code:
return tmpPlayer; // if GetCityConvertor = 0, means city is not converted
this comment is no longer true, since you're storing the religion when the city is created now, so it will never be 0, what this means for the code I haven't analyzed, though
code:
void_f AddCityToReligionCount (city_t tmpCity, int_t tmpConvertor) {
this function is really not necessary, since you've got every city already in the array by default (when it's created), so you just need to store the new religion value in the appropriate place
The handling of the ConvertCity event looks fine. If you used it for the 'DoYouWantToConvert' trigger it's clear that the message boxes will appear over and over again, since you're in a loop there too. The problem with the ConvertCityUnit event I see is that I'm not really sure if it determines already the conversion in the game or if there's still a probability check with some constant. Does the Kill() in the code just stop you're event handler or also the event that triggered it? I don't know, really. But if not, then you can't habe the 'DoYouWantToConvert' be 'pre'.
Now for the Reformation, same reasoning with kill() and 'pre' here.
So much for now, work here I come...
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
quote: Originally posted by mapfi
code:
ConvertorCiv[ReligiousCount] = city[0]; // Store the converted city
ConvertedCity[ReligiousCount] = player[0]; // and the player who converted
That's never going to work since you're story cities in the int array and vice versa - just switch the two |
Oops 
quote: Originally posted by mapfi
code:
void_f AddCityToReligionCount (city_t tmpCity, int_t tmpConvertor) {
this function is really not necessary, since you've got every city already in the array by default (when it's created), so you just need to store the new religion value in the appropriate place
|
There ar two reasons i added this funtion. First because it appears many times in the game. Second to make easier to you to
change for that .# if you want. Other than that i am aware that a three lines funtion is a bit unecessary.
quote: Originally posted by mapfi
code:
return tmpPlayer; // if GetCityConvertor = 0, means city is not converted
this comment is no longer true, since you're storing the religion when the city is created now, so it will never be 0, what this means for the code I haven't analyzed, though |
This comment should be erased. As you may see i even took the GetCityConvertor == 0 off the every turn gold and the sell indulgences. Yet you were right about the cities loosing their converted cities when enacting new govs . This means we have to come up with an idea to fix this bad feature. I suggest we make the begin turn event convert all cities in the count again. Or Unless there is a government enacted event wich i think i read somewhere that there isnt. Maybe we will probably
have to edit the create city event (this remind me that i didnt tested this event. And the getCityConvertor == 0 may come back.
quote: Originally posted by mapfi
The handling of the ConvertCity event looks fine. If you used it for the 'DoYouWantToConvert' trigger it's clear that the message boxes will appear over and over again, since you're in a loop there too. |
I noticed that. and only solved by placing the kill() before the code. Bt i will wait to see how you'll fix this.
This loop thing is much more common than i imagined (As i said before i dont have experience with programming. All I know comes from the Locutus/IW Slic learning texts.
I am getting a bit paranoid with this loop thing. thinking that the pillaging bug may be a loop (but it is such simple code). I think i will send it those to you to.
quote: Originally posted by mapfi
The problem with the ConvertCityUnit event I see is that I'm not really sure if it determines already the conversion in the game or if there's still a probability check with some constant. Does the Kill() in the code just stop you're event handler or also the event that triggered it? I don't know, really. But if not, then you can't habe the 'DoYouWantToConvert' be 'pre'.
Now for the Reformation, same reasoning with kill() and 'pre' here.
|
As far as i know the kill() doesn stop anything. It just closes the messagebox.
quote: Originally posted by mapfi
So much for now, work here I come... |
Good Luck 
Last edited by Pedrunn on 09-08-2002 at 18:32
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
This line wrongly went inside on one of your quotes in my last post. I fix it. But i am afraid you wont read it again.
"As far as i know the kill() doesn stop anything. It just closes the messagebox."
the player[0] variable is for the messages.
I can only say that i wish i had someone "bickering" every code i make like you do with this one.
Last edited by Pedrunn on 09-08-2002 at 18:52
|
|
|  |
 |
|
J Bytheway
|
 |
England
Jul 2001 time: 05:21
|
|
quote: Originally posted by mapfi
I don't know if slic has a break order though. Anybody? |
I don't think so, but if you put the loop in a function of its own then you can use return to get out of the function and thus break the loop.
quote: Quoting myself:
That's something I need to know before I start on this again. Anybody? |
AFAIK the kill() will only stop the message box.
IIRC if you want to cancel the event you must return STOP;
Last edited by J Bytheway on 10-08-2002 at 00:48
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
Well, your UncovertCity handler was pre, so the result is, that whatever you program with your messageboxes it will still unconvert the city at the end, so that's why your code doesn't work in that part. Either you change it to post or use that stop order if it works.
player[0], ah yes, in the text part, forgot that...
note: don't get too excited seeing that your code got downloaded twice , that's me, since I got to have it at work and on my laptop.
well, i'll see if I can find the time to work on something tonight or tomorrow...
Last edited by mapfi on 09-08-2002 at 20:53
|
|
|  |
 |
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
As I said I wanted to give bonuses to the player depending on the religion. What kind of methods do we have to do just that, preferably for each city?
I tried to write into the city variable properties but that seems to be read-only.
I can only think of giving/taking gold of/from the player and city specific to add happiness by the HappinessTimer event. Anything else that you guys know of?
John: of course, return breaks it, why didn't I think of that... thanks. I couldn't find stop in the documentation but abort(). I'll just try.
edit: don't you just hate it when you find dozens of spelling mistakes the moment you posted it...
Last edited by mapfi on 10-08-2002 at 21:25
|
|
|  |
 |
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:21
|
|
Just noticed all this. This is a great idea! I've glanced over the code Pedrunn posted above and here's a few comments;
1) Re the AddCityToReligionCount function:
quote:
this function is really not necessary, since you've got every city already in the array by default (when it's created), so you just need to store the new religion value in the appropriate place
|
I agree with Mapfli; I think this is what you want:
code:
void_f ChangeCityReligion (city_t theCity, int_t tmpConvertor) {
int_t i;
city_t tmpCity;
tmpCity=theCity;
for(i = 0; i < ReligiousCount; i = i + 1) {
if(tmpCity == ConvertedCity[i]) {
ConvertorCiv[i] = PlayerReligion[tmpConvertor];
}
}
}
Then you can change the following handler to:
code:
HandleEvent(ConvertCity) 'ConvertCityAccordingToReligion' post {// When a city was converted
int_t i;
int_t tmpplayer;
int_t religion;
if(CityIsValid(city[0])) {// maybe not necessary, but safe
ChangeCityReligion(city[0],player[0]);
}
}
I haven't looked at the other places where you used AddCityToReligionCount, but doing it this way would mean that you'd have to make changes there.
Notice in the above function that I've got two city type variables where you'd think one would be sufficient. This is because of a bug in SLIC:
quote:
Important note! As this documenation is being prepared, the first patch for CTP2 is about to be released. Unfortunately a bug with functions was discovered too late to fix. Specifically, in some cases, using members of unit, army, city,and location variables that are function parameters may not always work as expected. There is, however, a workaround. Copy the function parameter to a local variable and use that variable instead. Example:
// This version may fail sometimes!
int_f DoesAHumanOwnThisUnit(unit_t theUnit)
{
if(IsHumanPlayer(theUnit.owner)) {
return 1;
}
return 0;
}
// This version should always work
int_f DoesAHumanOwnThisUnit(unit_t theUnit)
{
unit_t copiedUnit;
copiedUnit = theUnit;
if(IsHumanPlayer(copiedUnit.owner)) {
return 1;
}
return 0;
}
The author apologizes for this and promises that if there is another patch it will be fixed. But the above workaround should always work.
|
2) The 'PlayerHasConverted' message at line 131 is sent to AllButOne via an Alertbox. I don't think you can do this. For one thing AlertBoxes are modal, which means that they must contain at least one button which must be pressed before the game can continue. Your's doesn't have a button. Also, I can't see how you can send an Alertbox to an AI civ: they can't press buttons.
So, I guess you just want to use a messagebox.
3) Do you have DebugSlic=Yes? You must have it turned on while you're debugging your code, otherwise you're bound to end up with lots of errors that you don't know about.
When the next version comes out I'll try to have a more detailed look at it.
|
|
|  |
 |
|  |
 |
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
well, well, well,... I'm lost.
I tried again and again but can't get it to work the way I'd like, but since Europe has got the most shitty summer ever, there's really not much other stuff to do ;-) Now be careful when you say you got the best summer at your place because you'll have to have a bed ready for me the very next day 
I put the code in several files in order not to loose the overview. religion.slc has a few explanations right at the start which explain my intentions.
Problems I ran into:
- The handler of the createcity event should convert a newly founded city to the state religion of the player. The funny thing is, it works for all ai-players, their cities are converted. When the human player founds one though, the cross appears while the citymanager window is open and dissappears immeadetly when it's closed. Here I'm lost...
- The handler for the governmentchange uses the event beginturngovernment - seems like this one is called every turn though - nevertheless the code is executed because of the If(CityRel == player[0]) part, but when I take it out, the cities are converted to a random player. I'm beginning to fear the cityarray is not working as it should. But that couldn't be because it worked in the SellIndulgence part without flaws. So it might be the problem of point 5...
- I said before that I don't trust the convertcityunit event. However, I'm sure now that it works - nevertheless I won't get the message, even if I set probability really high - I think it might have to do something with the floating point values which are converted who knows how. I found something in the language documentation that says they're multiplied by 100 but in the context of DB access.
- the whole player[0], g.player freaked me out and I intoduced a new global variable to carry over the CityRel. Anyway, I think their's a logical flaw in the ConvertCity handler as Pedrunn and I wrote it before if player[0] is the player argument in the Event, because then the second time the handler is called the stored value isn't the same that the city was just converted to. Does this rubbish I'm writing make sense?...
- I fear that we're also up against the asynchronous event handling - just for an example what exactly happens if I call ConvertCity(tmpCity, CityRel, 0) when the global variable CityRel is changed by the following code before the event is execute?...
Have fun looking this through...
Attachment: religion.zip
This has been downloaded 6 time(s).
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
1)Peter, thanks to clarify some thing up. I did not know about that info.
quote: Originally posted by Peter Triggs
So, I guess you just want to use a messagebox.
|
2)Thanks for pointing that up. I will fix it
quote: Originally posted by Peter Triggs
Do you have DebugSlic=Yes?
|
3)No. But I will start turn it on
quote: Originally posted by mapfi
- The handler of the createcity event should convert a newly founded city to the state religion of the player. The funny thing is, it works for all ai-players, their cities are converted. When the human player founds one though, the cross appears while the citymanager window is open and dissappears immeadetly when it's closed. Here I'm lost...
|
I will check this one
quote: Originally posted by mapfi
- The handler for the governmentchange uses the event beginturngovernment - seems like this one is called every turn though - nevertheless the code is executed because of the If(CityRel == player[0]) part, but when I take it out, the cities are converted to a random player. I'm beginning to fear the cityarray is not working as it should. But that couldn't be because it worked in the SellIndulgence part without flaws. So it might be the problem of point 5...
| All those beginTurn events works like a BeginTurn. I dont knoe the difference among them but i think there must be some sort of timing. Eg. When the turns begin first check gov changes, then the armies moves, the the improvements are created, then... and those begin turns works like that. Athoulgh i am not sure about that.
quote: Originally posted by mapfi
- I said before that I don't trust the convertcityunit event. However, I'm sure now that it works - nevertheless I won't get the message, even if I set probability really high - I think it might have to do something with the floating point values which are converted who knows how. I found something in the language documentation that says they're multiplied by 100 but in the context of DB access.
| If we see this dont work we can create a new global variable to prevent messages to appear.
Something like:
code:
int_t ConversionMessage;
HandleEvent(ConvertCity) 'DoYouWantToConvert' pre { // also when a city is being converted
// Code removed to save post space
if (IsHumanPlayer(city[0].owner)) { // If he is a human player
if(ConversionMessage == 0) {
if ((CityCount*10)/TotalCityCount >= 0) {
message(city[0].owner, 'DoYouWantToConvertCiv');
}
}
else{
ConversionMessage = 0;
}
}
// Code removed to save post space
}
Another variable to follow the ConvertCity function Where Conversion message is previously set to be 1 before the ConvertCity is trigeered
eg.
code:
ConvertNum = 1; // avoiding a second conversion in a loop
ConversionMessage = 1; // Dont send the convert Civ Message
Event:ConvertCity(tmpCity, CityRel, 0);
quote: Originally posted by mapfi
- the whole player[0], g.player freaked me out and I intoduced a new global variable to carry over the CityRel. Anyway, I think their's a logical flaw in the ConvertCity handler as Pedrunn and I wrote it before if player[0] is the player argument in the Event, because then the second time the handler is called the stored value isn't the same that the city was just converted to. Does this rubbish I'm writing make sense?...
|
the player[0] and local variables did not worked. I just got that message to work correct with g.player.
quote: Originally posted by mapfi
- I fear that we're also up against the asynchronous event handling - just for an example what exactly happens if I call ConvertCity(tmpCity, CityRel, 0) when the global variable CityRel is changed by the following code before the event is execute?...
|
We need to be careful to this do not happen. But if we do this code properly i think it will natural preventing such error.
About the AI. Mapfi, i will post here a quick text to teach you how the strategies.txt interacts with goal.txt to work on the AI decisions on its units.
I will take a deeper look on the code now. But i have seen you did a lot of changes.
Last edited by Pedrunn on 12-08-2002 at 07:21
|
|
|  |
 |
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
I am not totally desconsidering the idea of those religions. I just prefer the way i am writting. I already thought in a way to convert the current way to this pre-defined religion way. To modify this is just a simple but relatively long modification in the 'settingreligion' event and a couple of ones in the text (specially unit.txt and gl_str.txt). As i said i rather finish the code to make this change on the way religions are going to be given. Since the only things really missing are the conversion of the city to its owner and the every turn bonus. After that we may add more stuff but it will be basically playtesting, fixing and balancing
I am too very excited to see locutus documentation. Speacially to add more to the religions bonus.
Try send the email to this address
pbcavalcanti@uol.com.br
my apolyton e-mail is broken
Last edited by Pedrunn on 15-08-2002 at 00:27
|
|
|  |
 |
|
mapfi
|
|
Zurich, Switzerland
Jul 2002 time: 06:21
|
|
Sorry for not being around but currently the tournament game is taking up all my free time and as I said summer's back for the last days this year so you'll have to wait till next week...
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:21
|
|
quote: Originally posted by mapfi
the religionlevel has a logical flaw in the code that I can't find. Even when I haven't founded a city yet it rises over 0% when the other players do and after a few turns it doesn't change at all anymore |
And you dont have any clue about a fix? Or a variation of the concept? I will try to come up with a solution .
quote: Originally posted by mapfi
the logregardevent: Haven't found that one in any documentation - it gives me wrong argument type errors and freezes my computer completely, even Microsofts three button wonder won't work - won't be too difficult to write a code doing the same though if we can't get it to work |
It works i am sure. probably something is wrong with my arguments (my guess is that i should have use 0 in the event type argument instead of 4). here are the info i have about it (from Peter Triggs documentation):
quote:
VOID LogRegardEvent(int, int, regardDelta, regardEventType, ID_string, Delta_what)
regardDelta is the amount to increase the first player's regard towards the second by.
The Regard Event Types are ScenarioEvent, MilitaryPowerEvent, MilitarySafetyEvent, DiplomacyEvent, GoldEvent, KnowledgeEvent, & ProductionEvent. So "0" is probably the null event type.
ID_string is a string used in the Diplomacy intelligence screen.
Delta_what has, I think, something to do with turns. For example,
// Make the Allies like each other
LogRegardEvent(2, 3, 1000, 0, ID_WW_BLANK, turnMax);
where turnMax is the number of turns in the WW2 scenario. It doesn't seem to make the change recur though.
|
quote: Originally posted by mapfi
[*]the KillPlayer handler won't work yet, no new signs appear[/list] | That is really bad new. but i am sure we can make a variation of it using CaptureCity checking how many cities the player has. But i want to be sure that a dead player really converts cities to barbs first.
quote: Originally posted by mapfi
the PlayerCityCount seems to need an argument that was assigned by a real player variable (like tmpPlayer = player[0]), a regular int won't work... so I worked around that when I was able to |
We can still use the function Cities(int_t) or even the built in variable player[0].cities. No big deal.
quote: Originally posted by mapfi
writing into player[1,2 or 5 or whatever] always gives slic errors but messages can also display global variables. problem is, we can't have the name of the religion's civ like that, just the player number |
it works if we use player[1,2 or 5 or whatever] in the code that triggers the message (not in the code inside the message).
And use the player[1,2 or 5 or whatever].civ_name_singular in the message ID.
quote: Originally posted by mapfi
found out that we have to test the validity of a city we want to read out of the allCities array before we assign it to a tmp city variable - otherwise slic errors |
We should have done this before to the storage of the city safer anyway.
quote: Originally posted by mapfi
I disabled all ConvertCity Events other than the ones in the BeginTurn and ConvertCity handler with the justification that under a reformation it takes half a turn to reform everybody... Just makes the code more foolproof when it has less of those events called during the game | Good Point. I think this really is for the best.
quote: Originally posted by mapfi
the game won't stop when an ai converts my cities - the Anywaymessagebox appears when it's my turn - not nice but not too grave... | It should stop since it is an alertbox and not a messagebox. I will check this up when i have time.
quote: Originally posted by mapfi
The whole code is packed to be an addition to SAP now. Just unzip in your CtP2 folder and you'll get a new option in modswapper - makes it easier to test and in the units.txt I set all the interfering values to 0. Why SAP - no other reason than I know it's behaviour better than the original game's. |
Ok. Not a problem for me.
quote: Originally posted by mapfi
I might still have another look at it tomorrow but any immediate help would be appreciated. |
I will look into it too. Tomorrow we talk about a improvements them.
PS: The CreateUnit event does work. we can make that idea of settlers settle cities that have the same religion of the city they were built.
Last edited by Pedrunn on 29-08-2002 at 09:00
|
|
|  |
 |
|  |
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
|
|
|
|
|
|