Derelict vision distance bonus

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

Derelict vision distance bonus

#1 Post by MatGB »

If you discover a derelict that gives you knowledge of the local area, that knowledge lasts for a turn, so if you move the ship and it completes a move in one turn, you get a brief glimpse of systems further away. A minor little bonus that doesn't matter one way or another.

However, if you get the bonus, move the ship to a new system and get the same bonus again, the second bonus is removed at the same time as the previous turns bonus, meaning while you've now got knowledge of the systems, they're all scanlined out and you can't really be sure what's there.

Is it possible to get the removal of bonus to process before new bonuses are applied so you don't get the sitrep telling you you've got a bonus but it's not actually visibly there?

Example attached, two autosaves sipped, the oldest reveals the bonus, the next has the ship also tell me it's had the bonus but has already lost 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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Derelict vision distance bonus

#2 Post by Dilvish »

MatGB wrote:Is it possible to get the removal of bonus to process before new bonuses are applied so you don't get the sitrep telling you you've got a bonus but it's not actually visibly there?
Good thought. I think this might do it.

r6855:

Code: Select all

reordered EffectsGroups of DERELICT_SPECIAL2 so that hopefully a ship currently possessing 
   DERELICT_SPECIAL2, arriving in a system with DERELICT_SPECIAL2, will still get the 
   benefit of that new DERELICT_SPECIAL2
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

Re: Derelict vision distance bonus

#3 Post by MatGB »

Tried it on my savegame, doesn't appear to have worked, but that might be a relic of the save, so I'll keep an eye out.

Shame, would've been cool to have something minor-but-annoying fixed really easily.
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: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Derelict vision distance bonus

#4 Post by Geoff the Medio »

