• 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.

DeathMaker900

Corporal
29 Badges
Apr 25, 2017
35
41
  • Age of Wonders: Planetfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Stellaris: Distant Stars
  • Stellaris: Ancient Relics
  • Stellaris: Apocalypse
  • Stellaris: Megacorp
  • Stellaris: Federations
  • Stellaris: Nemesis
  • Stellaris: Humanoids Species Pack
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Lithoids
  • Stellaris: Necroids
  • Shadowrun: Dragonfall
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines
  • BATTLETECH
  • Warlock: Master of the Arcane
  • Stellaris: Synthetic Dawn
  • Crusader Kings II
  • Crusader Kings III
  • Warlock 2: The Exiled
  • Warlock 2: Wrath of the Nagas
  • Tyranny: Archon Edition
  • Surviving Mars
I'm working on an event for an operation and I cannot for the life of me figure out why this condition is not working. The operation is supposed to remove a random corporate branch office the target owns from one of your planets. This is only possible if the target is a megacorp and has a branch office on at least one of your planets so every step of the operation I have a guard clause to make sure those things are still true. here's the code:

Code:
country_event = {
    id = expanded_operations.192
    hide_window = yes
    is_triggered_only = yes
    immediate = {
        if = {
            limit = {
                from = {
                    log = "From Target: [From.Target.GetName]"
                    log = "Target: [Target.GetName]"
                    log = "owner: [Owner.GetName]"
                    target = { is_megacorp = yes }
                    log = "condition 1 true"
                    target = { is_galactic_emperor = no }
                    log = "condition 2 true"
                    owner = {
                        any_owned_planet = {
                            has_branch_office = yes
                            log = "From Target (inner): [from.target.GetName]"
                            log = "Root (inner): [root.GetName]"
                            log = "Root.owner (inner): [root.owner.GetName]"
                            log = "This (inner): [This.GetName]"
                            log = "BOO (inner): [branch_office_owner.GetName]"
                            branch_office_owner = { is_same_value = from.target }
                        }
                    }
                    log = "condition 3 true"
                }
            }
            log = "Stage 3 valid"
            # random planet selection and clean operation code
            country_event = { id = expanded_operations.193 }
        }
        else = {
            log = "Stage 3 invalid"
            country_event = { id = expanded_operations.185 }
        }
    }
}

