Resolving Traffic Jams (UPDATED)

Freeform discussion about anything related to modding Transcendence.
Post Reply
Fleet Officer
Fleet Officer
Posts: 1494
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska

Again, I will try to post this.......

Sometime ago I corrected the traffic Jam issue in my personal games , totally forgot to give it out.

I tried to post it , then believed I made a mistake.. so set to work trying to figure out why it wasn't working..
( I never put the .xml into the game I was , yup..I am silly..)

You may want to add it to existing .xml..or give it it's own..

I did put this in the code box as an .xml .. ready to copy and run with.
Just be sure the lines are straight, the forum does not like long lines and the game hates it when the lines aren't flowing.

****** I once tried to get others interested in the traffic jams .. but they told me to " add more ports " ..which is running away from the challenge in my I kept at it and I thinks you will like it :)

One thing you might like to try is setting stations to buy things so NPCs can sell to ( fuel depot, corporate specialty dealers ) and to Sell so NPCs can buy from ( hotel, corporate enclave ) this will increase the flow of goods and give stations an " out" on accumulating items.

Code: Select all

<?xml version="1.0" ?>
<!DOCTYPE TranscendenceExtension
	<!ENTITY adPart188Desc	                    "0xEAB36UPH">	
	 <!-- Traffic -->
	  <!-- Commonwealth private crafts -->
  <!ENTITY evCorpTrafficBehavior            "0xEAB36UPG">

   UNID=            "0xEAB36UPH" 
	 version=			"1.0"
	  name=            "Traffic"
	<!-- Corporate Hierarchy Station Base Class
	USAGE: Corporate stations should inherit from this class. Derrived classes
		should manually call OnCreate and OnDestroy in case they need to override
		those events.
		needEscorts:		TRUE if we have a station without escorts.		
	<StationType unid="&baCorporateStation;"
			name=			"(Corporate station base class)"
			virtual=		"true"

				(block Nil
					; Behavior event 
				; This only applies to corporate stations
				(objMatches gSource Nil "sTAV +corporate; +corporateArms; +corporateCustoms; +populated; -korolovShipping;")
				 (objMatches gSource Nil "sTAV +corporate; +corporateArms; +corporateCustoms; +majorStation; +populated; -korolovShipping;")
					(sysAddObjRecurringTimerEvent 90 gSource "OnBehavior")
				(sysAddObjRecurringTimerEvent 150 gSource "OnTrafficControl")
				(fulTrafficControl gSource 10)
				(block (escorts escortCount portsLeft)
				; Initialize some variables
					(setq escorts (sysFindObject gSource "sHZ O:guard;"))
					(setq dockedFreighters (sysFindObject gSource "sHZ O:docked; +commonwealth;"))
					(setq freightersInFlight (objGetData gSource "freightersInFlight"))
					(setq freighterCount (add (count dockedFreighters) freightersInFlight))
					(setq escortCount (add (count escorts) freightersInFlight))

					; Exclude freighters being escorted by the player
					(setq dockedFreighters (filter dockedFreighters theFreighter
						(not (objGetData theFreighter "korolovPlayerEscort"))

					; See if we have any docking ports free
					(setq portsLeft (gr (objGetOpenDockingPortCount gSource) 1))

					; If we don't have enough escorts, then we better get some more
					(if (and portsLeft
								(and (ls escortCount 1) (eq (random 1 2) 1))
								(and (objGetData gSource "needEscorts") (eq (random 1 2) 1))
						(block (newShip)
							(setq newShip
									(random '(&scAsterionHeavyGunship; &scBritannia; &scManticore; &scCenturion; &scRoninC; &scWolfen; &scRoninB; &scRoninA; &scArmstrongTransport; &scManticore;))
									(objGetNearestStargate gSource) 
							(shpOrder newShip "guard" gSource)
							(objSetData gSource "needEscorts" Nil)

					; Send out a freighter to a random station
						; If we have no ports left, then send some escorts away
						(and (not portsLeft) escorts)
							(block (theCount)
								(setq theCount (max 1 (subtract (count escorts) 4)))
								(for i 1 theCount
									(block (theEscort)
										(setq theEscort (item escorts (subtract i 1)))
										(shpCancelOrders theEscort)
										(shpOrder theEscort 'gate)

						; Must have freighters
						(not dockedFreighters)

						; Random interval
						(and (gr (random 1 6) 1) portsLeft)
				(block Nil
					; we scare any sister ships
				(block (targets)
					(setq targets (sysFindObject gSource "sAN:25; B:commonwealth;"))
					(enum targets target
						(block Nil
							(shpCancelOrders target)
							(shpOrder target 'gate)
					(sysCancelTimerEvent gSource "OnBehavior")
					(sysCancelTimerEvent gSource "OnTrafficControl")
			<Text id="customs.chargedForDecon">
					"Corporate security stops your ship for decontamination. "
					"You are automatically charged " (@ gData 'cost) " for decontaminating your ship."
			<Text id="customs.cantAffordDecon">
					"Corporate security stops your ship for decontamination. "
					"Unfortunately, you do not have " (@ gData 'cost) " to pay for decontamination."
<!-- BEHAVIORS -->

	  <!-- Commonwealth private crafts -->

	<ShipTable unid="&tbCommPrivateCrafts;">
			<Ship levelFrequency="uuurr -----" count="1" class="&scBorer;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="ccrr- -----" count="1" class="&scRoninA;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="ccrr- -----" count="1" class="&scSapphireYacht;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="cccrr -----" count="1" class="&scIAVLight;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="cccuu r----" count="1" class="&scEI100;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="cccrr -----" count="1" class="&scEI100M;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="ruccc uur--" count="1" class="&scEI200;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="ruucc cr---" count="1" class="&scRoninB;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="uuucc cur--" count="1" class="&scWolfen;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="rrruc ccuuu" count="1" class="&scEI500;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="-rrcc cuurr" count="1" class="&scIAVMedium;" eventHandler="&evCorpTrafficBehavior;"/>
			<Ship levelFrequency="---uu ccccu" count="1" class="&scRoninC;" eventHandler="&evCorpTrafficBehavior;"/>
	<!-- Corp Traffic Behavior
		This controls random ships that travel between Commonwealth stations.
		To use:
		1. Create the ship at a stargate
		2. Set the event handler
		3. Set the home station
		4. Call "OrderBeginTraffic"
		behavior:			Ship's current behavior
								'enteredSystem			= Ship just entered the system
								'docked					= Ship is docked somewhere
								'repairingArmor			= docking with station to repair
								'leavingSystem			= Ship is heading out of the system
		home:				Ship's home station

	<ShipClass UNID="&evCorpTrafficBehavior;"
			class=				"(corporate traffic behavior)"
			virtual=			"true"
			noFriendlyFire=		"true"
			attributes=			"behaviorClass"
				<Trade currency="credit" max="50000" replenish="25000">
			    <Sell	criteria="*U -ID;"/>
				<Buy	criteria="*t~f U  -NotForSale;"/>
				(block (homeObj)
					; If the home station is not set, set it now
					(if (not (setq homeObj (objGetObjRefData gSource "home")))
						(block Nil
							(setq homeObj (sysFindObject gSource "TAFN +corporate; +primary;"))
							(if (not homeObj)
								(setq homeObj (sysFindObject gSource "TAFN +populated; -occupation; -blackMarket; -korolovShipping;"))

							(objSetObjRefData gSource "home" homeObj)

					; Set data so we know we are traffic
					(objSetData gSource "EAB39UP1_traffic" True)

					; Set state
					(objSetData gSource "behavior" 'enteredSystem)
				(block (behavior newBehavior allBits allDests dockedAt allWrecks allLoot)
					(setq behavior (objGetData gSource "behavior"))
					(setq dockedAt (shpGetDockObj gSource))
					; If we're docked at an object, dump any loot that we found
					(if (and dockedAt
							(objHasAttribute dockedAt "populated;")
							; Compose a list of all loot on board that the station
							; might want to buy from us.
							(setq allLoot (filter (objGetItems gSource "*U") theItem
								(objGetBuyPrice dockedAt theItem)
						(block Nil
							(enum allLoot theItem (objRemoveItem gSource theItem))
							(enum allLoot theItem (objAddItem dockedAt theItem))
					(if (and dockedAt
							(objHasAttribute dockedAt "populated;")
							; Compose a list of all loot on board that the station
							; might want to sell to us.
							(setq allBits (filter (objGetItems dockedAt "*t~fU") theItem
								(objGetSellPrice dockedAt theItem)
						(block Nil
							(enum allBits theItem (objRemoveItem dockedAt theItem))
							(enum allBits theItem (objAddItem gSource theItem))
					; Figure out what to do next

						; Check for wrecks in the area; if we find some, then loot them
						(and (leq (objGetDestiny gSource) 200)
								(not (objHasAttribute gSource "solon"))
								(leq (random 1 100) 90)
								; Compose a list of all wrecks in the area
								(setq allWrecks (filter (sysFindObject gSource "TK N:100; +shipwreck; -uncharted; -locked;") theObj
										(not (objIsRadioactive theObj))
										(not (objGetData theObj "EAB39UP1_marked"))
							(block (destObj)
								(setq destObj (random allWrecks))
								(shpOrder gSource 'loot destObj)
								(objSetData destObj "EAB39UP1_marked" True)
								(objSetData gSource "behavior" 'looting)
						; If we have no destinations or randomly, we gate out
						(or (and (not (eq behavior 'enteredSystem)) (leq (random 1 100) 20))
									; Compose a list of stations that we could go to.
									; We exclude the station that we're docked with and any
									; stations that don't have too many dock ports open.

									(setq allDests (filter (sysFindObject gSource "TAF +populated; -korolovShipping; -blackMarket; -occupation;") theObj 
										(and (gr (objGetOpenDockingPortCount theObj) 2)
											(or (not dockedAt) (not (eq dockedAt theObj)))
							(block (gateObj)
								(setq gateObj (random (sysFindObject gSource "G -uncharted;")))
								(shpOrder gSource 'gate gateObj)
								(objSetData gSource "behavior" 'leavingSystem)
						; Otherwise, we go to another station
						(block (destObj)
							(setq destObj (random allDests))
							(shpOrder gSource 'dock destObj)
							(shpOrder gSource 'wait (random 10 60))
							(objSetData gSource "behavior" 'docked)
					; If we were docked at an object that we just looted, then destroy the object
					(if (objGetData dockedAt "EAB39UP1_marked")
						(objDestroy dockedAt gSource)
				(block Nil
			;; remove everything from the station
						(objEnumItems gSource "*U" theItem
							(objRemoveItem gSource theItem)


OK, I am back again........
So, what I did was just rolled up what I got

" This resolves the now Infamous Traffic Jams.

It forces the Private Craft into a useful role As well as rotates the guards for Corporate stations - the guards will no longer hog ports.

This will Also Add Sell features to stations to sell to traffic ( not the player )

Manufacturing features to at least the Ice Farm ( that I remember doing )

guards to those stations that did not have any before. "
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
Post Reply