You'd need to have a save from a turn or two before this happened to see the difference. If the save is on the turn when you should but didn't have extended vision, the effect already (didn't) execute during the previous turn processing.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Derelict vision distance bonus

#5 Post by Dilvish »

ok so it looks like the problem was that the EffectsGroup with AddSpecial was keyed off of a System Source, whereas the EffectsGroup with RemoveSpecial was keyed off a Ship Source and was getting executed at a later time. So I added another EffectsGroup with the AddSpecial, keyed off a Ship Source (which has DERELICT_SPECIAL2) if it's in a system that still has DERELICT_SPECIAL2. It seems to work well enough.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

Re: Derelict vision distance bonus

#6 Post by MatGB »

Aye, that's worked fine on the above savegame.

Geoff, the save above has a scout that's just arrived at the first of three systems in a row with the derelict, it was that that prompted the post as I'd noticed it before but not to this extent and if it bugs me it'd really confuse a newish player.

Playing on a High Specials map deliberately, I'm getting loads of derelicts, Fruit and Gaia, but not much else, but that's for a different thread, weird though.
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
cami
Space Dragon
Posts: 411
Joined: Tue Sep 20, 2011 10:32 pm
Location: Halle (Saale)

Re: Derelict vision distance bonus

#7 Post by cami »

I'd recommend tieing both effects to the System, not the ship, because then the reference location doesn't change. Order both effects groups so that removal comes before addition (this currently only works properly when both are sourced by and targeting the same object).
This problem could actually be fixed by the new effects processing, which would enforce all removal effects come before all addition effects no matter what the source is. Then it should also be safe using the ship as the AddSpecial source. The removal should never be tied to the ship, because it happens one turn later and the ship can already be elsewhere. Consequently, the AddSpecial target cannot be the ship either.

P.S. a nice illustration that "source" is not always a properly defined object. Effects are activated by a situation, which need not always be the presence or state of a single object. We currently work around this by somewhat arbitrarily picking one of the objects creating the situation as the source and describing the situation as relations of the other objects to this source.
Yesterday, we were still on the brink. Fortunately, today we have come one step further.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Derelict vision distance bonus

#8 Post by Dilvish »

cami wrote:I'd recommend tieing both effects to the System, not the ship, because then the reference location doesn't change. Order both effects groups so that removal comes before addition (this currently only works properly when both are sourced by and targeting the same object).
I'm not quite following you here, & how you see this taking into account the fact that the ship can move (as you note later). Let me summarize the current operation of the derelict2 special in case there has been some confusion: the special starts out attached to a system. If a ship stops in that system, the system special increases the ship's detection range and adds the special to the ship, and removes itself from the system. The following turn, the ship special will remove itself from the ship (causing the detection range to drop back down), except (as a recent tweak to this script) if the ship moved into a system that also had derelict2 special then the ship special also causes itself to be reapplied. I suppose it would have been cleaner scripting to simply constrain the removal clause to not be triggered in that scenario, but the end result is the same. This deviates slightly from the optimally desired behavior, in that if two ships simultaneously enter a system with the derelict2 special, and one or both of the ships had the special to start, then both could wind up with the special at the end of the turn, when really it should just be one of them. I agree that the 'removal always before adding' of the new effects processing that you mention should allow us to fix this behavior properly.
This problem could actually be fixed by the new effects processing, which would enforce all removal effects come before all addition effects no matter what the source is. Then it should also be safe using the ship as the AddSpecial source. The removal should never be tied to the ship, because it happens one turn later and the ship can already be elsewhere. Consequently, the AddSpecial target cannot be the ship either.
I agree with the first sentence. I have no argument with the second sentence though it depends highly on the the rest of the structure. I can't agree with sentences (3) and (4) though. If we have removal-before-add enforced then it seems to me that the original script will work fine, transferring the special from the system to the ship. [edit]To clarify a little, I could see 'if (3) then (4)', and 'if (4) then (3)', but 'Not (3) And Not (4)' seems viable and actually more applicable to our situation.[/edit]
P.S. a nice illustration that "source" is not always a properly defined object. Effects are activated by a situation, which need not always be the presence or state of a single object. We currently work around this by somewhat arbitrarily picking one of the objects creating the situation as the source and describing the situation as relations of the other objects to this source.
The phrasing of this first sentence doesn't quite seem right to me. The scripter, considering a situation they wish to cover, may somewhat arbitrarily pick one of the involved objects to be the source, but at that point the source will be a 'properly' defined object. The choice will be somewhat constrained in the manner in which the script is desired to be associated with the object (via tech, special, building, etc). [edit]Perhaps I'm quibbling too much there; I do think your overall point is a good one to keep in mind when contemplating a situation and effect one wants to script up.[/edit]
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

Re: Derelict vision distance bonus

#9 Post by MatGB »

FWIW, if the special added itself to all sips in system when triggered but removed itself before they moved I think that would be the most optimal, on more than one occasion I've had a fleet trigger the special and a random ship get it, when the fleet contained a scanner equipped vision bonus species and tat ship didn't get the bonus thus it made zero difference.

From an in game perspective having the bonus stay briefly after you've moved always feels a bit abusive to me but I understand it's harder to fix that with current codebase.
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
cami
Space Dragon
Posts: 411
Joined: Tue Sep 20, 2011 10:32 pm
Location: Halle (Saale)

Re: Derelict vision distance bonus

#10 Post by cami »

Dilvish wrote:Let me summarize the current operation
Thanks for the explanation, it was indeed enlightening. The comment of MatGB also was, leading me to a somewhat different opinion of how to handle effects like this (see below).
Dilvish wrote:the new effects processing that you mention should allow us to fix this behavior properly.
Almost, but not quite. The moving of the bonus is still a problem, even if it doesn't wear off when it shouldn't.
Dilvish wrote:The scripter, considering a situation they wish to cover, may somewhat arbitrarily pick one of the involved objects to be the source, but at that point the source will be a 'properly' defined object. The choice will be somewhat constrained in the manner in which the script is desired to be associated with the object (via tech, special, building, etc). [edit]Perhaps I'm quibbling too much there; I do think your overall point is a good one to keep in mind when contemplating a situation and effect one wants to script up.[/edit]
The source is well-defined for FO once it is arbitrarly chosen, or chosen simply to be able to reference it. It is not well-defined by the effect I want to script itself. In the Zen of python: "there should be one (and preferably only one) obvious way to do it." The concept of a "source object" is an (over-)simplification. Normally I would say this is a design flaw, but in a game, I'd rather call it a deliberate simplification, because for the player it is much easier to have a single object as "cause" of an effect. Nevertheless, things get complicated when there is no single source semantically, in particular when you need to reference more than just one "source" object for the same effect. Partially this can be solved by re-computing the "other" source objects in valueref subconditions.
MatGB wrote:FWIW, if the special added itself to all sips in system when triggered but removed itself before they moved I think that would be the most optimal, on more than one occasion I've had a fleet trigger the special and a random ship get it, when the fleet contained a scanner equipped vision bonus species and tat ship didn't get the bonus thus it made zero difference.

From an in game perspective having the bonus stay briefly after you've moved always feels a bit abusive to me but I understand it's harder to fix that with current codebase.
Sorry for the fullquote. There are two important points here:
1) Effect stacking seems to prevent you from getting the bonus in some cases. This is a design flaw. Stacking groups should prevent effects from stacking on top of each other, but it should not prevent effects from replacing each other. We need to make sure superior bonuses are always applied before inferior ones, there is no other easy way to realize "maximization" effects.
2) The effect should not move with you, that is counterintuitive.

