CreateShip effects - SetStructure

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderator: Committer

Post Reply
Message
Author
dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

CreateShip effects - SetStructure

#1 Post by dbenage-cx » Wed Sep 21, 2016 11:53 pm

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.
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12249
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: CreateShip effects - SetStructure

#2 Post by Geoff the Medio » Thu Sep 22, 2016 7:39 am

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.

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: CreateShip effects - SetStructure

#3 Post by dbenage-cx » Thu Sep 22, 2016 11:32 am

Thank you for the detailed explanation Geoff, I'll look into the other route.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: CreateShip effects - SetStructure

#4 Post by MatGB » Thu Sep 22, 2016 5:41 pm

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.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply