I wish i could say the same <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid="
" border="0" alt="icon_wink.gif" />
All I got done this week is a function for the original topic of this thread, the occupying of towns.
It changes the fortcommanders nation, which automatically changes the whole fort as well, the uniforms of all townguards and the "town.nation" attribute, which affects such things as the names of random citizens. The scripted citizens remain unchanged, which would have also been the case in the historical "sugar island grabbings", and minimizes interference with the scripted texts.
This is the function:
<span style='`font-size`:16pt;`line-height`:100%'>
void ChangeTownNation (string townsk, int nat) // functioncall must include townname, i.e. townsack attribute, and nationindex
{
ref commander // the fortcommander of this town
if (townsk == "Falaise de Fleur") commander = (characterFromID("FalaisedeFleur Commander")); // why didn't Akella...
else if (townsk == "Isla Muelle") commander = (characterFromID("IslaMuelle Commander")); // stick to one spelling system ? @@
else commander = (characterFromID(townsk + " Commander"));
commander.nation = nat; // gets the nation from the functioncall
commander.model = SelectSoldierModelByNation(commander, "Soldier"); // and the appropriate charmodel
SetTownNation(townsk, nat); // town gets the nation from the functioncall
ref ch;
for(int n = 0; n < TOTAL_CHARACTERS; n++) // loop to cycle through all characters
{
makeref(ch, Characters[n]); // defines ch as character who has loopindex as characterindex
if(CheckAttribute(ch, "sound_type") && ch.sound_type == "soldier") // if ch is a soldier
{
if(CheckAttribute(ch, "location") && FindLocation(Characters[ch].location) >= 0)
// and if ch has a location
{
if(CheckAttribute(Locations[FindLocation(ch.location)],"townsack") && Locations[FindLocation(ch.location)].townsack == townsk) // and if ch is in this town
{
ch.nation = nat // ch gets nation from functioncall
ch.model = SelectSoldierModelByNation(commander, "Soldier"); // and a new uniform
facemaker(ch); // and the appropriate facepicture
}
}
}
}
PlayStereoSound("interfacenotebook.wav"); // notification by sound and screenmessage
Log_SetStringToLog(townsk + " has been occupied by " + GetNationDescByType(nat) + " forces" );
}
</span>Put this function in some key file, e.g. seadogs.c . There you can call it out of any other gameprocedure. E.g. you could add this link to the Enc_fort_dialog.c from the Location Tutorial 2:
<span style='`font-size`:16pt;`line-height`:100%'>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> Link.l5 = "Commander, I'll spare you and the town if you swear allegiance to Spain. Long live his Most Catholic Majesty Felipe, who will restore this town to the true belief... ";
Link.l5.go = "spain";
break;
case "spain":
ChangeTownNation (lcn.townsack, SPAIN); // passes .townsack attribute of current location...
//...and new nationindex to changenation function
DialogExit();
NextDiag.CurrentNode = NextDiag.TempNode;
break;<!--c2--></div><!--ec2-->
</span>
Or you could make it a random event to simulate "Colonial wars", like in Pirates! "You hear the news that Redmond has been occupied by Spain"
For that find this line in worldmapworldmap_events.c, which runs every "morning"
DailyCrewUpdate();
// NK <--
And insert below that for each town a random call of the new ChangeTownNation function:
<span style='`font-size`:16pt;`line-height`:100%'>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> switch(rand(100)) // 100 is intentionally bigger than the number of cases so that most days nothing happens
{
case 0:
ChangeTownNation ("Redmond", makeint(rand(5)+1) ); // would change nation for Redmond with a random nationindex
break;
case 6:
ChangeTownNation ("Conceicao", makeint(rand(5)+1) ); // would change nation for C'cao with a random nationindex
break;
...}<!--c2--></div><!--ec2-->
</span>
That way on some mornings you would get a message that a town has changed hands.
Be warned that the functioncall must instead of the townname pass the " .townsack" attribute which you can look up in the locationsinit files. That attribute may have a different spelling than the townname, thanks to Akella's unsystematic and sloppy workstyle (Falaise de Fleur, Falaise_de_Fleur, FalaiseDe Fleur, FaledeFleur... seems like every programmer just used some spelling he fancied )
What I don't know yet is what to do with the governors. Leaving an English governor in a townhall guarded by Spanish soldiers would look a little odd. OTH it could mess up the game and the quests terribly if e.g. Silehard would be replaced by some Don. Maybe I'll just leave them in place but replace the usual dialognodes with something like
"Sorry, I can't give you any missions cause i'm not in charge here anymore. Those occupants have put me under housearrest..."