Page 1 of 1

CreateShip effects - SetStructure

Posted: Wed Sep 21, 2016 11:53 pm
by dbenage-cx
I'm stumped on modifying the new objects structure/maxstructure within the effects of CreateShip.
A shortened version:

Code: Select all

// param 1: string New ship design to create
MONSTER_MATURATION
'''CreateShip
    design = "@1@"
    empire = Source.Owner
    name = Source.Name
    effects = SetMaxStructure value = Source.Structure
Destroy
'''
I suspected some issue with processing order, but universe/Effect.cpp:1477 appears to apply these after setting the objects initial max.

Modifying the effects to:

Code: Select all

effects = [
    SetMaxStructure value = 888
    GenerateSitrepMessage
        message = "EFFECT_TMP"
        label = "EFFECT_TMP_LABEL"
        parameters = [
            tag = "rawtext" data = Source.Structure
            tag = "ship" data = Source.ID
            tag = "predefinedshipdesign" data = "@1@"
        ]
]
With the appropriate stringtable entry, the sitrep generates and has the original objects structure for the rawtext (possible to use tag labels in sitrep params?).
Removing "Destroy", neither object has a modified max structure.

If the effect does not live long enough for a single turn, any options outside of using the capacity of a special?

As no existing entries use the effects portion of CreateShip, I wanted to make sure the usage was correct before reporting.

Re: CreateShip effects - SetStructure

Posted: Thu Sep 22, 2016 7:39 am
by Geoff the Medio
Setting max or target anything with a one-time effect doesn't make much sense. Even during a single turn update, effects are run multiple times, and any max / target meters will be reset to 0 and have effects re-run on them. The CreateWhatever effects are just run once, though, when the object is created, so any max / target meter modifications they make will be lost by subsequent resets of the meter. If you instead use it to set the active meter values (eg. structure) higher than the max value, it will probably also not work, as the active meters are frequently clamped to not exceed the corresponding max meter.

If you want something to have a higher max structure, there needs to be an effect that sets it higher every turn, not just once. That means add more structure to the hull, or have a tech that acts on suitable player-own ships, or add a special to the ship that sets the max structure, or add a part to the design that modifies its structure... something persistent.

Re: CreateShip effects - SetStructure

Posted: Thu Sep 22, 2016 11:32 am
by dbenage-cx
Thank you for the detailed explanation Geoff, I'll look into the other route.

Re: CreateShip effects - SetStructure

Posted: Thu Sep 22, 2016 5:41 pm
by MatGB
Not sure what you're working on, but if it's monster maturation related then putting an effect into the new monster would probably be easier.