Author Topic: CRZ's Utility Scripts.  (Read 1131 times)

0 Members and 1 Guest are viewing this topic.

CRZ's Utility Scripts.
do you like mines?
do you like motherships capable of creating fighters and turrets?
If you do than I have the scripts for you. with new fangled LUA technology researched probably 20 years ago aspiring mission makers can now own and operate these mines and factory ships.
The Mine Script:

My minescript is a fairly comprehensive script designed around weapon classes as mines (i.e. a cyclops detonating at a set range from enemy targets.)
There are a few functions for mine. There are a few ways to set it up, either using the SEXPs or the hooks-sct.tbm file. Scripting is preferred, and is necessary for custom functions (such as the homeworld style mines).

For the SEXPs the important things to note are before placing any mines first start the mine script either with lua-mine-set-active or lua-mine-activate-altMethod SEXP with true as it's argument.

For adding a new mine use the lua-mine-addOrMod-element SEXP (NOTE that this will carry over between missions as long as the player does not restart the game so add or alter mines to desired outcomes each time the mission starts).

Be aware that after every mission if you use the newer checking system (either through the SEXPs or you want it done through the hooks-sct.tbm file) you'll need to reactivate the script at the start of the next mission. To change this behaviour remove the lines
Code: [Select]
mineTable.newCheckSystem = false
mineTable.newCheckTime = 0.25
and if you always want the script to use the newChackSystem add the line
Code: [Select]
mineTable.newCheckSystem = true
after the line
Code: [Select]
require "mineScript"

if a mine is already added SEXPS such as


can alter mines even further allowing for a wide variety of effects to occur.

The alternate method is to alter the hooks-sct.tbm. the functions are:

Code: [Select]

weaponClassString is the weapon class to turn into the mine (such as "Harpoon" or something)

isMissileMine is a bool function to tell the script if upon mine detonation, the mine should launch missiles

weaponToCreate is another weapon class with the missile to create in it. This argument is a string (something like "Harpoon"). if the previous argument is false than any string will do. (technically it doesn't have to be a missile)

numMissilesToCreate determines the number of missiles to make upon detonation. use any integer greater than zero (at or below zero will do nothing, which defeats the purpose). Place any number in if isMissileMine is set to false

rangeToDetonate is the range (center of weapon to center of target ship) to detonate at. 1000m means a ship 1000m away will trigger the mine. use a number greater than the distance from the center of the ship to the edge of it's model. (something like multiple km would be needed against a destroyer for an example)

launchedMissilesTargeted when applied to a missile mine will tell the missiles launched from the mine to target the unit it was launched against (useful if you want to launch a cyclops from a mine or whatever).

stealthRangeMultiplier is the multiplier for the detonation range on ships that have the stealth tag (any stealth ship). a number of zero or less prevents the mine from detonation while a number of 1 allows the mine to detonate at the same range for both stealth and non-stealth ships. a number greater than one means the mine will detonate further away on ships with the stealth tag and a number below 1 but above 0 will make the mine detonate below the target (0.5 means the mine detonates at 500m away on stealth ships if the mine normally detonates at targets 1km away). Optional, defaults to zero.


The function below makes the mine fire the weapon missile or other weapon at the target with a plater defined lead
Code: [Select]


WeaponClassString must be the same as the above function (i.e. Harpoon).

targetLead determines how much target

delayVar determines the gap between subsquent weapon firings

addOrRemoveLaserMine determines if the mine becomes a targeted time or if that functionality is removed from the mine (set to true unless you're altering a mine mid mission or something)

The Function below handled random detonation (checked per ship per sweep cycle.
Code: [Select]

weaponClassString same as createMineTableElement() function.

highterCheck max integer to check in the fandom function

thresholdToDetonate is the number above which the mine will detonate (the number being checked is a random number between 1 and higherCheck

The function below handles what types of targets mines can hit
Code: [Select]

weaponClassString is mine to alter

{Object Type} is the types of objects to allow the mine to target (as determined by object-types.tbl In table form {"Fighter","Bomber"} means the mine only detonates on fighters or bombers. All table elements must be strings

isTargetRestricted tells the script to actually listen to the target restriction or just target all hostiles (use traitor mines to attack everything)

Functional Mines. Functional mines are any mine which operates via scripted defined functions.

To set this up simply make a function like: ONLY use this after creating the mine class using the function createMineTableElement().
Code: [Select]
An Example
mineTable[WeaponClassString].mineFunction = function(weapon,targetShip) --Creates Mine Function for the mine to utalize DO NOT CHANGE THE ARGUMENTS
weapon:Vanish() -- Required to stop the mine from constantly triggering. always use this before any async.await functions or anything else

The factory script requires more documentation than I am willing to do tonight. but it is more in depth to edit than the mine script.

Current Downloads Are:
Factory Script
Mine Script
Music Utilities

I might create a github page or something in the future but for now the links will work. (Mine script link updated, the older files are still available on the HLP discord server).

Update 1:
Minescript made weapon which had a lifetime of under 128.1 invincible if the weapon was given infinite life. This bug has been fixed but any weapon which you want to add infinite life must be above 2 seconds (I recommend a higher lifetime, something like 300secons or something).

Update 2: New script, the Music Utilities script is a method of playing music through the mission and the debriefing uninterrupted.

Update 3: Music Utilities has been updated. now you can set music to be played in Red Alert mission briefings (with the same delay as briefings). to do this check the musicUtilsramusic-sct.tbm file in tables folder.
Each line like this: musicUtils.briefingMusicTrackDictionary["TestMission2"] = {"filename.wav",0.15,true} indicates one red alert mission you want to handle. The first thing to alter is TestMission2 to your mission filename (minus any extensions). Then you can alter the filename.wav to whatever audio file placed in either scripts or music (include extensions here). After that you can alter the 0.15 to whatever volume multiplier you want (above 1 is not recommended). This also scales with the music slider as well. the boolean value of either true or false tells the script if you want the music to loop or not (true for looping and false for not looping).

Update 4: Rudimentary Fade in. (optional parameter in SEXPs for the mod)
« Last Edit: October 11, 2023, 08:38:19 pm by CRZgatecrusher »


Offline Darius

  • 211
The homeworld-style mines are a lot of fun  :yes: Currently using it to spawn defensive stationary minefields with mines that start moving and homing on enemy ships when they get close. Tons of customisability including what team and object types the mines will recognise. Haven't tried playing around with static mines that detonate on proximity but there's that option too.

Making use of them in Solaris Act 3, so keep an eye out!