• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

WIP Periods, royalty names & wars

You can use the DumpAttributes(RelationChanges) to see what is going on.
Could it be you maybe also call the init function again somewhere and therefore overwrite the attribute for war_active?
right, Ill try it! also edited my prev post right while you were posting :p its a disaster
 
right, Ill try it! also edited my prev post right while you were posting :p its a disaster
A trouble shooting tip:
If things are going into if statements when you think they shouldn't you could do something like this:
trace("check if "+dateDay+">"+endDay+" and "+dateMonth+" > "+endMonth)
you can expand that line even more.
I would suggest adding the index of your loop to it too, this way you can see what is happening. Also adding a trace line in the if statement would make sure you know it is true or not :).
That way you can check if something in your logic might not be right.
 
Ive realized two problems. one is that Im checking day, month and year separately, which means that if the start date is 23.5.1618 and the current date is 22.6.1620, the current day number is still lower than the start date number, so it will return false. second is that Im checking the start and end dates backwards :facepalm gonna have to give it some thought
 
Last edited:
alright, so Ive found a way check for the date I think
Code:
        int TimeSinceStart = GetPastTime("day",startYear,startMonth,startDay,GetTime(),dateYear,dateMonth,dateDay,GetTime());
        int TimeSinceEnd = GetPastTime("day",endYear,endMonth,endDay,GetTime(),dateYear,dateMonth,dateDay,GetTime());
the GetPastTime thing returns the number of days since a date. so if I feed it the war date values, it gives a number between 0 (if the date hasnt passed yet) to a lot of days.
Code:
if(GetAttribute(RelationChanges,(war_name)+".war_active") == "tralse" && TimeSinceStart > 0 && TimeSinceEnd == 0){
Code:
if(GetAttribute(RelationChanges,(war_name)+".war_active") == "true" && TimeSinceStart > 0 && TimeSinceEnd > 0){
so these ifs seem to work fine. however since its an int I dunno if the number of days can be so many as to exceed the int maximum :shrug

anyway, another problem has reared its ugly head
Code:
int amount_of_relation_changes = GetAttributesNum(RelationChanges.(war_name).relations)/3;
I just cannot for the life of me get this to work. it always returns zero which means no relation changes since it doesnt run the for loop
Code:
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)
            }
Ive tried several variations, but it refuses to get the number of attributes from a sub-attribute :ko

EDIT: the subattribute in question looks like this in the wars themselves
Code:
RelationChanges.30_years_war_england.relations.rel1.nation1 = ENGLAND;
    RelationChanges.30_years_war_england.relations.rel1.nation2 = HOLLAND;
    RelationChanges.30_years_war_england.relations.rel1.state = RELATION_FRIEND;
    RelationChanges.30_years_war_england.relations.rel2.nation1 = ENGLAND;
    RelationChanges.30_years_war_england.relations.rel2.nation2 = SPAIN;
    RelationChanges.30_years_war_england.relations.rel2.state = RELATION_ENEMY;
 
Last edited:
alright, so Ive found a way check for the date I think
Code:
        int TimeSinceStart = GetPastTime("day",startYear,startMonth,startDay,GetTime(),dateYear,dateMonth,dateDay,GetTime());
        int TimeSinceEnd = GetPastTime("day",endYear,endMonth,endDay,GetTime(),dateYear,dateMonth,dateDay,GetTime());
the GetPastTime thing returns the number of days since a date. so if I feed it the war date values, it gives a number between 0 (if the date hasnt passed yet) to a lot of days.
Code:
if(GetAttribute(RelationChanges,(war_name)+".war_active") == "tralse" && TimeSinceStart > 0 && TimeSinceEnd == 0){
Code:
if(GetAttribute(RelationChanges,(war_name)+".war_active") == "true" && TimeSinceStart > 0 && TimeSinceEnd > 0){
so these ifs seem to work fine. however since its an int I dunno if the number of days can be so many as to exceed the int maximum :shrug

I believe the max is 65536 so that would span 180 years, so that's possible indeed.
Did you consider just doing:
if(dateYear == startYear && dateMonth == startMonth && dateDay == startDay)

that should work right?

anyway, another problem has reared its ugly head
Code:
int amount_of_relation_changes = GetAttributesNum(RelationChanges.(war_name).relations)/3;
I just cannot for the life of me get this to work. it always returns zero which means no relation changes since it doesnt run the for loop
Was afraid of that already.
try it like this:
Code:
aref war;
makearef(war, RelationChanges.(war_name).relations);
int amount_of_relation_changes = GetAttributesNum(war)/3;
 
I believe the max is 65536 so that would span 180 years, so that's possible indeed.
Did you consider just doing:
if(dateYear == startYear && dateMonth == startMonth && dateDay == startDay)

that should work right?
aye, but when its done Id rather not run it every day, both for a bit of realism and cuz its not the fastest function as it has quite a lot of stuff to check

Was afraid of that already.
try it like this:
Code:
aref war;
makearef(war, RelationChanges.(war_name).relations);
int amount_of_relation_changes = GetAttributesNum(war)/3;
no luck :modding
 
aye, but when its done Id rather not run it every day, both for a bit of realism and cuz its not the fastest function as it has quite a lot of stuff to check


no luck :modding
Could you do a trace to see what it gives for value without the divided by 3?
 
Could you do a trace to see what it gives for value without the divided by 3?
not only that, removing the 3 also made it work! thanks! xD obvious in hindsight, but rel1 is ofc one attribute with 3 subattributes, not 3 attributes in itself, so the /3 made it into 0 :p rn it always returns the first nations and state as -1 tho, but I guess thats because Im checking for "rel"+j and j is 0 the first loop, so I think Ive got to change it to "rel"+(j+1) and itll be fixed
 
I believe the max is 65536 so that would span 180 years, so that's possible indeed.
I tested a trace with the GetPastTime thing. started a game in Revolutions and got the num of days since 1 January 1530
Code:
Days since 1530.1.1 = 96194
there is probly an easy explanation I dunno bout, but it does somehow count higher than I thought an int could, so the if I did shud work
 
I tested a trace with the GetPastTime thing. started a game in Revolutions and got the num of days since 1 January 1530
Code:
Days since 1530.1.1 = 96194
there is probly an easy explanation I dunno bout, but it does somehow count higher than I thought an int could, so the if I did shud work
I tought the storm engine only used 16 bit integers, but I guess they are 32 bit integers. in that case there shouldn't be a problem at all.
You can test it if you want.
I guess they store a signed integer so that would have a total of 4294967296 values, so you need to divide it by 2 to see what the max is you can go (because the values go both positive and negative).
So in theory the highest values you can store is 2147483648, so that would almost by 6 million years. So unless someone is going to add a TARDIS to the game I don't think we get in problems here.
 
Back
Top