1. Dismiss Notice
  2. GOG.com logo

    Thanks to YOUR votes, GOG.com now sells:
    - Sea Dogs - Sea Dogs: Caribbean Tales
    - Sea Dogs: City of Abandoned Ships

    Vote now to add Pirates of the Caribbean to the list!

    Dismiss Notice
  3. Under the Crossbones Podcast

    A Pirate Podcast with Interviews
    Music, Comedy and all things Pirate!

    - Episode Guide - About - Subscribe -
    - Twitter - Facebook - iTunes - Android -
    - Youtube - Fill the Coffers -

    Dismiss Notice
  4. New Horizons logo

    Quick links for PotC: New Horizons
    - Download latest version
    - Wiki - FAQ - Report bugs here
    - ModDB profile

  5. GOF logo

    Quick links for AoP2: Gentlemen of Fortune 2
    - Downloads and info
    - Historical Immersion Supermod
    - ModDB Profile

Dismiss Notice
New to the forum?
Please take a moment to read our Welcome Message and Forum Rules.

WIP Periods, royalty names & wars

Discussion in 'Build Beta and Brainstorming' started by DeathDaisy, Nov 20, 2017.

  1. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    384
    Gender:
    Female
    right, Ill try it! also edited my prev post right while you were posting :p its a disaster
     
    Levis likes this.
  2. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,858
    Gender:
    Male
    Occupation:
    ICT
    Location:
    The Netherlands
    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.
     
  3. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    384
    Gender:
    Female
    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: Dec 8, 2017 at 3:11 PM
  4. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    384
    Gender:
    Female
    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: Dec 8, 2017 at 3:20 PM
  5. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,858
    Gender:
    Male
    Occupation:
    ICT
    Location:
    The Netherlands
    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?

    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;
    
     
  6. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    384
    Gender:
    Female
    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
     
  7. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,858
    Gender:
    Male
    Occupation:
    ICT
    Location:
    The Netherlands
    Could you do a trace to see what it gives for value without the divided by 3?
     
  8. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    384
    Gender:
    Female
    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
     
    Pieter Boelen and Levis like this.
  9. DeathDaisy

    DeathDaisy Freebooter Storm Modder

    Joined:
    Aug 18, 2017
    Messages:
    384
    Gender:
    Female
    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
     
  10. Levis

    Levis Find(Rum) = false; Staff Member Programmer Creative Support Storm Modder

    Joined:
    Oct 6, 2013
    Messages:
    6,858
    Gender:
    Male
    Occupation:
    ICT
    Location:
    The Netherlands
    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.
     
    DeathDaisy likes this.

Share This Page