Hi all;
Well I think I have settled on a formula for terrorism that I am happy with. I was basing the eqns on a players score vs the average but then as the average score climbed climbed I found the gap between the leader (invariable me) and the average needed to get stupid large before terrorism took place.
So the eqn I settled on has nothing to do with actual score but with ratios of scores.
For example if the scores are:
1x 2x 3x 4x 5x 6x 7x 8x then the number of terror strikes will be the same no matter how big x might be.
In addition I have included a factor of how popular the target is. If everyone in the world (or at least those with lower scores) love you then you will not suffer any strikes. The number of strikes in my spreadsheets can climb as high as 12 if your score is 60% of the total and everyone is at war with you.
The code follows but I have NOT TESTED this yet. I am particularly leary about the RegardLevel function and how things will pan out in the early game when scores are very low, but I'll let everyone know how the testing goes. If any are adventurous then feel free:
Gedrin
[This message has been edited by Gedrin (edited October 20, 2000).]
Well I think I have settled on a formula for terrorism that I am happy with. I was basing the eqns on a players score vs the average but then as the average score climbed climbed I found the gap between the leader (invariable me) and the average needed to get stupid large before terrorism took place.
So the eqn I settled on has nothing to do with actual score but with ratios of scores.
For example if the scores are:
1x 2x 3x 4x 5x 6x 7x 8x then the number of terror strikes will be the same no matter how big x might be.
In addition I have included a factor of how popular the target is. If everyone in the world (or at least those with lower scores) love you then you will not suffer any strikes. The number of strikes in my spreadsheets can climb as high as 12 if your score is 60% of the total and everyone is at war with you.
The code follows but I have NOT TESTED this yet. I am particularly leary about the RegardLevel function and how things will pan out in the early game when scores are very low, but I'll let everyone know how the testing goes. If any are adventurous then feel free:
//Trigger Setup
trigger 'Setup' when ((g.player == 0) && (g.year == 0)) {
// This is the value from userprofile.txt that details the number of players that STARTED the game.
// This may of course be very different from the number currently in the game.
numberOfPlayers = Preference("NumPlayers");
// note the 196 is the map bonus for the gigantic map and I have not figured out the right values for other sized maps.
// If smalled map sizes are used without updating this value it will cause fewer strikes and cause funny stuff as the scores rise.
scoreBonus = g.maxscore - 3600 + (75 * numberOfPlayers) + 196;
}
messagebox 'PopTerrorized' {
// POP_TERRORIZED defined in info_str.txt reads like:
// POP_TERRORIZED "Foreign backed terrorists strike in [city.1.name]. Casualties are high."
Text(ID_POP_TERRORIZED);
MessageType("WARNING");
}
trigger 'AveScoreEff' when (g.player >= 0) {
// Player = 0 is the Barbarian who does not suffer from terrorist attacks
// but we still need the total score
if (g.player == 0) {
totalScore = 0;
index = 1;
while (index < Preference("NumPlayers")) {
if (IsPlayerAlive(index) == 1) {
SetPlayer(1,index);
totalScore = totalScore + player.1.score - scoreBonus;
}
index = index + 1;
}
totalScoreSqd = totalScore * totalScore;
} else {
SetPlayer(1,g.player);
strikes = 0;
index = 1;
// The following is the sum for each enemy still alive and with a lower score than me:
// Regard(enemy towards me) * (myScore/enemyScore -1) * enemyScore/totalScore * myScore/totalScore
// = his opinion of me * how much I am beating him by * how strong he is * how strong I am
// = 1/totalScore^2 * SUM ( Regard * myScore * (myScore - enemyScore) )
while (index < numberOfPlayers) {
SetPlayer(2,index);
// this enemy must be alive and have a lower score to make terrorist strikes.
if ((IsPlayerAlive(index) == 1) && (player.1.score > player.2.score)) {
myScore = player.1.score - scoreBonus;
enemyScore = player.2.score - scoreBonus;
strikes = strikes + RegardLevel(index,g.player) * myScore * (myScore - enemyScore);
}
index = index +1;
}
// This division is deferred til now for speed and accuracy from rounding errors.
strikes = strikes / totalScoreSqd;
// Now resolve all the strikes.
// Note that CityCount > 0 is not the same as IsPlayerAlive. Consider turn 0.
// The chances that a terrorist strike kills a civ's last city is small but not nil
cityCount = Cities (g.player);
while ((strikes > 0) && (cityCount > 0)) {
destCity = Random (cityCount);
SetCityByIndex(1,g.player,destCity);
// Always message BEFORE reducing pop since it might destroy the city
Message(g.player, 'PopTerrorized');
AddPops(city.1, -1);
cityCount = Cities (g.player);
strikes = strikes - 1;
}
}
}
}
Gedrin
[This message has been edited by Gedrin (edited October 20, 2000).]
Comment