Problem with onDestroy event

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
kurukku
Anarchist
Anarchist
Posts: 6
Joined: Thu Jul 27, 2006 11:51 am

Hi folks,

I am working on a little mod making EI100s really carrying goods. But of course this shouldn't be a welcome to players to shot down freighters en masse to loot them. So I thought that the Corporation should send a gunship as a enforcer, when a freighter is shot down.

I tried to make it with a onDestroy-Event taking the code from the intCorporateOnDestroy, but sadly it doesn't work. I get a 'content missing'-error for the sysCreateShip. Has anyone an idea, why it doesn't work? Is onDestory valid for <ship> anyways?

My Code:
<Events>
<OnDestroy>
(block (corporateHunter)
; Create a corporate hunter to avenge the freighter
(setq corporateHunter
(sysCreateShip &scCenturion; (objGetNearestStargate gPlayerShip) &svIndependent;) ***
)

; If someone destroyed the freighter, avenge
(if aDestroyer
(block Nil
(objSendMessage gSource gPlayerShip "Security alert! Deploy corporate enforcer!")
(shpOrderAttack corporateHunter (objGetOrderGiver aDestroyer))
)
)

; Take all the items from the freighter (so that others won't loot it)
(shpOrderLoot corporateHunter gSource)

; Gate out
(shpOrderGate corporateHunter)
)
</OnDestroy>
</Events>
*** At this position the parser says content missing.
Yugi
Fleet Officer
Fleet Officer
Posts: 1027
Joined: Sun Mar 05, 2006 8:21 am

Well, have you made the coding for this "corprateHunter"? Please send the whole .xml so some of us can debug it :)
User avatar
evilbob
Militia Captain
Militia Captain
Posts: 555
Joined: Sun Mar 05, 2006 1:23 pm

yeah, I want to make my own version, so having one to debug and look at will help.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

What are those three asterisks (***) at the end of the sysCreateShip line?

That would definitely be a problem.
User avatar
kurukku
Anarchist
Anarchist
Posts: 6
Joined: Thu Jul 27, 2006 11:51 am

@yugimoto
The problem isn't in the rest of the ship definition, it's strictly in the pseudo-lisp code. The rest of the code is quite trivial and does work, when I comment the event out. Here's the complete source. (Not documented, but as said it's quite trivial. The critical part is commented out.)

@george
That's just a mark for the line, the parser gets stuck. Sadly it got misplaced here. ;) Of course it's not in the source. :roll: The debug.log reads: Unable to parse kuru-freight.xml: Line(94): content expected Line 94 is the line where I sysCreateShip.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Looks like scCenturion and svIndependent are not defined in the ENTITY section. That could be the problem.
User avatar
kurukku
Anarchist
Anarchist
Posts: 6
Joined: Thu Jul 27, 2006 11:51 am

Ah, thanks what a stupid mistake. I shouldn't code such stuff on too hot days. Well, it works now, but for a little thing. gSource isn't set. I thought that would automatically set to the object that invokes a piece of code. Am I wrong with this and if so, how can I set it?

Uploaded code updated to a functional version.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

I don't have the code in front of me, but I believe the OnDestroy code sets the gStation global instead of gSource.

Because OnDestroy started out as a station event, it is called gStation even for ships.

Not sure what to do about that--I might do a global rename (gSource everywhere) but that would break a bunch of extensions.
User avatar
kurukku
Anarchist
Anarchist
Posts: 6
Joined: Thu Jul 27, 2006 11:51 am

Not sure if it works. Well, actually the 'loot' part isn't that important I guess.
Yugi
Fleet Officer
Fleet Officer
Posts: 1027
Joined: Sun Mar 05, 2006 8:21 am

Btw, Kurukku, where is your username from?
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

kurukku wrote:Not sure if it works. Well, actually the 'loot' part isn't that important I guess.
I wouldn't mind hearing some more details. Why doesn't it work? What happens?

I assume that the Centurion attacks whatever ship destroyed the freighter. Then, *after* the attacker is destroyed, the Centurion should loot the wreck and gate out. Is that not what happens?

Anyway, I've made a couple of changes in the next version, thanks to your post:

1. I have made the error message better when you forget to define an entity. Now it tells you that an entity is undefined (rather than the obscure "content expected")

2. I have changed all places to use gSource instead of gStation for the target of the event. This will make it consistent and easier to remember (hopefully).
User avatar
dvlenk6
Militia Captain
Militia Captain
Posts: 519
Joined: Sun Mar 05, 2006 6:56 am
Location: Sanctuary and beyond
Contact:

george moromisato wrote:2. I have changed all places to use gSource instead of gStation for the target of the event. This will make it consistent and easier to remember (hopefully).
Will that mean that current extensions that use gStation for event targets will need to be re-written to use gSource?
Not complaining, just asking :o .

- - - - -

EDIT - @kurukku

Code: Select all

(objGetNearestStargate gSourcep)
gSourcep? Not familiar with what the p is for.
"War is hell."
-William Tecumseh Sherman
http://dvlenk6.blackraven3d.com/transgals.html
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

dvlenk6 wrote:Will that mean that current extensions that use gStation for event targets will need to be re-written to use gSource?
Yes, unfortunately, it does. I've also changed DockScreens to use gSource (basically everything uses gSource now).

It didn't take me long to search/replace in all of my source code. Hopefully it won't be too bad for extensions either.
User avatar
kurukku
Anarchist
Anarchist
Posts: 6
Joined: Thu Jul 27, 2006 11:51 am

@dvlenk6
Just, a typo, I didn't saw, as I use gPlayerShip in my script right now.

@george
Thanks, I guess that will make things definitely easier!
Post Reply