Difference between revisions of "FraggleScript functions"
From DoomWiki.org
[unchecked revision] | [checked revision] |
(large addition - part 2) |
(I have literally never heard the term "sinus" before and can't find any examples on Wikipedia or Google search. Maybe originates in another language?) |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 54: | Line 54: | ||
} | } | ||
} | } | ||
− | ; prnd ( | + | ; prnd (Doom Legacy extension): Returns a random integer from 0..255 (using the doom random table) |
; input : (non-functional) read a line from the keyboard | ; input : (non-functional) read a line from the keyboard | ||
; beep : Make a sound | ; beep : Make a sound | ||
Line 66: | Line 66: | ||
; exitlevel: Exit the level | ; exitlevel: Exit the level | ||
; tip : Display a message to the player (in the centre of the screen) | ; tip : Display a message to the player (in the centre of the screen) | ||
− | ; timedtip ( | + | ; timedtip (Doom Legacy extension): Prints a centered message to all players, which lasts clocks/100 number of seconds |
=== Messages === | === Messages === | ||
Line 79: | Line 79: | ||
print("player 2 is in the game!"); | print("player 2 is in the game!"); | ||
} | } | ||
− | ; gameskill ( | + | ; gameskill (Doom Legacy extension): Returns a value from 1 to 5 representing the skill level of the current game |
− | ; gamemode ( | + | ; gamemode (Doom Legacy extension): Returns an integer value representing the current mode of gameplay |
=== Player information and control === | === Player information and control === | ||
Line 86: | Line 86: | ||
; playername: Returns the name of a given player | ; playername: Returns the name of a given player | ||
; playerobj: Returns a reference to the object controlled by a player | ; playerobj: Returns a reference to the object controlled by a player | ||
− | ; playeraddfrag ( | + | ; playeraddfrag (Doom Legacy extension): With one argument 1 frag will be added to that player's frag count. If passed two arguments, 1 frag will be added to the first player's frag count against the second player specified (for tally screen). If both players are the same number, a frag will be subtracted from that player's frag count (suicide) |
− | ; isplayerobj ( | + | ; isplayerobj (Doom Legacy extension): Returns 1 if the trigger object or specified object is a player avatar, and 0 otherwise |
− | ; skincolor ( | + | ; skincolor (Doom Legacy extension): Returns the number corresponding to a player's colour, or can be used to set colour |
− | ; playerkeys ( | + | ; playerkeys (Doom Legacy extension):If passed a player number (0-31) and a key number (0-5), this function will return 1 if the player possesses that key or 0 if he does not. If additionally passed the givetake parameter, it will give the key to the player if givetake is non-zero, or will take the key away from the player if givetake is zero. In this case, the function always returns zero regardless |
− | ; playerammo ( | + | ; playerammo (Doom Legacy extension):If passed a player number (0-31) and an ammo type number (0-5), this function will return the amount of that type of ammo the player has. If additionally passed the amount parameter, it will set the player's ammo of that type to this amount, clipping it into the range of zero to the maximum amount the player can carry for that type |
− | ; maxplayerammo ( | + | ; maxplayerammo (Doom Legacy extension): Sets a player's maximum ammo |
− | ; playerweapon ( | + | ; playerweapon (Doom Legacy extension): If passed a player number and weapon type number, this function will return 1 if that player has that weapon, 0 if he does not. If additionally passed the givetake parameter, it will set the player's possession of that weapon. 0 will take the weapon away, while any non-zero number will give it to the player |
=== Objects === | === Objects === | ||
Line 100: | Line 100: | ||
; removeobj : Passed a mapthing number or mobj reference, this function will remove the mapthing to which it refers | ; removeobj : Passed a mapthing number or mobj reference, this function will remove the mapthing to which it refers | ||
; objx: Returns the X coordinate of an object | ; objx: Returns the X coordinate of an object | ||
− | ; objy: Returns the | + | ; objy: Returns the Y coordinate of an object |
; objz: Returns the Z coordinate of an object | ; objz: Returns the Z coordinate of an object | ||
; teleport : Passed one parameter, this function attempts to teleport the trigger object to a teleport destination in the sector with tag number sectortag. Passed a mapthing number or a mobj reference, this function attempts to teleport the specified mapthing. This function automatically spawns fog objects and plays sounds in the appropriate locations | ; teleport : Passed one parameter, this function attempts to teleport the trigger object to a teleport destination in the sector with tag number sectortag. Passed a mapthing number or a mobj reference, this function attempts to teleport the specified mapthing. This function automatically spawns fog objects and plays sounds in the appropriate locations | ||
Line 111: | Line 111: | ||
; objangle : Passed nothing, this function returns the high-precision angle of the trigger object. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing. Passed a mapthing number or mobj reference and an angle the specified mapthing's angle will change | ; objangle : Passed nothing, this function returns the high-precision angle of the trigger object. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing. Passed a mapthing number or mobj reference and an angle the specified mapthing's angle will change | ||
; objhealth : Passed nothing, this function returns the current health value of the trigger object. Passed an integer or mobj reference, this function does likewise for the specified mapthing | ; objhealth : Passed nothing, this function returns the current health value of the trigger object. Passed an integer or mobj reference, this function does likewise for the specified mapthing | ||
− | ; spawnexplosion ( | + | ; spawnexplosion (Doom Legacy extension): Spawns a projectile and immediately changes it to the death state so it creates an explosion |
− | ; radiusattack ( | + | ; radiusattack (Doom Legacy extension): Creates a silent, invisible radius attack at the location of mobj spot. Mobj source defines the creator of the attack (for message purposes). The damage in the center of the attack is defined by int damage. The size of the radius depends on the amount of damage passed to the function |
− | ; testlocation ( | + | ; testlocation (Doom Legacy extension): Passed nothing, this function returns if the trigger object is clear of any wall or other objects. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing |
− | ; pushthing ( | + | ; pushthing (Doom Legacy extension): Given a mapthing number or mobj reference, this function pushes the specified thing along a line from its location in the direction of angle for a distance and speed affected by the force applied and its mass. External forces such as friction, wind, or explosions are vector-additive and will still affect the object while it is moving |
− | ; objdead ( | + | ; objdead (Doom Legacy extension) |
− | ; objreactiontime ( | + | ; objreactiontime (Doom Legacy extension) |
− | ; reactiontime ( | + | ; reactiontime (Doom Legacy extension): Passed one value, a mapthing number or mobj reference, this function will return the specified object's reaction time, or the amount of time it must sit without being able to move. Given the val parameter, it will first set the object's reaction time to the specified value, and then return this new value |
− | ; objtarget ( | + | ; objtarget (Doom Legacy extension): Passed one value, a mapthing number or mobj reference, this function will return a reference to that object's current target, which for enemies is the last thing to hurt them and get their attention. If the second parameter is passed, which may also be either a mapthing number or mobj reference, the target will be set to this object |
− | ; objmomx ( | + | ; objmomx (Doom Legacy extension): This function either returns or sets the x momentum of the specified object |
− | ; objmomy ( | + | ; objmomy (Doom Legacy extension): This function either returns or sets the y momentum of the specified object |
− | ; objmomz ( | + | ; objmomz (Doom Legacy extension): This function either returns or sets the z momentum of the specified object |
− | ; spawnmissile ( | + | ; spawnmissile (Doom Legacy extension): This function can be used to cause one object to fire a projectile at another object. The source and target parameters may be either integer mapthing numbers or mobj references |
− | ; mapthings ( | + | ; mapthings (Doom Legacy extension): Returns the number of mapthings in a level. This does not include projectiles, dropped weapons, or FS spawned entities |
− | ; objtype ( | + | ; objtype (Doom Legacy extension): Returns the type of an object in the form of an integer. When nothing is passed the type of the trigger will be returned. When passed a map object or mapthing number it will return the type of that object |
− | ; mapthingnumexist ( | + | ; mapthingnumexist (Doom Legacy extension): This will test a mapthing number to see if it exists. It will return 1 for an existing mapthing number or 0 for a non-existing mapthing number |
=== Sector control === | === Sector control === | ||
− | ; floorheight | + | ; floorheight : Passed one parameter, this function returns the current floor height of the first sector with tag number tagnum. Given two parameters, it first instantly sets the floor height of all sectors with this tag and then returns the new height |
; floortext | ; floortext | ||
− | ; floortexture ( | + | ; floortexture (Doom Legacy extension): Passed one parameter, this function returns the current flat displayed on the floor of the first sector with tag number tagnum. Given two parameters, it will set the flats of all tagged floors to flatname, and then return the new flat name |
− | ; movefloor | + | ; movefloor : Passed two parameters, this function gradually moves all sectors' floors tagged tagnum to destheight at the default floor movement speed. If given the speed parameter, the speed of the floors will be as specified multiplied by the basic floor movement factor |
; ceilheight | ; ceilheight | ||
− | ; ceilingheight ( | + | ; ceilingheight (Doom Legacy extension): Passed one parameter, this function returns the current ceiling height of the first sector with tag number tagnum. Given two parameters, it first instantly sets the ceiling height of all sectors with this tag and then returns the new height |
; moveceil | ; moveceil | ||
− | ; moveceiling ( | + | ; moveceiling (Doom Legacy extension): Passed two parameters, this function gradually moves all sectors' ceilings tagged tagnum to destheight at the default ceiling movement speed. If given the speed parameter, the speed of the ceilings will be as specified multiplied by the basic ceiling movement factor |
; ceiltext | ; ceiltext | ||
− | ; ceilingtexture ( | + | ; ceilingtexture (Doom Legacy extension): Passed one parameter, this function returns the current flat displayed on the ceiling of the first sector with tag number tagnum. Given two parameters, it will set the flats of all tagged ceilings to flatname, and then return the new flat name |
− | ; lightlevel | + | ; lightlevel : Passed one parameter, this function returns the current light level of the first sector with tag number tagnum. Given two parameters, it first instantly sets the light level of all sectors with this tag and then returns the new level |
− | ; fadelight | + | ; fadelight : Passed two parameters, this function gradually changes the light level of all sectors tagged tagnum to destlevel at the default light fade speed. If given the speed parameter, the speed of the fade will be as specified multiplied by the basic light fade factor |
− | ; colormap | + | ; colormap : Passed one parameter, this function returns the current colormap of the first sector with tag number tagnum. Given two parameters, it first sets the colormap of all sectors with this tag and then returns the name of the new colormap. If the colormap specified does not exist between C_START and C_END in a currently loaded wad, an error will occur and the game will exit |
=== Cameras === | === Cameras === | ||
− | ; setcamera | + | ; setcamera : This function instantiates a camera viewpoint at the object specified by either a mapthing number or an mobj reference with the given optional parameters. Pitch may be a value between -50 and 50, with 0 being straight ahead |
− | ; clearcamera | + | ; clearcamera : This function turns off any currently active cameras and returns the viewpoint to the console player |
− | ; movecamera ( | + | ; movecamera (Doom Legacy extension):This function is used to move a camera object toward the target object and to targetheight z coordinate at 'movespeed' speed, while independently turning it to face targetangle from its current angle, turning at 'anglespeed' speed.This function returns the integer value 1 if the camera moved, and 0 if it did not. This function is best used in a loop that tests its return value, calling it repeatedly until it returns 0, and then waiting for the next gametic. This could be accomplished as in the following example: |
+ | |||
+ | script 0 | ||
+ | { | ||
+ | while(movecamera(cameranodes.elementAt(0), 40.0, 5.0, 0.0, 0.0)) | ||
+ | { | ||
+ | wait(1); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | This example would move the camera toward the first camera node on the map at 5 units per [[tic]], with zero change in angle. Notice that the camera's linear and angular movements are independent, and that either may be zero if only one type of movement is desired. | ||
=== Math functions === | === Math functions === | ||
− | ; pointtoangle | + | ; pointtoangle : This function returns the high-precision angle between the two points (x1, y1) and (x2, y2) relative to the coordinate axes |
− | ; pointtodist | + | ; pointtodist : This function returns the high-precision distance between the two points (x1, y1) and (x2, y2) |
− | ; max ( | + | ; max (Doom Legacy extension): Returns the maximum of two fixed-precision numbers |
− | ; min ( | + | ; min (Doom Legacy extension): Returns the minimum of two fixed-precision numbers |
− | ; abs ( | + | ; abs (Doom Legacy extension): Returns the absolute value of a fixed-precision number |
− | ; sin ( | + | ; sin (Doom Legacy extension): Returns the sine, in radians, of a fixed-precision angle |
− | ; asin ( | + | ; asin (Doom Legacy extension): Returns the arcsine, in radians, of a fixed-precision angle |
− | ; cos ( | + | ; cos (Doom Legacy extension): Returns the cosine, in radians, of a fixed-precision angle |
− | ; acos ( | + | ; acos (Doom Legacy extension): Returns the arc cosine, in radians, of a fixed-precision angle |
− | ; tan ( | + | ; tan (Doom Legacy extension): Returns the tangent, in radians, of a fixed-precision angle |
− | ; atan ( | + | ; atan (Doom Legacy extension): Returns the arctangent, in radians, of a fixed-precision angle |
− | ; exp ( | + | ; exp (Doom Legacy extension): Returns the exponential of a fixed-precision number |
− | ; log ( | + | ; log (Doom Legacy extension): Returns the logarithm of a fixed-precision number |
− | ; sqrt ( | + | ; sqrt (Doom Legacy extension): Returns the square root of a fixed-precision number |
− | ; floor ( | + | ; floor (Doom Legacy extension): Returns the floor of a fixed-precision number |
− | ; pow ( | + | ; pow (Doom Legacy extension): Returns the power of a fixed-precision number by another fixed-precision number |
=== Sound effects === | === Sound effects === | ||
− | ; startsound | + | ; startsound : This function plays a sound from lump "soundname" at the location of the mapthing specified. soundname can be any sound whether normally in the game or not (new sounds will be hashed in dynamically), but the sound lump must exist and must start with "DS" |
− | ; startsectorsound | + | ; startsectorsound : This function plays a sound from lump "soundname" at the sound origin of the first sector with tag number tagnum. soundname can be any sound whether normally in the game or not (new sounds will be hashed in dynamically), but the sound lump must exist and must start with "DS" |
− | ; | + | ; stopsound (Doom Legacy extension): This functions stops any sound playing at the specified origin mobj |
− | ; | + | ; stopsectorsound (Doom Legacy extension): This functions stops any sound playing at all sectors that have the specified tag |
− | ; ambientsound ( | + | ; changemusic : This function changes the currently playing music to the music lump "musname." As with sounds, this may be a new lump, but it must exist and must start with "D_". Passing the string "-" to this function will cause the music to stop without any new song starting |
+ | ; ambientsound (Doom Legacy extension): This function plays a sound from lump "soundname" at full-volume on the global sound channel. This is suitable for global ambience that needs no general source. soundname can be any sound whether normally in the game or not (new sounds will be hashed in dynamically), but the sound must exist and must start with "DS" | ||
=== Hubs === | === Hubs === | ||
Line 176: | Line 187: | ||
=== Doors === | === Doors === | ||
− | ; opendoor | + | ; opendoor : This function opens all sectors tagged tagnum like doors. If no waittime or speed are specified, the door will open at normal speed and will not close on its own. If waittime is specified, the door will wait that number of clocks (100 clocks per second). If waittime is present but is 0, the door will not close on its own. speed may be set to alter the opening and closing speed of the door |
− | ; closedoor | + | ; closedoor : Similar to opendoor(), this function closes all sectors tagged tagnum like doors |
=== Heads-up GUI === | === Heads-up GUI === | ||
− | ; newhupic ( | + | ; newhupic (Doom Legacy extension) |
− | ; createpic ( | + | ; createpic (Doom Legacy extension): Creates a new heads-up pic using the lump 'lumpname', which must be a [[picture format|standard Doom-format screen graphic]], at unscaled screen coordinates (x, y), which may range from 0 to 319 and from 0 to 199 respectively. If draw is non-zero, the pic will be drawn to the screen, and if trans is non-zero, the pic will be drawn translucent. Priority determines how the pic will draw in relation to any other existing heads-up pics spawned by FraggleScript -- it will draw over any pics with a lower priority number, and under any pics with a higher priority number. Note that FraggleScript heads-up pics always have lower priority than any native heads-up graphics, such as the player HUD. |
− | ; deletehupic ( | + | |
− | ; modifyhupic ( | + | Heads-up pics are valid for the duration of the level in which they were created, and will be saved in savegames. This function returns an integer value which can be used as a handle to track and later manipulate this particular heads-up pic. You should always capture the handle unless you never intend to change or hide the pic after creating it. There is not currently any method for creating different heads-up pics on a particular player's screen |
− | ; modifypic ( | + | ; deletehupic (Doom Legacy extension) |
− | ; sethupicdisplay ( | + | ; modifyhupic (Doom Legacy extension): Modifies attributes of the FS heads-up pic with this handle. lumpname must be set, but it can be set to its current value if it is not desired to change it. x or y can be optionally changed as well, and x may be set to -1 if no change in x coordinate is desired |
− | ; setpicvisible ( | + | ; modifypic (Doom Legacy extension) |
+ | ; sethupicdisplay (Doom Legacy extension) | ||
+ | ; setpicvisible (Doom Legacy extension): Modifies the visibility of the FS heads-up pic with this handle. Set visible to a non-zero value to have the pic drawn, and set it to zero to hide it | ||
=== Miscellaneous === | === Miscellaneous === | ||
Line 198: | Line 211: | ||
} | } | ||
; linetrigger: Activates a particular Doom line trigger | ; linetrigger: Activates a particular Doom line trigger | ||
− | ; playdemo ( | + | ; playdemo (Doom Legacy extension): Plays the specified demo if the lumpname exists |
− | ; checkcvar ( | + | ; checkcvar (Doom Legacy extension): Returns the value of a console variable |
− | ; setlinetexture ( | + | ; setlinetexture (Doom Legacy extension): Used to set texture for linedefs with a specified tagnum |
− | ; lineflag ( | + | ; lineflag (Doom Legacy extension): This function retrieves or sets flags for a line. If passed two parameters, this function will return 1 if the specified flag is set for the line, and 0 otherwise. Passed all 3 arguments it will set or clear a flag for the specified line. A list of line flags can be found in things.h. Note that line numbers are as they are in the editor, and not tags. Also, 1-sided lines will always block clipped objects even if the blocking flag is cleared |
− | ; setcorona ( | + | ; setcorona (Doom Legacy extension):This function can change the dynamic light/corona settings of a sprite which has a dynamic light/corona setting attached to it |
+ | ; setfade (Doom Legacy extension): Set the screen's color to the one specified with the red, green and blue attributes. The alpha value determines the translucency of the color. All values are in the range of 0 to 255 | ||
+ | |||
+ | == External links == | ||
+ | * [http://doomlegacy.sourceforge.net/docs/fsfuncs.html Doom Legacy FraggleScript Function Reference] | ||
+ | * {{zdoomwiki|title=FraggleScript}} | ||
[[Category:Scripting languages]] | [[Category:Scripting languages]] | ||
+ | [[Category:Lists]] |
Latest revision as of 09:55, 10 May 2023
This is a comprehensive list of FraggleScript functions:
Contents
System variables[edit]
These are functions rather than variables, but are always available to the player:
- consoleplayer
- The player on the console, ie. in a network game, the player on this machine.
- displayplayer
- fov
- The current field of view size
- trigger
- The object which triggered the current script to start
script 82 { // kill the object which started this script kill(trigger); }
Control functions[edit]
- break
- Exit a loop, eg.
while (1) { break(); }
- continue
- Move to the next iteration in a loop
while (1) { continue(); print("this message is never displayed"); }
- return
- Stop the current script
script 1 { return(); print("this message is never displayed"); }
- goto
- Jump to a particular label
script 1 { goto(my_label); print("this message is never reached"); my_label: }
- include
- Execute the contents of the lump specified (acts like "#include" in C)
// include the contents of the wad lump named 'things.h' include("things.h");
Basic language functions[edit]
- Print a message to the console
print("hello, world");
- rnd
- Returns a random number from 0..255
script 1 { int my_number = rnd(); if (my_number % 2 == 0) { print("heads"); } else { print("tails"); } }
- prnd (Doom Legacy extension)
- Returns a random integer from 0..255 (using the doom random table)
- input
- (non-functional) read a line from the keyboard
- beep
- Make a sound
- clock
- Returns the level time, in 1/100ths of a second
- wait
- Causes the current script to delay further execution for time number of clocks (1 clock = 1/100 of a second)
- tagwait
- Causes the current script to delay further execution until all activity associated with the tag number passed to it has stopped
- scriptwait
- Causes the current script to delay further execution until all instances of the script with number scriptnum have finished execution
- startscript
- Causes script to run at the start of a level
- scriptrunning
- Returns a non-zero result if any instances of the script with scriptnum are currently waiting, and zero otherwise
- startskill
- Starts a new game on a skill level from 1 to 5
- exitlevel
- Exit the level
- tip
- Display a message to the player (in the centre of the screen)
- timedtip (Doom Legacy extension)
- Prints a centered message to all players, which lasts clocks/100 number of seconds
Messages[edit]
- message
- Display a message to the player
- playermsg
- Send a message to a particular player
playermsg(2, "Hello, player 2");
- playertip
- Send a tip to a particular player (centre-of-screen message)
playertip(2, "Dont go this way, player 2!");
- playeringame
- Returns 1 if the given player is in the game
if (playeringame(2)) { print("player 2 is in the game!"); }
- gameskill (Doom Legacy extension)
- Returns a value from 1 to 5 representing the skill level of the current game
- gamemode (Doom Legacy extension)
- Returns an integer value representing the current mode of gameplay
Player information and control[edit]
- playername
- Returns the name of a given player
- playerobj
- Returns a reference to the object controlled by a player
- playeraddfrag (Doom Legacy extension)
- With one argument 1 frag will be added to that player's frag count. If passed two arguments, 1 frag will be added to the first player's frag count against the second player specified (for tally screen). If both players are the same number, a frag will be subtracted from that player's frag count (suicide)
- isplayerobj (Doom Legacy extension)
- Returns 1 if the trigger object or specified object is a player avatar, and 0 otherwise
- skincolor (Doom Legacy extension)
- Returns the number corresponding to a player's colour, or can be used to set colour
- playerkeys (Doom Legacy extension)
- If passed a player number (0-31) and a key number (0-5), this function will return 1 if the player possesses that key or 0 if he does not. If additionally passed the givetake parameter, it will give the key to the player if givetake is non-zero, or will take the key away from the player if givetake is zero. In this case, the function always returns zero regardless
- playerammo (Doom Legacy extension)
- If passed a player number (0-31) and an ammo type number (0-5), this function will return the amount of that type of ammo the player has. If additionally passed the amount parameter, it will set the player's ammo of that type to this amount, clipping it into the range of zero to the maximum amount the player can carry for that type
- maxplayerammo (Doom Legacy extension)
- Sets a player's maximum ammo
- playerweapon (Doom Legacy extension)
- If passed a player number and weapon type number, this function will return 1 if that player has that weapon, 0 if he does not. If additionally passed the givetake parameter, it will set the player's possession of that weapon. 0 will take the weapon away, while any non-zero number will give it to the player
Objects[edit]
- spawn
- Spawns a new mapthing with various parameters
- kill
- Passed nothing, this function kills the thing that triggered the current script. Passed a mapthing number or mobj reference, this function will kill the mapthing to which it refers
- removeobj
- Passed a mapthing number or mobj reference, this function will remove the mapthing to which it refers
- objx
- Returns the X coordinate of an object
- objy
- Returns the Y coordinate of an object
- objz
- Returns the Z coordinate of an object
- teleport
- Passed one parameter, this function attempts to teleport the trigger object to a teleport destination in the sector with tag number sectortag. Passed a mapthing number or a mobj reference, this function attempts to teleport the specified mapthing. This function automatically spawns fog objects and plays sounds in the appropriate locations
- silentteleport
- This function works identically to teleport() except that no fog is spawned and no sounds are played
- damageobj
- Passed one parameter, this function attempts to do damage in the specified amount to the trigger object. Passed a mapthing number or mobj reference, this function attempts to do damage to the specified object
- player
- If the object is a player, returns the number of the player
- objsector
- Passed nothing, this function returns the tag number of the sector which the trigger object is currently in. Passed a mapthing number or mobj reference, this function attempts to do likewise for the specified object
- objflag
- If passed only one argument, this function will return 1 if the specified flag is set for the trigger object, and 0 otherwise. Passed all 3 arguments it will set or clear a flag for the specified object
- pushobj
- objangle
- Passed nothing, this function returns the high-precision angle of the trigger object. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing. Passed a mapthing number or mobj reference and an angle the specified mapthing's angle will change
- objhealth
- Passed nothing, this function returns the current health value of the trigger object. Passed an integer or mobj reference, this function does likewise for the specified mapthing
- spawnexplosion (Doom Legacy extension)
- Spawns a projectile and immediately changes it to the death state so it creates an explosion
- radiusattack (Doom Legacy extension)
- Creates a silent, invisible radius attack at the location of mobj spot. Mobj source defines the creator of the attack (for message purposes). The damage in the center of the attack is defined by int damage. The size of the radius depends on the amount of damage passed to the function
- testlocation (Doom Legacy extension)
- Passed nothing, this function returns if the trigger object is clear of any wall or other objects. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing
- pushthing (Doom Legacy extension)
- Given a mapthing number or mobj reference, this function pushes the specified thing along a line from its location in the direction of angle for a distance and speed affected by the force applied and its mass. External forces such as friction, wind, or explosions are vector-additive and will still affect the object while it is moving
- objdead (Doom Legacy extension)
- objreactiontime (Doom Legacy extension)
- reactiontime (Doom Legacy extension)
- Passed one value, a mapthing number or mobj reference, this function will return the specified object's reaction time, or the amount of time it must sit without being able to move. Given the val parameter, it will first set the object's reaction time to the specified value, and then return this new value
- objtarget (Doom Legacy extension)
- Passed one value, a mapthing number or mobj reference, this function will return a reference to that object's current target, which for enemies is the last thing to hurt them and get their attention. If the second parameter is passed, which may also be either a mapthing number or mobj reference, the target will be set to this object
- objmomx (Doom Legacy extension)
- This function either returns or sets the x momentum of the specified object
- objmomy (Doom Legacy extension)
- This function either returns or sets the y momentum of the specified object
- objmomz (Doom Legacy extension)
- This function either returns or sets the z momentum of the specified object
- spawnmissile (Doom Legacy extension)
- This function can be used to cause one object to fire a projectile at another object. The source and target parameters may be either integer mapthing numbers or mobj references
- mapthings (Doom Legacy extension)
- Returns the number of mapthings in a level. This does not include projectiles, dropped weapons, or FS spawned entities
- objtype (Doom Legacy extension)
- Returns the type of an object in the form of an integer. When nothing is passed the type of the trigger will be returned. When passed a map object or mapthing number it will return the type of that object
- mapthingnumexist (Doom Legacy extension)
- This will test a mapthing number to see if it exists. It will return 1 for an existing mapthing number or 0 for a non-existing mapthing number
Sector control[edit]
- floorheight
- Passed one parameter, this function returns the current floor height of the first sector with tag number tagnum. Given two parameters, it first instantly sets the floor height of all sectors with this tag and then returns the new height
- floortext
- floortexture (Doom Legacy extension)
- Passed one parameter, this function returns the current flat displayed on the floor of the first sector with tag number tagnum. Given two parameters, it will set the flats of all tagged floors to flatname, and then return the new flat name
- movefloor
- Passed two parameters, this function gradually moves all sectors' floors tagged tagnum to destheight at the default floor movement speed. If given the speed parameter, the speed of the floors will be as specified multiplied by the basic floor movement factor
- ceilheight
- ceilingheight (Doom Legacy extension)
- Passed one parameter, this function returns the current ceiling height of the first sector with tag number tagnum. Given two parameters, it first instantly sets the ceiling height of all sectors with this tag and then returns the new height
- moveceil
- moveceiling (Doom Legacy extension)
- Passed two parameters, this function gradually moves all sectors' ceilings tagged tagnum to destheight at the default ceiling movement speed. If given the speed parameter, the speed of the ceilings will be as specified multiplied by the basic ceiling movement factor
- ceiltext
- ceilingtexture (Doom Legacy extension)
- Passed one parameter, this function returns the current flat displayed on the ceiling of the first sector with tag number tagnum. Given two parameters, it will set the flats of all tagged ceilings to flatname, and then return the new flat name
- lightlevel
- Passed one parameter, this function returns the current light level of the first sector with tag number tagnum. Given two parameters, it first instantly sets the light level of all sectors with this tag and then returns the new level
- fadelight
- Passed two parameters, this function gradually changes the light level of all sectors tagged tagnum to destlevel at the default light fade speed. If given the speed parameter, the speed of the fade will be as specified multiplied by the basic light fade factor
- colormap
- Passed one parameter, this function returns the current colormap of the first sector with tag number tagnum. Given two parameters, it first sets the colormap of all sectors with this tag and then returns the name of the new colormap. If the colormap specified does not exist between C_START and C_END in a currently loaded wad, an error will occur and the game will exit
Cameras[edit]
- setcamera
- This function instantiates a camera viewpoint at the object specified by either a mapthing number or an mobj reference with the given optional parameters. Pitch may be a value between -50 and 50, with 0 being straight ahead
- clearcamera
- This function turns off any currently active cameras and returns the viewpoint to the console player
- movecamera (Doom Legacy extension)
- This function is used to move a camera object toward the target object and to targetheight z coordinate at 'movespeed' speed, while independently turning it to face targetangle from its current angle, turning at 'anglespeed' speed.This function returns the integer value 1 if the camera moved, and 0 if it did not. This function is best used in a loop that tests its return value, calling it repeatedly until it returns 0, and then waiting for the next gametic. This could be accomplished as in the following example:
script 0 { while(movecamera(cameranodes.elementAt(0), 40.0, 5.0, 0.0, 0.0)) { wait(1); } }
This example would move the camera toward the first camera node on the map at 5 units per tic, with zero change in angle. Notice that the camera's linear and angular movements are independent, and that either may be zero if only one type of movement is desired.
Math functions[edit]
- pointtoangle
- This function returns the high-precision angle between the two points (x1, y1) and (x2, y2) relative to the coordinate axes
- pointtodist
- This function returns the high-precision distance between the two points (x1, y1) and (x2, y2)
- max (Doom Legacy extension)
- Returns the maximum of two fixed-precision numbers
- min (Doom Legacy extension)
- Returns the minimum of two fixed-precision numbers
- abs (Doom Legacy extension)
- Returns the absolute value of a fixed-precision number
- sin (Doom Legacy extension)
- Returns the sine, in radians, of a fixed-precision angle
- asin (Doom Legacy extension)
- Returns the arcsine, in radians, of a fixed-precision angle
- cos (Doom Legacy extension)
- Returns the cosine, in radians, of a fixed-precision angle
- acos (Doom Legacy extension)
- Returns the arc cosine, in radians, of a fixed-precision angle
- tan (Doom Legacy extension)
- Returns the tangent, in radians, of a fixed-precision angle
- atan (Doom Legacy extension)
- Returns the arctangent, in radians, of a fixed-precision angle
- exp (Doom Legacy extension)
- Returns the exponential of a fixed-precision number
- log (Doom Legacy extension)
- Returns the logarithm of a fixed-precision number
- sqrt (Doom Legacy extension)
- Returns the square root of a fixed-precision number
- floor (Doom Legacy extension)
- Returns the floor of a fixed-precision number
- pow (Doom Legacy extension)
- Returns the power of a fixed-precision number by another fixed-precision number
Sound effects[edit]
- startsound
- This function plays a sound from lump "soundname" at the location of the mapthing specified. soundname can be any sound whether normally in the game or not (new sounds will be hashed in dynamically), but the sound lump must exist and must start with "DS"
- startsectorsound
- This function plays a sound from lump "soundname" at the sound origin of the first sector with tag number tagnum. soundname can be any sound whether normally in the game or not (new sounds will be hashed in dynamically), but the sound lump must exist and must start with "DS"
- stopsound (Doom Legacy extension)
- This functions stops any sound playing at the specified origin mobj
- stopsectorsound (Doom Legacy extension)
- This functions stops any sound playing at all sectors that have the specified tag
- changemusic
- This function changes the currently playing music to the music lump "musname." As with sounds, this may be a new lump, but it must exist and must start with "D_". Passing the string "-" to this function will cause the music to stop without any new song starting
- ambientsound (Doom Legacy extension)
- This function plays a sound from lump "soundname" at full-volume on the global sound channel. This is suitable for global ambience that needs no general source. soundname can be any sound whether normally in the game or not (new sounds will be hashed in dynamically), but the sound must exist and must start with "DS"
Hubs[edit]
- changehublevel
Doors[edit]
- opendoor
- This function opens all sectors tagged tagnum like doors. If no waittime or speed are specified, the door will open at normal speed and will not close on its own. If waittime is specified, the door will wait that number of clocks (100 clocks per second). If waittime is present but is 0, the door will not close on its own. speed may be set to alter the opening and closing speed of the door
- closedoor
- Similar to opendoor(), this function closes all sectors tagged tagnum like doors
Heads-up GUI[edit]
- newhupic (Doom Legacy extension)
- createpic (Doom Legacy extension)
- Creates a new heads-up pic using the lump 'lumpname', which must be a standard Doom-format screen graphic, at unscaled screen coordinates (x, y), which may range from 0 to 319 and from 0 to 199 respectively. If draw is non-zero, the pic will be drawn to the screen, and if trans is non-zero, the pic will be drawn translucent. Priority determines how the pic will draw in relation to any other existing heads-up pics spawned by FraggleScript -- it will draw over any pics with a lower priority number, and under any pics with a higher priority number. Note that FraggleScript heads-up pics always have lower priority than any native heads-up graphics, such as the player HUD.
Heads-up pics are valid for the duration of the level in which they were created, and will be saved in savegames. This function returns an integer value which can be used as a handle to track and later manipulate this particular heads-up pic. You should always capture the handle unless you never intend to change or hide the pic after creating it. There is not currently any method for creating different heads-up pics on a particular player's screen
- deletehupic (Doom Legacy extension)
- modifyhupic (Doom Legacy extension)
- Modifies attributes of the FS heads-up pic with this handle. lumpname must be set, but it can be set to its current value if it is not desired to change it. x or y can be optionally changed as well, and x may be set to -1 if no change in x coordinate is desired
- modifypic (Doom Legacy extension)
- sethupicdisplay (Doom Legacy extension)
- setpicvisible (Doom Legacy extension)
- Modifies the visibility of the FS heads-up pic with this handle. Set visible to a non-zero value to have the pic drawn, and set it to zero to hide it
Miscellaneous[edit]
- runcommand
- Executes a console command
script 10 { // quit the game runcommand("quit"); }
- linetrigger
- Activates a particular Doom line trigger
- playdemo (Doom Legacy extension)
- Plays the specified demo if the lumpname exists
- checkcvar (Doom Legacy extension)
- Returns the value of a console variable
- setlinetexture (Doom Legacy extension)
- Used to set texture for linedefs with a specified tagnum
- lineflag (Doom Legacy extension)
- This function retrieves or sets flags for a line. If passed two parameters, this function will return 1 if the specified flag is set for the line, and 0 otherwise. Passed all 3 arguments it will set or clear a flag for the specified line. A list of line flags can be found in things.h. Note that line numbers are as they are in the editor, and not tags. Also, 1-sided lines will always block clipped objects even if the blocking flag is cleared
- setcorona (Doom Legacy extension)
- This function can change the dynamic light/corona settings of a sprite which has a dynamic light/corona setting attached to it
- setfade (Doom Legacy extension)
- Set the screen's color to the one specified with the red, green and blue attributes. The alpha value determines the translucency of the color. All values are in the range of 0 to 255