FreeOrion

Forums for the FreeOrion project
It is currently Mon Dec 11, 2017 4:57 pm

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Sep 21, 2017 5:23 pm 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 708
Ophiuchus wrote:
For countdown you could also think of using a capacity .

I was the last one playing around with specials for the supply ships idea I think. Maybe the UNLOADING_SUPPLIES.focs.txt special will help you with creation turn and/or capacity:

https://github.com/agrrr3/freeorion/blo ... S.focs.txt
Thanks, that's useful indeed. Do you know if there is a way to directly retrieve the special capacity value? That'd be helpful for creating a tooltip for the pdc countdown special, to show how many turns are remaining until the planet's destruction.

Having rewritten the .focs code to use capacity instead of multiple specials, freeoriond.exe now crashes when starting a new game or loading a game. I don't really have a clue why this is happening, no parsing errors are reported. I've attached the logs, and the PR is updated with my current development build, if someone can help me figure out what's going on I'd very much appreciate it.


Attachments:
freeoriond.log [10.83 KiB]
Downloaded 1 time
freeorion.log [16.27 KiB]
Not downloaded yet

_________________
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.
Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 6:16 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12040
Location: Munich
The Silent One wrote:
Do you know if there is a way to directly retrieve the special capacity value?

https://github.com/freeorion/freeorion/ ... b2acb1449d
Quote:
freeoriond.exe now crashes when starting a new game or loading a game. I don't really have a clue why this is happening, no parsing errors are reported.

There's an access violation in parse::specials.
Code:
Unhandled exception at 0x008939CE in FreeOrionD.exe: 0xC0000005: Access violation reading location 0x00000020.


Might help to have quotes around DESTRUCTION_COUNTDOWN_SPECIAL in
Code:
effects = RemoveSpecial name = "DESTRUCTION_COUNTDOWN_SPECIAL"


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 7:09 pm 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 708
Geoff the Medio wrote:
Might help to have quotes around DESTRUCTION_COUNTDOWN_SPECIAL in
Code:
effects = RemoveSpecial name = "DESTRUCTION_COUNTDOWN_SPECIAL"
Indeed, thank you.

_________________
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.


Top
 Profile  
 
PostPosted: Fri Sep 22, 2017 7:08 pm 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 708
Sorry to have to ask for help yet again, I tried for the last week to figure this one out, but no luck.

The countdown using SpecialCapacity does work as it is supposed to. However, when the countdown reaches 0, the planet is not completely destroyed, only the population and resource output vanish, buildings and specials and the planet type remain (it is just reduced to outpost status maybe?). No destruction sitreps are generated. But on the next turn, if the Destroy Button is pushed again, the planet is destroyed. I've attached an image of the current situation below. Relevant focs parts are:

Code:
         // if countdown ends, destroy planet
         EffectsGroup
            scope = And [
                [[PDC_SCOPE]]
                HasSpecialCapacity name = "DESTRUCTION_COUNTDOWN_SPECIAL" high = 0.5
            ]
            [[PLANET_DESTRUCTION_EFFECT]]
