
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:
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.
