Nanorobotic hull starting structure

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report on GitHub. For problems building from source, post in Compile.

Moderator: Oberlus

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

Nanorobotic hull starting structure

#1 Post by MatGB »

Just lost 5 nanobot ships to a Juggernaut, looked at the combat log and realised it was merely hitting them to kill. they start on zero structure and don't repait themselves until the end of the turn after they're built.

I vaguely recall that being mentioned ages back but I haven't used them for ages & I'm working through testing the robotic shield interface and they also don't kick in until the end of the first turn. Looking at the script I can't see why it's happening this way, any ideas how to fix it?
Mat Bowles

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

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

Re: Nanorobotic hull starting structure

#2 Post by Geoff the Medio »

MatGB wrote:Looking at the script I can't see why it's happening this way, any ideas how to fix it?
It's probably due to this effectsgroup:

Code: Select all

        EffectsGroup
            scope = Source
            activation = Source
            effects = SetStructure Target.MaxStructure
On the first time such ships have their effects executed, right after being produced, they'll have meters initially all 0, including MaxStructure. This thus sets the structure to 0.

To prevent that, perhaps disable that effect on the turn they're produced.

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

Re: Nanorobotic hull starting structure

#3 Post by MatGB »

That would make sense, so assuming it's Source.Age for that, does that start at 0 or 1?
Mat Bowles

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

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

Re: Nanorobotic hull starting structure

#4 Post by Geoff the Medio »

MatGB wrote:...does that start at 0 or 1?
Should be 0...

Code: Select all

int UniverseObject::AgeInTurns() const {
    if (m_created_on_turn == BEFORE_FIRST_TURN)
        return SINCE_BEFORE_TIME_AGE;
    if ((m_created_on_turn == INVALID_GAME_TURN) || (CurrentTurn() == INVALID_GAME_TURN))
        return INVALID_OBJECT_AGE;
    return CurrentTurn() - m_created_on_turn;
}

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

Re: Nanorobotic hull starting structure

#5 Post by MatGB »

Bumping this, as it needs fixing a bit more urgently.

There was a space cloud pinned down by a snowflake at my major shipyard. Nanobot hulls launched, stargate set to send them to the front line. I just loaded the savegame from earlier that I'd saved at the start of turn and was confused, reread the sitreps, and they all died in the first round of combat.

The new combat mechanics kill if you're on zero structure, even if you haven't taken a hit, so I just lost 5 expensive hulls that were in the middle of my safest areas way away from frontlines because a space cloud triggered a fight.

I recall playing around with various scripts for this, but I don't think I got any of them working, I shall try again when I've time tomorrow but if I can't, or if anyone can see a line or two of code that would fix it, it really does need fixing, it goes from "annoying bug caused by processing order" to "potentially game breaking bug for a newish player" and something that's annoyed me somewhat, even though I know exactly what the problem is.

Like I said, I can spend time trying to get it to work, but if anyone else that's a better scripter than me can just fix it that'd be awesome.
Mat Bowles

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

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

Re: Nanorobotic hull starting structure

#6 Post by Geoff the Medio »

Try something like

Code: Select all

        EffectsGroup
            scope = Source
            activation = Turn low = Source.CreationTurn + 1
            effects = SetStructure Target.MaxStructure

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

Re: Nanorobotic hull starting structure

#7 Post by MatGB »

Whenever I see the code that solves a problem I've been working on for ages it looks so simply and obvious, my brain is obviously having an off month. Works fine on the nanorobotics, I'll look at applying it to the other two hulls we've had problems with and put it into the patch I've put the draft version of up already over the weekend.

Thx.
Mat Bowles

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

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Nanorobotic hull starting structure

#8 Post by Vezzra »

MatGB wrote:Whenever I see the code that solves a problem I've been working on for ages it looks so simply and obvious, my brain is obviously having an off month.
Welcome to the world of programming. I've long lost count of how often I sat staring at some misbehaving code and just didn't see the forest for the trees. You're in good company ;)

AndrewW
Juggernaut
Posts: 791
Joined: Mon Feb 04, 2013 10:15 pm

Re: Nanorobotic hull starting structure

#9 Post by AndrewW »

Vezzra wrote:Welcome to the world of programming. I've long lost count of how often I sat staring at some misbehaving code and just didn't see the forest for the trees. You're in good company ;)
Dyson Forests getting stealthy?

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

Re: Nanorobotic hull starting structure

#10 Post by MatGB »

*checks*

Code: Select all

Hull
    name = "SH_TREE_BODY"
    description = "SH_TREE_BODY_DESC"
    speed = 0
    starlaneSpeed = 0
    fuel = 0
    stealth = 5
Nope, didn't mess that one up like I did the snowflakes and kraken.

don't do that to me

;-)

Anyway, sorta to topic. Nanorobotic hull had activation = turn, but logistics facilitator and bioadaptive hull had activation = source. But they do effectively the same thing, and I've just tested changing it to turn for the facilitator and it works fine.

So, what's the actual difference in our nice little bespoke scripting language, if it made no difference this time when/why would it?
Mat Bowles

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

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

Re: Nanorobotic hull starting structure

#11 Post by Geoff the Medio »

MatGB wrote:Nanorobotic hull had activation = turn, but logistics facilitator and bioadaptive hull had activation = source. But they do effectively the same thing...

So, what's the actual difference in our nice little bespoke scripting language, if it made no difference this time when/why would it?
"activation = Source" does nothing... in the sense that the activation condition always just checks if the source object matches the condition, so that condition will always match the source object, and could be just left out.

"activation = Turn" will match the source object on any turn... so always. This is effectively the same as "activation = Source". It's also very odd and pointless, as generally one would want to specify a high or low parameter to the Turn condition to match objects only when the game turn is within the specified range, such as "Turn low = Source.CreationTurn + 1" to match the source object when the game turn is after the turn the source object was created.

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

Re: Nanorobotic hull starting structure

#12 Post by MatGB »

OK, so both, as written, were pointless and didn't need to be there, but turn allows for parameters that can be fairly easily defined. That makes sense.

So, in the spirit of code cleanup, is it worth going through and removing the activation = source lines in various places?

(also, I think this will be very helpful in my tutorial sitrep idea that I was working on awhileback, which is nice)
Mat Bowles

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

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

Re: Nanorobotic hull starting structure

#13 Post by Geoff the Medio »

MatGB wrote:So, in the spirit of code cleanup, is it worth going through and removing the activation = source lines in various places?
I have no strong opinion on the matter.

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

Re: Nanorobotic hull starting structure

#14 Post by MatGB »

In which case I'll remove it if I see it when working on other stuff but not actively chase them down as that's effort ;-)
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