Fleet wingman behavior help please

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Fri Aug 30, 2019 4:13 am

Looking to upgrade the Binary System Stargates mod. This mod puts a small stargate near each star in binary systems. The player can use the gates to jump to the other gate rather than fly all the way between stars.

I have the next version already jumping autons and character wingmen to the other gate but Fleet wingmen are quite erratic. I believe the 'fleet' controller code is hard-coded so I have no idea how it works.

This code:

Code: Select all

(enum shipObjectList theObj
	(block Nil
		(objSetPos theObj destGate)
		(objSetVel theObj Nil)
		(shpOrderImmediate theObj 'wait 2)
	)
)
works fine for autons and Volkov. They wait for the specified time and then deploy to their escorting positions.
But Fleet wingmen just stay frozen at the gate. They do not end the 'wait' order and also no longer appear in the 'Communications' menu.

Code: Select all

(setq fleetShips (sysFindObject gPlayerShip "sJ:&svCommonwealthFleet;; O:escort;"))
I have tried various things like setting behavior to 'escorting, setting the ship controller to Nil then back to 'fleet, canceling the orders then re-ordering them, plus combinations of all of these but nothing works.
The Fleet ships either don't gate with the player and fly to the other gate, disappear or gate and stay waiting forever.

Has anyone got any tips on how to make the Fleet ships jump with the player, stay in position for the specified time and then deploy to their normal formation?

Mod attached where the Fleet ships just stay at the gate waiting forever.
Also an override mod which makes C1 a binary system for every game.
Attachments
BinarySystemStargates dev 16.zip
(282.11 KiB) Downloaded 20 times
Make C1 binary.xml
(17.85 KiB) Downloaded 22 times
Stupid code. Do what I want, not what I typed in!

NMS
Militia Captain
Militia Captain
Posts: 551
Joined: Tue Mar 05, 2013 8:26 am

Fri Aug 30, 2019 5:52 pm

Here's the code that creates Fleet wingmen:

Code: Select all

					(for i 0 (- aCount 1)
						(block (wingmanObj)
							(setq wingmanObj (sysCreateShip
								theClass
								baseObj
								&svCommonwealthFleet;
								'fleet
								))
							(shpOrder wingmanObj 'escort gPlayerShip i)
It assigns them a formation position. Maybe the Fleet controller requires that and can't remember it through another order? Try creating an event that runs when you want them to rejoin the formation and does something like:

Code: Select all

(for i 0 (- (count shipObjectList) 1)
	(block (
		(theObj (@ shipObjectList i))
		)
		(shpCancelOrders theObj)
		(shpOrder theObj 'escort gPlayerShip i)
		)
	)

relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Mon Sep 02, 2019 3:38 am

Thanks. I'll give it a go.
I tried 'enum'ing orders back onto the ships but not with the formation. Fingers crossed!
Stupid code. Do what I want, not what I typed in!

relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Mon Sep 23, 2019 4:32 am

Thanks. Using the 'i' value helped. The Fleet wingmen would deploy to the Fleet formation after gating.
It seems these positions must be defined in the controller code (maybe CFleetShipAI.cpp). Setting the controller to 'auton or Nil had position 7 out in front of the playership whereas the Fleet controller postion 7 is to the right and back.

But I can't find a way to break the 'wait order. Or 'hold either.
The ships will hold or wait indefinitely regardless of the time entered into the orders. 'shpCancelOrders' just jumps straight to the 'escort order. I tried a timer event without success but poor code probably contributed. I don't have much experience wth events.
I also tried changing the ship controller to 'auton or Nil, giving the orders, and then resetting it to 'fleet but no success there either.

Another idea for the too hard basket for a couple of years!
Stupid code. Do what I want, not what I typed in!

NMS
Militia Captain
Militia Captain
Posts: 551
Joined: Tue Mar 05, 2013 8:26 am

Mon Sep 23, 2019 6:55 am

Maybe old controllers don't have an order queue at all? So you'd have to use an event that runs when you want them to return to formation. E.g.

Code: Select all

(block Nil
	(enum theObjList theObject
		(shpOrder theObject ...)
		)
	(sysAddTypeTimerEvent delay myType myEvent)
	(typSetData myType 'objList theObjList)
	)

...

<MyType>
	<Events>	
		<MyEvent>
			(block ((i 0))
				(enum (typGetData myType 'objList) theObject
					(block Nil
						(shpOrder theObject 'escort gPlayerShip i)
						(setq i (+ i 1))
						)
					)
				)
		</MyEvent>
	</Events>
</MyType>

relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Wed Sep 25, 2019 3:49 am

Cool. It usually takes me hours of trial and error to get events working. I'll give your code a go. Thanks.
Stupid code. Do what I want, not what I typed in!

relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Fri Sep 27, 2019 2:01 am

Nope. For some reason the 'escort order is always applied instantly regardless of timer event delays. 'shpSetController' may be priority code which always runs instantly or something.

Last version attached. The Fleet ships always go straight to the formation position regardess of the first order given, here 'dock but 'wait and 'hold were also tried with and without delay times.

Anyone can feel free to muck around with it. I'll update the mod so wingmen and autons gate with the player and include a note that Fleet wingmen don't use the gate.
Attachments
BinarySystemStargates dev 17.zip
(282.32 KiB) Downloaded 9 times
Stupid code. Do what I want, not what I typed in!

NMS
Militia Captain
Militia Captain
Posts: 551
Joined: Tue Mar 05, 2013 8:26 am

Fri Sep 27, 2019 7:47 am

It works if you set a reasonable delay value. It's in ticks.

However, Fleet escorts can get left behind if you gate back immediately, before they form up. That's probably not what you want.

Also, if you wanted to imitate real stargates, you could use a recurring event to have the escorts teleport one at a time, and play an effect for each.

relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Wed Oct 02, 2019 2:56 am

NMS wrote:
Fri Sep 27, 2019 7:47 am
It works if you set a reasonable delay value. It's in ticks.
Aargh. That caught me out in an earlier version. Confusion between the timings values in code. :? I must have regressed back again. Many thanks.
Stupid code. Do what I want, not what I typed in!

NMS
Militia Captain
Militia Captain
Posts: 551
Joined: Tue Mar 05, 2013 8:26 am

Tue Oct 15, 2019 5:35 am

I just remembered, this will also break if the player saves and loads between using the gate and the escorts coming through. You would need to store the IDs using objGetID and objGetObjByID, or maybe store the data on the gate object and use objSetObjRefData and objGetObjRefData. (I'm not sure if that works with a list of objects.)

relanat
Militia Captain
Militia Captain
Posts: 817
Joined: Tue Nov 05, 2013 9:56 am

Sat Oct 19, 2019 7:45 am

Although your sequential move idea is great it is beyond my coding skills ATM. The mod will work as such.
1. Move the playership to the center of the other minigate. Add a 'ship freeze' overlay similar to the EP start effect to freeze the ship for 1 or 2 seconds real-time.
2. Move character wingmen and autons to the center of the other gate. Order them to 'hold or 'wait (whichever one doesn't let them fire on nearby enemies) for the same time period. This simulates the freeze on the playership.
3. Move Fleet wingmen to the center of the other gate. Order them as per wingmen for the same time period.
4. After the relevant time period remove the 'freeze' overlay from the playership, change the wingmen/auton order to 'escort and change the Fleet orders back to 'escort with attention to Fleet controller formations. All objects will then deploy to their previous positions.

The 'freeze' is because I found an instantaneous jump to be a bit jarring. Tiber also had some great ideas for effects which I will mess around with.

Because all the objects are found using 'sysFindObject' and moved in the same 'block' of code for every gating there shouldn't be any problems with anyone getting left behind (he says with fingers crossed).

Note to self: check for existing 'wait orders.

Thanks for the tip.
Stupid code. Do what I want, not what I typed in!

NMS
Militia Captain
Militia Captain
Posts: 551
Joined: Tue Mar 05, 2013 8:26 am

Sat Oct 19, 2019 8:46 pm

relanat wrote:
Sat Oct 19, 2019 7:45 am
Because all the objects are found using 'sysFindObject' and moved in the same 'block' of code for every gating there shouldn't be any problems with anyone getting left behind (he says with fingers crossed).
If you don't store the ships' IDs, then if the player saves and loads during the delay, the event that orders them to return to formation won't work. Also, if the player can use the gate again during the delay, the sysFindObject code you're using won't find the ships that haven't returned to formation yet, so they won't be teleported back. The fix for this is probably to get the list of ships waiting to be ordered to return to formation and append the new list of ships you find. Just remember to clear the list after giving them their orders.

Post Reply