Name that bug!

Freeform discussion about anything related to modding Transcendence.
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

There's a rather odd game-crashing glitch with the newest segment of my Mines mod. However since I am not at all sure whether my issue is a problem with the mod, or a game framework problem...I think I'll describe everything and see what better minds than me can come up with.

The mod segment is part of my mines mod. It's a ship (that functions as the mine) and a virtual item with an OnFireWeapon event that triggers the self destruct on the ship which otherwise would activate after a certain amount of time.

However, if three or more mines are laid, and then an enemy ship spawns, then when the mines start going off, the game crashes. Debug.log gives the following:

Code: Select all

program state: updating events
TimedCustomEvent
m_pObj: 7944680 [invalid]
event: SelfDestruct
game state: in game

Please contact [email protected] with a copy of Debug.log. We are sorry for the inconvenience.
Below is the code for the mine, and the virtual item that gives it it's teeth:

Code: Select all


<!--Patriot Mine-->

<ShipClass UNID="&scPlasmaMine;"
manufacturer= "NAMI"
class= "Patriot Mine;"
type= ""
score= "1"
rotationCount= "1"
mass= "600"
cargoSpace= "0"
thrust= "0"
maneuver= "2"
maxSpeed= "5"

leavesWreck= "0"
>

<Armor>
<ArmorSection start="0" span="360" armorID="&itPlasteelPlate;" areaSet="0,2,3,7" />
</Armor>

<Devices>
<Device deviceID="&vtPlasmaBlast;"
 SecondaryWeapon="true" Omnidirectional="true"/>
</Devices>

<Image imageID="&rsMissiles6;" imageX="0" imageY="0" imageWidth="24" imageHeight="24" rotationCount="1"/>


<AISettings
fireRateAdj= "10"
fireAccuracy= "50"
perception= "2"
/>

<Events>
<OnCreate>
;; we register a delayed timer (45 sec - 90 sec) to activate the self destruct
(sysAddObjTimerEvent (random 1350 2250) gSource "SelfDestruct")
</OnCreate>
<SelfDestruct>
(objDestroy gSource gSource)
</SelfDestruct>
</Events>
</ShipClass>


<!-- Plasma Blast -->

<ItemType UNID="&vtPlasmaBlast;"
        name=				"plasma blast"
        virtual=            "true"
        >

    <Image imageID="&rsItems1;" imageX="96" imageY="0" imageWidth="96" imageHeight="96"/>

    <Weapon
            type=			"particles"
            count=			"1d4+4"
            damage=			"plasma:3d20+12; WMD2"
            fireRate=		"15"
            missileSpeed=	"50-65"
            lifetime=		"20-28"
            powerUse=		"300"

            particleCount=	"5d6"
            particleEmitTime="5-12"
            particleSpreadWidth="5" 
            particleSpreadAngle="3"

            sound=			"&snMissileLauncher;"
            >

        <Effect>
            <Shape
                    directional=		"true"
                    scaleLength=		"4" 
                    scaleWidth=			"3"

                    scaleLengthInc=		"3" 

                    color=				"0xc0, 0x30, 0x04"
                    opacity=			"64"
                    >
                <Point x="0"	y="0"/>
                <Point x="-5"	y="29"/>
                <Point x="-10"	y="44"/>
                <Point x="-20"	y="50"/>
                <Point x="-30"	y="47"/>
                <Point x="-40"	y="44"/>
                <Point x="-100"	y="0"/>
                <Point x="-40"	y="-44"/>
                <Point x="-30"	y="-47"/>
                <Point x="-20"	y="-50"/>
                <Point x="-10"	y="-44"/>
                <Point x="-5"	y="-29"/>
            </Shape>
        </Effect>
    </Weapon>
    <Events>
        <OnFireWeapon>
            (block nil
                ;; the 'SelfDestruct' event MUST be on the ship that mount's this weapon
                ;; and the event should hold the self-destruction code
                (sysAddObjTimerEvent 12 gSource "SelfDestruct")
                ;; we must return Nil for the weapon to fire
                Nil
            )
        </OnFireWeapon>
    </Events>
      
</ItemType>

Still has the commenting by Prophet (who made the original version of this for the Hydra mine, and also coded the Plasma Blast)

Personally, I think it's a problem with the interface between the weapon and the ship....possibly a clash with the timer. But I'm not sure.
Mischievous local moderator. She/Her pronouns.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Shrike wrote:However, if three or more mines are laid, and then an enemy ship spawns, then when the mines start going off, the game crashes.
It doesn't happen to have anything to do with the timer event being fired after the mine is already destroyed, does it? (Just a guess). Could you add debug code to check for object existence before addressing it, or something?
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

No, because I'm not familiar with using debug. What I COULD do is change it from using Selfdestruct to using two identical events, Selfdestruct1 and selfdestruct2...that would seperate the two timers.
Mischievous local moderator. She/Her pronouns.
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

I believe ptbptb is correct, the onCreate event sets a time for the self destruct which tries to fire after the ship is already gone.

