---------------------------------------------------
In my personal games my ships are stocked at the gate w/ &trCargoContainer and / or &trStationSupplies ( depends on the traffic, I have one for corporate, commonwealth & blackMarket (&trIllegalItems2 ) )
Code: Select all
(block (theShip)
(setq theShip (sysCreateShip
&tbCommTraffic;
(random (sysFindObject Nil "G -uncharted;"))
&svCommonwealth;
&evCommTrafficBehavior;
))
(objSetObjRefData theShip "home" homeObj)
; Add some items to the transport
(objAddRandomItems theShip &trCargoContainer; (random 1 4))
(objFireEvent theShip "OrderBeginTraffic")
)
Now that covers the part where the stuff comes in, but it will overload the stations if the system calls in alot of ships ..so that = ships have got to get rid of the stuff as well.
Code: Select all
ShipClass UNID="&evCommTrafficBehavior;"
class= "(commonwealth traffic behavior)"
virtual= "true"
noFriendlyFire= "true"
attributes= "behaviorClass"
>
<StaticData>
<Trade currency="credit" max="50000" replenish="25000">
</Trade>
</StaticData>
<Events>
<OrderBeginTraffic>
(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 +commonwealth; +primary;"))
(if (not homeObj)
(setq homeObj (sysFindObject gSource "TAFN +populated; -korolovShipping; -occupation;"))
)
(objSetObjRefData gSource "home" homeObj)
)
)
; Set data so we know we are traffic
(objSetData gSource "0010300C_traffic" True)
; Set state
(objSetData gSource "behavior" 'enteredSystem)
)
</OrderBeginTraffic>
<OnOrdersCompleted>
(block (behavior newBehavior allDests dockedAt allWrecks allLoot allBits)
(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 "*~f 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 "tU -Info; -Fuel;") theItem
(objGetSellPrice dockedAt theItem)
))
)
(block Nil
(enum allBits theItem (objRemoveItem dockedAt theItem))
(enum allBits theItem (objAddItem gSource theItem))
)
)
; Figure out what to do next
(switch
; Check for wrecks in the area; if we find some, then loot them
(and (leq (objGetDestiny gSource) 180)
(not (objHasAttribute gSource "freighter"))
(leq (random 1 100) 50)
; Compose a list of all wrecks in the area
(setq allWrecks (filter (sysFindObject gSource "TK N:100; +shipwreck; -uncharted; -locked;") theObj
(and
(not (objIsRadioactive theObj))
(not (objGetData theObj "0010300c_marked"))
)
))
)
(block (destObj)
(setq destObj (random allWrecks))
(shpOrder gSource 'loot destObj)
(objSetData destObj "0010300c_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))
(not
; Compose a list of stations that we could go to.
; stations that don't have too many dock ports open.
(setq allDests (filter (sysFindObject gSource "TAF +populated; -korolovShipping; -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 "0010300c_marked")
(objDestroy dockedAt gSource)
)
)
</OnOrdersCompleted>
</Events>
</ShipClass>
Code: Select all
; If we are out of fuel, then we stop
(if (and (not dockedAt
(not (objGetItems gSource "f"))
(objAddItem gSource (itmCreate &itHelium3FuelRod;(random 2 6)))
))
; Figure out what to do next
but that's just me : the wrecks have to be set so the player can't overload with loot and in one of my .xml I had them set to give up nothing if the player killed them ( they became hostile wrecks too )
but I doubt there is a totally perfect answer to the problem ..we have tried the Galactic Trader
we added refreshing dynamic inventories ...but it's always seems to just be there to bite us in the dark ...