Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vic3] Complex scripted_effect to define a scope leads to false positive #167

Open
kaiser-chris opened this issue Feb 1, 2025 · 1 comment

Comments

@kaiser-chris
Copy link
Contributor

Hi @amtep,

this may be a tricky one.

A scope I have defined in a scripted_effect is detected as missing even though it works.
I suspect the complexity of the scripted_effect is the reason but I don't know for sure.

Setup

This is an example Event where the scope is detected as missing:

mbudye.14 = {
	type = country_event
	dlc = dlc_magic_gate
	placement = scope:mbudye_event_state

	immediate = {
		scope_random_lunda_subject = yes
	}

	title = mbudye.14.t
	desc = mbudye.14.desc
	flavor = mbudye.14.f

	event_image = {
		video = "africa_animism"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"

	icon = "gfx/interface/icons/religion_icons/golden_faith.dds"

	duration = 3

	option = {
		name = mbudye.14.a
		default_option = yes
		add_loyalists = {
			value = medium_radicals
		}
		add_conversion_progress = {
			country = scope:mbudye_event_country
			conversion_progress = 10
			support_change = 5
		}
		ai_chance = {
			base = 10
			modifier = {
				trigger = {
					check_mbudye_support = {
						support_change = 5
					}
				}
				add = 90
			}
		}
	}
}

Scripted Effect where the scope is set (is called in the immediate block of the Event):

scope_random_lunda_subject = {
	save_scope_as = gate_mbudye_dominion
	random_subject_or_below = {
		limit = {
			OR = {
				this = c:LND
				this = c:CHK
				this = c:KZM
				this = c:KSN
			}
			is_subject_of = c:GAD
		}
		if = {
			limit = {
				this = c:LND
				c:GAD = {
					je:je_gate_mbudye = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_lunda
							value < 100
						}
					}
				}
			}
			save_scope_as = mbudye_event_country
		}
		else_if = {
			limit = {
				this = c:CHK
				c:GAD = {
					je:je_gate_mbudye = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_chokwe
							value < 100
						}
					}
				}
			}
			save_scope_as = mbudye_event_country
		}
		else_if = {
			limit = {
				this = c:KZM
				c:GAD = {
					je:je_gate_mbudye = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_kazembe
							value < 100
						}
					}
				}
			}
			save_scope_as = mbudye_event_country
		}
		else_if = {
			limit = {
				this = c:KSN
				c:GAD = {
					je:je_gate_mbudye = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_kasanje
							value < 100
						}
					}
				}
			}
			save_scope_as = mbudye_event_country
		}
		else = {
			c:LND = {
				save_scope_as = mbudye_event_country
			}
		}
	}
	scope:mbudye_event_country = {
		random_scope_state = {
			save_scope_as = mbudye_event_state
		}
	}
}

At last the Journal Entry, but it should not matter since it only triggers the events:

