First, here is what I want it to do. Ask the player if they want to sign up for program. If they do, charge the average price of an Advanced Satellite + 30% and "Satellite Deployment Services" will place one for you.
I know it works up to two jumps from a trade dock, I'm starting my ship out from the nearest one. Once it leaves it flies out or if need be ju,ps to the sector to place the sat and "drops" it off. Then, it returns to the trade dock and goes away.
I need to work on the player input. (still figuring things out.)
I'm still testing, so still finding bugs. If you have some time to kill take a look and let me know if you might change something and way (that way I learn from my mistake).
There is a script being called, it creates my ship, names it, kits it out and returns it as a variable. I can post that, or any of the associated AL files that go with it, feel free to ask.
Here is me code so far......
and here it is after some changes to eliminate duplicate code.....
Code: Select all
Script al.tek.satdeployservices.timer
Version: 1
for Script Engine Version: 32
Creates a ship, names it and has it deploy Satellite.
1: al.PluginID , Var/String , 'AL Plugin ID'
2: al.State , Var/String , 'AL State Array'
3: Ship.ID , Var/String , 'Ship ID'
001 $AL.STATE.VERSION = 0
002 $AL.STATE.ENABLED = 1
003
004 if $al.State[$AL.STATE.ENABLED]
005 load text: id=8971
006 $Ship.ID = read text: page=8971 id=2
007 $sat = Advanced Satellite
008 $sector = [PLAYERSHIP] -> get sector
009 $race = $sector -> get owner race
010 $flags = [Find.Nearest]
011 $station = Trade Dock
012
013 $pos = array alloc: size=0
014 append 0 to array $pos
015 append 0 to array $pos
016 append 0 to array $pos
017
018 * See if satellite already exist.
019 $satellite = find ship: sector=$sector class or type=Nav. Satellite race=Player flags=$flags refobj=[PLAYERSHIP] maxdist=100000 maxnum=1 refpos=$pos
020
021 * If no satellite exist, then order one to be setup.
022 if not $satellite
023 $pcredits = get player money
024 $cost = get average price of ware Advanced Satellite
025 * Total cost to install satellite is equal to the cost of the Sat plus 30%.
026 $totalcost = $cost + ( $cost / 3 )
027 if $pcredits < $totalcost
028 $message = 'Not enought credits to have the satellite deployed for you.'
029 play sample: incoming transmission 1361, from object $Ship.ID
030 write to player logbook $message
031 else if $pcredits >= $totalcost
032 $totalcost = - $totalcost
033 add money to player: $totalcost
034
035 * Find the Trade Center to buy the Satellite from.
036 $tradecenter = find station in galaxy: startsector=$sector class or type=$station race=null flags=$flags refobj=[PLAYERSHIP] serial=null max.jumps=5
037 $trade.dock.sector = $tradecenter -> get sector
038
039 * Create the delevery ship.
040 if not $deliveryship == $Ship.ID
041 @ $deliveryship = [THIS] -> call script 'al.tek.SDS.ship.builder' : Ship ID=$Ship.ID Delivery Ship=$deliveryship Trade Center=$tradecenter
042
043 * Issue the command to fly to the deployment location.
044 $deliveryship -> set race logic control enabled to [FALSE]
045
046 skip if $sector == $trade.dock.sector
047 = $deliveryship -> use jump drive: target=$sector
048 @ = $deliveryship -> move around 3000 ms
049 @ $Deploy.Location = $deliveryship -> move to position: x=100 y=500 z=0 with precision 10 m
050 $deliveryship -> set command: [ACTION_IDLE]
051 * Deploy the satellite.
052 $sat = create ship: type=Advanced Satellite owner=Player addto=$sector x=0 y=500 z=0
053 * Then have him fly home.
054 @ = $deliveryship -> move around 3000 ms
055 skip if $sector == $trade.dock.sector
056 = $deliveryship -> use jump drive: target=$trade.dock.sector
057 *$Home.Sector = $deliveryship -> fly to sector $trade.dock.sector
058 @ = $deliveryship -> fly to station $tradecenter
059 * Destroy ship to cleanup.
060 $deliveryship -> destruct: show no explosion=1
061 set global variable: name=$Ship.ID value=$ShipID
062 end
063 end
064 end
065 end
066 return null