Page 1 of 3 123 LastLast
Results 1 to 20 of 45

Thread: Fleet_to_army_supply effect bundle?

  1. #1

    Default Fleet_to_army_supply effect bundle?

    Hi

    is this effect_bundle still in use in DeI 1.2 or is it some leftover from the past?

    https://i.imgur.com/Ip4JNic.jpg


    can't find the trigger in supply_system.lua, or enywhere else, also the bundle does not trigger in gameplay

  2. #2

    Default Re: Fleet_to_army_supply effect bundle?

    It could be a leftover. There is an effect bundle for when an army is being supplied by a fleet, I don't remember if its this one or not.

    ----> Website -- Patreon -- Steam -- Forums -- Youtube -- Facebook <----

  3. #3

    Default Re: Fleet_to_army_supply effect bundle?

    Yes,

    The effect bundle you're referring to is "army_from_fleet_supply" that grants the supply effect and function to army itself (scope being army). Now this "fleet_to_army_supply" uses scope navy, giving some negatives to fleet when supplying army on land. As I mentioned I couldn't find this script action from 1.1 DeI nor in 1.2, but all in all this would be very nice effect to have in use. Logic being, when navy is supplying army, there's some distraction to it and thus it sufferes some negatives?

  4. #4

    Default Re: Fleet_to_army_supply effect bundle?

    It was probably an idea that never got utilized.

    ----> Website -- Patreon -- Steam -- Forums -- Youtube -- Facebook <----

  5. #5

    Default Re: Fleet_to_army_supply effect bundle?

    Hmm, had to try this one out...

    Spoiler Alert, click show to read: 


    ---- Fleet to army supply with supply ships ----
    LogSupply("SupplyCivForChar()","Start Fleet close to army in region for: "..region_name.." Command Queue Index: "..army);
    local char_list = curr_char:faction():character_list()
    for l = 0, char_list:num_items() - 1 do
    local naval_char = char_list:item_at(l)
    local fleet = naval_char:cqi()
    if char_is_general_with_navy(naval_char)
    and naval_char:cqi() ~= curr_char:cqi()
    and distance_2D(naval_char:logical_position_x(), naval_char:logical_position_y(), x, y) < supply_values_table["radius_fleet"]
    and Unit_Is_In_Army(naval_char, supply_ship_list)
    and not SupplyNearEnemyFleet(curr_char:logical_position_x(), curr_char:logical_position_y(), supply_values_table["radius_enemy_fleet"], char_faction, EnemyFactionKeys)
    and naval_char:turns_at_sea() <= 8
    then scripting.game_interface:apply_effect_bundle_to_characters_force("Army_from_Fleet_Supply", army,-1, "Fleet_to_Army_Supply", army,-1);
    GlobalSupplyCosts = 2;
    LogSupply("SupplyCivForChar()","Fleet close to army -> supply established "..region_name.." Command Queue Index: "..army);
    return GlobalSupplyCosts;
    end;
    end;



    Whitch line defines whether the effect is targeted to fleet or on land army? The scopes are alright with these "Army_from_Fleet_Supply" and "Fleet_to_Army_Supply", but the scopes do not resolve this. If scripting game interface, what is the target? Conditional sentences deternminate what are the conditions and the conditions work vice versa in here just fine I believe

  6. #6
    ~Seleukos.I.Nikator~'s Avatar Campidoctor
    Join Date
    Nov 2010
    Location
    The United Europe, currently residing in Norway
    Posts
    1,642

    Default Re: Fleet_to_army_supply effect bundle?

    I don't know this script (yet), but regarding your question about the target, that's always in the command parameters which are in this case "Army_from_Fleet_Supply" and "Fleet_to_Army_Supply" - these two are the effect boundles which are meant to be applied - "army" is the target - which in this case must signify the land army and not the navy - and "-1" means that the effect is indefinite, i.e. there is no turn limit it's applied for.

  7. #7

    Default Re: Fleet_to_army_supply effect bundle?

    Thank you very much for your answer.
    In this script its the navy that castes indefinite effect bundle with certain radius. Now, "Army_from_fleet_supply" should go to land army as it goes BUT "fleet_to_army_supply" should go to fleet itself... I was wondering if it should be the army that counter castes this bundle to navy?

    If "army" is target parameter for land army, what is the parameter to navy? Tried to find it in scripts but could not find one

  8. #8
    ~Seleukos.I.Nikator~'s Avatar Campidoctor
    Join Date
    Nov 2010
    Location
    The United Europe, currently residing in Norway
    Posts
    1,642

    Default Re: Fleet_to_army_supply effect bundle?

    That parameter might be 'navy', I suppose, but that's not how it works, I believe.

    Army cannot basically supply the navy and you can see that in the conditions you have in your script 'if char_is_general_with_navy(naval_char)'.

    Regarding the effect bundles, I'm not sure exactly what effects are associated with them and I can't check this as I'm currently still at work, but it seems to me that both bundles deal with navy suppling the army and not vice versa.

  9. #9

    Default Re: Fleet_to_army_supply effect bundle?

    Just a little comfused with this: 'if char_is_general_with_navy(naval_char)'
    Does it mean that navy originates the effect bundle cast? I mean there is this radius and conditions that if met, the bundle is casted regardless what instance spawnes it?

    The problem here is that I only got option target "army,-1", there's no option for navy. So navy suplies in this case but the navy should suffer effect bundle that is "fleet_to_army_supply". It should give negatives to fleet as it is supplying the army in land.

  10. #10

    Default Re: Fleet_to_army_supply effect bundle?

    That part of the script is there to check if a navy is near the army. This script is only dealing with the army in question, but has a part that will check for navies.

    To add the effect bundle you are talking about, you would need another script to handle that.

    ----> Website -- Patreon -- Steam -- Forums -- Youtube -- Facebook <----

  11. #11

    Default Re: Fleet_to_army_supply effect bundle?

    I see, this was something that I feared of. To make a counter bundle that originates from the target army of the original bundle casted, could make things interesting...

    Here we go

    Spoiler Alert, click show to read: 


    ---Fleet supplying army gets effect bundle from army itself---
    if context:character():faction():is_human() == true
    and context:character():has_military_force() == true
    and (char_is_general_with_navy(context:character())) == false
    and context:character():character_type("general")

    then local char_list = context:character():faction():character_list()
    for l = 0, char_list:num_items() - 1 do
    local curr_char = char_list:item_at(l)
    if char_is_general_with_army(curr_char)
    and curr_char:cqi() ~= context:character():cqi()
    and distance_2D(curr_char:logical_position_x(), curr_char:logical_position_y(), x, y) < supply_values_table["radius_transport"]
    then scripting.game_interface:apply_effect_bundle_to_characters_force(Fleet_to_Army_Supply", army,-1);
    return
    end
    end
    end



    This does not work yet but the basics should go like this:
    1. We restrict this to human only
    2. Has military force (not navy), --not sure if the resctrictions could be simpler in this case, maybe one line too many perhaps...
    3. "curr char" is in this case, the land army with general and it should caste the bundle with the radius ["radius_transport"] restriction, anything inside this radius gets the bundle "Fleet_to_Army_Supply". Unfortunately, if theres another army nearby, it gets the bundle also because "army,-1" means both navy and land army?

    With trial and error you can get so far with so many spent hours in vain...

    I was wondering, is there any debugging tools to help to test the script your putting up. I found one in this thread: http://www.twcenter.net/forums/showthread.php?694602-Introduction-To-Scripting

    But without any tutorial it's pretty useless
    Last edited by ♔Greek Strategos♔; April 25, 2019 at 06:37 AM. Reason: Merged posts.

  12. #12
    ~Seleukos.I.Nikator~'s Avatar Campidoctor
    Join Date
    Nov 2010
    Location
    The United Europe, currently residing in Norway
    Posts
    1,642

    Default Re: Fleet_to_army_supply effect bundle?

    I'm not sure, MrTimber, how you can possibly make use of that Magnar's pack with debugging tool, but from what I've learnt so far this is not as simple as placing a pack with the debugging tool in your data folder.

    Debugging is basically a function that you need to insert in your script and then call it every time you find it appropriate.

    Take a look at this satrapal rebellion script;

    Spoiler Alert, click show to read: 
    Code:
    SeleucidDebugging = false;
    EasternRebellionTriggered = false;
    SeleucidTurnProtection = 15;
    
    
    all_diplomatic_treaty_types = {
    "current_treaty_vassal_of_player",
    "current_treaty_client_of_player",
    "current_treaty_at_war",
    "current_treaty_defensive_alliance",
    "current_treaty_military_alliance",
    "current_treaty_trade_agreement",
    "current_treaty_non_aggression_pact",
    "current_treaty_giving_soft_military_access_turns",
    "current_treaty_trade_embargoed",
    "current_treaty_embargoing_trade"
    };
    
    
    local function SeleucidGetTreaties(context)
    if not EasternRebellionTriggered and context:faction():name() == "rom_seleucid" then
    local human = context:faction():is_human()
    
    
    if scripting.game_interface:model():turn_number() == 2 and human then
    scripting.game_interface:show_message_event("custom_event_520", 0, 0);
    end;
    
    
    if SeleucidTurnProtection < scripting.game_interface:model():turn_number() then
    DebugSeleucid("SeleucidGetTreaties");
    SeleucidTreatyDetailsGetTreaties(context:faction():treaty_details(), context:faction():faction_attitudes(), human);
    end;
    end;
    end;
    
    
    function SeleucidTreatyDetailsGetTreaties(treaty_details, faction_attitudes, human)
    local count = 0;
    local VassalFactionKeys = {};
    for faction, details in pairs(treaty_details) do
    DebugSeleucid("details.culture: "..details.culture);
    if details.culture == "rom_Eastern" then
    DebugSeleucid("faction ??: "..tostring(faction));
    for k, treaty in ipairs(details) do
    DebugSeleucid("treaty_details: "..treaty);
    if treaty == "current_treaty_vassal_of_player" 
    or treaty == "current_treaty_client_of_player" then
    table.insert(VassalFactionKeys, tostring(faction));
    count = count + 1;
    DebugSeleucid("Faction Added: "..faction);
    end;
    end;
    end;
    end;
    if count > 2 then SeleucidRebellionFactions(VassalFactionKeys, faction_attitudes, count, human) end;
    end;
    
    
    function SeleucidRandomSeed()
    local region = "emp_syria_antioch";
    TotalPop = 0;
    for i = 1, 4 do
    TotalPop = rom_region_to_pop_table[region][i] + TotalPop;
    end;
    DebugSeleucid("TotalPop as random seed: "..tostring(TotalPop))
    return TotalPop;
    end;
    
    
    function SeleucidRandomNumber()
    DebugSeleucid("SeleucidRandomNumber")
    local random_var = SeleucidRandomSeed();
    math.randomseed(random_var);
    random_var = math.random(1,100);
    DebugSeleucid("random_var: "..tostring(random_var));
    random_var = math.random(1,100);
    DebugSeleucid("random_var: "..tostring(random_var));
    return random_var;
    end;
    
    
    function SeleucidRebellionFactions(VassalFactionKeys, faction_attitudes, count, human)
    local RebelFactions = {};
    local MaxRebels = 0;
    local strength = 0;
    if count > 2 then
    DebugSeleucid("SeleucidRandomNumber: Start Rebel Faction List");
    for _,i in pairs(VassalFactionKeys) do
    local VassalFaction = i;
    DebugSeleucid("faction_attitudes[VassalFaction]: "..faction_attitudes[VassalFaction])
    if not human and MaxRebels < 5 
    or (human and MaxRebels < 5 and faction_attitudes[VassalFaction] <= 0) then 
    local newstrength = SeleucidRebelStrength(VassalFaction)
    if newstrength > 1 then 
    table.insert(RebelFactions, VassalFaction)
    strength = strength + newstrength
    MaxRebels = MaxRebels + 1;
    DebugSeleucid("Rebel Faction added: "..VassalFaction)
    end;
    end;
    end;
    end;
    DebugSeleucid("MaxRebels: "..tostring(MaxRebels));
    DebugSeleucid("strength: "..tostring(strength));
    if MaxRebels >= 2 then SeleucidRebellionChance(MaxRebels, strength, RebelFactions) end;
    end;
    
    
    function SeleucidRebellionChance(MaxRebels, Rebelstrength, RebelFactions)
    local SeleucidStrength = SeleucidRebelStrength("rom_seleucid")
    DebugSeleucid("SeleucidStrength: "..tostring(SeleucidStrength));
    local strength = Rebelstrength - SeleucidStrength
    if strength < 0 
    then strength = -1
    end;
    local randomNumber = SeleucidRandomNumber();
    local chance = (MaxRebels*3) + (strength*5);
    DebugSeleucid("chance: "..tostring(chance));
    
    
    if randomNumber < chance 
    then SeleucidTriggerRebellionForFactions(RebelFactions);
    end;
    end;
    
    
    
    
    function SeleucidRebelStrength(CheckFaction)
    local minUpkeepThreshold = 1000;
    
    
    if CheckFaction == "rom_seleucid" 
    then minUpkeepThreshold = 2500
    end;
    
    
    local strength = 0;
    local faction = scripting.game_interface:model():world():faction_by_key(CheckFaction)
    local forceCount = faction:military_force_list():num_items();
    for i = 0, forceCount - 1 do
    local force = faction:military_force_list():item_at(i);
    if force:upkeep() > minUpkeepThreshold then
    strength = strength + 1;
    end;
    end;
    DebugSeleucid("CheckFaction: ".. CheckFaction.. " strength: "..strength);
    return strength; 
    end;
    
    
    function SeleucidTriggerRebellionForFactions(RebelFactions)
    DebugSeleucid("SeleucidTriggerRebellionForFactions")
    for _,i in pairs(RebelFactions) do
    local RebelFaction = i;
    scripting.game_interface:force_declare_war(RebelFaction, "rom_seleucid");
    scripting.game_interface:cai_strategic_stance_manager_promote_specified_stance_towards_target_faction(RebelFaction, "rom_seleucid", "CAI_STRATEGIC_STANCE_BITTER_ENEMIES")
    scripting.game_interface:cai_strategic_stance_manager_promote_specified_stance_towards_target_faction("rom_seleucid", RebelFaction, "CAI_STRATEGIC_STANCE_BITTER_ENEMIES")
    scripting.game_interface:cai_strategic_stance_manager_block_all_stances_but_that_specified_towards_target_faction(RebelFaction, "rom_seleucid", "CAI_STRATEGIC_STANCE_BITTER_ENEMIES") 
    scripting.game_interface:force_change_cai_faction_personality(RebelFaction, "minor_eastern_alternative");
    end;
    
    
    for _,i in pairs(RebelFactions) do
    local RebelFaction = i;
    for _,k in pairs(RebelFactions) do
    local RebelFaction2 = k;
    if RebelFaction ~= RebelFaction2 then
    scripting.game_interface:force_make_peace(RebelFaction, RebelFaction2);
    end;
    end;
    end;
    scripting.game_interface:show_message_event("custom_event_510", 0, 0); -- add new message about Eastern Rebels
    EasternRebellionTriggered = true;
    end;
    
    
    function DebugSeleucid(text, isTitle, isNew)
    
    
    if not SeleucidDebugging then 
    return
    end;
    
    
    local logfile;
    text = tostring(text);
    if isNew then
    logfile = io.open("DebugSeleucid.log.txt","w");
    local text = tostring("- Sleucid Debug Log -\n");
    logfile:write(text.."\n\n");
    else
    logfile = io.open("DebugSeleucid.log.txt","a");
    if not logfile then logfile = io.open("DebugSeleucid.log.txt","w") end
    end
    
    
    if isTitle then
    local title_text = "*************************************************************************\n";
    text = "\n"..title_text..text.."\n"..title_text;
    end
    
    
    logfile:write(text.."\n");
    logfile:close();
    end;


    Marked in red at the bottom of that script there is the debugging function for this script.

    Then marked in greek there is every instance of the debugging function being called in the script.

    So if you want the debugging function in your script you need to write something smiliar to this.

    I know DeI has also its own debugging tool built into its camapaign script that you can toggle on and off, but I can't really tell you exactly how you can use it. I guess Dresden can tell you more about it.

  13. #13
    Jake Armitage's Avatar Artifex
    Patrician

    Join Date
    Apr 2011
    Location
    apartment 6
    Posts
    4,694

    Default Re: Fleet_to_army_supply effect bundle?

    Thx, this may be useful

  14. #14
    ~Seleukos.I.Nikator~'s Avatar Campidoctor
    Join Date
    Nov 2010
    Location
    The United Europe, currently residing in Norway
    Posts
    1,642

    Default Re: Fleet_to_army_supply effect bundle?

    No problem, Jake!

    I just hope that Dresden will also verify this and correct me if I was wrong.

  15. #15

    Default Re: Fleet_to_army_supply effect bundle?

    Hi again!

    This is what I'm testing right now:

    Spoiler Alert, click show to read: 


    ---- Fleet close to army, fleet gets own effect bundle ----
    LogSupply("SupplyCivForChar()","Start army close to Fleet in region for: "..region_name.." Command Queue Index: "..army);
    if context:character():has_military_force() == true
    and (char_is_general_with_navy(context:character())) == true
    and context:character():has_region() == false
    and Unit_Is_In_Army(curr_char, supply_ship_list)
    and context:character():turns_at_sea() <= 8
    and context:character():faction():has_food_shortage() == false
    then local char_list = context:character():faction():character_list()
    for l = 0, char_list:num_items() - 1 do
    local curr_char = char_list:item_at(l)
    local army = curr_char:cqi()
    if not char_is_general_with_navy(naval_char)
    and curr_char:cqi() ~= context:character():cqi()
    and distance_2D(curr_char:logical_position_x(), curr_char:logical_position_y(), x, y) < supply_values_table["radius_fleet"]
    and not SupplyNearEnemyFleet(curr_char:logical_position_x(), curr_char:logical_position_y(), supply_values_table["radius_enemy_fleet"], char_faction, EnemyFactionKeys)
    then scripting.game_interface:apply_effect_bundle_to_characters_force("Fleet_to_Army_Supply", army,-1);
    end;
    end;
    end;



    So far I have managed to spawn the bundle: "Fleet_to_Army_Supply" only for the land army, not the fleet as intended.

    I need little assistance/clarification on these:
    1. First "if" tells what the entity should be to gets the effect bundle, am I right?
    2. What syntax is this, what does it mean/do: for l = 0, char_list:num_items() - 1 do
    3. Just to be sure, does "local char" check every character/army in whole faction or only selected ones?
    4. What does this do: and curr_char:cqi() ~= context:character():cqi()

    Thanks o/

  16. #16
    Jake Armitage's Avatar Artifex
    Patrician

    Join Date
    Apr 2011
    Location
    apartment 6
    Posts
    4,694

    Default Re: Fleet_to_army_supply effect bundle?

    1. yeah, sort of, is the condition for having the trigger (in this case it means a deployable character)
    2. don't mind about that it's a sort of call syntax, it's the common way to do that in lua (search some tutorial to understand it)
    3. check for the equivalence "local char = ...." and you will find what char is (at the end it's an abbreviation). Could be inside the script or could be inside library > dei_utility_functions. Don't mistake a concept here: the triggered event is described on the callbacks (most of the time), not in the function itself, search for the callbacks at hte end of the sheet (or of the script) and see how it works (faction, region, start turn ecc...). All teh triggerable events are inside an event tab.
    4. cqi is a lua function, should be a string number different for every character so you can store it for a certain character and then call it back when you need

    (in this case it means a deployable character) = sorry that's not the case I didn't read the entire script, but you can understand by yourself

    if context:character():has_military_force() == true
    and (char_is_general_with_navy(context:character())) == true
    and context:character():has_region() == false
    and Unit_Is_In_Army(curr_char, supply_ship_list)
    and context:character():turns_at_sea() <= 8
    and context:character():faction():has_food_shortage() == false
    Last edited by ♔Greek Strategos♔; April 25, 2019 at 06:38 AM. Reason: Merged posts.

  17. #17
    ~Seleukos.I.Nikator~'s Avatar Campidoctor
    Join Date
    Nov 2010
    Location
    The United Europe, currently residing in Norway
    Posts
    1,642

    Default Re: Fleet_to_army_supply effect bundle?

    2. that 'for l = 0, char_list:num_items() - 1 do' is basically a loop where 'l = 0' is the initial value and 'char_list:num_items() - 1' the maximum value. Why, however, that maxium value is always subtracted by 1 in this kind of loops, that I don't unfortunately know.

  18. #18

    Default Re: Fleet_to_army_supply effect bundle?

    Thanks Jake & Seleukos!

    This helps a lot to undestand what I'm doing. At his point I'm pretty sure that the code I've created is intact enough but it does not work for some reason I just can't figure out... Infact when I add this code to supply_system.lua it disables all the functions that can be found there. What one would except is that the corrupt code is leaped over or ignored, but that everything in that file goes south because of my added lines.


    These are lines that may cause the problem, please comment if you have better knowledge:

    LogSupply("SupplyCivForChar()","Start army close to Fleet in region for: "..region_name.." Command Queue Index: "..army); --- Is there need to log this event? Should log function be coded in somewhere else that this refers to?
    if not char_is_general_with_navy(naval_char) ---not operand should be plausable but is the syntax OK?
    local army = curr_char:cqi() --- is local army valid for curr_char? This is the operand that checks if there is a land army nearby

  19. #19
    ~Seleukos.I.Nikator~'s Avatar Campidoctor
    Join Date
    Nov 2010
    Location
    The United Europe, currently residing in Norway
    Posts
    1,642

    Default Re: Fleet_to_army_supply effect bundle?

    MrTimber,

    It would be actually easier if you paste in the whole code and just redmark those lines you are unsure about.

    Otherwise, the lines you've posted above are out of context so it's pretty hard to say anything.

  20. #20

    Default Re: Fleet_to_army_supply effect bundle?

    OK, now I think I'm really close.. something still bugs...

    Spoiler Alert, click show to read: 

    Code:
    ---- Fleet close to army, fleet gets own effect bundle ----
    LogSupply("SupplyCivForChar()","Start army close to Fleet in region for: "..region_name.." Command Queue Index: "..army); 
    if context:character():has_military_force() == true
        and (char_is_general_with_navy(context:character())) == true
        and context:character():has_region() == false
        and Unit_Is_In_Army(context:character(), supply_ship_list)
        and context:character():turns_at_sea()  <= 8
        and context:character():faction():has_food_shortage() == false  
            then local char_list = context:character():faction():character_list()
            for l = 0, char_list:num_items() - 1 do
              local curr_char = char_list:item_at(l)
              local force = curr_char:cqi() 
                if not char_is_general_with_navy(curr_char)
                  and curr_char:cqi() ~= context:character():cqi() 
                  and distance_2D(curr_char:logical_position_x(), curr_char:logical_position_y(), x, y) < supply_values_table["radius_fleet"] 
                  and not SupplyNearEnemyFleet(curr_char:logical_position_x(), curr_char:logical_position_y(), supply_values_table["radius_enemy_fleet"], char_faction, EnemyFactionKeys)
                 then scripting.game_interface:apply_effect_bundle_to_characters_force("Fleet_to_Army_Supply", army,-1);
                end
            end
    end

Page 1 of 3 123 LastLast

Posting Permissions

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