Results 1 to 2 of 2

Thread: How to implement a battle loot system in a simple way

  1. #1

    Icon14 How to implement a battle loot system in a simple way

    The most important thing that distinguishes Total War from other strategy games are its battles. In this tutorial, we are going to make the connection between campaign and battles stronger by implementing a battle loot system.

    + If the player loses a battle, he shall lose a random amount of money, the more clearer the defeat, the more money the player should lose
    + If the player wins a battle, he shall gain a random amount of money, the more clearer the victory, the more money the player should gain

    What I like about this is that as a player you get an option to improve your factions finances if you have decent armies. You kind of get an incentive to be more aggressive on the campaign map because you can gain an financial advantage from that. And it gets even better - as a player, you get a higher tension not to lose a battle since you know that you will get punished for a defeat by losing money.

    This script is very easy and you do not need any "normal" programming language to achieve it, although it gets much easier to code if you do (example see bottom of this tutorial) and it gets even far more easier if you use my Atlas mod build tool.

    Here is the campaign script snippet:

    Code:
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = crushing
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 1
            console_command add_money 100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 23AA5CDA40B443CE249891DAB6E7AB1561612188_TITLE
            body 23AA5CDA40B443CE249891DAB6E7AB1561612188_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 2
            console_command add_money 200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_TITLE
            body 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 3
            console_command add_money 300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_TITLE
            body 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 4
            console_command add_money 400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3E3146EA7001973BB6628BB1908D2C123654ACB8_TITLE
            body 3E3146EA7001973BB6628BB1908D2C123654ACB8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 5
            console_command add_money 500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title EB10C0C79D9F5B415FA3413C699B3240862AE61F_TITLE
            body EB10C0C79D9F5B415FA3413C699B3240862AE61F_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 6
            console_command add_money 600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title EBA77509E012C3DB80CFE01B42438F53CFBBC14F_TITLE
            body EBA77509E012C3DB80CFE01B42438F53CFBBC14F_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 7
            console_command add_money 700
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 0B33E6C26C5F4229F0811CC7BC69FDBF59D982B8_TITLE
            body 0B33E6C26C5F4229F0811CC7BC69FDBF59D982B8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 8
            console_command add_money 800
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title FF3BA9DCF0C479A63F52905088D0A758066CFEA0_TITLE
            body FF3BA9DCF0C479A63F52905088D0A758066CFEA0_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 9
            console_command add_money 900
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title B1F283EFD2DE886828DDE3B57E0ABD6978D91818_TITLE
            body B1F283EFD2DE886828DDE3B57E0ABD6978D91818_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 10
            console_command add_money 1000
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title A85F9D204BE4FF46D9A88A00428CC709C92B3C0C_TITLE
            body A85F9D204BE4FF46D9A88A00428CC709C92B3C0C_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootPlus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = clear
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 1
            console_command add_money 100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 23AA5CDA40B443CE249891DAB6E7AB1561612188_TITLE
            body 23AA5CDA40B443CE249891DAB6E7AB1561612188_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 2
            console_command add_money 200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_TITLE
            body 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 3
            console_command add_money 300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_TITLE
            body 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 4
            console_command add_money 400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3E3146EA7001973BB6628BB1908D2C123654ACB8_TITLE
            body 3E3146EA7001973BB6628BB1908D2C123654ACB8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 5
            console_command add_money 500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title EB10C0C79D9F5B415FA3413C699B3240862AE61F_TITLE
            body EB10C0C79D9F5B415FA3413C699B3240862AE61F_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 6
            console_command add_money 600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title EBA77509E012C3DB80CFE01B42438F53CFBBC14F_TITLE
            body EBA77509E012C3DB80CFE01B42438F53CFBBC14F_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 7
            console_command add_money 700
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 0B33E6C26C5F4229F0811CC7BC69FDBF59D982B8_TITLE
            body 0B33E6C26C5F4229F0811CC7BC69FDBF59D982B8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 8
            console_command add_money 800
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title FF3BA9DCF0C479A63F52905088D0A758066CFEA0_TITLE
            body FF3BA9DCF0C479A63F52905088D0A758066CFEA0_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootPlus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = average
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 1
            console_command add_money 100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 23AA5CDA40B443CE249891DAB6E7AB1561612188_TITLE
            body 23AA5CDA40B443CE249891DAB6E7AB1561612188_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 2
            console_command add_money 200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_TITLE
            body 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 3
            console_command add_money 300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_TITLE
            body 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 4
            console_command add_money 400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3E3146EA7001973BB6628BB1908D2C123654ACB8_TITLE
            body 3E3146EA7001973BB6628BB1908D2C123654ACB8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 5
            console_command add_money 500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title EB10C0C79D9F5B415FA3413C699B3240862AE61F_TITLE
            body EB10C0C79D9F5B415FA3413C699B3240862AE61F_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 6
            console_command add_money 600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title EBA77509E012C3DB80CFE01B42438F53CFBBC14F_TITLE
            body EBA77509E012C3DB80CFE01B42438F53CFBBC14F_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootPlus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = close
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 1
            console_command add_money 100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 23AA5CDA40B443CE249891DAB6E7AB1561612188_TITLE
            body 23AA5CDA40B443CE249891DAB6E7AB1561612188_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 2
            console_command add_money 200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_TITLE
            body 6B4151F71E5E2D3DC6A236100F190E8A81DD1BDF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 3
            console_command add_money 300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_TITLE
            body 1DD92C2CCA3BDB2F74F312879F569A180ED68B52_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootPlus = 4
            console_command add_money 400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3E3146EA7001973BB6628BB1908D2C123654ACB8_TITLE
            body 3E3146EA7001973BB6628BB1908D2C123654ACB8_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootPlus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = crushing
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 1
            console_command add_money -100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 12254C81214EFF91E06A3C0F56FE4E969438FBC2_TITLE
            body 12254C81214EFF91E06A3C0F56FE4E969438FBC2_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 2
            console_command add_money -200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_TITLE
            body 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 3
            console_command add_money -300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_TITLE
            body 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 4
            console_command add_money -400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 4F74BF8459712226E0457F214CC1AA5E106F9AE4_TITLE
            body 4F74BF8459712226E0457F214CC1AA5E106F9AE4_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 5
            console_command add_money -500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_TITLE
            body 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 6
            console_command add_money -600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 7799888D4489F735469A104CB9BB631D6F337C39_TITLE
            body 7799888D4489F735469A104CB9BB631D6F337C39_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 7
            console_command add_money -700
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 53685957B7EA068022518B5395792AF1A4EB70DE_TITLE
            body 53685957B7EA068022518B5395792AF1A4EB70DE_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 8
            console_command add_money -800
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 9354B96BE0DC1772848771922229F9455B8ADB9D_TITLE
            body 9354B96BE0DC1772848771922229F9455B8ADB9D_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 9
            console_command add_money -900
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_TITLE
            body BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 10
            console_command add_money -1000
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 2F365E60ADCD06B90AAAFD23D477FFC767462001_TITLE
            body 2F365E60ADCD06B90AAAFD23D477FFC767462001_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootMinus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = clear
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 1
            console_command add_money -100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 12254C81214EFF91E06A3C0F56FE4E969438FBC2_TITLE
            body 12254C81214EFF91E06A3C0F56FE4E969438FBC2_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 2
            console_command add_money -200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_TITLE
            body 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 3
            console_command add_money -300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_TITLE
            body 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 4
            console_command add_money -400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 4F74BF8459712226E0457F214CC1AA5E106F9AE4_TITLE
            body 4F74BF8459712226E0457F214CC1AA5E106F9AE4_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 5
            console_command add_money -500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_TITLE
            body 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 6
            console_command add_money -600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 7799888D4489F735469A104CB9BB631D6F337C39_TITLE
            body 7799888D4489F735469A104CB9BB631D6F337C39_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 7
            console_command add_money -700
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 53685957B7EA068022518B5395792AF1A4EB70DE_TITLE
            body 53685957B7EA068022518B5395792AF1A4EB70DE_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 8
            console_command add_money -800
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 9354B96BE0DC1772848771922229F9455B8ADB9D_TITLE
            body 9354B96BE0DC1772848771922229F9455B8ADB9D_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 9
            console_command add_money -900
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_TITLE
            body BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 10
            console_command add_money -1000
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 2F365E60ADCD06B90AAAFD23D477FFC767462001_TITLE
            body 2F365E60ADCD06B90AAAFD23D477FFC767462001_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootMinus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = average
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 1
            console_command add_money -100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 12254C81214EFF91E06A3C0F56FE4E969438FBC2_TITLE
            body 12254C81214EFF91E06A3C0F56FE4E969438FBC2_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 2
            console_command add_money -200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_TITLE
            body 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 3
            console_command add_money -300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_TITLE
            body 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 4
            console_command add_money -400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 4F74BF8459712226E0457F214CC1AA5E106F9AE4_TITLE
            body 4F74BF8459712226E0457F214CC1AA5E106F9AE4_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 5
            console_command add_money -500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_TITLE
            body 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 6
            console_command add_money -600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 7799888D4489F735469A104CB9BB631D6F337C39_TITLE
            body 7799888D4489F735469A104CB9BB631D6F337C39_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 7
            console_command add_money -700
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 53685957B7EA068022518B5395792AF1A4EB70DE_TITLE
            body 53685957B7EA068022518B5395792AF1A4EB70DE_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 8
            console_command add_money -800
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 9354B96BE0DC1772848771922229F9455B8ADB9D_TITLE
            body 9354B96BE0DC1772848771922229F9455B8ADB9D_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 9
            console_command add_money -900
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_TITLE
            body BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 10
            console_command add_money -1000
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 2F365E60ADCD06B90AAAFD23D477FFC767462001_TITLE
            body 2F365E60ADCD06B90AAAFD23D477FFC767462001_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootMinus 0
    end_monitor
    
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = close
    and not I_ConflictType Naval
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if RandomPercent < 25
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 1
            console_command add_money -100
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 12254C81214EFF91E06A3C0F56FE4E969438FBC2_TITLE
            body 12254C81214EFF91E06A3C0F56FE4E969438FBC2_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 2
            console_command add_money -200
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_TITLE
            body 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 3
            console_command add_money -300
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_TITLE
            body 3EA9397AF0E49E5E7E690887CA85422B9BAFF8AF_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 4
            console_command add_money -400
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 4F74BF8459712226E0457F214CC1AA5E106F9AE4_TITLE
            body 4F74BF8459712226E0457F214CC1AA5E106F9AE4_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 5
            console_command add_money -500
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_TITLE
            body 6C12A89C337BAEEB17E865CF045DB6E76750C7A7_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 6
            console_command add_money -600
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 7799888D4489F735469A104CB9BB631D6F337C39_TITLE
            body 7799888D4489F735469A104CB9BB631D6F337C39_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 7
            console_command add_money -700
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 53685957B7EA068022518B5395792AF1A4EB70DE_TITLE
            body 53685957B7EA068022518B5395792AF1A4EB70DE_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 8
            console_command add_money -800
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 9354B96BE0DC1772848771922229F9455B8ADB9D_TITLE
            body 9354B96BE0DC1772848771922229F9455B8ADB9D_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 9
            console_command add_money -900
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_TITLE
            body BC72DB60CCC36C2499E2B9D0AA036AF4D47165D8_BODY
            image script_prompt
            }
        
        end_if
    
    
        if I_CompareCounter BattleLootMinus = 10
            console_command add_money -1000
            
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 2F365E60ADCD06B90AAAFD23D477FFC767462001_TITLE
            body 2F365E60ADCD06B90AAAFD23D477FFC767462001_BODY
            image script_prompt
            }
        
        end_if
    set_counter BattleLootMinus 0
    end_monitor
    Be aware that you need to add the *_BODY and *_TITLE string to text/expanded_bi.txt

    Code:
    ...{12254C81214EFF91E06A3C0F56FE4E969438FBC2_TITLE}Lost 100 denarii in battle
    {12254C81214EFF91E06A3C0F56FE4E969438FBC2_BODY}Not only did we lose our men to our enemies, we also were looted off of our valuable stuff.
    ...
    You could of course use more meaningful IDs instead of these hashes (I get them automatically generated by my build tool Atlas).

    Also, if you want a higher loot to be more probable, you have to raise the RandomPercent from 25 to a higher value. I recommend staying in the range of 20-30.

    And this is how it looks in practice:

    Here, the Arverni general Butilinus Zyraxes achieved a clear victory against an army of the Aedui (who retreated to the aedui border south of Alesia) - we looted 700 denarii in that battle:



    If you use Atlas for modding or you can work with a programming language like Python paired with templating engine like Pythons Quik, the code if of course much easier to write and maintain because we can use for-loops here:

    Code:
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = crushing
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if I_CompareCounter BattleLootPlus = @i
            console_command add_money @{i}00
            @Scripter.MessageInfo("@{i}00 denarii looted in battle", "Not only did we defeat our enemies, we also were able to loot their valuable stuff.", "building_captured_battle")
        end_if
    #end
    set_counter BattleLootPlus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = clear
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8"]:
        if I_CompareCounter BattleLootPlus = @i
            console_command add_money @{i}00
            @Scripter.MessageInfo("@{i}00 denarii looted in battle", "Not only did we defeat our enemies, we also were able to loot their valuable stuff.", "building_captured_battle")
        end_if
    #end
    set_counter BattleLootPlus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = average
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6"]:
        if I_CompareCounter BattleLootPlus = @i
            console_command add_money @{i}00
            @Scripter.MessageInfo("@{i}00 denarii looted in battle", "Not only did we defeat our enemies, we also were able to loot their valuable stuff.", "building_captured_battle")
        end_if
    #end
    set_counter BattleLootPlus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and WonBattle
    and BattleSuccess = close
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootPlus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4"]:
        if I_CompareCounter BattleLootPlus = @i
            console_command add_money @{i}00
            @Scripter.MessageInfo("@{i}00 denarii looted in battle", "Not only did we defeat our enemies, we also were able to loot their valuable stuff.", "building_captured_battle")
        end_if
    #end
    set_counter BattleLootPlus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = crushing
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if I_CompareCounter BattleLootMinus = @i
            console_command add_money -@{i}00
            @Scripter.MessageInfo("Lost @{i}00 denarii in battle", "Not only did we lose our men to our enemies, we also were looted off of our valuable stuff.", "building_lost_battle")
        end_if
    #end
    set_counter BattleLootMinus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = clear
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if I_CompareCounter BattleLootMinus = @i
            console_command add_money -@{i}00
            @Scripter.MessageInfo("Lost @{i}00 denarii in battle", "Not only did we lose our men to our enemies, we also were looted off of our valuable stuff.", "building_lost_battle")
        end_if
    #end
    set_counter BattleLootMinus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = average
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if I_CompareCounter BattleLootMinus = @i
            console_command add_money -@{i}00
            @Scripter.MessageInfo("Lost @{i}00 denarii in battle", "Not only did we lose our men to our enemies, we also were looted off of our valuable stuff.", "building_lost_battle")
        end_if
    #end
    set_counter BattleLootMinus 0
    end_monitor
    
    monitor_event PostBattle TrueCondition
    and FactionIsLocal
    and not WonBattle
    and BattleSuccess = close
    and not I_ConflictType Naval
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if RandomPercent < @Get.Setting("BattleLootProbability")
            inc_counter BattleLootMinus 1
            console_command reseed_random
        end_if
    #end
    #for @i in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:
        if I_CompareCounter BattleLootMinus = @i
            console_command add_money -@{i}00
            @Scripter.MessageInfo("Lost @{i}00 denarii in battle", "Not only did we lose our men to our enemies, we also were looted off of our valuable stuff.", "building_lost_battle")
        end_if
    #end
    set_counter BattleLootMinus 0
    end_monitor
    A little caveat with this solution if you dont use Atlas build tool: instead of @Scripter.MessageInfo() you have to write the fully translated game script code:

    Code:
        message_prompt
            {
            flag_counter dummy_f
            result_counter dummy_r
            title 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_TITLE
            body 3814C0A97931BC2A863B2C6EF8EC49DE663ED594_BODY
            image script_prompt
            }
    Last edited by Ocyalos; January 30, 2022 at 01:53 AM.
    CPU: AMD Ryzen 5 5600X 4,6 Ghz AM4 | GPU: 2x NVIDIA GeForce RTX 3060Ti Gainward Ghost OC 8GB GDRR6 | RAM: Corsair Vengeance RGB PRO DDR4 3600 Mhz C18 16 GB | SSD: PNY XLR8 CS3030 4TB M.2 NVMe 3 GB/s | PSU: be quiet! Straight Power 11 Platinum 550 Watt | MB: Asus ROG Strix B550-F Gaming WiFi | Case: be quiet! Silent Base 801 Silver


    Long: New York Stock Exchange: MO, XOM, AAL, AMZN, FB, MSFT, GOOGL, AMD, CRM | Wiener Börse: POST, BG, ADKO, UBS | London Stock Exchange: BP, BATS | Hong Kong Stock Exchange: 3988, 601318 | Euronext Paris: ORA, FP | Bolsa de Madrid: ELE | Coinbase: BTC
    Short: -

  2. #2

    Default Re: How to implement a battle loot system in a simple way

    Thank you that looks usefull

Tags for this Thread

Posting Permissions

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