There are two competing issues here:
1) The effect should be applied to a ship because only one empire should get enhanced vision
2) The effect should be applied to the system because it should only enhance vision from within that system

As often, that contradiction reveals an invalid assumption we made, namely that one of the causing objects should carry the effect. What we really want is:
3) The effect should be applied to a stationary object owned by the discovering empire.

This could be done, perhaps an invisible field or ship that is created by the effect and self-destructing after one turn.
Yesterday, we were still on the brink. Fortunately, today we have come one step further.

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

Re: Derelict vision distance bonus

#11 Post by MatGB »

Not sure I agree with this:
There are two competing issues here:
1) The effect should be applied to a ship because only one empire should get enhanced vision
2) The effect should be applied to the system because it should only enhance vision from within that system
What decides which empire gets it? The effect is triggered only once, on the turn an owned ship is alive after combat in that system. If there are two competing scout ships arriving there at the same time, the game presumably randomly chooses one of them. There's no reason why both can't get it, else the bonus is random.

Of course, it could be random by design, that'd be a choice, but if there's a conflict then apply it to all ships there regardless of ownership if they survive combat, why not?
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Derelict vision distance bonus

#12 Post by Dilvish »

cami wrote:What we really want is: 3) The effect should be applied to a stationary object owned by the discovering empire. This could be done, perhaps an invisible field or ship that is created by the effect and self-destructing after one turn.
I'm afraid I don't see how creating this extra object and then destroying it would be a preferred approach here. It would be one way to address the issue of keeping the effect localized to the original system, but it introduces a number of other significant complications (Fields currently are not expected to be owned and do not grant empires visibility; what design to use for a such a ship to ensure it got the desired detection range?). If keeping the effect localized was paramount, the effect could easily render the receiving ship immobile for a turn "while it processes the extra data".
MatGB wrote:If there are two competing scout ships arriving there at the same time, the game presumably randomly chooses one of them. There's no reason why both can't get it, else the bonus is random. Of course, it could be random by design, that'd be a choice, but if there's a conflict then apply it to all ships there regardless of ownership if they survive combat, why not?
The game does currently choose one randomly. I share the frustration when a multi-ship fleet has the wrong ship get the bonus. All ships could get the bonus if we could resolve the issue of ships keeping the bonus when they move to a neighboring system (otherwise a little too ripe for abuse). The immobility mentioned above is one possibility for that. Another way of dealing with the multi-ship issue might be to have the Effect select the ship with the highest preexisting Detection (I think that should be possible).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply