View Full Version : MM2 PW Repair code.
stankarp
April 25, 2004, 17:29
I incorporated Wouters MM2 PW repair code into a Cradle mod.
It worked fine for over 100 turns then I suddenly noticed that I was getting a lump sum of pw every turn of over 1000 points which defeated the purpose of the code.
I checked it by commenting the code out again then back in again and it was definitely the MM2 PW repair code.
Wondering if anyone else had the same problem in MM2.
stankarp
April 26, 2004, 18:10
I gather no one has had this problem in Med Mod or has not noticed it then??
Peter Triggs
April 26, 2004, 18:24
I can't remember the last time I played MedMod. It's hardly ever mentioned around here anymore so I don't think there's a lot of people playing it now.
Locutus
April 26, 2004, 18:59
That wasn't the case when I last played the MedMod (though granted, that was a while ago) and that certainly shouldn't happen based on the code. Unless you have weird negative numbers for MapHP or ShieldCost in Units.txt, the SLIC code can only decrease the amount of PW a player has, not increase it.
Are you sure it's not because you're setting your HP value higher than usual to compensate for the extra PW demand?
If so, try disabling the SetHP lines of the SLIC code(there should be 2 of them: one following the second if statement and one as last line in the block following the elseif), see if you still get too much PW then? (The effect of this change will be that you're units are still repaired normally, but the cost is not deducted from your PW reserve.)
Locutus
April 26, 2004, 19:03
Also, post the SLIC file with your version of the code, something may have gone wrong incorporating it in Cradle.
stankarp
April 26, 2004, 20:09
I havnt done anything wierd re hit points or stuff like that. As I said it seems to go fine for about 100 or more turns then suddenly I start getting PW as if I was an AI:confused:
I'll try attaching the file but I remember having trouble doing this sometimes.
Gilgamensch
April 27, 2004, 06:07
Would be interresting to know.
I had a look at the file, but nothing jumping into my eye.
Unless it isn't a rounding problem somewhere.
Stankarp, do you actually have damaged units in your cities?
stankarp
April 27, 2004, 06:52
Gilgamensch, thats a point. Early in the game, the code definitely works on damaged units in cities. Its hard then and you count every PW. I found I banished damaged units to the country so I could build a road.
However, later when I had a fair bit of PW I was not checking so closely but since I am at war with someone always, I assume that I had damaged units. I am trying it again so I will pay closer attention this time and report.
I wonder if Locutus could extend the code to Fortresses and watch towers because its unrealistic that units repair instantly in those tile improvements. It actually makes going to war very hard because the AI gets plenty pw so its units repair faster than yours, whereas as it stands normally, they heal at the same rate.
Martin Gühmann
April 27, 2004, 12:49
I don't see any PW related problems, either. But I found this problem:
if (IsHumanPlayer(tmpPlayer) && notEnough == 1) { // if not enough pw and player is human
player[5] = tmpPlayer;
Message(1, 'MM2_NotEnoughPW_M'); // give message that more pw is needed
}
The meassage is always sent to player 1, not a good idea if you play Network games or if you play a scenario and you use another player then player 1, or you selected another player in our playtest built.
This code is better:
if (IsHumanPlayer(tmpPlayer) && notEnough == 1) { // if not enough pw and player is human
player[5] = tmpPlayer;
Message(tmpPlayer, 'MM2_NotEnoughPW_M'); // give message that more pw is needed
}
Another thing you could do, is to insert an player[5] = tmpPlayer; before a member of player[5] is used. The current version of CTP2 has the behaviour to forget the value of an array member if you set it yourself.
-Martin
stankarp
April 27, 2004, 18:30
Thanks Martin.
Still testing the current setup again to see if it happens again and check if I have damaged units in cities at the time.
stankarp
April 28, 2004, 00:25
Update.
On turn 125, I noticed I suddenly had 553 pw when I had been struggling with under 100 each turn. I had only managed to build roads to connect cities, not one mine, farm etc.
I turned off pw production, checked and found I had no damaged units in cities, ended turn and next turn I had 1411 PW. It seems like I suddenly start getting an AI's quota of pw. I had captured 3 cities, disbanded one, but hadnt captured one for 20 turns.
Mystery deepens.
stankarp
April 28, 2004, 00:59
I did a further check.
I commented out the repair slic file in script.slic, went back into the game, ended another turn and received another 800+ PW. I hit reload slic and ended turn and the extra pw did not happen again. I retried the exercise with and without any pw production and the results were the same. Until I reloaded slic I kept getting the extra PW. Reload slic and it stopped.
It has to be something in the repair slic code that is triggering it or establishing an association with PW_Cheat.slic.
Gilgamensch
April 28, 2004, 03:38
Just to recapture:
No damaged units, but PW being given.
You removed all/partial repair-slic? and it worked.....:hmmm: strange.......
How many units complete do you have? Maybe an overrun somewhere? Is it the only slic you are using?
stankarp
April 28, 2004, 06:12
At turn 125, I start getting 800+ pw if I am using the repair code, whether I have damaged units or not. If I hit reload slic which comments out the repair code slic file, then it stops.
I might try and just isolate the repair code into a separate file as it actually had 6 functions originally and I cut out several but there may be values, integers etc left in that are causing a problem.
I would really like to get this going ok as a lot of people, like Hex have been looking for ways to balance the game. Making war with the repair code means you commit a lot more resources or fight at a big disadvantage. Can only be good for play balance.
stankarp
April 28, 2004, 06:13
I am using many slic files including a couple of special ones written for me by Pedrun, such as advance from city capture and a new supply unit.
stankarp
April 28, 2004, 06:15
Re unit numbers, about 100 altogether but I dont think that has anything to do with it.
Gilgamensch
April 28, 2004, 06:25
Originally posted by stankarp
At turn 125, I start getting 800+ pw if I am using the repair code, whether I have damaged units or not. If I hit reload slic which comments out the repair code slic file, then it stops.
I might try and just isolate the repair code into a separate file as it actually had 6 functions originally and I cut out several but there may be values, integers etc left in that are causing a problem.
Yep, sounds like the best idea in the moment.
I am using many slic files including a couple of special ones written for me by Pedrun, such as advance from city capture and a new supply unit.
Can you put the slic for this one in, maybe it has something to do with it.
And for the number of units: Just to see if there might have been an overrun somewhere.
Locutus
April 28, 2004, 07:40
Stankarp,
Originally posted by Locutus
If so, try disabling the SetHP lines of the SLIC code(there should be 2 of them: one following the second if statement and one as last line in the block following the elseif), see if you still get too much PW then? (The effect of this change will be that you're units are still repaired normally, but the cost is not deducted from your PW reserve.)
Have you tried this? (So JUST disabling the two SetHP lines, not the rest of the repair code.) By doing so we can establish if the extra PW you get is actually coming from the repair code or if the repair code is just interfering with some other code (e.g. the pw cheat), which I suspect.
stankarp
April 28, 2004, 17:04
Hi Locutus,
I havnt tried disabling HP as you suggested yet. Will try it now.
Thanks.
stankarp
April 29, 2004, 08:24
OK, Firstly I tried putting the code in a separate file and started again. This time I got to turn 150 odd before it started happening. I lost a city on turn 149, retook it on 150 and got pw from the city capture code. Then next turn it started again, 500 odd pw arrived then next turn nearly 900.
I was saving every turn so I went back one turn, beefed up the city defences and it did not fall in that turn. However, the extra pw started happening on the same turn anyway. So went the theory that a city captured that gave a slab of pw triggered it happening.
I disabled the following lines;
//SetPW(tmpPlayer, (pw - pwCost));
and
//SetPW(tmpPlayer, (pw - pwCost));
relaoded slic and it stopped happening.
Theories or suggestions anyone. I really wanted this one to work, I think it really adds to the game.
Gilgamensch
April 29, 2004, 08:37
<strike>
This would mean that pw - pwcost would be negative.
For pwcost to be greater than pw
But the first problem is, if you don't have damaged units it shall not be happening. :confused:
</strike>
Can you enable the first one again, which shall just get active if you have enough PW and let us know the result?
stankarp
April 30, 2004, 09:53
I tried various things.
With both lines disabled, I got no bonus PW and full repair of units in one turn.
With the first line only disabled I got full repair and no bonus PW.
With the 2nd line only disabled, I got full repair plus bonus PW.
I tried playing with both lines open and disabling pw_Cheat.slc, the code that gives the AI pw points but I was still getting the extra pw points.
The conclusion is that something triggers the repair code to give me pw points. It works fine for 100+ turns then after that it starts. The earliest has been turn 110 and the latetst 150.
What about changing the code so that it only applies to the human player, ie, all ai units in cities heal automatically, since the ai gets lots of pw its academic anyway. I dont know enough about slic to do this yet.
Martin Gühmann
April 30, 2004, 16:10
Maybe I should add my observations from GoodMod, I have there the city capture code in and also the pwcheat. If I play with the Barbarians capture a city then I get some of the pw of the victim that is indented, every turn this city generates pw, if I give away this city or let it capture someone else, I still get a pw bonuns even if I shouldn't get anything, I am neither an AI player (well this should be forced by the scenario editor) nor I own any single city (as Barbarian I can have zero cities). And of course this pw repair code is not in my slic database.
-Martin
stankarp
April 30, 2004, 18:42
Hi Martin,
I have the pw cheat and city capture code as standard but have not noticed getting that sort of pw bonus before. I am using the city capt code that does not give enslavement, only expand empire or bloodbath.
I am sure I have not been getting that large a bonus of pw before using this code. Maybe I should check, but when I comment out repair code altogether and play on for another 100 turns and monitor. I have occassionally noticed what I think is a small discrepancy in pw but I am talking 20 to 30 pw a turn, but if I turn off pw production, I dont get any pw. With repair code I am talking 800+ pw per turn wheher I produce pw or not.
Can U explain how to make repair code only work for the human player and leave out AI please?
stankarp
April 30, 2004, 18:49
"but when I comment out repair code altogether and play on for another 100 turns and monitor"??
What I meant was comment out the repair code and play on for another 100 turns and see if the pw situation changes.
What Martin said is interesting because MEDMod does not use the PWcheat.slc or the city capture options slc. And lucutus said the pw bonus does not happen in MedMod.
stankarp
May 2, 2004, 01:52
I commented out the repair code in script.slic and played another 70 turns. I did not get any extra pw that I am aware off so I was not getting the problem that Martin referred to.
I made two copies of the repair file, changed the handlers in the second one and inserted the line-
if(!(IsHumanPlayer(player[0])) && (player[0] != 0)) { // not human
and a }
at the end and the code works only for the ai.
I tried-
if(IsHumanPlayer(tmpPlayer)){ //ie human player only
with the extra } at the end
but it did not work for the human player.
I am hoping that if I separate the two functions the bonus PW problem might not happen.
Can anyone advise the correct peice of code to make something run only for the human player or player 1.
stankarp
May 2, 2004, 04:35
For interest, I have attached the slic code for pw from pillage. I dont think any other code would affect pw except for the pw_cheat.slic code already in Cradle.
stankarp
May 4, 2004, 00:28
I tried to isolate the problem.
I started by going back to med mod and played for 175 turns and the pw bonus did not start.
I went back to my cradle mod and disabled every file that I found that changed pw, for ai and/or human player and replayed a turn in a game where the pw bonus started after reloading slic. While I had the repair code for the human enabled, I got the bonus pw that turn no matter what I did(changed moves, stopped the building of a wonder due that turn etc).
I re-enabled the slic codes and the repair code for the ai and disabled the repair code for the human and the bonus pw did not occur. It has something to do with setPW for the human player after a certain turn in the human version of the repair code while using cradle mod. I cant work it out.
I have attached the repair code for the human player, I am not sure it is working for only the human player. Could someone advise how to change it so it only works for the human player please.
stankarp
May 10, 2004, 07:02
I have nearly solved the problem. I found I had accidentally increased the amount of pw the ai got through pwcheat.slc.
I reduced it back to thhe original amount and the problem nearly stoped. Occassionally I get a small amount of pw (5-25 points) and once every 20-40 turns seem to get a bag of up to 500 pw points, unrelated to my city cpaturing. The net effect is that the repair code is now working well enough to use.
Thanks for the help and suggestions.
stankarp
June 20, 2004, 19:19
Update.
Regardless of what I did while I had the code in its original format, sometime after turn 100 I started to get an overflow of pw.
I sent it to Peter Triggs and he suggested removing the changes from player[0] to player[5] in the code and tidied it up a bit and it now works. I have played to turn 400 and not had any overflow problem I can detect except for possible a hand full of points occassionally (less than 20).
Thanks for Peter's help.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.