# Math Formulas

A page dedicated for helping users of Ssomar's plugins to create more complex things that require advanced math formulas

## Particle-Related Math Formulas

### Player-Direction Offset Formula

Requires: - PlaceholderAPI & Math Expansion

Example Usage:

Command below shoots firework particles like a shotgun (Commands below are in config form)

How this works is that, a RNG placeholder was used to add/subtract values from your yaw pitch values in the formula so it would try to "spread" out the particles.

Basically the rng placeholders are there just to "make" you look somewhere since the math formula depends on your yaw pitch values.

The reason why there's a *-1 in the formula because when the original formula was used, it made particles move in complete opposite of where you're looking at

You can also use this very same method to perform directional dashes which FRONTDASH is unable to perform

You could use (%x%) instead of {player_x_long] but I'll explain the more detailed stuff.

The formula above ONLY gets the displacement between 2 points but CUSTOMDASH1 requires the xyz location because it doesn't have your xyz location as a reference so you have to add your xyz values to the equation to properly launch yourself towards your direction. To increase the speed of the launch, increase the distance value which is the "2" value that you can see in the math formula.

As to why you have to use the xyz placeholder that gives decimal values instead of non-decimal values, it is to make sure you're landing at the correct location or else you would be flying off somewhere.

### Player-Direction Offset Formula v2

The above formula only deals with the forward/backward offset but doesn't consider the up/down and left/right offsets.

Just replace the ^x ^y ^z with offset values. DO NOT KEEP THE ^ SYMBOL

#### Example

Let's say a player is at coordinates `{player_x_long} = 100`

, `{player_y_long} = 64`

, `{player_z_long} = 100`

, facing east (`{player_yaw} = 90°`

, `{player_pitch} = 0°`

). If you use the command `/tp ^1 ^0 ^1`

, the player will be teleported as follows:

`{player_yaw}`

= 90° (east)`{player_pitch}`

= 0°

Using the formulas:

`{new_x_long} = 100 + (1 * cos(0*-1) * sin(90*-1)) + (1 * cos(90*-1))`

`{new_y_long} = 64 + (1 * sin(0*-1)) + 0`

`{new_z_long} = 100 + (1 * cos(0*-1) * cos(90*-1)) - (1 * sin(90*-1))`

#### Sample Application:

^1 ^2 ^3

## Origin-Related Math Formulas

### Distance from XYZ

Requires: - PlaceholderAPI - Math Expansion - Player Expansion

Example Usage: You want to get the distance between you and a specific XYZ location which is x:30, y:60, z:-120

## Using offsets to distance target from location

How this works is first, you get the displacement of 2 points.

The formula above for example, would use the target block's xyz and the player's xyz values to get the displacement between the 2 points then add it along with the target block's xyz coordinates so you would be able to either pull yourself more towards the location or away from the location.

The formula currently has `*-(<multiplier>)`

at where it is at. The higher the number in `<multiplier>`

, the greater the displacement value. If you want to distance the user away from that point, use the negative symbol. Otherwise, remove the negative symbol to further pull the player towards the location

Example Usage:

## Threshold Value Math Formula

This is an example of a math formula where it deals with the player health placeholder. But if the player health value surpasses the value of 500, it will stop there.

The detailed explanation goes like this. in the IF() formula, it first checks if the placeholder would return a number greater than 500.

If the placeholder's value is greater than 500, it would get the difference between the placeholder's value and 500 and use that value to subtract from the placeholder's value to prevent it from going above 500.

If the placeholder's value is less than 500, nothing happens

## Oscillating Formula

`f(x)=sin(2πx)`

Example Usage:

The main function of this method is the Y values

Check the part of where the SIN() is at.

%for1% represents the increasing number

2 is just part of the formula

The 31.4 is the number you have to properly adjust to produce bigger oscillations

Last updated