Aghh, so much for no problems with my scenario. Can anyone help with a few tricky problems (real tricky because the game works fine, just not as intended).'
1. Here is my code that should stop the people from buliding in Locations Dummy and Dummy2 which are defined elsewhere. To me the code looks good. Why doesnt it stop me from building cities and show a message?
2. Here is some non-working code that should display a messagebox when you bulid in location Dummy3, but alas it is also not working.
3. Finally (and this one doesnt evene look like it is close to being correct) code that should display a message box when you first arrive on the 3 land tiles (dummy, dummy2 and dummy3)
I would be very,very,very,very,very,very,very,very,very,very, very,very, grateful if someone could help me, as this scenario is really beginning to take shape (well the code that is
)
heardie - head hurting because he has banged it against the desk so many times tonight!
1. Here is my code that should stop the people from buliding in Locations Dummy and Dummy2 which are defined elsewhere. To me the code looks good. Why doesnt it stop me from building cities and show a message?
Code:
HandleEvent(CreateCity) 'WWCreateCity_F' pre {
int_t m; // Used for loop
int_t tmpNum; // How many units in the civilization
unit_t tmpUnit; // Used to see if unit lands on land
player[0] = 0;
tmpNum = player[0].units;
for(m = 0; m < tmpNum; m = m + 1){
GetUnitByIndex(player[0], m, tmpUnit);
if (tmpUnit == UnitDB(UNIT_SETTLER) | | tmpUnit == UnitDB(UNIT_SEA_ENGINEER) | | tmpUnit == UnitDB(UNIT_URBAN_PLANNER)){
if (tmpUnit.Location == Dummy | | tmpUnit.Location == Dummy2){
Message (g.player, 'WWTerrainRecommend');
return STOP;
}
else {
return 0;
}
}
}
}
Code:
HandleEvent(CreateCity) 'WWCreateCity2_F' post {
location_t tmpLocation; // Used for the Dummy locations
city_t tmpCity; // Used as the variable for city index
int_t m; // Used for loop
//Use the following to check whether the player creates a land city
for(m = 0; m < player[0].cities; m = m + 1){
GetCityByIndex(player[0], m, tmpCity);
if(CityIsValid(tmpCity)) {
if(tmpCity.Location == Dummy3){
if(turnCount > 101 ){
playerScore = playerScore + 1000; // Max Score!!
hasCity = 1;
Message (g.player, 'WWCityBuilt');
}
elseif(turnCount > 204){
playerScore = playerScore + 750;
hasCity =1;
Message (g.player, 'WWCityBuilt2');
}
elseif(turnCount > 307){
playerScore = playerScore + 500;
hasCity =1;
Message (g.player, 'WWCityBuilt3');
}
}
}
}
}
Code:
HandleEvent(MoveArmy) 'WWMoveUnits_F' post {
int_t m; // Used for loop
int_t tmpNum; // How many units in the civilization
army_t tmpArmy; // Used to see if unit lands on land
// If Units land on land terrain
player[0] = 0;
tmpNum = player[0].units;
for(m = 0; m < tmpNum; m = m + 1){
GetArmyByIndex(player[0], m, tmpArmy);
if(isCityThere == 1) {
if(tmpArmy.Location == Dummy | | tmpArmy.Location == Dummy2 | | tmpArmy.Location == Dummy3){
// Tell the player to settle here now!
Message (g.player, 'WWSettleNow');
DisableTrigger('WWMoveUnits_F');
}
}
elseif(isCityThere == 0){
if(tmpArmy.Location == Dummy | | tmpArmy.Location == Dummy2 | | tmpArmy.Location == Dummy3){
// Tell the player to destroy city then settle here
Message (g.player, 'WWDestroySettle');
DisableTrigger('WWMoveUnits_F');
}
}
}
}
)heardie - head hurting because he has banged it against the desk so many times tonight!


Comment