my overlay is not removing

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

Wed Aug 03, 2011 3:32 am

The thread on more realistic solar panel arrays led me to try an overlay based approach for an external solar panel.

Unfortunately I am running into problems. when the overlay is damaged to maximum it disappears like a pteravore, and damages the solar panel array device. That works fine. But twice, at 33% and 66% damage the overlay is removed, and its data transferred to a new overlay that visually appears [more] damaged. The problem is it is failing to delete the old overlay and I can't see why, especially since objRemoveOverlay keeps returning true... Line 168.

http://dl.dropbox.com/u/10879324/Transc ... 0panel.zip
ImageImage
Thanks to digdug for the banners.

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Wed Aug 03, 2011 3:16 pm

Hmm, i looked at this quite thoroughly and think it is a bug. I have a feeling it is related to adding an overlay in the same event that you remove one. I tried fixing this in a lot of ways, but nothing seems to really work.

Some other comments:

You could simplify your check for whether the player has an overlay active in the invoke code (line 57). I would suggest something like this:

Code: Select all

(if (typHasAttribute (objGetOverlayType gSource ovid) "SolarOverlay")
  ....
)
and then add attributes="SolarOverlay" to all you solar panel overlays

In general i think it is a very nice mod and hope we find a workaround or the bug.
Get your own Galactic Omni Device
Get it now. It's free!!
Image

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Wed Aug 03, 2011 3:53 pm

Here is a small mod that proves my above hypothesis. If it is run, you will see how the overlay it claims to remove is not removed. If one comments the addition of the overlay in the OnDamage, then all goes as expected.

Code: Select all

    <Globals>
        (block nil
            (setq solar (lambda nil
                (objAddOverlay gPlayerShip &ovTestOverlay; (objGetPos gPlayerShip) 0)
            ))
        )
    </Globals>

    <OverlayType UNID="&ovTestOverlay;">
        <Events>
            <OnCreate>
                (block nil
                    (dbgLog "========== OnCreate ===========")
                    (dbgLog "Added overlay: " aOverlayID)
                    (dbgLog "Ship now has " (count (objGetOverlays gPlayerShip)) " overlays")
                    (dbgLog (objGetOverlays gPlayerShip))
                )
            </OnCreate>

            <OnDamage>
                (block nil
                    (dbgLog "========== OnDamage ===========")
                    (dbgLog "Ship has " (count (objGetOverlays gPlayerShip)) " overlays")
                    (dbgLog (objGetOverlays gPlayerShip))
                    (dbgLog "Damaging overlay ID: " aOverlayID)
                    (dbgLog "Removing that overlay: " (objRemoveOverlay gPlayerShip aOverlayID))
                    (dbgLog "Ship now has " (count (objGetOverlays gPlayerShip)) " overlays")
                    (dbgLog (objGetOverlays gPlayerShip))
                    (objAddOverlay gPlayerShip &ovTestOverlay; (objGetPos gSource) 0)

                    aDamageHP
                )
            </OnDamage>

        </Events>
    </OverlayType>	
Get your own Galactic Omni Device
Get it now. It's free!!
Image

User avatar
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

Wed Aug 03, 2011 4:26 pm

Thanks, Alterecco.

I got it to work by setting a variable/flag on the overlay instead of removing it. It removes itself next time the onDamage or onUpdate runs. There's a slight lag if it isn't shot immediately again but that's ok since no code is run in duplication except for the check.

I added the suggested simplification.


That bug should be added to the track.
ImageImage
Thanks to digdug for the banners.

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Wed Aug 03, 2011 7:06 pm

Bobby wrote:Thanks, Alterecco.

I got it to work by setting a variable/flag on the overlay instead of removing it. It removes itself next time the onDamage or onUpdate runs. There's a slight lag if it isn't shot immediately again but that's ok since no code is run in duplication except for the check.
That seems like a good solution. I tried making the overlay that was added remove all other solaroverlays, but that seemed to crash the game... another thing to investigate it seems.

I hope George will have a peek at the bug and name it. Then we can always add it to track.
Get your own Galactic Omni Device
Get it now. It's free!!
Image

george moromisato
Developer
Developer
Posts: 2950
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Wed Aug 03, 2011 7:11 pm

I think the problem is in the code that tries to deal with overlays being destroyed inside their own events. I've re-written the code in 1.07, so it should solve all the problems (including the crash when trying to delete all overlays).

But please preserve the mods with the original code so that we can test it when 1.07 comes out.

Post Reply