FreeOrion

Forums for the FreeOrion project
It is currently Tue Dec 12, 2017 12:52 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Sep 21, 2016 11:53 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
I'm stumped on modifying the new objects structure/maxstructure within the effects of CreateShip.
A shortened version:
Code:
// 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:
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.


Top
 Profile  
 
PostPosted: Thu Sep 22, 2016 7:39 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12040
Location: Munich
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.


Top
 Profile  
 
PostPosted: Thu Sep 22, 2016 11:32 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Thank you for the detailed explanation Geoff, I'll look into the other route.


Top
 Profile  
 
PostPosted: Thu Sep 22, 2016 5:41 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3286
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group