(Don't see what could go wrong here.)
as well as

Code:
PLANET_DESTRUCTION_EFFECT
'''         effects = [
                GenerateSitRepMessage  // sitrep for destroying empire
                    message = "EFFECT_PLANET_DESTRUCTION"
                    label = "EFFECT_PLANET_DESTRUCTION_LABEL"
                    icon = "icons/sitrep/planet_destroyed.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "empire" data = Target.Owner
                    ]
                    empire = Source.Owner
                GenerateSitRepMessage  // sitrep for targeted empire
                    message = "EFFECT_PLANET_DESTRUCTION_OWN"
                    label = "EFFECT_PLANET_DESTRUCTION_LABEL"
                    icon = "icons/sitrep/planet_destroyed.png"
                    parameters = [
                        tag = "planet" data = Target.ID
                        tag = "empire" data = Source.Owner
                    ]
                    empire = Target.Owner
                RemoveAllSpecials
                RemoveAllBuildings
                SetOwner empire = -1
                SetSpecies name = ""
                SetPopulation value = 0
                SetPlanetType type = Asteroids
            ]
'''
Any idea what might cause this behaviour?

[Edit]I should add that the planet destruction focs code works if the countdown isn't involved; "direct" destruction with the lvl 2 pdc works!


Attachments:
bug.jpg
bug.jpg [ 78.2 KiB | Viewed 101 times ]

_________________
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.
Top
 Profile  
 
PostPosted: Fri Sep 22, 2017 8:56 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Have any log errors? Possibly the PDC_LVL2 activation macro is not replaced, since planet_destruction.macros does not end in newline.


Top
 Profile  
 
PostPosted: Fri Sep 22, 2017 8:58 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4390
I posted in your PR, with what I think is a fix. When confronted with bugs, always remember to check your logs.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sat Sep 23, 2017 8:05 am 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 708
dbenage-cx wrote:
Have any log errors? Possibly the PDC_LVL2 activation macro is not replaced, since planet_destruction.macros does not end in newline.
I'm sure it is being replaced, because planet destruction without a countdown is working, and that uses the macro as well.

Dilvish wrote:
I posted in your PR, with what I think is a fix. When confronted with bugs, always remember to check your logs.
:oops: I hadn't seen anything on the console, but I'll make sure to check the logs as well in the future.

_________________
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.


Top
 Profile  
 
PostPosted: Sat Sep 23, 2017 5:30 pm 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 708
I think I've tracked the bug down, but it's really ...weird. See the code below; unexplicably, SetPopulation value = 0 is already executed when the countdown hits 1, but everything else is executed on the turn after, how it is actually supposed to... :? After commenting out SetPopulation, everything works as intended and at the right time (except that some population remains after planet destruction). Console doesn't show anything, and I can't find anything conspicuous in the logs. A save is attached, Celtsi Alpha is awaiting destruction on the south part of the map.

Any bright ideas what may be happening here?

From SP_PLANET_DESTROYER.focs.txt:
Code:
          // if countdown ends, destroy planet
          EffectsGroup
              scope = And [ [[PDC_SCOPE]] ]
             // HasSpecialCapacity name = "DESTRUCTION_COUNTDOWN_SPECIAL" high = 0.5

             activation = Number low = 1 condition = HasSpecialCapacity name = "DESTRUCTION_COUNTDOWN_SPECIAL" high = 0.5
             effects = [
                 GenerateSitRepMessage
                     message = "TEST_MESSAGE"
                     label = "TEST_MESSAGE"
                     icon = "icons/sitrep/planet_destroyed.png"
                     empire = Source.Owner
                 RemoveAllSpecials
                 RemoveAllBuildings
                 SetOwner empire = -1
                 SetSpecies name = ""
                 SetPlanetType type = Asteroids
                 SetPopulation value = 0
            ]


Attachments:
save-20170918_132910.sav [1.49 MiB]
Downloaded 1 time

_________________
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.
Top
 Profile  
 
PostPosted: Sat Sep 23, 2017 6:47 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4390
Regarding the SetPopulation issue, unlike that is the others that is a meter effect, and so gets processed an additional time towards the end of the turn (the stated intent of which is to cover newly created objects, but I think this is getting caught up in it also).

fleets_move
combat
all effects applied, including building new "current" meter values from "initial" meter values
supply & resources updated
things made
scripted events processed
meter effects applied again (rebuilds new "current" meter values from "initial" meter values, not adding another dollop to current meter values)
population growth
back-propagation of meters ("initial" values overwritten by "current" values)
turn number advanced

The best solution that comes to mind to me is to use an additional special along with the new SpecialAddedOnTurn condition Geoff made-- when the first special finishes its countdown it adds the second special, and the second special (with the additional condition that it must have been created on the previous turn) serves as the trigger for all the effects.

I also want to note, I am pretty sure that you'll need to keep that SpecialCapacity condition in the scope, or tighten up the scope in some other way (like maybe tightening the OrderedBombarded condition). Otherwise, it looks to me like in a situation with multiple planet destructions proceeding in the system with different countdowns, a single activation could trigger them all to destroy at once.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sun Sep 24, 2017 6:00 am 
Offline
Graphics
User avatar

Joined: Tue Jul 01, 2003 8:27 pm
Posts: 708
Found a way to fix this (finally :) ). Solution was to create a special after planet destruction, which then takes care of removing the population. This will synchronise population removal with the other destruction effects. Thanks for the help getting this sorted out.

_________________
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

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