Results 1 to 9 of 9

Thread: Does apply_effect_bundle work in this game

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Does apply_effect_bundle work in this game

    .
    Edit - Please see third post for updated question



    Hi guys,

    I have created some new effect bundles that I add to a faction by scripting. Nothing crashed but I can't tell if the effect bundle has been added. Is there anywhere to check in game, or in the save file?

    If you help me I will let you use my stuff, it is pretty cool ...
    Last edited by Col.KanKrusha; May 11, 2015 at 12:46 AM.
    ~ Too soon old, too late smart ~

  2. #2
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: How to check when an effect bundle has been attached to a faction?

    OKay, now fixed so it being run with an AddEventCallBack. The effect bundle should affect diplomacy but i see no effect. I assume if I add an effect bundle to a faction it should show in the Faction screen on the Summary tab. Is that right? if so, it aint working .
    ~ Too soon old, too late smart ~

  3. #3
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: Does add_effect_bundle work in this game.

    Okay, still cant get things to work. I am starting to feel that add_effect_bundle doesnt work. Has anyone actually used this successfully????

    I should specify i am trying to add an effect bundle to a faction

    I have copied code from functional shogun 2 scripts and i am pretty sure my code is bug free. The only thing i havent tried is using cm: instead of scripting.game_interface
    Last edited by Col.KanKrusha; April 15, 2015 at 04:44 PM.
    ~ Too soon old, too late smart ~

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

    Default Re: Does add_effect_bundle work in this game.

    it is apply_effect_bundle instead of add_effect_bundle

    example:
    scripting.game_interface:apply_effect_bundle("effect_bunlde_name", "faction name", turn time (integer so no "" requiered)); it is also possible to make it work with a faction variable.

    example
    local faction = context:character():faction():name()
    scripting.game_interface:apply_effect_bundle("effect_bunlde_name", faction, -1)

  5. #5
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: Does add_effect_bundle work in this game.

    Thanks, I did use apply_effect_bundle in my script. That is the danger of posting on forums from work instead of getting on with my job!

    It's good to know that this should work (or at least someone else has made this work before)

    here is the actual script from main campaign scripting.lua


    Spoiler Alert, click show to read: 

    Code:
    function kk_onfinishbattle(context)
         local attackerculture = context:pending_battle():attacker():faction():culture()
         local defenderculture = context:pending_battle():defender():faction():culture()
    
    
        local attacking_faction = context:pending_battle():attacker():faction()
        local defending_faction = context:pending_battle():defender():faction()
        local attackingfaction = attacking_faction:name()
        local defendingfaction = defending_faction:name()
    
    
               -- set up tables if not present
            if not _G.kk_culturetable
                             then _G.kk_culturetable = {}
            end
    
    
    
    
            if  not _G.kk_culturetable[attackingfaction]  then
                             _G.kk_culturetable[attackingfaction] = {hellenic = 0, roman = 0, barbarian = 0, eastern = 0}
            end
    
    
            -- increment settlements taken counter
            if defenderculture == "rom_Hellenistic" then
                _G.kk_culturetable[attackingfaction]["hellenic"] = _G.kk_culturetable[attackingfaction]["hellenic"] + 1
                local remove_root = "hellenic_diplomacy_penalty_"
            -- create counter that removes all effect bundles by concantenating string except the desired one
                if _G.kk_culturetable[attackingfaction]["hellenic"] >= 1 and _G.kk_culturetable[attackingfaction]["hellenic"] < 3 then
                    local to_apply = "hellenic_diplomacy_penalty_1"
                elseif _G.kk_culturetable[attackingfaction]["hellenic"] >= 3 and _G.kk_culturetable[attackingfaction]["hellenic"]< 5 then
                    local to_apply = "hellenic_diplomacy_penalty_2"
                elseif _G.kk_culturetable[attackingfaction]["hellenic"] >= 5 and _G.kk_culturetable[attackingfaction]["hellenic"]< 10 then
                    local to_apply = "hellenic_diplomacy_penalty_3"
                elseif _G.kk_culturetable[attackingfaction]["hellenic"] >= 10 and _G.kk_culturetable[attackingfaction]["hellenic"]< 20 then
                    local to_apply = "hellenic_diplomacy_penalty_4"
                elseif     _G.kk_culturetable[attackingfaction]["hellenic"] >= 20 then
                    local to_apply = "hellenic_diplomacy_penalty_5"
                end
            end
    
    
            -- increment settlements taken counter
            if defenderculture == "rom_Roman" and not defendingfaction == "rom_slave" then
                _G.kk_culturetable[attackingfaction]["roman"] = _G.kk_culturetable[attackingfaction]["roman"] + 1
                local remove_root = "roman_diplomacy_penalty_"
            -- create counter that removes all effect bundles by concantenating string except the desired one
                if _G.kk_culturetable[attackingfaction]["roman"] >= 1 and _G.kk_culturetable[attackingfaction]["roman"] < 3 then
                    local to_apply = "roman_diplomacy_penalty_1"
                elseif _G.kk_culturetable[attackingfaction]["roman"] >= 3 and _G.kk_culturetable[attackingfaction]["roman"]< 5 then
                    local to_apply = "roman_diplomacy_penalty_2"
                elseif _G.kk_culturetable[attackingfaction]["roman"] >= 5 and _G.kk_culturetable[attackingfaction]["roman"]< 10 then
                    local to_apply = "roman_diplomacy_penalty_3"
                elseif _G.kk_culturetable[attackingfaction]["roman"] >= 10 and _G.kk_culturetable[attackingfaction]["roman"]< 20 then
                    local to_apply = "roman_diplomacy_penalty_4"
                elseif     _G.kk_culturetable[attackingfaction]["roman"] >= 20 then
                    local to_apply = "roman_diplomacy_penalty_5"
                end
            end
    
    
            if defenderculture == "rom_Barbarian"  then
            _G.kk_culturetable[attackingfaction]["barbarian"] = _G.kk_culturetable[attackingfaction]["barbarian"] + 1
                local remove_root = "barbarian_diplomacy_penalty_"
            -- create counter that removes all effect bundles by concantenating string except the desired one
                if _G.kk_culturetable[attackingfaction]["barbarian"] >= 1 and _G.kk_culturetable[attackingfaction]["barbarian"] < 3 then
                    local to_apply = "barbarian_diplomacy_penalty_1"
                elseif _G.kk_culturetable[attackingfaction]["barbarian"] >= 3 and _G.kk_culturetable[attackingfaction]["barbarian"]< 5 then
                    local to_apply = "barbarian_diplomacy_penalty_2"
                elseif _G.kk_culturetable[attackingfaction]["barbarian"] >= 5 and _G.kk_culturetable[attackingfaction]["barbarian"]< 10 then
                    local to_apply = "barbarian_diplomacy_penalty_3"
                elseif _G.kk_culturetable[attackingfaction]["barbarian"] >= 10 and _G.kk_culturetable[attackingfaction]["barbarian"]< 20 then
                    local to_apply = "barbarian_diplomacy_penalty_4"
                elseif     _G.kk_culturetable[attackingfaction]["barbarian"] >= 20 then
                    local to_apply = "barbarian_diplomacy_penalty_5"
                end
            end
    
    
            if defenderculture == "rom_Eastern" then
                _G.kk_culturetable[attackingfaction]["eastern"] = _G.kk_culturetable[attackingfaction]["eastern"] + 1
                local remove_root = "eastern_diplomacy_penalty_"
            -- create counter that removes all effect bundles by concantenating string except the desired one
                if _G.kk_culturetable[attackingfaction]["eastern"] >= 1 and _G.kk_culturetable[attackingfaction]["eastern"] < 3 then
                    local to_apply = "eastern_diplomacy_penalty_1"
                elseif _G.kk_culturetable[attackingfaction]["eastern"] >= 3 and _G.kk_culturetable[attackingfaction]["eastern"]< 5 then
                    local to_apply = "eastern_diplomacy_penalty_2"
                elseif _G.kk_culturetable[attackingfaction]["eastern"] >= 5 and _G.kk_culturetable[attackingfaction]["eastern"]< 10 then
                    local to_apply = "eastern_diplomacy_penalty_3"
                elseif _G.kk_culturetable[attackingfaction]["eastern"] >= 10 and _G.kk_culturetable[attackingfaction]["eastern"]< 20 then
                    local to_apply = "eastern_diplomacy_penalty_4"
                elseif     _G.kk_culturetable[attackingfaction]["eastern"] >= 20 then
                    local to_apply = "eastern_diplomacy_penalty_5"
                end
            end
    
    
        for counter = 1,5 do
    
    
            local to_remove = remove_root..counter
    
    
            if to_remove ~= to_apply then
                scripting.game_interface:remove_effect_bundle(to_remove, attackingfaction)
            end
        end
    
    
        scripting.game_interface:apply_effect_bundle(to_apply, attackingfaction, -1)
    
    
    end
    
    
    scripting.AddEventCallBack("PendingBattle", kk_onfinishbattle)
    ~ Too soon old, too late smart ~

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

    Default Re: Does add_effect_bundle work in this game.

    are you sure the command is firing at all ? The Syntax seems to be fine, but maybe add a logging function helping you to figure out what is happening before/after a battle. I really like your idea btw. and hope you can get this to work. Make sure that your effect bundles target a faction.

    Example of a basic log function we have used in DeI

    Spoiler Alert, click show to read: 
    PHP Code:
    function Log(textisTitleisNew)   
     if 
    not isLogAllowed then return end
        local logfile
    ;    text tostring(text);   
     if 
    isNew then      
      logfile 
    io.open("DeI_Saka_Reform_Log.txt","w");    
        
    local curr_date os.date("%A, %m %B %Y");     
       
    local text tostring("- Divide et Impera Saka Reform Log\n".."- "..curr_date);  
          
    logfile:write(text.."\n\n");   
     else    
        
    logfile io.open("DeI_Saka_Reform_Log.txt","a");     
       if 
    not logfile then logfile io.open("DeI_Saka_Reform_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 

  7. #7
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: Does add_effect_bundle work in this game.

    Thank you for looking at the code and thanks for the logging function. Hopefully I can try that out this weekend
    ~ Too soon old, too late smart ~

  8. #8
    Drakeb22's Avatar Civis
    Join Date
    Jan 2015
    Location
    Illinois
    Posts
    146

    Default Re: Does add_effect_bundle work in this game.

    I'm actually really interested in this is if works too so please post your findings cause I wouldn't mind using the command to do something along the lines of adding a bonus or two to factions when their AI controlled, or in this case, making rome or carthage stronger if their rival is human controlled.

  9. #9
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: Does add_effect_bundle work in this game.

    Yes, function not firing at all. Don't understand it. Lua is like a really bad girlfriend. Sometimes she'll do anything you want and then somedays she won't even talk to you.

    Drake, litharion is using this for a script in the DEI mod. Have a look at his work
    Last edited by Col.KanKrusha; May 02, 2015 at 09:35 PM.
    ~ Too soon old, too late smart ~

Posting Permissions

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