Scopes

From Victoria 3 Wiki
Jump to navigation Jump to search

Scope is where exactly the effect or trigger happens. When coding game logic, you may want to filter game data structures (countries, states, pops, buildings, etc) within a certain universe. For example the pops of a certain country, or the buildings within a state. For that we scope the selection within the universe we want.

Scope is the exact instance of that exact object, if you want to figure out what can filter scope, see Event targets, to see the types of scopes, see #Types of scopes.

Further introduce[edit | edit source]

Just like other paradox games, ROOT,PREV,THIS,FROM is the basic scope.

For a specific scope, it starts with certain letter(s), such as s,c,var,law_type followed by : ending with certain tag name to call the scope, e.g, s:STATE_MINNESOTA calls a state_region scope named STATE_MINNESOTA.

Scopes can be linked by event targets, they are a series of functions to link from input scopes to output scopes.

s is an event target, also it requires data, therefore it must be followed by : then a certain name to call the scope. Due to s being a global link event target, it can be used independently. region_state is not a global link so it should be follow by . after a state_region scope.

Using . you can quickly link scopes. The most common example is s:STATE_MINNESOTA.region_state:USA, firstly is state_region scope then with . it links to state. Next we can add one more ., just like s:STATE_MINNESOTA.region_state:USA.var:usa_state_flag_block

However, some scopes cannot be quickly switch, if the parent scope is uncertain. diplomatic_play usually is an uncertain scope, so Event targets should be considered

random_diplomatic_play = { 
    # random/every are used in effects
    # any is used in triggers
    # random,every and any are all uncertain, cannot use . to link next scope
    limit = {
        is_war = yes
    }
    initiator = { change_infamy = 5 } # initiator is event target of diplomatic_play, it outputs a country
}

Below a detailed example of scope usage:

example_event.1 = {
	type = country_event # It means that, root is the country which happend the event, instead of state.
    random_diplomatic_play = {
        limit = {
            is_war = yes
            any_scope_play_involved = {
                THIS = ROOT # THIS is the current scope, in this line THIS is any_scope_play_involved
            }
            NOR = { # not or 
                initiator = ROOT # initiator and target is the event target of diplomatic_play
                target = ROOT
            }
        }
        initiator = { # this scope can only be used in diplomatic scope
            save_scope_as = initiator_scope # therefore, it should be saved to be handled in other scopes
        }
        target = {
            save_scope_as =  target_scope
        }
        if = { limit = { ROOT = { is_diplomatic_play_enemy_of = scope:initiator_scope } } # to judge on ROOT scope
            if = { limit = { scope:initiator_scope = { infamy >= infamy_threshold:infamous } } # now we handdle saved scope in other scope
                ROOT = { change_infamy = 5 }
            }
            ROOT = {
                set_owes_obligation_to = {
                    country = scope:target_scope
                    setting = yes
                }
            }
            remove_target_backers = { ROOT } # remove_target_backers can only effects on diplomatic_play scope.
            # however, this effect just can display, it do not really make ROOT exit the war, it is frustrating.
        }
    }
 }


Country scope[edit | edit source]

Scoping to a country you use the letter "c", for example:

 c:SIA = {
     add_treasury = 100 # example of game logic
 }

A list of all the vanilla countries is available here, and is useful to easily find the tag you need.

Country triggers[edit | edit source]

WIP

State scope[edit | edit source]

First of all, let me clear up the difference between a "state region" and a mere "state".

Given the example of the country Spain, it has the single "state region" "STATE_GRANADA". "STATE_GRANADA" is split between Spain and Great Britain, the state region of "STATE_GRANADA" has been split in two in what is called a "split state". Great Britain has a state named "British STATE_GRANADA" and Spain would have a state named "Spanish STATE_GRANADA". The base and whole "state region" STATE_GRANADA would be composed by the two split states of "British STATE_GRANADA" and "Spanish STATE_GRANADA". The name of the partial will be determined by the amount of provinces, Spain has most of "STATE_GRANADA", therefore, "Spanish STATE_GRANADA" will be named as "STATE_GRANADA".

This is a concept important to understand as you need to properly instruct the game if what you want is, for example:

  1. the WHOLE state region geographical is "state region"
  2. A country to own a state of that state region is "state", whether the country own whole the state region or not.

Scoping to a state, you use the letter "s", for example:

 s:STATE_AMAZONAS = {
     add_homeland = brazilian 
 }
 s:STATE_AMAZONAS.region_state:BRZ = {
     set_state_type = incorporated 
 }

A list of all the vanilla state regions is available here, and is useful to easily find the tag you need.

To learn how to change state traits you may wanna check out the workshop mod "More State Modifiers".

State triggers[edit | edit source]

WIP

Building scope[edit | edit source]

Although technically there is a building scope, in practice, game logic that involves buildings is done indirectly through the state scope. Here's an example I use in one of my mods. Check if a specific country, in a specific state region it owns, has a specific building in level 2.

 c:SIA = {
 	any_scope_state = {
 		state_region = s:STATE_NORTH_BORNEO
 		any_scope_building = {
 			is_building_type = building_sulfur_mine
 			level >= 2					
 		}
 	}
 }

The letter to scope buildings is "b". However it's uses are very limited and is mostly used for basic world building.

 if = {
 	limit = {
 		exists = state.b:building_sulfur_mine
 	}
 	add = state.b:building_sulfur_mine.level
 }


Building triggers[edit | edit source]

  • is_building_type = building_sulfur_mine
  • level >= 2

Culture scope[edit | edit source]

Culture scope seems to work in a similar fashion to buildings scope, indirectly referenced. However has more use cases.

Scoping to a culture you use the letters "cu", for example:

 state_region = {
 	is_homeland = cu:greek
 }


Culture triggers[edit | edit source]

  • is_homeland = cu:greek

Interest Group scope[edit | edit source]

Scoping to an interest group you use the letters "ig", for example:

ig:ig_landowners = {
	remove_ideology = ideology_paternalistic # example of game logic
	add_ideology = ideology_republican_paternalistic
}


The different interest groups tags are:

Pretty name Tag name
Armed Forces ig_armed_forces
Devout ig_devout
Industrialists ig_industrialists
Intelligentsia ig_intelligentsia
Landowners ig_landowners
Petite bourgeoisie ig_petty_bourgeoisie
Rural Folk ig_rural_folk
Trade unions ig_trade_unions

IG triggers[edit | edit source]

  • is_in_government = yes

Market Good scope[edit | edit source]

Scoping to a market good you use the letters "mg", for example:

 mg:tools = { 
     save_scope_as = cool_tools # game logics
 }

MG triggers[edit | edit source]

  • market = { mg:tools = { market_goods_delta >= 10 } }

Types of scopes[edit | edit source]

  • none
  • value
  • bool
  • flag
  • country
  • technology
  • technology_status
  • culture
  • state
  • province
  • pop
  • pop_type
  • building
  • building_type
  • interest_group
  • market
  • market_goods
  • interest_marker
  • strategic_region
  • diplomatic_action
  • diplomatic_pact
  • diplomatic_play
  • diplomatic_relations
  • character
  • state_region
  • war
  • theater
  • religion
  • institution
  • institution_type
  • law
  • law_type
  • journalentry
  • trade_route
  • decree
  • commander_order
  • commander_order_type
  • front
  • battle
  • interest_group_trait
  • ideology
  • goods
  • canal_type
  • country_definition
  • civil_war
  • state_trait
  • country_creation
  • country_formation
  • hq
  • objective
  • battle_side
  • political_movement
  • combat_unit
  • party
  • shipping_lane