Modding Questions
Hi all,
I played T2 extensively many years ago now, under a different username. Base game, Renegades mod (AFO and Epoch clans), and especially Construction. Construction definitely helped me get started in my career of coding. Periodically I've been checking back in to see what's new and play a few CTF rounds here and there. I'm glad the servers are still up and it's amazing that Krash has been hard at work making the game even better.
I'm on sabbatical from my work right now, and decided to go back and mess around with some modding again for fun. I remember a few things from way back when, and other things I've been figuring out along the way, and overall it has been a tad easier now that I have more programming experience.
I had a few general/ workflow questions for those who have done a lot of T2 modding though. I thought I might ask here, since I know there's some people still active. Any help is appreciated.
1) Is there a programmatic way to enumerate all the .dts shapes and .wav files? I got a list of .dts files using grep/strings, but the same didn't seem to work the same for .wav. More generally, is there a good way to cycle through them to figure out which might fit for a given $widget? I vaguely remember way back, that when making a simple custom gun, I was cycling through audio clips somehow to see what would fit for the spinup state, but I don't remember how I was doing that.
2) In a similar vein, is there a python dir() equivalent for TGEA scripting? I know the console has tab complete which helps, just not sure how that is implemented and if I could do that from .cs scripts. Sometimes it's a roundabout process to get a handle to what I'm trying to inspect from the console.
3) What is the workflow people use to test datablock changes? For one example, I'm looking to speed up the iteration process for trying to make a new gun that's composed of multiple ShapeBaseImageData definitions, so to make sure the layered images look right. As another example, tweaking particle colors. I've realized that for some tweaks, like a shotgun's projectiles, it's easiest if the definition is in an e.g. onFire function, because those reload easily and cleanly. I'm curious if there's a comparable mechanism for datablocks that I'm missing. I have a feeling I need to just make a handful of helpful scripted primitives for the particle color example.
4) I remember Thyth and/ or Linker having a script that could copy another player's construction build pieces. Has anyone attempted to use that sort of technique to build a custom map with e.g. a space ship pre-built in it? I remember blnukem had some combat construction mod (CCM) scenarios, and one involved leading a team assault against a freighter (which honestly I can't remember if that was a construction build or not). I just don't know if he/ his team baked that into a map itself or just loaded it manually from build save. I would bet the latter if it was construction. In any case, if someone hypothetically could bring a construction build into a map, would that map then require download ahead of time, or could it still be loadable by everyone like e.g. Flatdash?
-Arg0
Comments
1: You can query the resource manager's file list through script using
findFirstFile(pattern),findNextFile(pattern)andgetFileCount(pattern). In the patched version, you can use multiple*wildcards, and multiple?single unknown character matches, but in the standard version it's best to just use a single wildcard, i.e.audio/*.wavas your search pattern. The most common way you'll see this used in for enumeration isfor (%file = findFirstFile(%pattern); %file !$= ""; %file = findNextFile(%pattern))and a suuuuper basic way you'd use this to dump a list or cycle through waves could look something like:function findWaves() { %fo = new FileObject(); %fo.openForWrite("wave.txt"); $CurrentWave = 0; $TotalWaves = 0; %search = "*.wav"; for (%wav = findFirstFile(%search); %wav !$= ""; %wav = findNextFile(%search)) { %wavStart = strstr(%wav, "audio/"); if (%wavStart != -1) %wav = getSubStr(%wav, %wavStart + 6, 1000); // if (alxGetWaveLen(%wav) == 0) // continue; %fo.writeLine($TotalWaves TAB %wav); $Wave[$TotalWaves] = %wav; $TotalWaves++; } %fo.close(); %fo.delete(); GlobalActionMap.bind("keyboard", "ctrl ;", "playNextWave"); } $WaveHandle = ""; function playNextWave(%keydown) { if (!%keydown) return; alxStop($WaveHandle); %wav = $Wave[$CurrentWave]; $WaveHandle = alxCreateSource(AudioChat, %wav); alxPlay($WaveHandle); echo("Playing wave file [" @ $CurrentWave @ "/" @ $TotalWaves - 1 @ "]" SPC %wav); if ($CurrentWave++ >= $TotalWaves) $CurrentWave = 0; }Of course, the utility in playing thousands of waves in sequence is a little limiting, so it'd be easier if they were in a GUI element or just played externally.
2:
%obj.dump();will list the fields and methods attached to an object in the console3: If you want to change datablocks while ingame, the server needs to run
%client.transmitDataBlocks(0);after every change to reset the entire set on any client you want to see these changes. You'll also want to make sure that this is avoided if the previous transmit hasn't completed, avoid changing the number of datablocks while running if you can, and to that point avoid referencing any datablock that the client wasn't made aware exists at an earlier point (they'll almost certainly crash if for example you created a new projectile datablock and fired it before they've been sent that datablock).4: Construction mod save files are essentially just scripts with a list of commands to create a set of static shapes and assign certain properties. The CCM/ACCM servers were typically actively managed by the admins with normal save files and a period of setup and chat commands run to keep events going. They weren't baked into the maps because you could set up multiple scenarios or just wipe and reset everything by loading a save at any point.
The saves do have Construction-specific datablocks and function calls included, but generally speaking for a simple building using beams/pads there's nothing that'd prevent them from being included in any mission file, and they don't have to use any content that requires a download. There have been a few mods that've used Construction saves for one thing or another. It'd be a little more advanced to parse the save and convert them into interior blocks to be fully static and cast shadows, but that's also been done in the past.