群星
ParaWikis
最新百科
都市天际线2百科
英雄无敌3百科
维多利亚3百科
奇妙探险队2百科
罪恶帝国百科
英白拉多:罗马百科
热门百科
群星百科
欧陆风云4百科
十字军之王2百科
十字军之王3百科
钢铁雄心4百科
维多利亚2百科
ParaWikis
申请建站
ParaWikis
ParaCommons
最近更改
随机页面
加入QQ群
工具
链入页面
相关更改
特殊页面
页面信息
页面值
阅读
编辑
编辑源代码
查看历史
讨论
编辑“
动态模组创作
”
自由之民
(
讨论
|
贡献
)
2022年3月8日 (二) 01:50的版本
(文本替换 - 替换“Category:Modding]]”为“Category:模组制作]]”)
(
差异
)
←上一版本
|
最后版本
(
差异
) |
下一版本→
(
差异
)
警告:您正在编辑的是本页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
{{Version|3.0}} This page is about the abstract but super flexible modding features, namely [[effects]] and [[conditions]] as well as scripted localization and scripted variables. == Effects == Effects are statements to be executed and affect game status. Many game objects and [[event modding]] use this for dynamic effects. Head to effects for full list of effect statements. Effects must be executed under a [[scope]]. Head to scopes for details. === Scripted effects === There are more than singular statements of effects to be used for an effect. Scripted effects are moddable blocks of effect statements to be used as an effect. They are defined at "common/scripted_effects/xxx.txt". ==== How to use ==== A scripted effect consists a block of [[Effects|effect statements]] and/or other scripted effects. That's it. example_scripted_effect = { shift_ethic = ethic_materialist … } Defined scripted effects can be used as though they were effects. For instance, "example_scripted_effect" can be called with <code>example_scripted_effect = yes</code>. ==== Parameters ==== Scripted effects can have parameters. All parameters are strings and will be dynamically inserted into the scripted effects. For example, a scripted effect can be like this, so the empire will have their ethic shifted to materialist: # definition example_scripted_effect = { shift_ethic = ethic_$ETHIC$ } # calling example_scripted_effect = { ETHIC = materialist } Or even like this, so the empire will have their ethic shifted to materialist twice: # definition example_scripted_effect = { while = { count = $COUNT$ shift_ethic = ethic_$ETHIC$ } } # calling example_scripted_effect = { ETHIC = materialist COUNT = 2 } ==== Parameter conditions ==== You can also write a condition block for parameters with "double" square brackets, making the stuff within it only called if the parameter (here $homeworld$) is passed through in the effect call. <pre>[[homeworld] <<<STUFF HERE>>>]</pre> Example: <pre> last_created_species = { save_global_event_target_as = vaadwaurSpecies [[homeworld]set_species_homeworld = event_target:tempHomeworld] } </pre> You can also declare a fallback value in the parameter itself using the pipe symbol, e.g.: <pre> has_global_flag = crisis_stage_$STAGE|1$</pre> The vanilla game ([[2.6|2.6]]) does not yet use much of this scripted syntax feature (introduced in [[Patch 2.3 版本|2.3]]). Only few examples can be found in: common/scripted_effects/archaeology_event_effects.txt common/scripted_triggers/00_scripted_triggers.txt Instead, [[Star_Trek_New_Civilisations|Star Trek]] mods like "New Civilisations" use this feature a little more often. ==== Inline math ==== Scripted effects and scripted triggers can also have <code><nowiki>@\[ ... ]</nowiki></code>, a simple inline math statement. <pre> inline_math_example = { add_monthly_resource_mult = { resource = unity value = $COUNT|1$ min = @\[ $COUNT|1$ * 10 ] max = 99999999 } } </pre> This scripted effect will give the scoped empire X times their monthly unity income (up to 99,999,999 and down to X * 10), where X is the parameter given as COUNT. For example, <code>inline_math_example = { COUNT = 10 }</code> gives the scoped empire 10 times their monthly unity income (up to 99,999,999 and down to 100). Inline math has a drawback. Only the '''FIRST''' <code><nowiki>@\[ ... ]</nowiki></code> statement in a scripted effect / trigger is correctly recognized and evaluated. If multiple inline math statements is needed anyway, create multiple scripted effects that call each other. To the authoring of this entry there are 4 known functional operators for inline math statements: ;“+” :Adds the number on the right to the number on the left. ;“-” :Subtracts the number on the right from the number on the left. ;“*” :Multiplies the number on the left by the number on the right. ;“/” :Divides the number on the left by the number on the right. Any other attempted operator such as a <nowiki>=</nowiki> or <nowiki>^</nowiki> will result in the joining of the two sides. For example, if the statement <nowiki>@\[ 4 = 2 ]</nowiki> is ran, the resultant will be 42 to the effect. <pre> # If <condition A> is true, give the scoped empire twice the monthly unity income, otherwise once the monthly unity income. # If <condition B> is true, unity gained this way is reduced by -25%. inline_math_drawback = { if = { limit = { <condition A> } inline_math_drawback_step_2 = { COUNT = 2 } } else = { inline_math_drawback_step_2 = { COUNT = 1 } } } inline_math_drawback_step_2 = { if = { limit = { <condition B> } inline_math_drawback_step_3 = { COUNT = $COUNT$ MULT = 0.75 } } else = { inline_math_drawback_step_3 = { COUNT = $COUNT$ MULT = 1.0 } } } inline_math_drawback_step_3 = { inline_math_drawback_step_4 = { RESOURCE = unity COUNT = @\[ $COUNT$ * $MULT$ ] } } inline_math_drawback_step_4 = { add_monthly_resource_mult = { resource = $RESOURCE$ value = $COUNT$ min = @\[ $COUNT$ * 100 ] max = 100000000 } } </pre> It should be noted however that if multiple inline math statements are required for your code you will have to execute them in a manner of one per scripted effect call. It is however possible to send an inline math statement as a parameter by wrapping it in a pair of quotations <code><nowiki>"@\[ ... ]"</nowiki></code>. Wrapping an inline math statement will allow for a scripted event to use multiple inline statements so long as the statements are a parameter to another effect, although it cannot send more than one statement as a parameter to an effect. <pre> # If <condition A> is true, give the scoped empire twice the unity income, otherwise once a static unity income. # If <condition B> is true, unity gained this way is reduced by -25%. inline_math_effect = { if = { limit = { <condition A> } inline_math_drawback_step_2 = { COUNT = 2 } } else = { inline_math_drawback_step_2 = { COUNT = 1 } } } inline_math_drawback_step_2 = { # These inline statements won't run here allowing us to pick and chose which one we want, but it will autofill the $COUNT$ parameter in this statement. if = { limit = { <condition B> } inline_math_drawback_step_3 = { Resource = unity Value = "@\[ $COUNT$ * 0.75 * 500]" } } else = { inline_math_drawback_step_3 = { Resource = unity Value = "@\[ $COUNT$ * 500]" } } } inline_math_drawback_step_3 = { add_resource = { $Resource$ = $Value$ } } </pre> == Conditions == Conditions are statements to be evaluated for a yes or no. Many game objects and [[event modding]] use this for dynamic conditions. Head to [[conditions]] for full list of condition statements. Conditions must be checked on a [[scope]]. Head to scopes for details. === Scripted triggers === Similarly, there are more than singular statements of xonditions to be used for a condition. Scripted triggers are moddable blocks of condition statements to be used as a condition. They are defined at "common/scripted_triggers/xxx.txt". ==== How to use ==== Like scripted effects, a scripted trigger is a block of [[Conditions|condition statements]] and/or other scripted triggers. example_scripted_trigger = { has_ethic = ethic_materialist has_ethic = ethic_fanatic_materialist … } Defined scripted triggers can be used as though they were Conditions. For instance, "example_scripted_trigger" can be called with <code>example_scripted_trigger = yes/no</code>. ==== Parameters ==== Scripted triggers do also have parameters. # definition example_scripted_trigger = { has_ethic = ethic_$ETHIC$ has_ethic = ethic_fanatic_$ETHIC$ } # calling example_scripted_trigger = { ETHIC = materialist } A scripted trigger with parameters can't be called in <code>xxx = no</code> form, but can be called in <code>NOT = { … }</code> block. == Scripted localization == Scripted localizations are defined at "common/scripted_loc/xxx.txt". === How to use === First, define an instance. defined_text = { name = GetAuthorityName text = { trigger = { has_authority = auth_democratic } localization_key = auth_democratic } text = { trigger = { has_authority = auth_oligarchic } localization_key = auth_oligarchic } … } Then go to the localisation files and just use <code>[<scope>.GetAuthorityName]</code> to call this scripted loc. This instance of scripted loc is designated to be called from country scopes, but there is actually no scope type limitations on scripted loc itself. == Scripted variables == Scripted variables are defined at "common/scripted_variables/xxx.txt". === How to use === Scripted variables are no game objects. They are only "@" variables to be used from other game files. A game file can have its own "@" variables defined but those variables can't be used by other game files. However, scripted variables are shared through all game files. For example, we can define a scripted variable like this: @example = 2 And use it like this: example_scripted_effect = { while = { count = @example shift_ethic = ethic_$ETHIC$ } } Or this: example_scripted_effect = { while = { count = $COUNT$ shift_ethic = ethic_$ETHIC$ } } example_scripted_effect = { ETHIC = materialist COUNT = @example } Modifiers can also have "@" variables for their numeric values. == Modifiers == Since [[patch 3.0]]<ref>A little bit earlier, but undocumented.</ref> there is a [[modifiers]] <code>multiplier</code> parameter for <code>add_modifier</code>, were you can multiply numeric values. effect = { add_modifier = { modifier = soul_diet1 multiplier = 6 days = 360 } } == Flags == Flags are '''boolean values''' (flag is either present or not), which can be attached to the following scopes: leader, planet, country (first_contact), fleet, ship, species, pop (pop_faction), federation, galactic_object (ambient_object), megastructure, espionage_operation or global. The command to set or clear a flag are: * <code>set_<scope>_flag = <flag_name></code> * <code>set_timed_<scope>_flag = { flag = <flag_name> days = <int> }</code> * <code>remove_<scope>_flag = <flag_name></code> Flags can be checked via conditions, for the flag presence <s>or the duration since the flag has been set</s> <sup>(not yet implemented)</sup>: * <code>has_<scope>_flag = <flag_name></code> *<s><code>had_<scope>_flag = { flag = <flag_name> days = <duration> } </code></s> Note that [[modifiers]] are somewhat similar to flags, but in addition they alter the statistics of the scope they are attached to. === Dynamic flags === The flag name may be dynamic, by appending @ and a scope (leader, country or title):<ref>[[forum:774248/page-20#post-20109979]]</ref> It only affects how the actual flag name is created, but doesn't change how the flag is checked. <code>FROM = { set_leader_flag = is_friend_of_@ROOT }</code> ==== How to use ==== For example, if a leader has a leader ID of 140, the saved leader flag will be <code>is_friend_of_140</code>. They can also be used in triggers: <code>has_leader_flag = is_friend_of_@FROM</code> Use of dynamic flags is currently only supported for set|remove_''scope''_flag commands and has_''scope''_flag conditions. They cannot be used in the flag line of the create_leader command (flags used in instances other than those listed previously must be static).<ref>[[forum:589686/page-1707#post-24382261]]</ref> Note that scopes saved as variables in [[event target]]s can be used in dynamic flags as well.<ref>[[forum:589686/page-1633#post-23624865]]</ref> {{ModdingNavbox}} [[Category:模组制作]]
摘要:
请注意您对群星百科的所有贡献都被认为是在知识共享署名-非商业性使用-相同方式共享下发布,请查看在
群星百科:版权
的细节。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源。
未经许可,请勿提交受版权保护的作品!
为防止机器编辑,请完成下方验证
取消
编辑帮助
(在新窗口中打开)
本页使用的模板:
Template:Clear
(
编辑
)
Template:ModdingNavbox
(
编辑
)
Template:Navbox
(
编辑
)
Template:Navboxgroup
(
编辑
)
Template:Version
(
编辑
)
×
登录
密码
记住登录
加入群星百科
忘记密码?
其他方式登录