Self-Replicating Probe

Freeform discussion about anything related to modding Transcendence.
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

found a problem in my second code (which would make the ship gate out of the system) and I've had problems with sysFindObject before:

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" (objGetPos targetStation))
		(shpOrderGoto gSource (objGetPos 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>
The problem was in using just targetStation instead of (objGetPos targetStation)
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Code: Select all

            (block Nil
               (setq targetStation)
               (setq flag 0)
            )
(setq targetStation [value]) ?
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

[quote="F50"]found another problem :oops: (thanks periculi) :

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 thisStation) ; oops!
					(setq flag 0)
				)
			)
		)
		(objSetData gSource "distPos" (objGetPos targetStation))
		(shpOrderGoto gSource (objGetPos 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>
:oops: :oops: :oops:
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

very well, but the fundamental idea is most definitely *not* flawed, we just haven't figured out the flaws in the implementation.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Code: Select all

         (if (objIsAbandoned thisStation))
            (block Nil
               (setq targetStation thisStation)
               (setq flag 0)
            )
         )
should be (if (objIsAbandoned thisStation)

You closed the if statement before giving it a function to perform.
I think if you fix that then the targetStation will be set properly.

Code: Select all

      (if (eq (objGetData gSource "distPos") (objGetPos gSource))
         (block (ship)
            (setq station (sysCreateStation &stReplicationStation; (objGetPos gSource)))
            (shpOrderGuard gSource station)
            (sysCancelTimerEvent gSource "CheckPos")
         )
      )
This one is right:
(if (eq (something) (something))

(block (ship)
...)
) <--- that's the end of the if block.


I also think you can just use flag as the condition in the enumwhile.

(enumwhile stationList flag thisStation

if you change (setq flag 0) to (setq flag Nil)

Although I assume that (eq flag 1) works just as well, I thought enumwhile needed a Nil condition to break off. Is 0 Nil?


Have you experimented with RegisterForEvents?

Man, this <OnAttackedByPlayer> tag in the Antartica mission is driving me crazy.. What triggers it? I have searched and searched and nothing seems to be connected to it. In the 0.98 release history on the main site, George states that the event was implemented for ship classes, but no mention is made anywhere about how to use it!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

:lol: I figured it out!

You have to make the Replicator a CSC. In other words, a ship/station pair that uses the station like a CSC and orders the ship to hold- it can get new orders later. Ok, so you get that and a special ship for it and a sovereign for it- and here was another tricky bit, the sov needs to be friendly. Not neutral, not enemy- friendly ONLY.

(You don't need to keep it looking or acting like a CSC, just using the same station to ship relation set up that allows the event to fire. The ship can be anything you want the station to have in the Ships tag and then the ship itself can make use of the <OnAttacked event.)

Now you can use <OnAttackedByPlayer> in the ship to fire scripts. Isn't that great. :)

I just copied a CSC station and Ship and made them into a new sovereign and then was able to have it fire the event. Once. Then I had the event fire a small countdown to another event to reset the dispostion of the Sov in order for the attacked event to fire again. That way if the attacked event was causing a event like replication, it wouldn't just fire once, it would continuosly fire while attacked by the player. I think.

Code: Select all

		<Events>


			
			<OnAttackedByPlayer>
				(block Nil
					(objFireEvent gSource "TestEvent")
					(sovSetDisposition &svSpecialSov; &svPlayer; 0)
					(sovSetDisposition &svPlayer; &svSpecialSov; 0)
					
				)


			</OnAttackedByPlayer>

<TestEvent>
(block Nil
(sysAddObjTimerEvent 30 gSource "ReCycler")
(objSendMessage gPlayerShip Nil "IT IS FINISHED!")


)
</TestEvent>

<ReCycler>
(block (target)
	(sovSetDisposition &svSpecialSov; &svPlayer; 2)
	(sovSetDisposition &svPlayer; &svSpecialSov; 2)

)
</ReCycler>
			

		</Events>
Something like that.

Edit- correction, if the Sov doesn't change like the CSC code makes it do, the event will continue to fire while the player is attacking.

Odd that it is restricted to being friendlies, maybe I will experiment some more to see if there is something I missed.

Anyhow, after a good 6 hours of frustrating backward engineering the mystery of making use of <OnAttackedByPlayer> is revealed- CSC style ships only, must be attached to a station with the shipEncounter="true" and must be a friendly sovereign.

hmm... here I am about to get blasted by my corsair 'replicating' CSC- behold the swarm of death approaching my sapphire:

Image

I set the event to fire a 4 ship creation cycle which sets the ships to be neutral to the CSC sovereign so they won't attack it, but hostile to me.

The CSC is still 'friendly' although I would have to say that unleashing all those drones was an unfriendly act. :evil:
Last edited by Periculi on Sun May 11, 2008 7:59 am, edited 1 time in total.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Swarm behavior leaves a lot to be desired:


Image

They can't hit me because they won't hit their own... we need some berserker AI modes to call up for these swarms to be any fun. There should just be a barrage of laser fire cutting through the position I am in regardless of who gets hit!

Has anyone experimented with close range weapons? Maybe with the Himal 'fly-by' behavior and a short ranged weapon the swarm might have a chance to kill me. :evil:


I did some experiments with new swarm sov- a set of sovs that gets applied to each ship randomly- the swarm ends up being comprised of 4 different neutral sovs, so a small percentage of the ships don't care if they hit the larger percent- for each sov. So, now they fire on me regardless of who is in the way of the 3 other sovs:

Image

At the end I also noticed that if the sovs were all different and the ships weren't neutral at all, they went for me more often. They are ordered to attack the player, so they don't just fight each other.

I also tinkered with the AI perception, seems that they fire more often when the perception is lower. They also seem to fire more often around 60-70% accuracy.
Last edited by Periculi on Sun May 11, 2008 7:55 am, edited 2 times in total.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I put together the samples for you to look at the code:
Sample on Xelerus

I improved the spawning code and the phases that the CSC goes through and explained some of the details I found to making a successful use of <OnAttackedByPlayer> Events.

The sample is a text file, you will need to prepare it to use it.

You will need to create UNIDs, and then alter the data for the ship to suit. I also think you could avoid the items usage for the spawns with the replicator by simply storing a variable that represents the supply or materials or whatever. If you need the items to appear on a wreck, you can write an <OnDestroy> event that looks up the variable and adds the proper number of remaining replicator widgets.

Another trick I am finding is that with a large swarm it is feasible to have them comprised of several sovs- all neutral to each other. It seems that when the CSC and the pirates are neutral dispositions, they have no problem with shooting 'through' each other, and hitting their neutral allies. Which is nice, I can see some swarm improvements coming soon. :)
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Sure, I could take a look.


If I can drag myself away from the madness:


Image

No, even with a god-modded shield I didn't last very long there.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Yes, I had an unfortunate accident with some Ranx Gunship bait, let it spill all over my cargo holds.. and as you can see the result was a Ranx feeding frenzy.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Your code has a number of problems.

Code: Select all

      (setq flag Nil)
Enumwhile functions only while your condition is not Nil. This is causing the enumwhile to not function.
(setq flag "True")

Code: Select all

      ((enumwhile stationList flag thisStation
         (if (objIsAbandoned thisStation)
            (block Nil
               (setq targetStation thisStation) ; oops!
               (setq flag 0)
            )
         )
         )
      )
((enumwhile ?

No. just do (enumwhile remove that extra set of ().

Code: Select all

    		 (sysAddObjRecurringTimerEvent 4 gSource "SplitCheck")
Every 4 frames? totally overkill. 30 frames per second, so you are checking over 7 times per second? Why not try 15 or 30 in there. :)

Code: Select all

            			(setq ship (sysCreateShip &scHunterReplicator; gSource &svReplicators; [ship]))
Where did you get [ship] from? I am not sure that the script language takes anything in a [] as a value ever. Be careful using the functions as they are written on xelerus, Betelgeuse provides samples not totally functioning code.

Also, sysCreateShip needs only 3 values. (sysCreateShip number vector number)
The sample shows [string] in there.
[string] is, I think, a word for the orders to give the ship, from what I have seen of it being used. So not ever [ship]. try 'attack or 'hold or 'gate in there instead. I usually ignore that and use a shpOrder command because I am unsure about the true purpose of the [string] in that usage.
So something like (setq ship (sysCreateShip &scHunterReplicator; gSource &svReplicators;))
and then (shpOrderAttack ship gPlayerShip) would work great.

That's just what I saw from a quick look over the code, there might be other problems but those are the major ones.

Some of your if's look fishy but I don't feel like diving into this anymore than I have already.
Post Reply