Self-Replicating Probe

Freeform discussion about anything related to modding Transcendence.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

<OnAttackedByPlayer> is an event so it usually is getting called from another piece of code such as a timer or objFireEvent

I don't think that it fires the event just because the player is attacking.

I tried this in a station and it didn't do anything:

Code: Select all

<OnAttackedByPlayer>
(block (message)
(objSendMessage gPlayerShip Nil  "Ouch!")
)
</OnAttackedByPlayer>
On the other hand, I can't find where that event gets called in any of the Antartica code, so it's a mystery to me. It really seems to be using just <OnAttackedByPlayer> on it's own! But how?

It appears that it would be a handy event to make use of like <OnCreate> or <OnObjDestroyed>, but I can't get <OnAttackedByPlayer> to do anything on it's own like <OnCreate> does.

The same code

Code: Select all

<OnAttackedByPlayer>
(block (message)
(objSendMessage gPlayerShip Nil "Ouch!")
)
</OnAttackedByPlayer>
Placed in a ship doesn't work at all,
but this does:

Code: Select all

<OnDestroy>
(block (message)
(objSendMessage gPlayerShip Nil "You killed me!")
)
</OnDestroy>
So I think that <OnAttackedByPlayer> is a custom event, and that it is being called from somewhere obscure that makes it difficult to see how it really working. It may not even be used, it could just be a fossil.
Last edited by Periculi on Sun May 04, 2008 8:09 pm, edited 1 time in total.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

There are two problems with this code:

1.

Code: Select all

(block Nil
   (objFireEvent gSource "OnDuplicate")
   (objRemoveItem gSource &itParts; 25)
)
This code does first check to see if you have the necessary items hence your infinite drone problem.

2. <OnAttackedByPlayer> is likely not a standard event. Try using <OnDestroy> and a for loop to use all available parts.


You could prevent infinite division of ships by giving the ships only 10 parts to start and then setting a recurring timer event (using <OnCreate>) to give them parts s time goes on.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

But that's not registering the attacker.

How does the Antartica know that the Player has attacked them?
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

A better question is how does a station know that you've attacked it (and thus undocks its ships and orders them to gate). The Antarctica would likely have too big of a delay for the drones.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

An answer to either question would be great.

But more importantly: How do we make stations or ships fire events when they get attacked by the player?
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

You need to set a recurring timer event:

Code: Select all

[Events]
	[OnCreate]
		(sysAddObjRecurringTimerEvent 4 gSource "SplitCheck")
	[/OnCreate]
	[SplitCheck]
		(if (ls (objGetDistance gPlayerShip gsource) 100)
			(block (ship)
				(setq ship (sysCreateShip &scHunterReplicator; gSource &svReplicators; [ship]))
				(shpOrderAttack ship gPlayerShip)
			)
		) 
	[/SplitCheck]
[/Events]
I am currently working on checking the item requirement.

EDIT: here it is

Code: Select all

(objEnumItems gSource "" thisItem
	(if (and (itmMatches thisItem "+part;") (gr (itmGetCount thisItm) 25))
		; place code for removing items and creating ships here
	)
)
PS: all code is untested, particularly the empty string in the call to objEnumItems
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

12Ghost12 wrote:I also want a ship that finds a random planet, goes to it, and when it reaches it, creates a station.
make sure to upload your mod on xelerus, a station-creator ship would be quite useful for my future plans.

(objSetData gSource "distPos" (objGetPos (random (sysFindObject gSource "t-M"))))
look up the function (random) on xelarus, its your problem. Try using the function (item) to get a planet to go to.

If you're still stuck, I'll see if I can make some code for you.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

12Ghost12 wrote:
I also want a ship that finds a random planet, goes to it, and when it reaches it, creates a station.
make sure to upload your mod on xelerus, a station-creator ship would be quite useful for my future plans
Bobby's Luminous Conquest mod has a station-creator ship.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

A replicator race sounds neat, especially if you can do some artwork for them.

Try this

Code: Select all

<Events>
	<OnCreate>
	(block Nil
		(objSetData gSource "distPos" (objGetPos (item (sysFindObject gSource "t-M") 0)))
		(shpOrderGoto gSource (objGetData gSource "distPos"))
		(sysAddObjRecurringTimerEvent 10 gSource "CheckPos")
	)
	</OnCreate>
			
	<CheckPos>
		(if (eq (objGetData gSource "distPos") (objGetPos gSource))
			(block (ship)
				(setq station (sysCreateStation &stReplicationStation; (objGetPos gSource)))
				(shpOrderGuard gSource station)
				(sysCancelTimerEvent gSource "CheckPos")
			)
		)
	</CheckPos>
</Events>
if that doesn't work, try this. Unfortunately, this code checks to see if the object is destroyed, not if the object is a planet.

Code: Select all

<Events>
	<OnCreate>
	(block (targetStation stationList thisStation flag) ;define temp variables
		(setq targetStation Nil) ; makes sure that the ship will gate out if targetStation is not set in the loop
		(setq flag 1)
		(setq stationList (sysFindObject gSource "t"))
		(enumwhile stationList (eq flag 1) thisStation
			(if (objIsAbandoned thisStation))
				(block Nil
					(setq targetStation)
					(setq flag 0)
				)
			)
		)
		(objSetData gSource "distPos" targetStation)
		(shpOrderGoto gSource targetStation)
		(sysAddObjRecurringTimerEvent 10 gSource "CheckPos")
	)
	</OnCreate>
			
	<CheckPos>
		(if (eq (objGetData gSource "distPos") (objGetPos gSource))
			(block (ship)
				(setq station (sysCreateStation &stReplicationStation; (objGetPos gSource)))
				(shpOrderGuard gSource station)
				(sysCancelTimerEvent gSource "CheckPos")
			)
		)
	</CheckPos>
</Events>
Is there a way to check if an object is a planet?
Post Reply