Results 1 to 9 of 9

Thread: Hunnic Army spawn issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Radious's Avatar I came, I saw, I modded
    Join Date
    Mar 2009
    Location
    Czech Republic
    Posts
    11,169

    Icon4 Hunnic Army spawn issue

    Hello everyone,

    maybe you will be able to help me with this.

    I noticed that att_preservation_data is somehow broken, since AI always spawns just 1 type of the army for Hunns in each campaign era (3 eras, after some turns it moves to next). Since it was annoying to fight always against exact same armies i wanted to add way more variations, but not exactly sure how to do it and how to fix that file, when even vanilla game has 2 variations for each era, but always spawns just 1 type of the army - the first one in that file and never the second type.

    So before adding more army variations, it must be fixed.

    Any help from anyone with some scripting skills wil lbe greatly appreciated.
    Last edited by Radious; August 22, 2015 at 05:09 AM.

    Winner of the 2011, 2012. 2014, 2015, 2016 and 2017 Modding Awards in Total War Shogun 2, Rome 2, Attila, Warhammer 1 and Warhammer 2.
    Follow us here - Team Radious




  2. #2
    Radious's Avatar I came, I saw, I modded
    Join Date
    Mar 2009
    Location
    Czech Republic
    Posts
    11,169

    Default Re: Hunnic Army spawn issue

    1 month and nothing..... Nobody cares or nobody knows?

    Winner of the 2011, 2012. 2014, 2015, 2016 and 2017 Modding Awards in Total War Shogun 2, Rome 2, Attila, Warhammer 1 and Warhammer 2.
    Follow us here - Team Radious




  3. #3
    Litharion's Avatar Artifex
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    2,622

    Default Re: Hunnic Army spawn issue

    I was unaware of this issue. I think the function responsible for selecting and randomizing which army template to spawn is the one we need to look at.

    att_preservation.lua

    Code:
    function get_hun_army_string()
        local turn_number = cm:model():turn_number();
        
        -- verify we still have at least one army template
        if #hun_preservation_army_template_list < 1 then
            script_error("ERROR: get_hun_army_string() called but we have no army templates to look through - returning an emergency force but this needs fixing");
            return "emergency", "att_nom_steppe_levy";
        end;
        
        -- for each of our army templates, work out if the current turn falls in the min/max range
        
        local possible_armies = {};
    
    
        for i = 1, #hun_preservation_army_template_list do
            local current_template = hun_preservation_army_template_list[i];
            
            local min_date = current_template.min_date;
            local max_date = current_template.max_date;
            
            if (min_date < 0 or min_date <= turn_number) and (max_date < 0 or max_date >= turn_number) then
                
                table.insert(possible_armies, current_template);
            end;
        end;
        
        if #possible_armies > 0 then
            local possible_armies = cm:random_sort(possible_armies); -- Sort the table randomly
            return possible_armies[1].name, possible_armies[1].army_string; -- Pick the first one, which will be random
        end
        
        script_error("WARNING: get_hun_army_string() called but couldn't find any matching force for the current turn " .. tostring(turn_number) .. ", using the first force string");
        
        return hun_preservation_army_template_list[1].name, hun_preservation_army_template_list[1].army_string;
    end;
    At a glance I don't see a problem with the function.

  4. #4
    Radious's Avatar I came, I saw, I modded
    Join Date
    Mar 2009
    Location
    Czech Republic
    Posts
    11,169

    Default Re: Hunnic Army spawn issue

    Well from the preset armies it always picks the first 1, never the second. So you constantly fight always vs same 1 army type. I would like to fix that, so it realy picks them randomly and then even add more Hunnic army variations. Now they have 2 army types for each campaign phase - yet picks always just 1 same in each phase.

    Winner of the 2011, 2012. 2014, 2015, 2016 and 2017 Modding Awards in Total War Shogun 2, Rome 2, Attila, Warhammer 1 and Warhammer 2.
    Follow us here - Team Radious




  5. #5

    Default Re: Hunnic Army spawn issue

    I would try making it so it randomly picks a row, even if the script is written completely fine when it comes to standard lua scripting, there is no gaurentee saying that the games hardcoding isn't going to mess it up somehow, resulting in a seemingly fine implementation breaking down.

    Having a redundant layer of randomness might provide a failsafe against this.

  6. #6
    Litharion's Avatar Artifex
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    2,622

    Default Re: Hunnic Army spawn issue

    Pseudo random number generators outside the functions provided by the Game are somehow tricky to implement as they cause Multiplayer Desyncs if both players generate different random numbers. It can be done but it is a bit more complicated.

  7. #7
    Radious's Avatar I came, I saw, I modded
    Join Date
    Mar 2009
    Location
    Czech Republic
    Posts
    11,169

    Default Re: Hunnic Army spawn issue

    Script itself is pretty much based on random spawns. If it works as it should, then it randomply spawns different Hunnic armies.

    Winner of the 2011, 2012. 2014, 2015, 2016 and 2017 Modding Awards in Total War Shogun 2, Rome 2, Attila, Warhammer 1 and Warhammer 2.
    Follow us here - Team Radious




  8. #8
    Radious's Avatar I came, I saw, I modded
    Join Date
    Mar 2009
    Location
    Czech Republic
    Posts
    11,169

    Default Re: Hunnic Army spawn issue

    Problem solved, issues fixed, new juicy stuff released in recent Radious Update. This changes how AI handles Hunns and mainly what it drops on your heads!

    Winner of the 2011, 2012. 2014, 2015, 2016 and 2017 Modding Awards in Total War Shogun 2, Rome 2, Attila, Warhammer 1 and Warhammer 2.
    Follow us here - Team Radious




  9. #9
    SharpEyed's Avatar Be Fair and Thankful!
    Join Date
    Oct 2013
    Location
    the Vale of Tears
    Posts
    3,384

    Default Re: Hunnic Army spawn issue

    Congratz Radious

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •