Touhou Wiki
Advertisement

Mathematical or Information Functions

Mathematical functions and functions to get information. Angles are in degrees (not radians).

cos

Get cosine of the angle. Cosine is the x-coordinate of the point on the unit circle, whose radius is 1.

1 Parameter
    1) angle
Return value
    cosine of the angle

sin

Get sine of the angle. Sine is the y-coordinate of the point on the unit circle, whose radius is 1.

1 Parameter
    1) angle
Return value
    sine of the angle

tan

Get tangent of the angle. Tangent is the slope of the line.

1 Parameter
    1) angle
Return value
    tangent of the angle

acos

Get arccosine of the value. acos(cos(x)) = x, if the x is in 0 ~ 180.

1 Parameter
    1) value
Return value
    arccosine of the value

asin

Get arcsine of the value. asin(sin(x)) = x, if the x is in -90 ~ 90.

1 Parameter
    1) value
Return value
    arcsine of the value

atan

Get arctangent of the value. atan(tan(x)) = x, if the x is in -90 ~ 90.

1 Parameter
    1) value
Return value
    arctangent of the value

atan2

Get arctangent of y/x, which is the direction angle from (0, 0) to (x, y).

2 Parameters
    1) y
    2) x
Return value
    arctangent of y/x

log

Get natural (base e) logarithm of the value.

1 Parameter
    1) value
Return value
    natural logarithm of the value

log10

Get common (base 10) logarithm of the value.

1 Parameter
    1) value
Return value
    common logarithm of the value

rand

Get a random real value in min ~ max. Both the min. and the max. are contained within the range. If min > max, it returns rand(max, min).

2 Parameters
    1) min. value
    2) max. value
Return value
    random real value

rand_int

Get a random integer in min ~ max. Both the min. and the max. are contained within the range. If min > max, it returns rand(max, min).

2 Parameters
    1) min. value (integer)
    2) max. value (integer)
Return value
    random integer

prand

Get a predetermined random real value in min ~ max. Both the min. and the max. are contained within the range. If min > max, it returns rand(max, min).

This random number sequence is generated by psrand function.

2 Parameters
    1) min. value
    2) max. value
Return value
    random real value

prand_int

Get a predetermined random integer in min ~ max. Both the min. and the max. are contained within the range. If min > max, it returns rand(max, min).

This random number sequence is generated by psrand function.

2 Parameters
    1) min. value (integer)
    2) max. value (integer)
Return value
    random integer

psrand

Initialize the random number sequence for the prand and prand_int functions.

1 Parameter
    1) random seed

int

Cast the value to an integer. This function is not recommended. trunc has higher precision.

1 Parameter
    1) value
Return value
    integer

truncate

Truncate the fractional part. trunc is the shortened name of truncate. Both names are available.

1 Parameter
    1) value
Return value
    truncating result

round

Round the value.

1 Parameter
    1) value
Return value
    rounding result

ceil

Ceil the value (Find the nearest integer greater than or equal to the value).

1 Parameter
    1) value
Return value
    ceiling result

floor

Floor the value (Find the nearest integer less than or equal to the value).

1 Parameter
    1) value
Return value
    flooring result

absolute

Get the absolute value. Operator (| |) is available for this sake, too.

1 Parameter
    1) value
Return value
    absolute value

length

Get the length of the array.

1 Parameter
    1) array
Return value
    length

integral

Calculate the definite integral numerically. e.g.

integral(0, 1, 64, "x^2+3");
4 Parameters
    1) lower bound
    2) upper bound
    3) span
    4) formula
Return value
    integration result

ToString

Convert the value to a string.

1 Parameter
    1) value
Return value
    string

Collision_Line_Circle

Detect the collision between line and circle.

8 Parameters
    1) x-coordinate of the beginning point of the line
    2) y-coordinate of the beginning point of the line
    3) x-coordinate of the terminal point of the line
    4) y-coordinate of the terminal point of the line
    5) width of the line
    6) x-coordinate of the center of the circle
    7) y-coordinate of the center of the circle
    8) radius of the circle
Return value
    true : collide
    false: not collide

Collision_Obj_Obj

Detect the collision between two objects.

2 Parameters
    1) object 1
    2) object 2
Return value
    true : collide
    false: not collide

GetX

Get the x-coordinate of the current script.

Return value
    x-coordinate

GetY

Get the y-coordinate.

Return value
    y-coordinate

GetSpeed

Get the speed.

Return value
    speed

GetAngle

Get the angle.

Return value
    angle

GetEnemyX

Get the x-coordinate of the main enemy (boss).

Return value
    x-coordinate

GetEnemyY

Get the y-coordinate of the main enemy (boss).

Return value
    y-coordinate

GetEnemyLife

Get the left life of the main enemy (boss).

Return value
    life

GetTimer

Get the left limit time.

Return value
    time

GetEnemyNum

Get the number of enemies.

Return value
    number of enemies

GetEnemyShotCount

Gets the number of enemy shots in existence.

Return value
    number of enemy shots

GetEnemyShotCountEx

Gets the number of enemy shots existing in a given circle.

4 Parameters
    1) The x coordinate of the center of the circle
    2) The y coordinate of the center of the circle
    3) The radius of the circle
    4) The type of enemy shots to count (ALL is all types)
Return value
    number of enemy shots matching the criteria

Enemy Enumeration

Enumerate all the enemy. e.g.

ascent(enemy in EnumEnemyBegin..EnumEnemyEnd) {
    let enemyID   = EnumEnemyGetID(enemy);
    let enemyLife = GetEnemyInfo(enemyID, ENEMY_LIFE);
}

EnumEnemyBegin

Initialize the enemy enumeration and get the beginning point of it.

Return value
    beginning point

EnumEnemyEnd

Get the end point of the enemy enumeration.

Return value
    end point

EnumEnemyGetID

Get the enemy ID from the abstract index. This function must be used in the enemy enumeration loop, but enemy IDs returned by this function can be used out of the loop.

1 Parameter
    1) abstract index
Return value
    enemy ID

GetEnemyInfo

Get information from the enemy ID. When the arguments are invalid, it returns false.

2 Parameters
    1) enemy ID
    2) kind of information
        ENEMY_X   : x-coordinate
        ENEMY_Y   : y-coordinate
        ENEMY_LIFE: life
Return value
    information

GetEnemyInfoDefault

Get information from the enemy ID. If there is no enemy corresponds to the enemy ID, the function returns the default value.

2 Parameters
    1) enemy ID
    2) kind of information
        ENEMY_X   : x-coordinate
        ENEMY_Y   : y-coordinate
        ENEMY_LIFE: life
    3) default value
Return value
    information, or default value if no enemy exists

GetPlayerX

Get x-coordinate of the player's character.

Return value
    x-coordinate

GetPlayerY

Get y-coordinate of the player's character.

Return value
    y-coordinate

GetAngleToPlayer

Get the direction to the player's character.

Return value
    direction angle

GetPlayerType

Get type of the player's character.

Return value
    type of the character
        REIMU_A    : Reimu Hakurei (Spirit Sign); 霊夢(霊符)
        REIMU_B    : Reimu Hakurei (Dream Sign); 霊夢(夢符)
        MARISA_A   : Marisa Kirisame (Magic Sign); 魔理沙(魔符)
        MARISA_B   : Marisa Kirisame (Love Sign); 魔理沙(恋符)
        USER_PLAYER: user-defined character
                     (character name can be obtained by  GetPlayerScriptName)

GetPlayerScriptName

Get the character-script name.

Return value
    name of the character

GetPlayerLife

Get the number of the remaining players.

Return value
    number of players

GetPlayerBomb

Get the number of the remaining bombs.

Return value
    number of bombs

GetPlayerMoveState

Get the move state of the character.

Return value
    move state
        MOVE_SLOW  : slow move
        MOVE_NORMAL: normal

GetPlayerInfo

Gets the designated information.

1 Parameter
    1) Type of information to get
        PLAYER_SPEED_HIGH - the player script's unfocused movement speed
        PLAYER_SPEED_LOW  - the player script's focused movement speed
Return value
    the requested information.

GetTimeOfPlayerInvincibility

Get the left time of the player invincibility.

Return value
    left time of invincibility

GetTimeOfSuperNaturalBorder

Get the left time of super natural border.

Return value
    left time of SNB

GetMissCount

Get the miss count.

Return value
    miss count

GetMissCountInThisSpell

Get the miss count in this spell card attack.

Return value
    miss count

GetBombCount

Get the count of bombing.

Return value
    bomb count

GetBombCountInThisSpell

Get the count of bombing in this spell card attack.

Return value
    bomb count

GetScore

Get the current score.

Return value
    score

GetGraze

Get how many times enemy shots have grazed the player's character.

Return value
    graze

GetPoint

Get the current number of point items.

Return value
    number of point items

Continued

Get whether continued or not.

Return value
    true : continued
    false: not continued

GetAllowedContinueCount

Get the allowed times to continue.

Return value
    continue count

OnPlayerMissed

Get whether or not the player just missed.

Return value
    true if the player was just hit and is respawning, false otherwise.

OnBomb

Get whether on bombing or not.

Return value
    true : on bombing
    false: not on bombing

OnEnemySpell

Get whether or not an enemy spellcard is active

Return value
    true: spellcard is active
    false: no spellcard is active

OnEnemyLastSpell

Get whether or not an enemy last spell is active

Return value
    true: last spell is active
    false: last spell is not active

IsBossExisting

Get whether a boss is existing or not.

Return value
    true : existing
    false: not existing

IsBGStopping

Get whether background is stopping or not.

Return value
    true : stopping
    false: not stopping

IsReplay

Get whether on replaying or not.

Return value
    true : replaying
    false: not replaying

GetCenterX

Get x-coordinate of the center of the game field.

Return value
    224

GetCenterY

Get y-coordinate of the center of the game field.

Return value
    240

GetClipMinX

Get x-coordinate of the left of the game field.

Return value
    32

GetClipMaxX

Get x-coordinate of the right of the game field.

Return value
    416

GetClipMinY

Get y-coordinate of the top of the game field.

Return value
    16

GetClipMaxY

Get y-coordinate of the bottom of the game field.

Return value
    464

GetCurrentScriptDirectory

Get the path of the folder which contains the current script.

Return value
    folder path

UsedDebugKey

Get whether debug keys are used or not.

Return value
    true : used
    false: not used

GetKeyState

Get the key state.

1 Parameter
    1) key
        VK_LEFT    : left arrow key
        VK_RIGHT   : right arrow key
        VK_UP      : up arrow key
        VK_DOWN    : bottom arrow key
        VK_SHOT    : shot key
        VK_BOMB    : bomb key
        VK_SLOWMOVE: slow move key
        VK_SKIP    : message skip key
        VK_USER    : user-defined key
Return value
    state
        KEY_FREE: the key is free
        KEY_PUSH: the key is pushed now
        KEY_HOLD: the key is holding
        KEY_PULL: the key is released now

GetFps

Get frames per second.

Return value
    FPS

GetTime

Gets the amount of time since the script started running, in milliseconds.

Return value
    Time the script has been running, in milliseconds.

erase

Erases an element from an array.

2 Parameters
    1) Array
    2) Index
Return value
    The given array, with the element at the given index removed

Advertisement