DragonKnightOfBreeze / Paradox-Language-Support

IDEA Plugin: Paradox Language Support.
https://windea.icu/Paradox-Language-Support
MIT License
42 stars 5 forks source link

Victoria 3 link Comparisons #101

Open kaiser-chris opened 1 week ago

kaiser-chris commented 1 week ago

Hi I think a CWT extension is needed here:

In Victoria 3 scripts you can use a link to get value comparision with another scope.

This gets the number of trade route levels with another country: num_mutual_trade_route_levels_with_country(root)

This gets the relations number between the in scope country and actor: relations(scope:actor)

This format is also used in Victoria 3 scripts, which seems to be the same as above: relations:root

to define something like this in links would need something like:

relations = {
    input_compare_scopes = country
    input_scopes = country
    output_scope = value
    type = value
}

The idea is when input_compare_scopes is set the following things would then be valid: relations:root relations:prev relations(c:PRU) scope of prussia relations(scope:actor) some scope that is defined for the context

DragonKnightOfBreeze commented 1 week ago

Not quite understand how to impelement, may be manually checked and debugged later...

DragonKnightOfBreeze commented 1 week ago
  1. Is output_scope and input_compare_scopes not always the same?
  2. Can input_compare_scopes be multiple?
  3. Is x in relations(x) a scope field expression (just like common root.owner.event_target:xxx), nested in the whole expression relations(x)?

There must be more uncleared questions...

kaiser-chris commented 1 week ago

If you look at this pull request it shows a few examples I defined for test purposes. Maybe that can help with understanding: https://github.com/kaiser-chris/cwtools-vic3-config/commit/afcf0f95b4dc336d823bb19a259ab3c5f180d99f

To your questions:

  1. output_scope and input_compare_scopes should generally be different. If you look at the example I provided with relations, the output_scope is value since a number is returned after the comparision.
  2. Maybe? I have not found any examples in the base game but I could easily construct/think of things where this could be possible in the future the same way where a value field can have multiple input_scopes already.
  3. relations(x) is not a scope expression but a value expression because what it does is take the country that is in scope (this) and gets its relations with another country x. You get the value of something.

Just maybe to clarify and provide a further example. Let us look at scripted_bar_progress. What does it do:

Here is an example how it is used in a base game file trigger:

... more code before
    fail = {
        custom_tooltip = {
            text = communism_progress_bar_at_full_tt
            scope:journal_entry = {
                "scripted_bar_progress(communism_1_progress_bar)" >= 100
            }
        }
    }
... more code after

An example how I would configure it in CWT (This is just an idea and example):

scripted_bar_progress = {
    compare_from_data = yes # Not in current CWT standard
    compare_data_source = <scripted_progress_bar> # Not in current CWT standard
    input_scopes = journal_entry
    output_scope = value
    type = value
}

This is different from relations because it does not expect a scope as input but a type.

DragonKnightOfBreeze commented 1 week ago

Oh I see. it's another specific scope field expression (like script value expression value:xxx|X|X|)

DragonKnightOfBreeze commented 1 week ago

There are various (and more) 'complex' expressions in paradox script&loc files, and so do plugin's codes. I once thought the implementation for complex expressions is not so good, but currently, luckly, it's still not very hard to implement those language features.

kaiser-chris commented 1 week ago

Just one more example I found: image

Seems like scope chaining can also happen in there.

DragonKnightOfBreeze commented 5 days ago

image

Is this correct and necessary? I have no idea to differ and match these two configs exactly yet.

kaiser-chris commented 5 days ago

Hmm I think only the arithmetic one is needed.

But I am not 100% sure. I am currently not at home to search the base game files for it.

DragonKnightOfBreeze commented 5 days ago

image

relations:xxx

This is missing in cwt configs, may be defined first, and implemented by plugin second (througth final cwt configs may be changed)

DragonKnightOfBreeze commented 5 days ago

Hi I think a CWT extension is needed here:

In Victoria 3 scripts you can use a link to get value comparision with another scope.

This gets the number of trade route levels with another country: num_mutual_trade_route_levels_with_country(root)

This gets the relations number between the in scope country and actor: relations(scope:actor)

This format is also used in Victoria 3 scripts, which seems to be the same as above: relations:root

to define something like this in links would need something like:

relations = {
    input_compare_scopes = country
    input_scopes = country
    output_scope = value
    type = value
}

The idea is when input_compare_scopes is set the following things would then be valid: relations:root relations:prev relations(c:PRU) scope of prussia relations(scope:actor) some scope that is defined for the context

For this, relations:root and relations(root) shall be all valid and same, and input_scopes and input compare_scopes should be same, for you cannot use : to separate prefix relations and dynamic scope link c:PRU. so, it may be just a alias format if datasource = scope_field or datasource = scope[country], etc.

DragonKnightOfBreeze commented 5 days ago

And, it should be only valid and avaiable for value_field (ParadoxValueFieldExpression, in plugin code)

DragonKnightOfBreeze commented 3 days ago

fyi nearly implemented

DragonKnightOfBreeze commented 3 days ago

https://github.com/user-attachments/assets/b6e3cbcc-98ff-4969-aa5d-ca07fd4c4bd6

DragonKnightOfBreeze commented 3 days ago

There still are some bugs and unimplemented features, like the validation for data source type scope[country]

DragonKnightOfBreeze commented 3 days ago

@kaiser-chris Since now you can create the PR for from_argument link configs :)

DragonKnightOfBreeze commented 3 days ago

Paradox-Language-Support-1.3.26.zip

kaiser-chris commented 3 days ago

@kaiser-chris Since now you can create the PR for from_argument link configs :)

Would love to but I will be unable to until late next week since I am currently traveling.

But thank you already this looks good but does it also support things like the scripted_bar_progress I have written about above or is that part still missing?

kaiser-chris commented 3 days ago

If you look at this pull request it shows a few examples I defined for test purposes. Maybe that can help with understanding: kaiser-chris/cwtools-vic3-config@afcf0f9

If you want a few more test cases you can find almost all compare uses in the Commit I linked. I needed to remove them because they broke the original CWT tools but it still provides a comprehensive list of them.

Otherwise I will configure them myself in CWT late next week.

DragonKnightOfBreeze commented 2 days ago

I will seen them next week