Code:
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1805. From Target: Panaxala Cartel
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1806. Target: Panaxala Cartel
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1807. owner: Minnerian Union
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1809. condition 1 true
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1811. condition 2 true
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1815. From Target (inner): Panaxala Cartel
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1816. Root (inner): Minnerian Union
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1817. Root.owner (inner): Minnerian Union
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1818. This (inner): Salorim Cove
[14:45:35][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1819. BOO (inner): Panaxala Cartel
[14:45:35][effect_impl.cpp:19501]: [2244.7.6] Log command triggered from effect in file: events/expanded_operations_events.txt line: 1912. Stage 3 invalid

In my test game I am playing the Minnerian Union and Salorim Cove is my only planet, and it does indeed have a branch office from the Panaxala Cartel on it. The logs show that from.target and branch_office_owner are both the Panaxala Cartel so why is my code jumping to the else statement?

Edit: More Context
 
Last edited:
I'm working on an event for an operation and I cannot for the life of me figure out why this condition is not working. here's the code:

Code:
immediate = {
    if = {
        limit = {
            from = {
                log = "From Target: [From.Target.GetName]"
                log = "Target: [Target.GetName]"
                log = "owner: [Owner.GetName]"
                target = { is_megacorp = yes }
                log = "condition 1 true"
                target = { is_galactic_emperor = no }
                log = "condition 2 true"
                owner = {
                    any_owned_planet = {
                        has_branch_office = yes
                        log = "From Target (inner): [From.Target.GetName]"
                        log = "This (inner): [This.GetName]"
                        log = "BOO (inner): [branch_office_owner.GetName]"
                        branch_office_owner = { is_same_value = from.target }
                    }
                }
                log = "condition 3 true"
            }
        }
        log = "Stage 3 valid"
        country_event = { id = expanded_operations.193 }
    }
    else = {
        log = "Stage 3 invalid"
        country_event = { id = expanded_operations.185 }
    }
}

Code:
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1804. From Target: Panaxala Cartel
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1805. Target: Panaxala Cartel
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1806. owner: Minnerian Union
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1808. condition 1 true
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1810. condition 2 true
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1814. From Target (inner): Panaxala Cartel
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1815. This (inner): Salorim Cove
[07:30:16][trigger_impl.cpp:21848]: [2244.7.6] Log command triggered from trigger in file: events/expanded_operations_events.txt line: 1816. BOO (inner): Panaxala Cartel
[07:30:16][effect_impl.cpp:19501]: [2244.7.6] Log command triggered from effect in file: events/expanded_operations_events.txt line: 1909. Stage 3 invalid

In game Salorim Cove is my only planet, and it does indeed have a branch office from the Panaxala Cartel on it. The logs show that from.target and branch_office_owner are both the Panaxala Cartel so why is my code jumping to the else statement?
Try removing log from trigger block. I know it is a valid input but maybe there is a bug with it.
 
Seems like a bug or uncommon limitation to me, because I really don't see a reason why that wouldn't work.

I know you're checking for it with those log entries, but since we're essentially grasping for straws, have you verified that it really is that check itself causing trouble? Try replacing it with something that should always return true:
Code:
branch_office_owner = { always = yes }

And you could try rechecking the scopes directly in the branch_office_owner wrapper, in case it somehow messes something up. It really shouldn't, but... again, grasping for straws.

For a potential workaround / solution, you could try saving from.target as an event_target at the very start of the effect and then simply use that in the end, in case the scope dancing somehow messes with the check. Something along the lines of...

Code:
country_event = {
    id = expanded_operations.192
    hide_window = yes
    is_triggered_only = yes
    immediate = {
        from.target = { save_event_target_as = operation_target }
        if = {
            limit = {
                any_owned_planet = {
                    has_branch_office = yes
                    branch_office_owner = { is_same_value = event_target:operation_target }
                }
            }
            # random planet selection and clean operation code
            country_event = { id = expanded_operations.193 }
        }
        else = {
            country_event = { id = expanded_operations.185 }
        }
    }
}

I left out the from = { owner = { [...] } } part under the assumption that country the event triggers for is also the scope of the owner, and those switches were just there for the debug prints. If I'm misinterpreting the scopes, then they do of course need to be added in again.
 
Seems like a bug or uncommon limitation to me, because I really don't see a reason why that wouldn't work.

I know you're checking for it with those log entries, but since we're essentially grasping for straws, have you verified that it really is that check itself causing trouble? Try replacing it with something that should always return true:
Code:
branch_office_owner = { always = yes }

And you could try rechecking the scopes directly in the branch_office_owner wrapper, in case it somehow messes something up. It really shouldn't, but... again, grasping for straws.

Hmm interesting! I didn't know I could do something like that code snippet but it makes sense now that you mention it. to me equals is an assignment operator when really its much more complicated than that. I'm still a bit fuzzy on which lines contribute to the overall boolean conditional and how data gets passed back up to parent scopes but this certainly sheds some light on it (by doing something outside of my paradigm).

For a potential workaround / solution, you could try saving from.target as an event_target at the very start of the effect and then simply use that in the end, in case the scope dancing somehow messes with the check. Something along the lines of...

Code:
...

I left out the from = { owner = { [...] } } part under the assumption that country the event triggers for is also the scope of the owner, and those switches were just there for the debug prints. If I'm misinterpreting the scopes, then they do of course need to be added in again.

This is a good thought, and if I had not come here to post the solution I found it would be a great next step. do/can event_targets transfer between events? like it i make a player choose something as step 1 of an operation can I read and recall that choice in stage 4 of the operation?

As for the solution it seems that the owner block being inside the from block was the issue. put them side by side in the limit and it works perfectly. according to the logs that didn't change the name of from.target but apparently that's what I needed... ¯\_(ツ)_/¯
Code:
immediate = {
    if = {
        limit = {
            from = {
                target = { is_megacorp = yes }
                target = { is_galactic_emperor = no }
            }
            owner = {
                any_owned_planet = {
                    has_branch_office = yes
                    branch_office_owner = { is_same_value = from.target }
                }
            }
        }
        country_event = { id = expanded_operations.193 }
    }
    else = {
        country_event = { id = expanded_operations.185 }
    }
}
 
You can probably remove the owner = {} wrapper completely, since it should not even be needed in that case. You're already in a country scope since it's a country_event, owner will just return the country scope again.

But good your problem is solved. Still a weird thing though.
 
Yeah I think I have even more questions now that it works. I'm stuck on the fact that the logs from the original code show that two objects (should both be countries) with the same name are not considered equivalent. That to me sounds like a memory pointer issue, or data duplication, or something like that going on in the script interpreter itself. It could also be that I fundamentally misunderstand the syntax of the scripting language and what ={ is doing, but to me at least it seems buggy.