[Script] Headquarters Management and Upgrade Framework - [1.1][updated 25/07/09]

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

[Script] Headquarters Management and Upgrade Framework - [1.1][updated 25/07/09]

Post by Osiris_sam » Fri, 3. Jul 09, 01:44

Headquarters Management and Upgrade Framework

Overview:
Manages Station Credits
Manages autotraders
Manages Station Traders
Produces Reports

pink ftw
Download:[.rar] ~ SPK included
Trader Description and details: See V1 update notes

Alternative download link from xdownloads:
[ external image ]

Installation:
1)Download the .rar and either
- Open the .spk file to auto install the script
-requires Cycrows Plugin Manager

- Extract the t folder to the respective *x3TC directory*/t folder, and scripts to the *x3TC directory*/Scripts folder


Description:
The ingame headquarters description brings 4 elements to your attention:
1)Credit Management
2)Locations
3)Ware Control
4)Profitability analysis

Recommended/compatible scripts
The HQ management will interact with the following scripts:
Commercial Agent (CAG) by Lucike
Economy and Supply Trader (EST) by Lucike


1) Credit management:
Once activated, this script will maintain an amount, set in the configuration menu, to all the stations you own. Profits will be Transfered back to the HQ. These are logged, and then sent back to the player ~ if using the built in money transfer

2)Locations:
The script can produces reports on the homebase locations of all of your mk3 autotraders (and ESTs) and your stations.

3)Ware control:
Again, the script can produce a report, detailing all the products you produce, and factories that produce them. This can come in the form of a logbook entry, or as a menu.
The menu will produce details on factories; for a given product.

4)Profitability analysis:
I tried to have some fun with this, but x3 doesnt like decimals... so its kinda plain. The advanced money transfer stores the last 20 pre-transfer amounts in a list, which is accessable. These values can be written to a report, or two values, selected from a menu, can be compared.


Some other features:

