[MOD] TPWar Mod Tools

The place to discuss scripting and game modifications for X4: Foundations.

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

Post Reply
albysmith
Posts: 37
Joined: Thu, 6. Dec 18, 14:57
x4

[MOD] TPWar Mod Tools

Post by albysmith » Mon, 13. May 19, 05:03

https://www.nexusmods.com/x4foundations/mods/324/

Universe Health will add a folder with additional useful log files: Documents\Egosoft\X4\4531893\logs\universe_health

Set Launch Options in Steam: -debug all -logfile x4debug.log -scriptlogfiles -showfps

-scriptlogfiles is required to see the log


Check the comments at the top of Mod_Tools.xml in the md folder!
create stations
create fleet battles
warp to any sector
configure your character to have anything needed without a new gamestart




We make The Teleportation Wars and have been working on version 3 for a very long time now. In that process, we have discovered a number of undocumented things about mdscript and made some mod testing tools. If you've come across any undocumented stuff, please message @albysmith or @mewosmith on the discord (https://discord.gg/UMDw3Z).

We may be wrong about various items below either because we made a mistake in testing them, or because they were patched. Please message us on the discord if you have any issues or anything you'd like to change.


Here are some things that aren't specific to mdscript:

<rotation yaw="0" pitch="0" roll="0" /> <--- can be used in place of quaternions
defaults.xml <--- contains a bunch of default values for many parts of the game (like default plot size, faction relation changes per kill, and definitions of connection types)
software entries in wares.xml <--- Factory is the name of the menu category the software will appear under (new categories can be added in this way)
gate placement <--- gates bug when placed at 0,0,0 and misaligned gates can sometimes eat ships
buy and sell offers <--- not calculated in mdscript or aiscript; they are a black box
cluster_black2_sector01_macro <--- there is an unconnected empty sector in the vanilla galaxy; find_sector will find it unless you exclude it


Random how-to-make-a-mod stuff:

<dependency id="#####" optional="true"/> <--- add this to your content.xml file to make sure your mod loads after another mod, otherwise the order is alphabetical
g_null workaround <--- you can avoid the g_null lua error if you are ok with replacing the file; if you actually make something cool, you can come back and implement the g_null workaround
index <--- when adding things to the index, you can reference any path; you don't need to duplicate vanilla X4 and spread out your files across the universe
md.$EquipmentTable <--- when adding a new faction, you must add them to this table in Setup.xml for loadouts to work properly



Here are some things specific to mdscript:

md tends to fail positively, for example: if it's unable to evaluate your do_if value= then it will ignore the do_if and run its contents
not global.$Value <--- invalid (works without the global.)
set_known <--- need to set_known the object, zone, sector, cluster to actually see the object
get_suitable_jobs <--- cannot find inactive jobs
factionlogic <--- factionlogic operates very slowly; if you would like to create a lot of change in the galaxy, factionlogic is the wrong place to do that


Functions that we experienced poor performance with: <--- (this is just based on our experiences with them and does not reflect how the code actually works)
create_construction_plan
create_ship <- a lot worse for big ships
find_object_component <- easiest way to get in trouble for me
event_object_attacked <- triggers for every hit
Still bad performance, but immensely better than the list above:
find_whatever
warp
drones <- not as bad as full ships, but are still hogs compared to their gameplay value


Here are some things specific to aiscript:

aiscripts run on entities <--- "this" is the entity; "this.ship" is the ship of the entity
every aiscript needs a wait <--- aiscripts run as a loop until something tells it not to. As quickly as it can. Which is nice if you are looking for heat in the winter.
attention level <--- decides what functions can run based on context (like lod for script)


The universe is made of macros:
galaxy <---
cluster <--- contains the 3D skybox
sector <--- a point in a cluster; you can fly around planets if you go fast enough or wait long enough, since the sector doesn't have a border (you can even go outside the skybox)
zone <--- every object has a temporary zone (approx. 50km), but you can also define specific zones in the map files; zones will sometimes merge to form larger zones
object <--- stuff in the gameworld that has a location; zone, sector and cluster have a location and a macro but have their own find_ because they are not objects
frankenmacros <--- objects like stations are a series of other macros stitched together

datatypes <--- ships vs. cargo vs. inventory, they are all their own unique datatype with their own script properties defined in scriptproperties.xml



VScode <--- use it since it's the only thing with scriptproperty code complete
https://github.com/Cgettys/X4CodeComplete/releases

Tomonor
EGOSOFT
EGOSOFT
Posts: 1661
Joined: Wed, 12. Sep 07, 19:01
x4

Re: [MOD] TPWar Mod Tools

Post by Tomonor » Thu, 16. May 19, 02:01

No one seems to acknowledge this. Thanks for your efforts and information!
Image

swizzlewizzle
Posts: 6
Joined: Mon, 1. Oct 18, 04:17
x4

Re: [MOD] TPWar Mod Tools

Post by swizzlewizzle » Fri, 17. May 19, 08:18

This is superb - will be using these tools heavily for our testing and as inspiration for mission fleet spawning. Thanks for the contribution m8. :)
Creator - Conflicts Mod
Collaborator - X4 Star Wars

Post Reply

Return to “X4: Foundations - Scripts and Modding”