Try making two separate events, one for the timer and one for the weapon to call. In the weapon event cancel the timer event to fix the bug.

The ship events should look something like this:

<ShipClass...>
<Events>
<OnCreate>
;; we register a delayed timer (45 sec - 90 sec) to activate the self destruct
(sysAddObjTimerEvent (random 1350 2250) gSource "SelfDestruct1")
</OnCreate>

Code: Select all

<SelfDestruct1> 
(objDestroy gSource gSource) 
</SelfDestruct1> 

<SelfDestruct2> 
(block nil
(sysCancelTimerEvent gSource SelfDestruct1)
(objDestroy gSource gSource) 
)
</SelfDestruct2> 

</Events> 
</ShipClass> 

Then change the weapon event to call the SelfDestruct2 event.
Hope that helps
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

you could also try to check if the mine is still there before destroying it like this:

Code: Select all

<SelfDestruct1>
(if gSource
 (objDestroy gSource gSource)
)
</SelfDestruct1> 
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

digdug wrote:you could also try to check if the mine is still there before destroying it like this:

Code: Select all

<SelfDestruct1>
(if gSource
 (objDestroy gSource gSource)
)
</SelfDestruct1> 
As far as I remember it is a little bit more involved than that. gSource will contain an id, like 98713261, so it will actually evaluate to true, even though the object does not exists... what you can do is:

Code: Select all

<SelfDestruct>
(if (not (isError (objGetID gSource)))
     (objDestroy gSource)
)
</SelfDestruct>
It does not matter what fuction you call inside the (isError ...), it just matters that if it causes the game to crash, the (isError ...) catches it and prevents that from happening. You should then be able to safely use gSource inside the (if ...)
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

Combined Alterecco and prophet's codes, and it worked...sort of. The mines no longer crash the game, but the problem is still there.

I get the following error message flashed on the game window:

Code: Select all

SelfDestruct2 [Patriot Mine;]: No binding for symbol: SelfDestruct1 ### (sysCancelTimerEvent gSource SelfDestruct1) ### 
I believe I used Alterecco's code for SelfDestruct1, and Prophet's for SelfDestruct2.
Mischievous local moderator. She/Her pronouns.
sdw195
Militia Captain
Militia Captain
Posts: 779
Joined: Wed Nov 18, 2009 1:01 am
Location: Still looking for the csc Antarctica
Contact:

why are you uesing

Code: Select all

 (objDestroy gSource gSource)
and not just

Code: Select all

 (objDestroy gSource)
Image
Image
Image
Image
"Dash_Merc - George is a genius, in that he created this game engine that is infinitely extendable"
"<@sheepluva>Good night everybody, may the source be with you." <-- FOSG dev
"You only need THREE tools in life - WD-40 to make things go, Duct Tape to make things stop And C-4 to make things go away"
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Code: Select all

SelfDestruct2 [Patriot Mine;]: No binding for symbol: SelfDestruct1 ### (sysCancelTimerEvent gSource SelfDestruct1) ### 
should be:

Code: Select all

(sysCancelTimerEvent gSource "SelfDestruct")
Note the quotes around SelfDestruct. In general you can never write a string without quotes, unless you want it to be interpreted as a function or variable.

Ohh, and having one SelfDestruct even should be enough if you check for validity before using the object
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

alterecco wrote:

Code: Select all

SelfDestruct2 [Patriot Mine;]: No binding for symbol: SelfDestruct1 ### (sysCancelTimerEvent gSource SelfDestruct1) ### 
should be:

Code: Select all

(sysCancelTimerEvent gSource "SelfDestruct")
Note the quotes around SelfDestruct. In general you can never write a string without quotes, unless you want it to be interpreted as a function or variable.

Ohh, and having one SelfDestruct even should be enough if you check for validity before using the object
Replacing the code caused it to switch back to crashing, rather than flashing the error.
Mischievous local moderator. She/Her pronouns.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

This would be easier over IRC...

I suppose you have a "SelfDestruct" event?
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

Definitely would be easier over IRC, but I have timezone difficulties fairly often.

I changed it so it cancelled the SelfDestruct1 timer.
Mischievous local moderator. She/Her pronouns.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

OK... if you have it working, then great :)

If not, please post the whole mod on pastebin or someting, as it is quite impossible to guess what is going on at this point. Also, please describe what you expect to happen, and what does happen :)

.]
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

Done! While I can't put *all* the mod on (it's a testing framework that will eventually be split into separate XMLs, and so is massive....probably over 500-600 lines all in all), all the coding for the Patriot and the plasma blast virtual weapon is HERE.

:D
Mischievous local moderator. She/Her pronouns.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Well... that is practically the same pastie... whenever i spawn that ship ingame, it just sits there and does nothing... no firing of it's weapon, no nothing. I was hoping you could just provide something that could be saved as an xml, run and then the bug would appear... i suppose you have some way of deploying the weapon? What sovereign does the ship get? In general, what is it supposed to do? :)
Post Reply