Skip to content
nebulazorua edited this page Jul 30, 2023 · 5 revisions

Guide to Modifiers

Want to learn how to spice up the gameplay? Wanna make the notes hide as they get closer to being hittable, or how about whole complex modfiles? This'll help you learn what a modifier is and how they're used in Troll Engine!

What is a modifier

A modifier, mod for short, is seperate from the Gameplay Modifiers accessible through the Story/Freeplay menus. A modifier in this context, is something used to put effects on gameplay. This can be used to swap your scroll mid-song, move the notes to the beat, or even whole custom paths!

How do I add modifiers to a song?

Modifiers can be added to a song through scripting! And eventually through the event system but that's not done yet! This is done through the engine's Modifier Manager system, available to HScript via the "modMgr" variable, which handles setting and easing modifiers, and queueing them up to be played on certain steps within a song.

To make a modfile script, put a file in your song's folder and name it anything, but make sure it has the ".hscript" format, and open it. If lua is more your speed, you can also use the ".lua" format.

A basic hscript modfile, or modchart, will look like this:

function generateModchart(){ // Older versions of the engine may use onCountdownStarted or postModifierRegister for modchart queueing
    modManager.setPercent("sudden", 100, -1); // This sets the "sudden" modifier to 100% for all players (-1)
    // You can also use modManager.setValue("sudden", 1, -1); for the same effect
    // When wanting to target all players, you can omit the -1 aswell, so it ends up as just setValue("sudden", 1)/setPercent("sudden", 100)
}

And a lua one will look like this:

function generateModchart()
    setPercent("sudden", 100, -1) -- This sets the "sudden" modifier to 100% for all players (-1)
    -- You can also use setValue("sudden", 1, -1); for the same effect
    -- When wanting to target all players, you can omit the -1 aswell, so it ends up as just setValue("sudden", 1)/setPercent("sudden", 100)
end

When ran, this script looks like this:

sudden100.mov

Congratulations, you've written your first modfile! Modfiles are, in the end, just lines of modifiers being queued for the most part. If you want to change which player gets the modifier, just change the player number (the -1 in this example). By default, 0 is the player ("boyfriend") and 1 is the opponent ("dad")

But how do I make them change during gameplay?

That is where the queueEase and queueSet functions are useful! (And the Percentage variants, queueEaseP and queueSetP) These functions are used to queue modifiers to change during a song to make full modfiles! These are the backbone of any modfile!

queueSet is called with the following arguments:

modManager.queueSet(executionStep: Float, modName: String, value: Float, ?player: Int = -1)

With each argument like so:

  • executionStep - When the modifier should be set
  • modName - The modifier to be set
  • value - Whate the modifier will be set to
  • player - Which player should have the modifier set. Defaults to -1 (both players)

and queueEase is called like:

modManager.queueEase(startStep: Float, endStep: Float, modName: String, value: Float, ?style:String, ?player: Int = -1, ?startVal: Float)

With each argument like so:

  • startStep - When the modifier should start easing into value
  • endStep - When the modifier should finish easing into value
  • modName - The modifier to be set
  • value - What the modifier will be eased into
  • style - The name of the FlxEase to be used when easing the value
  • player - Which player should have the modifier set. Defaults to -1 (both players)
  • startVal - The value to start the ease at. Defaults to whatever the value is when the ease starts.

(The percentage variants are the exact same, but replace value with percent)

Now, these may SEEM complicated, but they just say when to set a modifier, how to set it, and what to set it to. Take this for example:

function generateModchart(){
    modManager.queueSetP(128, "beat", 100); // Sets the "beat" modifier to 100% on both players at step 128 (This can be found in the chart editor in the top left)
    modManager.queueEaseP(128, 144, "tipsy", 200, "quadOut", 0); // Eases the "tipsy" modifier to 200% on player 0 (boyfriend) starting at step 128 and ending at step 144, using the "quadOut" easing style.
    modManager.queueEaseP(128, 144, "drunk", 200, "backOut", 1); // Eases the "drunk" modifier to 200% on player 1 (dad) starting at step 128 and ending at step 144, using the "backOut" easing style.
}

Or in lua:

function generateModchart()
    queueSetP(128, "beat", 100) -- Sets the "beat" modifier to 100% on both players at step 128 (This can be found in the chart editor in the top left)
    queueEaseP(128, 144, "tipsy", 200, "quadOut", 0) -- Eases the "tipsy" modifier to 200% on player 0 (boyfriend) starting at step 128 and ending at step 144, using the "quadOut" easing style.
    queueEaseP(128, 144, "drunk", 200, "backOut", 1) -- Eases the "drunk" modifier to 200% on player 1 (dad) starting at step 128 and ending at step 144, using the "backOut" easing style.
end

The comments should explain what is going on here, and here's how it looks ingame:

queueDemo.mov

What next?

Mess around with the modifiers available! Try out different combinations, and get used to making modfile scripts.

Useful resources