Autotrader assignment:
The script will assign autotraders using suitable ships the HQ owns (which arn't doing anything else, dont worry, your CLS delivering goods is safe)
An upper limit is set using the configuration menu, and gradually, the script will assign traders up to this limit. Setting this limit below the amount of traders you already have will cause the script to not hire any more. This script can automatically assign ESTs (providing you have the script installed). This option is also available on the configuration menu.

Station trader assignment:
Like the autotrader assignement. This module (yes im comming to that) automatically assigns suitable ships the hq owns to stations that dont own any. If you have CAG installed... the script will automatically assign these. otherwise, you will have to set them up yourself to do whatever.


Menu System
Main Menu
[ external image ]

Begin Hq Automation:Start the automation system.

Change number of Autotraders: Change the number of automatically assigned autotraders (default [disabled] )

Toggle use of ESTs: Enables or disables the use of ESTs as default autotraders (default [disabled])

Change Station Fund Amount: Prompts you to enter the amount to be maintainted at your stations (default 200,000)

Module Options: Opens the Module Options Menu

Ware Report: Opens either the the ware information menu, or sends a report. Type of report is set in the Module Options -> Ware Management menu

Locations Report: Sends a locations report to you.


Module Options Menu
[ external image ]

Create Report on Installed Modules: A list of the installed modules and a breif description will be sent to you.


Installed Modules: This list will change based on what modules you have installed. By default. The three modules shown above are installed (along with 2 preinstalled modules)

Credit Transfer Management
[ external image ]

Write History to Log: Writes the last 20 reports to your logbook


Write History to Log: Compare two Entries from the last 20. This will bring up two menus. Select an entry in the first menu and the second and you will get a comparison of the two. Selecting one in the first menu and not the second, will show you the entry you selected.

Change Upper Limit: Change the upper limit for HQ funds.

Change Lower Limit: Change the lower limit for HQ funds. Setting this to 0 will disable it. If your HQs funds drop below this limit, then it will take money from the player account (if available) to make it up.

Reset Profit History: Delete existing entries.


Uninstall: Self explanatory. Note: this will only uninstall until your next load. To completely uninstall this module, open the script editor, find setup.plugin.hq and delete, or comment out line 58

Station Trader Management
[ external image ]

Uninstall: Self explanatory. Note: this will only uninstall until your next load. To completely uninstall this module, open the script editor, find setup.plugin.hq and delete, or comment out line 56

Ware Management
[ external image ]

Change Report Type: Change the type of report displayed by the 'Ware Report' option on the main menu


Modules
This script is designed to have new modules linked to it. This is very easy to do. Any script writers who wish to have a go ~ details on how to do this are in the next post.

Inbuilt Modules

-> Station Fund Management
-> Autotrader Management

Pre-Installed Modules

-> Station Trader Managemnt
-> Ware Management
-> Credit Transfer Management

External Modules

-> Station Stock Manager


Ok; This script is finished, and bug free as far as i have tested.
I havnt written a readme yet, so if you have any questions, post them here, and i will answer them (or at least try).

Please report any bugs by posting them here. Also please (please please please) give me feedback ~ i want to know what you think; good or bad

Technical Details:

Command Slots used:

<t id="1144">COMMAND_TYPE_STATION_44</t>: HQ Operations: Automate

Custom Command: 8200

Text file:

8200 - L044
6000 - L044 - page 8200

Credits:
S9ilent for his smashing (livesaver) hub/station check library

Version History:
V1.1
- New module interfacing
- Modules require purchase now (already installed modules do not need to be puchased again)
- Module menu system now on the main menu page, not a seperate one
- Some bug fixes
- Community plugin manager menu system

v1.0 ~ Official beta [.rar]
- New Station Stocking
- Some modifications to the menu
- one or two bug fixes

v0.7 ~ initial Release
[0.7]


Edit [6th Dec 2015]: Added alternative download link from xdownloads. X2-Illuminatus
Last edited by Osiris_sam on Sat, 25. Jul 09, 03:35, edited 6 times in total.

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Fri, 3. Jul 09, 01:44

In the next version i will be overhauling the module system for a much more friendly method installing. (plus cost for balancing the effects)
Guidelines for Module addon creation: should you wish to make one.

This script will run any addon that is hooked onto it. But remember... this script will call your addon periodically.

To start with, you need 3 scripts.
an admin script,
a config menu script
and a execute script

The admin File:
This is the script that will interface with the framework; To save time, this can be copied (the example below has notes to assist, should you wish to make one, it can be found in the scripts folder.)

Code: Select all

Script plugin.hq.station.trader.admin
Version: 7
for Script Engine Version: 43

Description
Module - Station traders - admin
Arguments
1: task , Var/String , 'task' 
Source Text

001   * 2009 - osiris sam - hq automation framework - modular addon admin script
002   * Station trader management
003   
004   $pageid = get global variable: name='hq.pageid'
005   
006   * Definition of tasks to complete - the various tasks the script can do.
007   * these do not need to be saved as variables, but i find it helps.
008   $null = null
009   $install = 'INSTALL'
010   $Uninstall = 'UNINSTALL'
011   $run = 'RUN'
012   $Menu.opt = 'MENU.OPTION'
013   $config = 'CONFIG'
014   
015   $scr.name = get script name
016   * the all important script name. note that this script will be the one called up
017   * by the hq framework. the tasks below are the minimum tasks for the script to
018   * function correctly
019   
020   if $task == $install
021   * call the install/uninstall script
022 @ |$retvar = $null -> call script 'plugin.hq.module.hook' :  Scriptname=$scr.name  task=$install
023   |
024   else if $task == $Uninstall
025   * call the install/uninstall script
026 @ |$retvar = $null -> call script 'plugin.hq.module.hook' :  Scriptname=$scr.name  task=$Uninstall
027   |
028   else if $task == $run
029   * call the function execution script - the main script of your module
030 @ |= [THIS] -> call script 'plugin.hq.sttrader.main' : 
031   |
032   else if $task == $Menu.opt
033   * load the text from the text file to be displayed on the framework menu system
034   * the text should be returned in an array. element 0 should be the heading
035   * element 1 should be a brief description of the module
036   |$retarray =  read text: page id=$pageid, from 2000 to 2001 to array, include empty=[FALSE]
037   |return $retarray
038   |
039   else if $task == $config
040   * call the configuration menu
041 @ |START [THIS] -> call script 'plugin.hq.sttrader.config.menu' : 
042   |
043   end
044   
045   return null
pageid ~ load the text file id that you will be using, mine is 8200
task ~ what task is this script going to run

script name ~ this is how the scripts interact, make sure this line is in there.

Install ~ register your addon with the script, done by calling plugin.hq.module.hook with task INSTALL

Uninstall ~ Unresigester your script, again by calling plugin.hq.module.hook but with task UNINSTALL

run ~ call the script which makes your addon do what it does

Mod opts (module options) ~ an array containing the display name of your script, and a breif description. name=Array[0], description=Array[1]

Config ~ call the configuration menu for your addon



The modules are first installed by setup script, along with loading the other things you need:
text files, hotkeys

you need a line which looks like

Code: Select all

055   * install default modules
056 @ = $null -> call script 'plugin.hq.station.trader.admin' :  task='INSTALL'
057 @ = $null -> call script 'plugin.hq.ware.admin' :  task='INSTALL'
058 @ = $null -> call script 'plugin.hq.transfer.admin' :  task='INSTALL'
To be safe, load the game with the framework installed at least once before you install another addon

If you're unsure of any part of this, drop me a pm... im happy to help.
Last edited by Osiris_sam on Fri, 17. Jul 09, 19:39, edited 1 time in total.

Lancefighter
Posts: 3144
Joined: Sun, 19. Dec 04, 02:41
x4

Post by Lancefighter » Fri, 3. Jul 09, 08:52

thats pretty cool - i remember this from x3r..

I just got one question - does it work this time?

I mean, if I give it my HQ and a sum of money (say, 10 mill), will it be able to stock the HQ for production (will it queue production/repair tasks?) and make a profit through est/ut?

You also say that it manages your stations.. So I can plop down stations, and it will 'take care' of them?

You say that it transfers money to/from the player, would it be possible to remove the player wallet from this, and instead use the HQ wallet, and request funds from the player if it needs to, through a incoming message? (i see it being like "attention, your headquarter wallet is under the recommended minimum, we need a bailout!"

It seems like a brilliant idea, if done right (i probably said the same last time), and i want to make sure it does what you say it does first :wink:

edit!
Does it DEFEND itself? Will it defend its factories or transports?

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Fri, 3. Jul 09, 12:49

Yes, it does work. ive tested each functions, but that doesnt mean i havnt overlooked bugs (not intentionally ofc)

No, atm, it wont stock the HQ for production ~ but this could be written as an addon (maybe). EST/UT profit still goes to the player, the script doesnt monitor that ~ i need to ask someone more on terms with that script to find out exactly how money is transfered before i attempt that

If you plop down a station, it will do 2 things.
Firstly it will give the station X credits (default 200,000) ~ setting on the config menu
If the HQ has an unused TS (only TS) landed on it, with the HQ set as homebase, it will assign this ship to the station, either as a CAG (if installed).
If no cag is installed... then you will need to set the trader up (im not writing a very basic station manager script - i hate trade scripts)

The HQ will not;
set ware prices, although a module for this is probably possible
pre-stock the station, also possible through module... but probably pushes the 'the script is playing my game' boundry

The transfer script could be modified to have another source, a private bank if you will, but i dont see the advantage of this over taking directly from the player ~ either way, the player is gonna have to put money into it.
The lower limit can be disabled, so the script basically becomes the default egosoft script with profit management inbuilt

ATM, it doesnt defend itself. or factories, or transports.
the way i see it, the trade scripts in existence - apart from the stock ones, have enough warnings (message book, incomming messages, etc...) for you to protect your own ships.
(not defending your HQ is a kinda bad idea ~ unless you dont mind cheating another one in)

final note: this isnt the same script as X3:R, even if it has some of the same functions... the are most likely executed in a completely different way. (even the credit distrubution code, believe it or not)

Lancefighter
Posts: 3144
Joined: Sun, 19. Dec 04, 02:41
x4

Post by Lancefighter » Sat, 4. Jul 09, 03:44

Looks pretty good - I may use this to manage my HQ and stations... After i find someplace to put it lol

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Sat, 11. Jul 09, 03:50

Version 1 Release
[.rar]

Changes:
- Some bug fixes
- Some improvements to the menu system

- New module - Station Stock Management

New Module overview:
Lancefighter wrote: You also say that it manages your stations.. So I can plop down stations, and it will 'take care' of them?
Now it does

Description
The Station Stock Module will stock newely built stations using a designated trader.
This script comes with a custom trader script which will be described in more depth in this post.
Stations will be stocked to 20% by default... but this amount is changeable through the normal configuration menu

Trader Functions

The trader can be assigned to any station or TL.
The Homebase must be set, but it can be set to another station

Setting the homebase to the same station as the one you designate to supply will lock the ship to the station, i.e it will continue to supply that station continuously. Otherwise it will stock it once and then return home.

To assign the ship to a tl ( which will unload specified wares from the ship to the homebase) a station homebase must be set. Choosing a TL as the stock target will open a list of wares, and then asks if it should be locked to the task.

any questions, comments, bugs or feedback PLEASE post them here

Lancefighter
Posts: 3144
Joined: Sun, 19. Dec 04, 02:41
x4

Post by Lancefighter » Sat, 11. Jul 09, 04:06

edit
nvm
Last edited by Lancefighter on Thu, 16. Jul 09, 11:38, edited 1 time in total.

Nho
Posts: 180
Joined: Fri, 24. Feb 06, 18:19
x3

Post by Nho » Thu, 16. Jul 09, 11:12

Sounds great! I just need an HQ to try it :)

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Sat, 25. Jul 09, 03:34

Version 1.1 Released (25/07/09)

Download:[.rar]
V1.1
- New module interfacing
- Modules require purchase now (already installed modules do not need to be puchased again)
- Module menu system now on the main menu page, not a seperate one
- Some bug fixes
- Community plugin manager menu system

End note:
Please provide feedback, i want to hear what is good or bad about this, bugs or otherwise.

TingTung
Posts: 3
Joined: Tue, 11. Aug 09, 13:20

Post by TingTung » Tue, 11. Aug 09, 13:32

How exactly do you get the scrip to work? I've installed it using the SPK, but when I build an HQ in game I can't do anything special with it.

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Tue, 11. Aug 09, 14:02

once the phq is built and the script is installed, open the hq command console, select a free command slot (as you would to activate any other command). HQ operations: automate should be on the list of available commands.
Selecting this, will bring up the menu, from which you start the system and change settings.

If that command fails to appear, could you pm me a list of the scripts you have installed. as well as;

could you also check that the text files are of the correct version (the script will not load unless the text files are the correct version)
this can be found by opening t/ 8200-L044.xml
on the first entry <t id="0"> the number should be 11 ( for version 1.1).
a message is also added to your log if the script is terminated in this way, checking for that will save you the hassel of opening the text file. (depeding how cluttered your logbook is :P, a new message should appear at each load if the t file is wrong)

TingTung
Posts: 3
Joined: Tue, 11. Aug 09, 13:20

Post by TingTung » Wed, 12. Aug 09, 19:28

Alright, that's the problem, using the cheat plugin, I added a Headquarter to a TL and then built it. When it was built I looked into the command slots to see what I could and nothing about station management was in place.

Installed plugins are as follows :

Cheat Collection Package
HQ Management
Property Baron

Also, your 1.1 SPK is broken, it's updating something that doesn't have the same name. The version numbers can be different but the package name can't be.

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Thu, 13. Aug 09, 18:51

a cheated in hq should work just fine (i tested this way). its more likely due to the spk problem. im not sure how that has arisen, i actually just changed the first file :\. ill fix and reupload.

TingTung
Posts: 3
Joined: Tue, 11. Aug 09, 13:20

Post by TingTung » Fri, 14. Aug 09, 16:24

Perhaps it's the version of X3 I'm running? I'm on 1.4

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Sat, 15. Aug 09, 15:26

that is also an issue, this script was written and tested in 2.0/1, so its probably not compaitble with 1.4

mobile_dan
Posts: 3
Joined: Sat, 13. Sep 08, 10:56
x3tc

'HQ Automation: This version of X3:TC in not compatable with this script'

Post by mobile_dan » Sun, 13. Jun 10, 09:21

WOW
if this works it would be the answer to all my head aces. However

I get this message after installing the script using Cycrows Plugin manager

'HQ Automation: This version of X3:TC in not compatable with this script'


I have tried if with X3:TC 2.6 with and 2.7 but with no luck.


Please help.



DAn
In a world with out walls or fences, why do we need windows or gates.

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Mon, 14. Jun 10, 11:38

i need to test this for the superbox, Ive not had time recently to check or update my scripts because of exams etc. Hopefully i will be able to check, and fix any problems running in v2.7

:EDIT: Version 1.1 works just fine with v2.7, i tested it reasonably thoroughly last night. I am fairly happy to help resolve the issue now i have some more time.

Sam

russbo
Posts: 862
Joined: Sat, 12. Nov 05, 21:53
x4

Post by russbo » Fri, 18. Jun 10, 01:02

OS, so how do you get this script to keep a certain lower limit of credits in each station? I thought i set this up correctly, but it's not working.

BTW, this script is a great accompaniment, and a necessity, to use in conjunction with this: http://forum.egosoft.com/viewtopic.php?t=280620

russbo
Posts: 862
Joined: Sat, 12. Nov 05, 21:53
x4

Post by russbo » Fri, 18. Jun 10, 01:33

OH, I see that you need the money in your HQ before it can transfer it to your stations. I think.... (it keeps buying stuff with the money I put into it, LOL)

EDIT: but after a few hours, the lower limit for PHQ is not maintained, despite plenty of money in the player account, and the lower limit (nor upper limits) are not managed with all of the other stations. Does this script work with existing stations, or just newly built ones after the PHQ starts the automate command? I'm using TC 2.7

Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam » Thu, 24. Jun 10, 14:36

The HQ doesnt consider new stations any different from old ones. In fact, it recreates the list of player stations with every cycle.

Did you purchase the module (main menu -> purchase new modules), that may be the problem

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”