• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

cristofolmc

Banned
40 Badges
Mar 5, 2009
3.455
4.357
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Third Rome
  • Stellaris
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: El Dorado
  • 500k Club
  • Europa Universalis IV: Golden Century
  • Europa Universalis III
  • Europa Universalis III: Chronicles
  • Europa Universalis III Complete
  • Divine Wind
  • Heir to the Throne
  • Crusader Kings II
  • Rome Gold
  • Hearts of Iron IV Sign-up
  • Victoria 2
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Mandate of Heaven
  • Age of Wonders III
  • Europa Universalis IV: Cradle of Civilization
  • Imperator: Rome
  • Imperator: Rome Sign Up
  • Crusader Kings III
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Europa Universalis III Complete
  • Europa Universalis III Complete
  • Europa Universalis IV
  • Victoria 2: A House Divided
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Old Gods
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Wealth of Nations
  • Rome: Vae Victis
  • Victoria 2: Heart of Darkness
  • Europa Universalis IV: Art of War
This is the event. The aim of the event is to get a modifier in all the provinces that produce grain. Everywhere. All of them.

Code:
namespace = trade_goods_value

trade_goods_value.1 = { #grain
    type = country_event
    title = "trade_goods_value.1.t"
    desc = "trade_goods_value.1.desc"
    picture = hellenic_marketplace
    hidden = yes
    left_portrait = root.current_ruler
    right_portrait = scope:city_1_target.governor
 
    trigger = {
        any_owned_province = {
            controller = root
            trade_goods = grain
        }
    }
 
    immediate = {
        set_variable = {
            name = grain_toggle
         
        }
        every_owned_province = {
            limit = {
                controller = root
                trade_goods = grain
            }
            set_variable = {
                name = grain_toggle
            }
        }
    }
 
    option = {
        name = "trade_goods_value.1.a"
        if = {
            num_goods_produced = 1
        }
        add_permanent_province_modifier    = grain_commerce_value_1 
    }
}

Can somebody help me spot the error? Im struggling with I:R since I only learn to code events in EU4. :(

Thanks
 
You're not scoping to the provinces in the option; right now you are applying a province trigger and effect to the root (country) scope. You would need every_owned_province = { in the option.
 
You're not scoping to the provinces in the option; right now you are applying a province trigger and effect to the root (country) scope. You would need every_owned_province = { in the option.

Thanks for replying. How about now? I removed it from the option as it made not much sense, and just add it as an immidiate effect. But I dont know if Im applying the scope and variable correctly now.

Code:
namespace = trade_goods_value

trade_goods_value.1 = { #grain
    type = country_event
    title = "trade_goods_value.1.t"
    desc = "trade_goods_value.1.desc"
    picture = hellenic_marketplace
    hidden = yes
    left_portrait = root.current_ruler
    right_portrait = scope:city_1_target.governor
   
    trigger = {
        any_owned_province = {
            trade_goods = grain
        }
    }
   
    immediate = {
        set_variable = {
            name = grain_toggle
           
        }
        every_owned_province = {
            limit = {
                has_local_variable = grain_toggle
                controller = root
                trade_goods = grain
            }
            if = {
                num_goods_produced = 1
            }
            add_permanent_province_modifier = grain_commerce_value_1   
            else_if = {
                num_goods_produced = 1
            }
            add_permanent_province_modifier = grain_commerce_value_2
            else_if = {
                num_goods_produced = 3
            }
            add_permanent_province_modifier = grain_commerce_value_3
        }
    }
   
    option = {
        name = "trade_goods_value.1.a"   
    }
}
 
1) the commands need to be inside the if/else_if statements
2) the triggers in those statements also need limit = { } around them
3) a quick check of the vanilla event files shows them using that command differently than you do
So it would look like:

if = {
limit = { num_goods_produced = 1 }
add_permanent_province_modifier = { name = grain_commerce_value_1 }
}
and so on.
 
1) the commands need to be inside the if/else_if statements
2) the triggers in those statements also need limit = { } around them
3) a quick check of the vanilla event files shows them using that command differently than you do
So it would look like:

if = {
limit = { num_goods_produced = 1 }
add_permanent_province_modifier = { name = grain_commerce_value_1 }
}
and so on.

Okay, its working now, but for some reason its not getting triggered. I've had to do it mannually.

Code:
namespace = trade_goods_value

trade_goods_value.1 = { #grain
    type = country_event
    title = "trade_goods_value.1.t"
    desc = "trade_goods_value.1.desc"
    picture = hellenic_marketplace
    hidden = yes
    left_portrait = root.current_ruler
    right_portrait = scope:city_1_target.governor
   
    trigger = {
        any_owned_province = {
            trade_goods = grain
        }
    }
   
    immediate = {
        every_owned_province = {
            limit = {
                trade_goods = grain
            }
            if = {
                limit = {
                    num_goods_produced = 1
                }
                add_permanent_province_modifier = {
                    name = grain_commerce_value_1
                }
            }   
            else_if = {
                limit = {
                    num_goods_produced = 2
                }
                add_permanent_province_modifier = {
                    name = grain_commerce_value_2
                }
            }
            else_if = {
                limit = {
                    num_goods_produced = 2
                }
                add_permanent_province_modifier = {
                    name = grain_commerce_value_3
                }
            } 
        }
    }
   
    option = {
        name = "trade_goods_value.1.a"   
    }
}

How do I make it so it gets automatically triggered at the start? There doesnt seem to be MTTH in this game.
 
There’s no MTTH in this game; everything is run by on_actions. So it needs to be added to the monthly country or yearly country lists or whatever.