je_gate_mbudye = {
	icon = "gfx/interface/icons/religion_icons/golden_faith.dds"

	group = je_group_internal_affairs

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = je_gate_mbudye_active_investigation
				trigger = {
					has_variable = mbudye_investigation
				}
			}
			triggered_desc = {
				desc = je_gate_mbudye_active_resistance
				trigger = {
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye
							value <= 20
						}
					}
				}
			}
			triggered_desc = {
				desc = je_gate_mbudye_passive_resistance
				trigger = {
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye
							value <= 40
						}
					}
				}
			}
			triggered_desc = {
				desc = je_gate_mbudye_ambivalent
				trigger = {
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye
							value <= 60
						}
					}
				}
			}
			triggered_desc = {
				desc = je_gate_mbudye_engaging
				trigger = {
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye
							value <= 80
						}
					}
				}
			}
			triggered_desc = {
				desc = je_gate_mbudye_accepting
			}
		}
	}

	immediate = {
		save_scope_as = gate_mbudye_dominion
		c:LND = {
			save_scope_as = gate_mbudye_lunda
		}
		c:CHK = {
			save_scope_as = gate_mbudye_chokwe
		}
		c:KZM = {
			save_scope_as = gate_mbudye_kazembe
		}
		c:KSN = {
			save_scope_as = gate_mbudye_kasanje
		}
		set_variable = {
			name = mbudye_conversion_type
			value = mbudye_conversion_balanced
		}
	}

	on_monthly_pulse = {
		random_events = {
			chance_of_no_event = 95
			2 = mbudye.3
			2 = mbudye.10
			2 = mbudye.11
			2 = mbudye.12
			1 = mbudye.13
			1 = mbudye.14
			1 = mbudye.16
		}
	}

	on_yearly_pulse = {
		random_events = {
			chance_of_no_event = 50
			1 = mbudye.4
			1 = mbudye.7
			1 = mbudye.8
			1 = mbudye.9
		}
	}

	complete = {
		custom_tooltip = {
			text = je_gate_mbudye_complete
			AND = {
				scope:journal_entry = {
					scripted_bar_progress = {
						name = pb_gate_mbudye
						value < 100
					}
				}
				OR = {
					c:LND = {
						NOT = {
							is_subject_of = c:GAD
						}
					}
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_lunda
							value >= 100
						}
					}
				}
				OR = {
					c:CHK = {
						NOT = {
							is_subject_of = c:GAD
						}
					}
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_chokwe
							value >= 100
						}
					}
				}
				OR = {
					c:KZM = {
						NOT = {
							is_subject_of = c:GAD
						}
					}
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_kazembe
							value >= 100
						}
					}
				}
				OR = {
					c:KSN = {
						NOT = {
							is_subject_of = c:GAD
						}
					}
					scope:journal_entry = {
						scripted_bar_progress = {
							name = pb_gate_mbudye_kasanje
							value >= 100
						}
					}
				}
			}
		}
	}

	fail = {
		custom_tooltip = {
			text = je_gate_mbudye_fail_support
			scope:journal_entry = {
				scripted_bar_progress = {
					name = pb_gate_mbudye
					value <= 0
				}
			}
		}
		custom_tooltip = {
			text = je_gate_mbudye_fail_annex
			has_global_variable = mbudye_unification
		}
	}

	on_complete = {
		hidden_effect = {
			trigger_event = {
				id = mbudye.1
				popup = yes
			}
		}
	}

	on_fail = {
		hidden_effect = {
			trigger_event = {
				id = mbudye.2
				popup = yes
			}
		}
	}

	scripted_button = je_gate_mbudye_button_aggressive
	scripted_button = je_gate_mbudye_button_balanced
	scripted_button = je_gate_mbudye_button_passive

	progressbar = no
	scripted_progress_bar = pb_gate_mbudye
	scripted_progress_bar = pb_gate_mbudye_lunda
	scripted_progress_bar = pb_gate_mbudye_chokwe
	scripted_progress_bar = pb_gate_mbudye_kazembe
	scripted_progress_bar = pb_gate_mbudye_kasanje

	transferable = no
	can_revolution_inherit = yes

	weight = 200
	should_be_pinned_by_default = yes
}

Error

warning(strict-scopes): `add_conversion_progress` expects scope:mbudye_event_country to be set
    --> [MOD] events\gate_events\mbudye_events.txt
1481 |         add_conversion_progress = {
     |         ^^^^^^^^^^^^^^^^^^^^^^^
    --> [MOD] common\scripted_effects\409_mbudye.txt
  11 |         $country$ = {
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- here
    --> [MOD] events\gate_events\mbudye_events.txt
1482 |             country = scope:mbudye_event_country
     |                       ^ <-- from here
    --> [MOD] common\journal_entries\406_mbudye.txt
  93 |             1 = mbudye.16
     |                 ^^^^^^^^^ <-- triggered from here
   1 | je_gate_mbudye = {
     | ^^^^^^^^^^^^^^ <-- scopes initialized here

Full Repo

This is my mod Repo for reference if you want to look deeper into this or test it directly:
https://github.com/kaiser-chris/gate-mod

Regards,

Chris

@amtep
Copy link
Owner

amtep commented Feb 9, 2025

I looked into it and I think you're looking at the wrong event :)

The warning is about mbudye.16, which as far as I can tell does not set those scopes in its immediate block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants