void RealisticNationsRelationsChange(){
int dateDay,dateMonth,dateYear;
ref PChar = GetMainCharacter();
dateDay = GetDataDay();
dateMonth = GetDataMonth();
dateYear = GetDataYear();
int amount_of_wars = GetAttributesNum(RelationChanges);
for(int i = 0; i < amount_of_wars; i++){
string war_name = GetAttributeName(GetAttributeN(RelationChanges,i));
trace("Checking " + war_name);
int startDay = sti(GetSubString(GetAttribute(RelationChanges,(war_name)+".date.start"),".",0));
int startMonth = sti(GetSubString(GetAttribute(RelationChanges,(war_name)+".date.start"),".",1));
int startYear = sti(GetSubString(GetAttribute(RelationChanges,(war_name)+".date.start"),".",2));
trace("Start = " + startDay+"."+startMonth+"."+startYear);
int endDay = sti(GetSubString(GetAttribute(RelationChanges,(war_name)+".date.end"),".",0));
int endMonth = sti(GetSubString(GetAttribute(RelationChanges,(war_name)+".date.end"),".",1));
int endYear = sti(GetSubString(GetAttribute(RelationChanges,(war_name)+".date.end"),".",2));
trace("End = " + endDay+"."+endMonth+"."+endYear);
int amount_of_relation_changes = GetAttributesNum(GetAttributeN(RelationChanges,i)+".relations")/3;
if(RelationChanges.(war_name).war_active != "true" && startDay >= dateDay && startMonth >= dateMonth && startYear >= dateYear && endDay <= dateDay && endMonth <= dateMonth && endYear <= dateYear){
RelationChanges.(war_name).war_active = "true";
trace(war_name + " is active");
for(int j = 0; j < amount_of_relation_changes; j++){
string relnum = "rel" + j;
string Nation1 = GetAttribute(RelationChanges,(war_name)+".relations."+(relnum)+".nation1");
string Nation2 = GetAttribute(RelationChanges,(war_name)+".relations."+(relnum)+".nation2");
string RelationState = GetAttribute(RelationChanges,(war_name)+".relations."+(relnum)+".state");
SetNationRelationBoth(Nation1,Nation2,RelationState);
trace("Nation 1 = " + Nation1 + " Nation 2 = " + Nation2 + " Relation = " + RelationState)
}
string logStartTitle = GetAttribute(RelationChanges,(war_name)+".desc.start") + "_Title";
string logStartEntry = GetAttribute(RelationChanges,(war_name)+".desc.start") + "_Entry";
WriteNewLogEntry(logStartTitle,logStartEntry,"General",true);
}
else{
if(RelationChanges.(war_name).war_active == "true" && endDay > dateDay && endMonth > dateMonth && endYear > dateYear){
trace(war_name + " has ended");
string logEndTitle = GetAttribute(RelationChanges,(war_name)+".desc.end") + "_Title";
string logEndEntry = GetAttribute(RelationChanges,(war_name)+".desc.end") + "_Entry";
WriteNewLogEntry(logEndTitle,logEndEntry,"General",true);
RelationChanges.(war_name).war_active = "tralse";
for(int k = 0; k < amount_of_relation_changes; k++){
string relnumEnd = "rel" + k;
string Nation1End = GetAttribute(RelationChanges,(war_name)+".relations."+(relnumEnd)+".nation1");
string Nation2End = GetAttribute(RelationChanges,(war_name)+".relations."+(relnumEnd)+".nation2");
SetNationRelationBoth(Nation1End,Nation2End,RELATION_NEUTRAL);
}
}
}
}
}