Skip to content

Instantly share code, notes, and snippets.

@2blackbar
Last active April 11, 2023 00:33
Show Gist options
  • Save 2blackbar/824467c8b604a81bab92e9c56fe78ad6 to your computer and use it in GitHub Desktop.
Save 2blackbar/824467c8b604a81bab92e9c56fe78ad6 to your computer and use it in GitHub Desktop.
openbor script reference
Script Reference
By uTunnels
A script contains an interpreter to parse from text and execute the code. It can be loaded from a text file. A script also contains a local variant list. If the script is executed, the immediate code(those outside any functions) will be executed and function main will be called one time. The script will be reseted before next executation, so all script variants will lost, but the variants in local variant list will not been deleted, they are useful to store values.
Syntax
Similar to c syntax. Some differences:
Ignore types. int long char void ... will be treated as the same thing, they only tell the engine it is a data type. And a function can return a value no matter you set void type before it.
#include is available, and #define is available in builds after 2936 and #import. No other preprocessor directives are supported.
String concatenation. You can use + operator to strings, "string1" + "string2" returns "string1string2".
Assignment. The right variant's value and type will be copied to the left variant. No type checking, so be careful. From r4403 are valid multiple assignment like: x = y = 1;
Available operators:
+
-
*
/
%
=
+=
-=
/=
*=
%=
! (it works for constants too from r4340+)
==
||
&&
!=
>
<
>=
<=
~ (from r4316+)
^
|
&
<<
>>
<<= (from r4316+)
>>= (from r4316+)
&= (from r4316+)
|= (from r4316+)
^= (from r4316+)
Available identifiers:
do
while
for
break
if
else
switch
case
Math Functions:
pow({double}, {double})
asin({double})
acos({double})
atan({double})
ssin({double}) // Not approximated.
scos({double}) // Not approximated.
sin({double}) // approximated.
cos({double}) // approximated.
trunc({double})
round({double})
Script Variants
They contain values that can be used by script. They have 5 data types, but the script engine dont check them when they are defined, until they are used by any functions. ~Empty type: If a variants is defined but not initialized, it is an empty variant. So functions return an empty variant, so you can check if the function returns a valid value. ~Integer type: These variants can be initialized from integer constants, e.g., 123, -20 ..., 0x986AD3 ~Decimal type: These variants can be initialized from decimal constants, e.g., 0.3, -2.6666 ... ~String type: These variants can be initialized from string constants(limited to 63 characters), e.g., "hello", "__abcd.efg\n", 'c'... ~Pointer type: These variants can not be initialized from constants, they are used to store handles returned from function calls.
Notice: string + string = string, integer +-*/% decimal = decimal,
Local variants
Each script can define its own variants by give it a unique name and a value. They wont be deleted when the script finishes executing and they live as long as the script itself. These variants cant be used by other scripts.
Global variants
The engine also has global variants. These variants can be used by all scripts. Each variant still must have a unique name, so you can retrieve it by name later.
Functions
You can define functions. Syntax is like this:
type functionname([type argument1, type argument2, type argument3, ....])
{
function body
....
....
[return value]
....
}
Yeah, same as a c function, here is an example:
int max(int a, int b)
{
if(a>b) {
return a;
} else {
return b;
}
}
Arrays
OpenBOR Script has a array support. There are 2 types. Numeric and Literal arrays. Numeric is set(array,0,value). Literal is set(array,"label",value). Here all functions.
array(size)
size is the initial size of array
size(array)
get the array size
from r4183+ it retrieve literal array size too
get(array,index)
get the value in the index
set(array,index,value)
set the value in the index
delete(array, index)
delete the value in the index and resize the array
dynamically remove an array element
you can use set(array,index,NULL()) to delete the value without resizing the array
add(array, index, value)
add an element in the index and resize the array (+1)
you can use set(array,index,value) but add() func is useful to add an element betwewn existent indexes
next(array)
move the pointer from current literal position to next position
previous(array)
move the pointer from current literal position to previous position
reset(array)
reset the pointer incremented by next (in literal arrays) to first position
value(array)
in literal arrays, it retrieve the value in the current position
key(array)
in literal arrays, it retrieve the key value/label in the current position
islast(array)
in literal arrays, it returns 1 if current pointer is on last element of literal array, otherwise it returns 0
isfirst(array)
in literal arrays, it returns 1 if current pointer is on first element of literal array, otherwise it returns 0
free(array)
free an allocated array
you must free an array somewhere, to avoid memory issues
Filestream
Filestreams are functions to write/read a file. A filestream is an indexed file so when you open a file the file is saved in a index.
openfilestream(path,location)
path is the string path of a file, ex.: "data/scripts/file.txt"
location is an optional value (default 0). if location is 1, openfilestream open a file with base the openbor saves path
it returns filestreamindex
closefilestream(filestreamindex)
close a opened file handler
getfilestreamline(filestreamindex)
it returns the string line in current position of the indexed opened file
filestreamindex is the indexed opened file
getfilestreamargument(filestreamindex,argument,type)
it returns the value from file, at the position
filestreamindex is the indexed opened file
argument: is a int. if the returned string contains spaces or tabs it retuns the argument number x.
example: getfilestreamargument() reads the string "RYU 200 points"
I can read this line with: name = getfilestreamargument(filestreamindex,0,"string"); value = getfilestreamargument(filestreamindex,1,"int"); unit = getfilestreamargument(filestreamindex,2,"string");
type: this is the argument type. Types are: "int", "float", "string", "byte"
if you set type "byte" the argument parameter is ignored
filestreamnextline(filestreamindex)
increase pointer of filestreamindex opened file to next line from position
getfilestreamposition(filestreamindex)
it returns the file pointer at the position
setfilestreamposition(filestreamindex,position)
it sets the pointer of filestreamindex file to position
filestreamappend(filestreamindex,value,write_type,value_type)
it writes a value in filestreamindex file in the buffer
value is the string or number that you want to write
write_type: is set 0, it appends a NULL char and "\r\n", 1 it appends a NULL char, otherwise it appends just the value
value_type: optional, if is "byte" you can write a byte value
examples: filestreamappend(savefile, 200, 2, "byte")
createfilestream()
it create a filestream and returns filestreamindex
savefilestream(filestreamindex,filename,pathname,type)
it saves buffer to file
file: file handler
filename: filename string
pathname: optional, if set use pathname otherwise use saves openbor path
type: optional, is set "byte" it writes a byte (no newline at EOF)
examples: savefilestream(savefile, "testwrite.txt", 0, pathname, "byte")
Predefined Script Functions
The following is a list of the predefined script functions:
isempty(variant)
Test if a ScriptVariant is an empty value.
Return 1 if it is an empty value, 0 if it isn't.
NULL()
Return an empty value. You can use expression "variant == NULL()" to test if the variant is an empty value, it has the same effect with "isempty(variant)".
getglobalvar(varname)
Return a global variant by name. If the value is not found, will return an empty value.
See 'global variants'.
setglobalvar(varname, value)
Set a persistent global variant's value by name. If the value is empty, the variant will be deleted.
Return 1 if succeeded, 0 if failed.
See 'global variants'.
Notice: It is important to remove unused global variants since there's a limit in amount (see above).
getlocalvar(varname)
Return a local variant by name. If the value is not found, will return an empty value.
See 'local variants'.
setlocalvar(varname, value)
Set a persistent local variant's value by name. If the value is empty, the variant will be deleted.
Return 1 if succeeded, 0 if failed.
See 'local variants'.
Notice: It is important to remove unused local variants since there's a limit in amount (see above).
clearglobalvar()
Clear up all global variants.
Return: none
You can use it when a level starts or ends to save memory.
clearlocalvar()
Clear up local variants. Only affect current script, though.
Return: none
getindexedvar(int index)
Return a indexed global variant.
setindexedvar(int index, value)
Give value to a indexed global variant.
getscriptvar(int index)
Return a indexed script variant.
setscriptvar(int index, value)
Give value to a indexed script variant.
getentityvar(entity, int index)
Return a indexed entity variant.
setentityvar(entity, int index, value)
Give value to a indexed entity variant.
openborvariant(varname)
Return a openbor variant by name.
Names available:
”background", - is the BG used in a level
"blockade", - Limit x scroll back
"branchname", - Gets level branch name. Works ONLY if you touch the item to branch and gets reseted once you leave the stage.
"cheats" - TRUE if cheats are activated, otherwise FALSE.
"count_enemies", - counts how many enemies are active
"count_entities", - counts how many entities are active
"count_npcs", - counts how many npc are active
"count_players", - counts how many enemies are active
"current_branch", - Gets the current branch name.
"current_level", - Level index of current set, start from 0.
"current_palette", - gets current system palette
"current_scene", - gets current scene
"current_set", - Current difficulty set index, start from 0.
"current_stage", - Stage index of current set, start from 1.
"effectvol", - gets Sound fx volume
"elapsed_time", - gets the elapsed time until the moment
"ent_max", - get the maximum number of entities
"freeram", - gets the ammount of free ram
"game_paused", detects if the game is paused
"game_speed", detects the game speed
'game_time", detects the stage time. (4456+)
int game_time = Openborvariant(“game_time”);
changeopenborvariant(“game_time”, game_time);
Acceptable range is 0-99. Any value exceeding range in either direction will be overwritten to nearest acceptable value on the next engine cycle.
"gfx_x_offset", - Enable X offset adjustment by modders. X coords of the screen.
"gfx_y_offset", - Enable Y offset adjustment by modders. Y coords of the screen.
"gfx_y_offset_adj", - is the shift relative to gfx_y_offset.
"hresolution", - Get screen width (Horizontal resolution)
"in_cheat_options", - detects cheat options
"in_control_options", - detects control options
"in_gameoverscreen", - detects GAME OVER screen
"in_halloffamescreen", detects HALL OF FAME screen
"in_level", Whether you are in a level (e.g., select screen is not a level).
"in_load_game", - detects LOAD GAME screen
"in_menuscreen", - detects MENU screen
"in_new_game", - detects NEW GAME screen
"in_options", - detects OPTIONS screen
"in_selectscreen", detects CHARACTER SELECT screen
"in_showcomplete", detects COMPLETE SCREEN screen
"in_sound_options", detects SOUND OPTIONS screen
"in_start_game", detects GAME OVER screen
"in_system_options", detects START GAME option
"in_titlescreen", detects TITLE screen (the one with PRESS START)
"in_enginecreditsscreen", detects if the engine's credits is displayed, but placed the variables for it in the shutdown command so that it can be called for even if the credits is not displayed.
"in_video_options", detects VIDEO OPTIONS screen
"lasthita", - Same of lasthity (DEPRECATED)
"lasthity", - Get Y axis of last hit
"lasthitc", - Confirms the last hit
"lasthitt", - is the last hit type (ex. ATK_NORMAL)
"lasthitx", - Get X axis of last hit
"lasthitz", - Get the Z value of last hit
"levelheight", - Gets the level height (set on the LEVELS.txt)
"levelpos", - Gets the curretn position on the level
"levelwidth", - Gets the total level width (how long is the level)
"lightx", - Gets the Light X value
"lightz", - Gets the Light Z value
"maxanimations", - gets the maximum number of animations
"maxattacktypes", - gets the maximum number of attack types
"maxentityvars", - gets maximum number of variables in each entity which is accessible by index
"maxglobalvars",- gets maximum number of global variables which is accessible by name.
"maxindexedvars", - gets maximum number of global variables which is accessible by index.
"maxplayers", -gets how many players could play at same time
"maxscriptvars", - gets maximum number of variables in each script which is accessible by index.
"models_cached", - gets the ammount of cached models
"models_loaded", - gets the ammount of loaded models
"musicvol", - gets the music volume
"nofadeout", - controls if the the screens fades out when you finish the current level
"nogameover", // don't show gameover (4396+)
"nohof", // don't show hall of fame before gameover (4396+)
"nojoin", - controls if the other players can join the game
"nopause", - controls if you can or cannot pause the game
"nosave", - controls if the game will be saved or not
"noscreenshot", - controls of you can take snapshots or not inside the game
"noshowcomplete" // don't show complete screen after NEXT (4396+)
"numbasemaps", // number of basemaps in the current level (4396+)
"numholes", // number of holes in the current level (4396+)
”numlayers", // number of layers in the current level (4396+)
"numpalettes", - gets the amount of palette from an entity
"numwalls", // number of walls in the current level (4396+)
"pakname", - gets the name of the game .pak
"pause", - detects if the game is paused
“pixelformat", - detects the pixel format (8 bit ,16bit, 32bit)
"player", - detects if the entity is a player
"player1", - detects the player 1
"player2", - detects the player 2
"player3", - detects the player 3
"player4", - detects the player 4
"player_max_z", - gets the maximum z position of the stage (how much "downward" on the stage an entity can go to).
"player_min_z", - gets the minimum z position of the stage (how much "upward" on the stage an entity can go to).
"porting" - gets the console version (4396+)
"sample_play_id", - is the last sound ID played (useful to stop the last sound played for example)
"scrollmaxx", - max scroll size that a level can scroll when you walk in X axis
"scrollmaxz", - max scroll size that a level can scroll when you walk in Z axis
"scrollminx", - min scroll size that a level can scroll when you walk in X axis. Example "scrollmaxx-scrollminx = 0" if you level has the same length of the game resolution (the level doesn't scroll)
"scrollminz", - min scroll size that a level can scroll when you walk in Z axis.
"self", - DEPRECATED. Is a global pointer in the engine code that refers to entity currently being updated. It's used by several internal functions and is essential to the engine.
"shadowalpha", - gfxshadow alpha mode
"shadowcolor" - gfxshadow color index.
"skiptoset", - Useful to change the active set (difficult).
"slowmotion", - detects it the slowmotion is active. Useful to detect boss kill (if the slowmotion isn't disabled)
"slowmotion_duration", - detects the duration of the slowmotion
"smartbomber", - detects if the player's special is a "smart bomb" which damages all onscreen enemies, regardless of position.
"soundvol", - controls the sound (samples) volume
"textbox", - is the textbox entity
"ticks", - is the MAIN time count like "elapsed_time" but is the elapsed time from engine run. Ticks is the time passed from engine run.
"totalram", - gets the total RAM available
"usedram", - gets the total used RAM
"vresolution", Get screen height (Vertical resolution)
"viewporth", - Height value for scrolling backgrounds/foregrounds
"viewportw", - Width value for scrolling backgrounds/foregrounds
"viewportx", - X value for scrolling backgrounds/foregrounds
"viewporty", - Y value for scrolling backgrounds/foregrounds
"vscreen", - allocated MAIN screen handler
"waiting", - is a var that is 1 if player waiting in a stage (set by wait at in level#.txt)
"xpos", - Level coords in x position, count from the left side of panels.
"ypos", - Level coords in y position, count from the top of panels.
rand()
retrieve a random number ±X.
srand(seed)
set a seed for random number generator
drawstring(int x, int y, int font#, text, layer)
Draw the text in (x, y) of the screen, with font specified.
This method is costy, because each character is a sprite. And to prevent blinking, have to put this function in an update script (a script that runs each game loop).
layer is the z position
getplayerproperty(playerindex, propname) / changeplayerproperty(playerindex, propname, value)
Get a player's property by name.
'playerindex' is an integer count from 0, that is, 0 means 1p, 2 means 3p, etc.
'propname' is the property's name.
'value' is new value you want to set.
Property names:
"colourmap" - This is the map for the player
"combokey" - This is the key pressed to make a combo, you need a supplementar param to use it: "combostep". Example: getplayerproperty(0, "combokey", getplayerproperty(0, "combostep"))
"combostep" - This is the step (integer number) from 0 to x that define the step move in a combo
"credits" - Credits left
"disablekeys" - This is a flag. these are the keys that you can disable from input.
"ent" - The entity of the player
"entity" - The entity of the player
"hasplayed" - This variable assumes 1 s the player has played at least once. useful for the custom HUD
"hmapl" - This is the start index of hidden map. You can retrieve this when you joining too!
"hmapu" - This is the end index of hidden map. You can retrieve this when you joining too!
"inputtime" - The time when you press a key to make a combo, you need a supplementar param to use it: "combostep". Example: getplayerproperty(0, "inputtime", getplayerproperty(0, "combostep"))
"joining" - This is 1 if tha player joining to play. Useful for custom HUD
"keys" - This is a flag. These are the total keys pressed.
"lives" - Lives left
"mapcount" - Map number of the player. You can retrieve this when you joining too!
"name" - The name of player
"newkeys" - This is a flag. These are the new keys pressed in current frame
"numweapons" - It retrieves the number of weapon of the player. You can retrieve this when you joining too!
"playkeys" - This is a flag. These are the keys to move the character in the level
"releasekeys" - This is a flag. These are the keys released in the current frame
"score" - Score is ...hmm, score. From 0 to 999999999
"spawnhealth" - Initial health of player
"spawnmp" - Initial MP of player
"weapnum" - This is the weapon index
"weapon" - This is a write only value. This is the weapon index. you need a supplementar param to use it: anim_flag. Example: changeplayerproperty(0, "weapon", 2, 0) to change to weapon 2 and anim_flag 0
anim_flag: if set to 1 for scripted midair weapon changing, default 0
Property names:
"model" - Change the model by name, follow the name is another argument, 0 means keep current animation, 1 means reset to default.
"weapon" - Change weapon by index.
"maxhealth" - Max health.
"health" - Current HP left, if it is greater than max, will be set to max.
"maxmp" - Max MP.
"mp" - Current MP left, if it is greater than max, will be set to max.
"name" - Name, or we say alias.
"position" - Follow by x, z, a, do a nice warp.
"base" - Base altitude of the entity.
"velocity" - Follow by speed in x, z, a direction, entity will move in this speed each A.I. loop. These values can be modified by A.I. functions, so it is almost useless until it is a non-AI controlled character,e.g., type none.
"defense" - Change one of the defense factors of this entity. Follow by an integer specifies the attack type(see 'openborconstant'), and a decimal value specifies the defense factor, e.g. 1.0 means reduce damage of this type by 100%.
"offense" - Change one of the offense factors of this entity. Follow by an integer specifies the attack type(see 'openborconstant'), and a decimal value specifies the offense factor, e.g. 1.0 means increase attack power of this type by 100%.
"nograb" - An integer, whether this entity can be grabbed, see nograb/cantgrab property of entity.
"map" - Integer that sets color remap of entity. 0 = default, 1 = first remap, and so on. Icons are not affected.
"stealth" - Entity's stealth factor.
"detect" - Entity's stealth detect factor.
"damage_on_landing" - Damage that will be applied at end of a fall. If -1, entity will instantly recover at end of fall and play "land" animation if it has one.
"attacking" - Enttiy's attack box status. When 0, attack box will not hit other entities.
"projectile" - Entity's projectile (blasted or thrown) status. 0 = Normal, 1 = Blasted or thrown.
"seal" - Entity's seal property. Entity cannot perform any special with an energy cost >= seal property.
"sealtime" - The elapsed gametime when engine will reset seal property to 0.
"blockpain" - Entity blockpain property. If intended damage from blocked attack >= blockpain, entity will briefly twitch or play Blockpain animation if it has one.
"drain" - Follow with {drain}, {draintime}, {drainamt}, {drainrate} to change drain properties.
"rush_count" - current rush count
"rush_tally" - max rush count
"rush_time" - how much time you have before rush has ended.
"animhits" - the internal hit counter for current animation.
tossentity(entity, height, speedx, speedz)
Just like a jump, 'toss' the entity to the air.
'entity' is the handle of that entity.
'height' is the jump height.
'speedx' is the speed in x direction.
'speedz' is the speed in z direction.
setspawnentry(propname, values)
Set a property of the spawn entry. These's a global spawn entry, you can change its properties so you can use it to spawn an entity.
'propname' is the property's name. Check spawn command in level's .txt.
'values' is new value.
Property names: All supported in a spawn entry, except 2p/3p/4pspawn.
clearspawnentry()
Clear up the global spawn entry.
spawn()
Use the global spawn entry to spawn an entity.
Return the entity.
openborconstant(name)
Get a constant or system value by name.
Return the value or just an empty variant if the name is not supported.
Names
Types and subtypes for entity. Not all are listed, and not all listed are useful right now.
Type
"TYPE_NONE"
"TYPE_PLAYER"
"TYPE_ENEMY"
"TYPE_ITEM"
"TYPE_OBSTACLE"
"TYPE_STEAMER"
"TYPE_SHOT"
"TYPE_TRAP"
"TYPE_TEXTBOX"
"TYPE_ENDLEVEL"
"TYPE_NPC"
Subtype
"SUBTYPE_NONE"
"SUBTYPE_BIKER"
"SUBTYPE_BOOMERANG"
"SUBTYPE_NOTGRAB"
"SUBTYPE_ARROW"
"SUBTYPE_TOUCH"
"SUBTYPE_WEAPON"
"SUBTYPE_NOSKIP"
"SUBTYPE_FLYDIE"
"SUBTYPE_BOTH"
"SUBTYPE_PROJECTILE"
"SUBTYPE_FOLLOW"
"SUBTYPE_CHASE"
Attack types
"ATK_NORMAL"
"ATK_NORMAL2"
"ATK_NORMAL3"
"ATK_NORMAL4"
"ATK_BLAST"
"ATK_BURN"
"ATK_FREEZE"
"ATK_SHOCK"
"ATK_STEAL"
"ATK_NORMAL5"
"ATK_NORMAL6"
"ATK_NORMAL7"
"ATK_NORMAL8"
"ATK_NORMAL9"
"ATK_NORMAL10"
"ATK_ITEM" = attack type when hit by an "itembox" from an item.
"ATK_LAND" = is for damage taken when damage_on_landing is applied, or from the engine's default Throw system.
"ATK_LIFESPAN = attack type which happens when the LIFESPAN value is reached
"ATK_PIT" = its an attack type which happens when you fall on a hole
"ATK_TIMEOVER = attack type which happens when you got a time over
Level directions.
"SCROLL_RIGHT"
"SCROLL_DOWN"
"SCROLL_LEFT"
"SCROLL_UP"
"SCROLL_BOTH"
Direction of an entity. (4194+)
DIRECTION_LEFT
DIRECTION_RIGHT
Direction adjustment property for binding and attack hits. (4194+)
DIRECTION_ADJUST_LEFT
DIRECTION_ADJUST_OPPOSITE -- Force target's direction to opposite of owner's.
DIRECTION_ADJUST_NONE
DIRECTION_ADJUST_RIGHT
DIRECTION_ADJUST_SAME -- Force target's direction to same of owner.
Animation id.
"ANI_IDLE"
"ANI_WALK"
"ANI_JUMP"
"ANI_LAND"
"ANI_PAIN"
"ANI_FALL"
"ANI_RISE"
"ANI_ATTACK1"
"ANI_ATTACK2"
"ANI_ATTACK3"
"ANI_ATTACK4"
"ANI_UPPER"
"ANI_BLOCK"
"ANI_JUMPATTACK"
"ANI_JUMPATTACK2"
"ANI_GET"
"ANI_GRAB"
"ANI_GRABATTACK"
"ANI_GRABATTACK2"
"ANI_THROW"
"ANI_SPECIAL"
"ANI_FREESPECIAL"
"ANI_SPAWN"
"ANI_DIE"
"ANI_PICK"
"ANI_FREESPECIAL2"
"ANI_JUMPATTACK3"
"ANI_FREESPECIAL3"
"ANI_UP"
"ANI_DOWN"
"ANI_SHOCK"
"ANI_BURN"
"ANI_SHOCKPAIN"
"ANI_BURNPAIN"
"ANI_GRABBED"
"ANI_SPECIAL2"
"ANI_RUN"
"ANI_RUNATTACK"
"ANI_RUNJUMPATTACK"
"ANI_ATTACKUP"
"ANI_ATTACKDOWN"
"ANI_ATTACKFORWARD"
"ANI_ATTACKBACKWARD"
"ANI_FREESPECIAL4"
"ANI_FREESPECIAL5"
"ANI_FREESPECIAL6"
"ANI_FREESPECIAL7"
"ANI_FREESPECIAL8"
"ANI_RISEATTACK"
"ANI_DODGE"
"ANI_ATTACKBOTH"
"ANI_GRABFORWARD"
"ANI_GRABFORWARD2"
"ANI_JUMPFORWARD"
"ANI_GRABDOWN"
"ANI_GRABDOWN2"
"ANI_GRABUP"
"ANI_GRABUP2"
"ANI_SELECT"
"ANI_DUCK"
"ANI_FAINT"
"ANI_CANT"
"ANI_THROWATTACK"
"ANI_CHARGEATTACK"
"ANI_VAULT"
"ANI_JUMPCANT"
"ANI_JUMPSPECIAL"
"ANI_BURNDIE"
"ANI_SHOCKDIE"
"ANI_PAIN2"
"ANI_PAIN3"
"ANI_PAIN4"
"ANI_FALL2"
"ANI_FALL3"
"ANI_FALL4"
"ANI_DIE2"
"ANI_DIE3"
"ANI_DIE4"
"ANI_CHARGE"
"ANI_BACKWALK"
"ANI_SLEEP"
"ANI_FOLLOW1"
"ANI_FOLLOW2"
"ANI_FOLLOW3"
"ANI_FOLLOW4"
"ANI_PAIN5"
"ANI_PAIN6"
"ANI_PAIN7"
"ANI_PAIN8"
"ANI_PAIN9"
"ANI_PAIN10"
"ANI_FALL5"
"ANI_FALL6"
"ANI_FALL7"
"ANI_FALL8"
"ANI_FALL9"
"ANI_FALL10"
"ANI_DIE5"
"ANI_DIE6"
"ANI_DIE7"
"ANI_DIE8"
"ANI_DIE9"
"ANI_DIE10"
"ANI_TURN"
"ANI_RESPAWN"
These are infact variable, but unchanged during a level.
"PLAYER_MIN_Z"
"PLAYER_MAX_Z"
"BGHEIGHT"
"MAX_WALL_HEIGHT"
These are the sound effects defined by the module and loaded at startup.
"SAMPLE_GO"
"SAMPLE_BEAT"
SAMPLE_BLOCK"
"SAMPLE_INDIRECT"
"SAMPLE_GET"
"SAMPLE_GET2"
"SAMPLE_FALL"
"SAMPLE_JUMP"
"SAMPLE_PUNCH"
"SAMPLE_1UP"
"SAMPLE_TIMEOVER"
"SAMPLE_BEEP"
"SAMPLE_BEEP2"
"SAMPLE_BIKE"
playerkeys(playerindex, newkey?, key1, key2, key3, ...)
Check if a key is pressed by the player.
'playerindex' is an integer count from 0, that is, 0 means 1p, 2 means 3p, etc.
'newkey?', 0 if the keys are not new.
key names:
"jump"
"attack"
"special"
"esc"
"start"
"moveleft"
"moveright"
"moveup"
"movedown"
"screenshot"
"anybutton"
Any combination is allow, but no reason to use "anybutton" with others.
Return 1 only when all buttons in list are pressed, keep in mind.
NOTE* This method call is a bit buggy as of 8/8/2007. If not used in "key#.c" it will always return 0 unless newkey? = 0. If used to detect multiple keys, 1 will be returned if ANY of the specified keys are pressed.
playmusic(name, loop)
Play a bor music.
'name' is the path.
'loop': 0 means dont loop, 1 means loop.
playsample(sample, prioroity, lvolume, rvolume, speed, loop)
Play a defined sound sample.
'sample' is a sample constant (see openborconstant()).
'priority' is the playing priority.
'lvolume' is left volume.
'rvolume' is right volume.
'speed' is the play speed.
'loop': 0 = no loop, 1 = loop.
To play a sound with normal defaults used by the engine, use the following settings (this will play the beat sound): 'playsample(openborconstant("SAMPLE_BEAT"), 0, 120, 120, 100, 0);'
changepalette(index)
Change current palette to specified one.
'index' is an integer, 0 means default palette, 1-? can be any palette you loaded with command palette in level's .txt. If it is out of range, default will be used.
Only the onscreen entity's palette will change. Its icon (if any) will not.
killentity(entity)
Kill the entity.
'entity' is the entity you want to kill.
This method wont display the entity's death animation, or any animation for that matter; the entity is removed instantly. If you want to kill an entity with death animation, use damageentity().
damageentity(entity, other, force, drop, type)
Damage the entity.
'entity' is the entity you want to damage.
'other' who damage this entity, can be itself, if you specify a player's entity, score will be added. Default to the entity itself.
'force' is the attack force. default to 1.
'drop' is whether the attack knocks down the entity.
'type' attack type, e.g., a shock attack or attack1-10, see openborconstant, the constants starts with 'ATK_'
findtarget(entity, int animnum)
Returns handle of the nearest hostile entity.
'entity' is the entity who?s nearest hostile you want to return. For example, if ?entity? is a PC, then the handle returned will be that of the nearest enemy character.
animnum - Animation id. Optional. If it is given, the range values of the animation will be used to test if the target is in range.
Among other things, this is very useful for making range based or "guided" attacks.
drawbox(x,y,width,height,z,color,alpha)
draw a filled box with specified position and size.
x,y: position values on screen
width,height: size values.
z: depth value, similar to setlayer command or entities, check it for details.
color: color index in palette, check you palette.
alpha: alpha blending effect from 1 to 6, this parameter is optional.
return: none
drawline(x1,y1,x2,y2,z,color,alpha)
draw a line from (x1, y1) to (x2, y2)
x1, y1: position values of the start point.
x2, y2: position values of the end point.
z: depth value, similar to setlayer command or entities, check it for details.
color: color index in palette, check you palette.
alpha: alpha blending effect from 1 to 6, this parameter is optional.
return: none
drawdot(x, y, z,color,alpha)
draw a dot at (x, y)
x, y: position values of the dot.
z: depth value, similar to setlayer command or entities, check it for details.
color: color index in palette, check you palette.
alpha: alpha blending effect from 1 to 6, this parameter is optional.
rgbcolor(value1,value2,value3)
the colors in computer are represented by 3 bytes in hexadecimal encoding (in form RGB).
ex. 0xFF0000 which is the color red. 0xFF is the red gradient R 0x00 is the green gradient G (empty) and the last 0x00 is the blue gradient B. This is the RGB form.
some devices read the color from left to right and the others on the contrary.
for example the Wii reads 0xFF0000 as 0x0000FF that is blue instead.
To overcome these disadvantages of incompatibility is useful to use rgbcolor().
EXAMPLE: good: changedrawmethod(NULL(), "tintcolor", rgbcolor(0xFF,0x00,0x00)); // red in anyway incompatibility issues: changedrawmethod(NULL(), "tintcolor", 0xFF0000); // red on pc but blue on Wii
allocscreen(width, height)
Create a screen, return the handle. Basically you should call it in levelscript, but it is up to you. Be sure to store the handle or if you lose it you will not be able to free it, so it will take up memory until shut down. You can exit the engine normally and check the log to see if you forget to releas some of them.
drawlinetoscreen(screen, x1, y1, x2, y2, color, alpha);
Similar to drawline, use the screen instead of the sprite queue. And also:
drawboxtoscreen(screen, x, y, width, height, color, alpha) drawdottoscreen(screen, x, y, color, alpha)
free(handle) Release a object created by script engine, it is now only available for the handle created by allocscreen, until we add some other dynamic alloc methods. Basically you should call it in endlevelscript, but it is up to you.
drawscreen(screen, x, y, z,alpha)
Draw current screen.
x, y: position values of the coordination.
z: depth value, similar to setlayer command or entities, check it for details.
color: color index in palette, check you palette.
alpha: alpha blending effect from 1 to 6, this parameter is optional.
jumptobranch(name, immediate)
Go to branch by name. Branches is defined in levels.txt, check the manual for details.
name: the branch name, must be those defined in levels.txt
immediate: when set to 1, you will go to that level immediately if you are currently in a level, or else, you will still need to beat current level.
bindentity(entity, target, int x, int z, int a, int direction, int bindanimation, int sortid)
Bind entity to target, so the target moves, the entity moves.
x, z, a: relative to target.
direction: 0 no change 1 same direction as target -1 opposite direction as target 2 always right -2 always left
bindanimation: 0 No effect. 1 Keep same animation as the target. 2 Also keep same frame as the target. 4 Kill the entity if the animation doesn't match.
sortid: -1 by default. -1 means that the binded entity is on back the target. you can set 1 to show binded entity in front of target or you can use what-you-want value.
To unbind a entity, use bindentity(entity, NULL());
Partial binding is now possible (4183+). Pass NULL() to any axis you do not want to bind.
Notice: You can combine those values for bindanimation, so it can be 6 which means 2 and 4.
changelight(int x, int z)
Change light direction for gfxshadow.
x, z: direction value, a positive x will make the shadow lean to the right, a positive z will make the shadow upward, or else they will be flipped.
Give 256 or -256 to z will make the shadow as long as its owner.
Try different values until you find the correct one.
changeshadowcolor(int colorindex)
Change gfxshadow color.
Note, gfxshadow use alpha 2, same as shadow.
changelevelproperty(name, propertyvalue)
Change a property value of current level, this function is not quite completed.
You need to provide at least two values (name and property value)
Some properties like "basemap", "wall" and "hole" needs more values.
Refer the manual for more information about each item.
Name can be:
"basemap",
"bgspeed"{float},
"cameraxoffset" {integer},
"camerazoffset"{integer},
"gravity" {float},
"hole",
"maxfallspeed" {float},
"maxtossspeed" {float},
"quake" {integer},
"rocking" {integer},
"scrollspeed"{float},
"type"{string},
"vbgspeed",
"wall",
Basemap has additional values (refer the manual for more information about Basemap):
"map" {integer},
"x" {float},
"xsize" {float},
"z" {float},
"zsize" {float},
Walls and Holes has additional values:
"depth" {float},
"height" {float},
"lowerleft" {float},
"lowerright" {float},
"type" {integer},
"upperleft" {float},
"upperright" {float},
"x" {float},
"z" {float},
loadmodel(name)
"Load" a model that is currently set as "know" in models.txt.
"name" is the model's name.
loadsprite(path)
Load a single sprite from the path specified and return the handle for later use.
You can free the sprite by calling script function free.
Notice, the sprite will never be free automatically by the engine until the engine is about to shutdown so you have to keep the handle and free it manually later.
Notice, the offset of the sprite will be always (0,0) like any regular icon and panel.
Notice, the sprite is completely new, so if the path is used by an entity, there's not side effects if the entity model is unloaded.
drawsprite(sprite, int x, int y, int z, int sortid)
Draw a sprite.
Sprite must be a valid handle.
x, y are the draw position.
z is depth, sprite with a greater z value will appear above those with smaller z values.
If more than one sprites use same z value, you need sortid to sort them, also, a greater value makes the sprite appear above others. In most situations, just use 0.
See function setdrawmethod if you want to use special effects for the sprite.
Notice: the sprite handle must be valid, that means if the sprite is removed already, an error might happen.
drawspritetoscreen(sprite, screen, int x, int y)
Draw a sprite to a screen.
sprite must be a valid handle.
screen must be a valid handle returned by allocscreen.
x, y are draw position.
See function setdrawmethod if you want to use special effects for the sprite.
setdrawmethod(entity, int flag, int scalex, int scaley, int flipx, int flipy, int shiftx, int alpha, int colourmap, int fillcolour, int rotate, int rotateflip, int transparencybg)
Set drawmethod for an entity or define a global drawmethod for other script functions.
entity must be a valid entity handle or an empty value.
All other parameters are optional.
flag defines whether the drawmethod is active, when set to 0, the drawmethod will not take effect.
scalex defines how the sprite will be stretch in x direction: sizex = original_sizex * scalex / 256
scaley defines how the sprite will be stretch in y direction: sizey = original_sizey * scaley / 256
flipx defines whether the sprite will be flipped left/right. 0 means don't flip and 1 means flip.
flipy defines whether the sprite will be flipped top/bottom. 0 means don't flip and 1 means flip.
shiftx defines how the sprite leans, like lightx in gfxshadow feature, in most situations you don't need this.
alpha defines which alpha blending effect will be used. 0 means no alpha effect. -1 means the entity(if given) will use its own alpha value.
colourmap(entity only) defines which colourmap will be used. 0 means no colourmap. -1 means the entity(if given) will use its current colourmap.
fillcolour is the colour used by the entire sprite. 0 means don't fill the sprites.
rotate is the rotate angle(clockwise), the range is from 0 to 359.
rotateflip(entity only) means whether the entity will flip its rotate direction if the facing is changed.
transparencybg(screen only) means whether the screen will use transparency colour.
Notice: In 8bit mode, fillcolour is the index in palette, otherwise, it will be a RGB value which needs to be calculate first(no system functions available now).
Notice: For screen, transparency colour is the first colour in palette(8bit) or pure black colour(which is also 0).
Notice: If the entity parameter is an empty value, it will change the global drawmethod, and can be used by other script functions like drawsprite or drawscreen.
changedrawmethod(entity, propertyname, value);
Change drawmethod for an entity or define a global drawmethod for other script functions.
alpha, // Defines which alpha blending effect will be used. 0 means no alpha effect. -1 means the entity(if given) will use its own alpha value.
amplitude, // Sets the amplitude of sine wave for water effect
beginsize, // Sets size multiplier of upper border. The upper border should be smaller than lower one cause the former is farther
centerx, // Sprite's X offset. For an entity's animations this is initially the same as the frame offset. Otherwise both is 0.
centery, // Sprite's X offset. For an entity's animations this is initially the same as the frame offset. Otherwise both is 0.
channelb, // Defines the value for the B (blue) channel
channelg, // Defines the value for the G (green) channel
channelr, // Defines the value for the R (red) channel
clip, // Accepts all clipping attributes at once. Leave it alone and use the individual clip attributes instead.
cliph, // Defines the width of the cropped area (horizontal)
clipw, // Defines the start point in x axis (horizontal)
clipx, // Defines the start point in y axis (vertical)
clipy, // Defines the height of the cropped area
enabled, // Redundant - both do the same thing. Use enabled.
endsize, // Sets size multiplier of upper border of Water mode
fillcolor, // Is the colour used by the entire sprite. 0 means don't fill the sprites. An integer value, from 0 to 255, specify a color index in your palette. It can be used with alpha, fill current frame with this color. You can either use a raw integer value or in R_G_B format, the later has better compatibility obviously.
flag, // defines whether the drawmethod is active, when set to 0, the drawmethod will not take effect.
fliprotate, // is binary value. When it is set to 1(should be only 0 or 1, not other values), the entity will change the rotate value when the direction is changed(entity's direction, if you use flipx for the frame, it is not affected), the rotate value will be 360-original, so
flipx, // defines whether the sprite will be flipped left/right. 0 means don't flip and 1 means flip. An integer value, when set to 1, the frame will be flipped leftright.
flipy, // defines whether the sprite will be flipped top/bottom. 0 means don't flip and 1 means flip. An integer value, when set to 1, the frame will be flipped updown.
perspective, // Defines z depth effect it should have (Water mode)
remap, // Defines which colourmap will be used. 0 means no colourmap. -1 means the entity(if given) will use its current colourmap.
reset, // Resets all attributes to their default values.
rotate, // Is the rotate angle(clockwise), the range is from 0 to 359.
scalex, // Defines how the sprite will be stretch in x direction: sizex = original_sizex * scalex / 256
scaley, // Defines how the sprite will be stretch in y direction: sizey = original_sizey * scaley / 256
shiftx, // defines how the sprite leans, like lightx in gfxshadow feature
table, // Pointer to color table in use by sprite. As always, if you apply a color table with cells that don't line up with the sprite's original table, you'll get Rainbow Dash with a hangover.
tintcolor, // Will tint the sprite with given tintcolor, in alpha mode tintmode
tintmode, // Defines the tintmode
transbg, // Behavior of the transparent color. 0 = Display the transparent color. 1 = Do not display transparent color. It's more efficient to display the transparent color, so use this option where your module design permits. Good candidates are the last layer in backgrounds, certain panels, signs, and so on.
watermode, // Determines water effect. Currently there are 3 modes.
wavelength, // Determines length of sine wave in pixels. It's repeated since it's sine wave. Only apply if {watermode} is not 3 (see below)
wavespeed, // Determines the moving speed of sine wave. Only apply if {watermode} is not 3 (see below)
wavetime, // (elapsed_time + text_time) * wavespeed each time a layer in the level is drawn. Has no functionality, it's mostly a debugging tool.
xrepeat, // Determine how many times the image will repeat in X axis. Setting 0 will make layer not drawn at all (it will become palette holder). Setting -1 will make it repeat forever
xspan, // For background layers, controls x spacing. See xspan.
yrepeat, // Determine how many times the image will repeat in Y axis. Setting 0 will make layer not drawn at all (it will become palette holder). Setting -1 will make it repeat forever
yspan, // For background layers, controls y spacing. See zspan.
Notice: In 8bit mode, fillcolour is the index in palette, otherwise, it will be a RGB value which needs to be calculate first(no system functions available now).
Notice: For screen, transparency colour is the first colour in palette(8bit) or pure black colour(which is also 0).
Notice: If the entity parameter is an empty value, it will change the global drawmethod, and can be used by other script functions like drawsprite or drawscreen.
playgif(path, int x, int y, int noskip)
Play a gif file as a cut scene, you can call it in game.
path, the gif file path, like first parameter of command animation in scene txt.
x, y position of the gif animation, like 2nd and 3rd parameters of command animation in scene txt.
noskip, when set to 1, you can't press button to skip it.
Notice: path is required. All other parameters are optional, and default value is 0.
Notice: it needs some extra memory to play a gif file, about 75kb if the screen is 320x240/8bit.
playwebm(path, int noskip)
Play a webm file as a cut scene, you can call it in game.
path, the gif file path, like first parameter of command animation in scene txt.
noskip, when set to 1, you can't press button to skip it.
Notice: path is required. All other parameters are optional, and default value is 0.
Notice: a webm is played ONLY if the device has the webm support.
checkrange(entity, target, int animid)
Check if the given target is in range. Range, rangez, rangea of the specified animation will be used for checking.
entity - animation owner. Must be a valid entity handle. Required.
target - must be a valid entity handle. Required.
animid - animation id. Optional. If it is not given, current animation will be used.
updateframe(entity, int frame)
This method update current animation's frame number, a replacement of changeentityproperty(..., "animpos").
performattack(entity, int anim, int resetable)
This method allow the entity to do an attack, not just give it attack animation.
anim - Optional. It stands for animation number, can be got by openborconstant.
resetable - Optional. If current animation number is same as this one, and resetable is 1, current animation will be reset or else, the anim will be ignored.
Notice: If you provide anim parameter, and this function is called in an animation script, you probably need to add a return behind it because the animation might be changed and the animation script will be re-called.
executeanimation(entity, int anim, int resetable)
it works like performattack() but just you play an animation without animation loop.
This function is useful to avoid changeentityproperty(entity,"animation",value) loop issue!
setidle(entity, int anim, int resetable, int stalltime)
This method change the entity back to idle status.
anim - same as above. Optional. You probably will use idle animation, but that is up to you.
resetable - same as above. Optional.
stalltime - how long will current idle status last, in game tick. 200 will be about 1 second. Optional.
Notice, idle status means the entity can change to other status automatically by the engine. So walk/run/idle can all be treated as idle.
Also notice, you can set velocity for the entity later to simulate walk/run.
getentity(int index)
Return entity by index.
If this method succeeds it will return the entity handle, but be sure to check "exist" property by getentityproperty because it might be a dead one. If index is out of range, this function will return an empty value, make sure you check it if you are not sure.
The range is from 0 to MAX_ENTS-1, you can get MAX_ENTS by openborconstant("MAX_ENTS")
Notice, the entities are not always in same order, if you call it during a gameloop, it is safe, but if you use same index next time, the result might be different.
MAX_ENTS is a large number, but most mods only have few entities on screen, so you should use openborvariant("ent_max") instead, it is a variable, so make sure you get it in different game loop.
recordinputs(value,pathname,filename)
This function allow you to rec/play your gameplay. It's a replay! Useful for attract mode for example.
pathname: is the pathname string. if set "" value (empty string) default pathname will be saves openbor path
filename: that you want to read/save
value:
0 to stop the rec/play
1 to rec
2 to play
3 to free (dont worry when you use 0 you free the buffer too). the 3 param is not really useful.
usage:
to rec: recordinputs(1,"","myrec.inp");
to play: recordinputs(2,"","myrec.inp");
to stop: recordinputs(0);
to free: recordinputs(3);
example: write in levelscript: recordinputs(1,"","myrec.inp"); if(playerkeys(0,1,"esc")) { recordinputs(0); } play at level.. press "esc" to terminate the rec. then change recordinputs(1,"","myrec.inp"); in recordinputs(2,"","myrec.inp"); to test and play the recorder gameplay!
note: you need for a deterministic game and so is not allowed a custom seed. If you change anything in your mod or change the engine version you need to re-record the gameplay!! I raccomanded you to disable all keys during the gameplay with new playerproperty(pindex,"disablekeys") excluded keys to stop the gameplay. then reactivate the Keys. to disable keys just changeplayerproperty(pindex,"disablekeys",openborconstant("FLAG_START")+openborconstant("FLAG_ATTACK")); for example to re-enable keys just: changeplayerproperty(pindex,"disablekeys",0);
getrecordingstatus()
use getrecordingstatus() to get the gameplay status 0 or 1 or 2 according to recordinputs() values
Entityproperty
getentityproperty(entity, propname) / changeentityproperty(entity, propname, values)
Get an entity's property by name.
'entity' is the handle of that entity.
'propname' is the property's name.
'value' is new value you want to set.
Property names:
"a" - Altitude (DEPRECATED)
"aggression" -
"aiattack" -
"aiflag" -
"aimove" -
"alpha" - Channel for sprite fusion. From 0 to 6.
"animal" -
"animating" - In return 0 if the entity isn't in animation (static frame), 1 if animation forward (from 0 to X) and -1 if animating backward (from X to 0). Example AI enemies when walking back have "animating" == -1.
"animation" - The handle of current animation.
"animation.handle" -
"animationid" - The id of current animation. It is an integer value, see 'openborconstant'.
"animheight" -
"animhits" - The internal hit counter for current animation.
"animnum" - Is the "animationid"
"animpos" - Frame position of current animation.
"animvalid" - It returns 1 if animation exists in entity.txt
"antigrab" -
"antigravity" -
"attackid" -
"attacking" - Entity's attack box status. When 0, attack box will not hit other entities.
"attackthrottle" -
"attackthrottletime" -
"autokill" -
"base" - Altitude base where is the entity on, if a equals base, this entity is in air.
"bbox" -
"blink" -
"blockback" -
"blockodds" -
"blockpain" - Entity blockpain property. If intended damage from blocked attack >= blockpain, entity will briefly twitch or play Blockpain animation if it has one.
"boomerang" - changeentityproperty(entity,"boomerang",acceleration,horizontal_distance) and getentityproperty(entity,"boomerang",flag) -> flag: 0 = acceleration, 1 = horizontal_distance
"boss" -
"bounce" -
"bound" -
"candamage" -
"chargerate" -
"colourmap" -
"colourtable" -
"combostep" -
"combotime" -
"custom_target" - If set it you can force an enemy to use it as target.
"damage_on_landing" - Damage that will be applied at end of a fall. If -1, entity will instantly recover at end of fall and play "land" animation if it has one.
"dead" -
"defaultmodel" - Model name base (no weapon name)
"defaultname" - Model name base (no weapon name)
"defense" - Return one of the defense factors of this entity. Follow by an integer specifies the attack type(see 'openborconstant', and also 'changeentityproperty').
"destx" - Destination of coord X for A.I.
"destz" - Destination of coord Y for A.I.
"detect" - Entity's stealth detect factor.
"direction" - Direction, 1 means left, 0 means right.
"dot" -
"dropframe" -
"edelay" -
"energycost" -
"escapecount" -
"escapehits" -
"exists" - Well, whether the entity is a valid one.
"facing" -
"falldie" -
"flash" -
"freezetime" -
"frozen" -
"gfxshadow" - This is the flag to set gfxshadow
"grabbing" - Entity currently held in a grab (if any). Only returns currently held entity.
"grabforce" -
"guardpoints" -
"hasplatforms" - It returns 1 if the entity you set is has a platform in current animation
"health" - Current HP left.
"height" - Height of a entity. If not set, you can't hit the latform with head.
"hitbyid" -
"hitheadplatform" - It returns the platform handler if the entity hit the platform with head and set the entity height > 0
"hitwall" - It returns 1 while you hit a wall/obstacle/platform while y > base
"hmapl" - Start index of hidden maps that you set with hmap X Y.
"hmapu" - End index of hidden maps that you set with hmap X Y.
"hostile" -
"icon" -
"iconposition" -
"invincible" -
"invinctime" -
"jugglepoints" -
"jumpheight" -
"jumpmovex" -
"jumpmovez" -
"jumpspeed" -
"knockdowncount" -
"komap" -
"landedplatform" - It returns the platform handler where the entity is on if entity is on, otherwise it returns NULL()
"landframe" -
"lifeposition" -
"lifespancountdown" -
"link" -
"map" - Current color remap in use. 0 = default, 1 = first remap, and so on.
"mapcount" - Number of maps
"mapdefault" -
"maps" -
"maptime" -
"maxguardpoints" -
"maxhealth" - Max health.
"maxjugglepoints" -
"maxmp" - Max MP.
"model" - Model name.
"mp" - Current MP left.
"mpdroprate" -
"mprate" -
"mpset" -
"mpstable" -
"mpstableval" -
"name" - Current name, or we say alias.
"nameposition" -
"nextanim" -
"nextmove" -
"nextthink" -
"no_adjust_base" -
"noaicontrol" -
"nodieblink" -
"nodrop" -
"nograb" -
"nohithead" - set nohithead 1 in entity.txt and even if you set an height for the entity, if it hit a platform with nohithead param set to 1, the entity will not block with head by a platform. But this platform will be walkable however. default is 0
"nolife" -
"nopain" -
"numweapons" - It returns the number of weapons of the entity.
"offense" - Return one of the offense factors of this entity. Follow by an integer specifies the attack type(see 'openborconstant', and also **'changeentityproperty').
"offscreen_noatk_factor" - set the chance (you need 1.0) has the enemy to attack offscreen. if you set 1.0 (NO ATK FACTOR) the enemy will not attack offscreen
"offscreenkill" - set after how many pixels offscreen the enemy can die
"opponent" - Last entity interacted with (damaged, damaged by, grabbed, etc.). Essentially this returns whoever would be showing up on a player's enemy life meter, but works for all entities.
"owner" -
"pain_time" -
"parent" -
"path" -
"pathfindstep" -
"playerindex" -
"position" -
"projectile" - Entity's projectile (blasted or thrown) status. 0 = Normal, 1 = Blasted or thrown.
"projectilehit" -
"range" -
"releasetime" -
"running" -
"rush_count" - current rush count
"rush_tally" - max rush count
"rush_time" - how much time you have before rush has ended.
"score" -
"scroll" -
"seal" - Entity's seal property. Entity cannot perform any special with an energy cost >= seal property.
"sealtime" - The elapsed gametime when engine will reset seal property to 0.
"setlayer" -
"shadowbase" -
"sortid" -
"spawntype" -
"speed" -
"sprite" -
"spritea" -
"stalltime" -
"stats" -
"staydown" -
"staydownatk" -
"stealth" - Entity's stealth factor.
"subentity" -
"subject_to_basemap" -
"subject_to_gravity" -
"subject_to_hole" -
"subject_to_maxz" -
"subject_to_minz" -
"subject_to_obstacle" -
"subject_to_platform" -
"subject_to_screen" -
"subject_to_wall" -
"subtype" - Subtype, e.g., arrow, biker. It is an integer value, see 'openborconstant'.
"takeaction" -
"think" -
"thold" -
"throwdamage" -
"throwdist" -
"throwframewait" -
"throwheight" -
"tosstime" -
"tossv" - Toss velocity (jumping or falling).
"trymove" -
"type" - Type, e.g, enemy, player. It is an integer value, see 'openborconstant'.
"velocity" - Set the velocity. It accepts 3 params. NULL() is valid.
"vulnerable" -
"walkoffmovex" -
"walkoffmovez" -
"weapent" -
"weaploss" - It accepts to values, example: changeentityproperty(entity,"weaploss",1,0). For first value see weaploss {flag} for second set the flag active on/off
"weapnum" - Set/get the weapon index
"weapon" - Set/get the weapon index but it accepts a second param, anim_flag: if set to 1 for scripted midair weapon changing, default 0
"x" - X position in level.
"xdir" - Horizontal velocity.
"y" - Altitude position in level.
"z" - Z position in level.
"zdir" - Vertical velocity.
Custom Menu Function
loadgamefile()
loadgamefile(): reload saved level file from saves (example bor.sav)
getsaveinfo(set_index, prop)
gets the info from *.sav file loaded by loadgamefile().
if a game has 3 SETS (ex ARCADE, VERSUS, TRAINING), set_index will be 0 (ARCADE) or 1 (VERSUS) or 2 (TRAINING).
set_index is the index of your set. from 0 to ... X
prop has these wildcards:
"flag": is there a slot in memory? if yes flag == 1 else 0.
"level"
"stage"
"times_completed"
"score"
"lives"
"credits"
"name"
"playername"
"health"
"mp"
getsaveinfo(0, "SCORE") returns the score in ARCADE set (if the set 0 is ARCADE for example) in the last playing.
playgame(set_index, usesave)
set_index like getsaveinfo and usesave == 1 if you want continue your game from a loaded file, else use 2.
Example: playgame(0,1) to continue the ARCADE mode or playgame(0,2) to start an ARCADE mode.
options()
it shows options menu (control, video, etc..) for a custom menu.
shutdown()
it closes the engine.
gotomainmenu(flag)
to go to main menu
flag: gotomainmenu(flag); flag: 1 = no gameover, 2 = no halloffame, 4 = no intro.txt; you can use a combination like 1+2 = 3 or all 1+2+4 = 7
flag doesn't affect set nogameover/nohof
Script Compile Functions
allocscript(name, comment)
it allocs a script in memory.
useful to compile a dynamic script on fly.
EXAMPLE: allocscript("Script1", "this script is the 1st one")
loadscript(handle, path)
it loads a script in the handle created by allocscript() from the specified path.
EXAMPLE: loadscript(script_handle, "data/scripts/script.c")
compilescript(handle)
it compile a script on fly
executescript(handle)
it executes a script.
void handle = allocscript("script1","any_comment");
loadscript(handle,"data/scripts/script.c");
compilescript(handle);
executescript(handle);
NOTE: if you want you can create a script file with filestream functions. then you can load and execute your script on fly!
String Functions
strinfirst(string, substring)
search the first match in a string.
params are complete string and substring to search in complete string.
it search SUBSTRING in STRING and if the substring is in string returns the substring, else it returns -1;
EXAMPLE: strinfirst("HELLO", "LLO") returns LLO strinfirst("HELLO", "HI") returns -1
strinlast(string, substring)
like strinfirst() but returns the last substring match.
that is the func search in the string from right (not from left)
strleft(string, index)
it returns a substring, the left part of a string from index 0 to INDEX.
EXAMPLE: strleft("HELLO", 4) returns "HELL"
strright(string, index)
like strleft() nut it return the right part from INDEX to END_OF_STRING
strlength(string)
it return the string length.
EXAMPLE: strlength("HELLO") returns 5 (the string is length 5 characters)
strwidth(string)
it returns the string width in pixels depending by the font.
if the width of the character is 6 pixels and the string is "HELLO"
strwidth("HELLO") will returns 6x5 = 30 (30 pixels)
useful to align a string in the screen specially if you use multi-byte strings.
EXAMPLE: strwidth("HELLO");
EXAMPLE of substr() and getchar():
char getchar(char str, int index) {
if ( index >= strlength(str) ) index = strlength(str)-1;
else if ( index < 0 ) index = 0;
if ( strlength(str) > 0 ) {
str = strright(str, index);
if ( strlength(str) > 1 ) {
index = 1;
str = strleft(str, index);
}
} //else str = "";
return str;
}
char substr(char str, int start_index, int length) {
if ( start_index+length > strlength(str) ) return NULL();
if ( start_index < 0 || strlength(str) <= 0 ) return NULL();
str = strright(str, start_index);
str = strleft(str, length);
return str;
}
Terrain Script Function
checkhole(x,z,y)
it returns 1 if there's hole here, otherwise it returns 0
y is optional but if you use it, then you can detect an hole just if hole height (default 0) >= y
checkholeindex(x,z,y)
it works like checkhole() but it returns the index of hole in the level, otherwise it returns -1
y is optional
you can use hole index for get/change levelproperty
checkwall(x,z,y)
it returns the height of wall from 0 (not wall or height 0) to... X height
y is optional but if you use it, then you can detect walls from height y, otherwise with just 2 params (x,z) it uses the default value (y = 100000)
checkwallindex(x,z,y)
it works like checkwall() but it returns the index of wall in the level, otherwise it returns -1
y is optional
you can use wall index for get/change levelproperty
checkbasemap(x,z)
it returns the base height in X,Z coords.
if there is a hole, it returns -1000
checkbasemapindex(x,z)
it works like checkbasemap() but it returns the index of basemap in the level, otherwise it returns -1
you can use basemap index for get/change levelproperty
checkplatformbelow(x,z,y)
it returns the platform handler (entity) in X,Z coords below y height, otherwise it returns NULL()
checkplatformabove(x,z,y)
it returns the platform handler (entity) in X,Z coords above y height, otherwise it returns NULL()
checkplatformbetween(x,z,y_min,y_max)
it returns the platform handler (entity) in X,Z coords and bewteen y_min and y_max, otherwise it returns NULL()
generatebasemap(map_index,rx,rz,x_size,z_size,min_y,max_y,x_cont)
It generates an inclined terrain
map_index: is the index of basemap. the new basemap must have last_index + 1 -> last_index + 1 == openborvariant("numbasempas")
rx: it generates basemap from coord X
rz: it generates basemap from coord Z
x_size: it generates basemap from coord X to x+x_size
z_size: it generates basemap from coord Z to z+z_size
min_y: is the minimum height
max_y: is the maxmimum height
you can invert min_y and max_y too!
x_cont: is an optional parameter. yif you set it you generate a basemap from x to x_cont as you set from min_y,max_y param, but from x_cont to x_size
the basemap will have max_y height. Example: generate_basemap(index, rx, rz, x_size, z_size, min_y, max_y, x_cont); from x_cont to x_size basemap will have the max_y height.
you can handle basemap via get/change levelproperty too to create custom basemap. For example generatebasemap() is the hardcoded version of:
void change_basemap(int map_index, float rx, float rz, float x_size, float z_size, float min_y, float max_y, int x_cont) {
float x,z;
float delta,y,tmp;
int dir = 0;
changelevelproperty("basemap", map_index, "x", rx);
changelevelproperty("basemap", map_index, "xsize", x_size+2);
changelevelproperty("basemap", map_index, "z", rz);
changelevelproperty("basemap", map_index, "zsize", z_size+2);
if (min_y <= max_y) dir = 1;
else
{
dir = 0;
tmp = min_y;
min_y = max_y;
max_y = tmp;
}
delta = (max_y - min_y) / ( (x_size <= 0) ? 1 : (x_size-1) );
for( x = 0; x < x_size; x++) {
if ( dir == NULL() || dir > 0 ) {
if ( x == x_size-1 ) y = max_y;
else y = x*delta + min_y;
} else y = max_y - (x*delta); // + min_a
if ( x_cont != NULL() ) {
if ( dir == NULL() || dir > 0 ) {
if ( x+rx >= x_cont ) y = max_y; // connect with the wall more smoothly
} else {
if ( x+rz <= x_cont ) y = max_y;
}
}
for ( z = 0; z < z_size; z++) {
changelevelproperty("basemap", map_index, "map", x, z, y);
}
}
}
Sound Functions
playmusic(name, loop, offset)
Pauses the music abruptly. technically, it toggles the variable 'sound_pause_music', commonly used for the pause menu to stop the music while the pause menu is present.
name: pathname
loop: toggle 1 or 0. 1 for loop music
offset: start music offset
fademusic(fade, name, loop, offset)
With only fade as parameter, it fades the music in or out. Adding parameters, it will replace the current music.
fade volume (0 ~ 128)
name: pathname
loop: toggle 1 or 0. 1 for loop music
offset: start music offset
setmusicvolume(left, right)
left: stereo left volume (0 ~ 128)
right: stereo left volume (0 ~ 128)
setmusictempo(ratio)
{ratio} is tempo. Normal ratio is 100. Higher the value, higher the tempo and vice versa.
pausemusic(toggle)
toggle: 1 or 0. 1 to pause music
pausesamples(toggle)
it works like pausemusic() but it works for ALL sounds.
pausesample(toggle,channel)
it works like pausemusic() but it works for one sound at channel #.
isactivesample(int channel)
it returns 1 if channel is active (sound in play), else it returns 0
sampleid(channel)
returns sample id in channel if sample is active, it returns -1 otherwise
querychannel(sound_id)
query a channel to search is a sound is active. it returns the channel where sound_id is active.
playsample(id, priority, lvolume, rvolume, speed, loop)
id: loaded sample
priority: to play channels with lowest current priority first. default -1
lvolume: left volume
rvolume: right volume
speed: sound speed (integer): from 0 to.. x
loop: 1 or 0. 1 for loop sound
loadsample(filename, log)
filename: filename to load
log: if 1 it writes a log
unloadsample(id)
id: loaded sample
NOTE: to get last sound played use openborvariant("sample_play_id") and to get the max number of channels use: openborvariant("maxsoundchannels")
Example of query function use:
int stop_last_sound(int snd_id) {
int playid = openborvariant("sample_play_id");
int channel;
if ( snd_id != NULL() ) playid = snd_id;
//if(playsample(yousampleid)) setentityvar(self, "lastchannel", openborvariant("sample_play_id"));
if ( playid ) {
channel = querychannel(playid);
//drawstring(20,50,0,channel);
if ( channel >= 0 ) stopchannel(channel);
}
return playid;
}
EXAMPLE SCRIPTS:
obstacle hit and toss direction
@script
void self = getlocalvar("self");
void opp = getentityproperty(self, "opponent");
if ( frame ==1 && getentityproperty(opp, "direction")==1 ){
tossentity(self, 2.3 , 1.2, 0);
changeentityproperty(self, "direction", 0);
}
if ( frame ==1 && getentityproperty(opp, "direction")==0 ){
tossentity(self, 2.3 , -1.2, 0);
changeentityproperty(self, "direction", 1);
}
@end_script
-------
camera move
spawn Empty
@script
void main()
{
void P1 = getplayerproperty(0, "entity");
int x = getentityproperty(P1,"x");
int y = getentityproperty(P1,"y");
changeopenborvariant("xpos", x-320);
changeopenborvariant("ypos", 690-y);
}
@end_script
----------------------
changecharacter working
@script
if(frame==2){
void self = getlocalvar("self");
int PIndex = getentityproperty(self,"playerindex");
changeplayerproperty(PIndex,"name","Donovan");
changeentityproperty(self, "model", "Donovan", 1);
changeentityproperty(self, "name", "Donovan");
setidle(self, openborconstant("ANI_IDLE"));
}
@end_script
------------------
@script
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iName; //Entity name.
int iMax = openborvariant("ent_max"); //Entity count.
float Tx;
float Tz;
float Disx;
float Disz;
if(frame == 0){
//Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iName = getentityproperty(vEntity, "name"); //Get target name
//Sign?
if(iName == "Sign" && vEntity!=self){
Tx = getentityproperty(vEntity, "x");
Tz = getentityproperty(vEntity, "z");
Disx = Tx - x;
Disz = Tz - z;
if(Disx >= -12 && Disx <= 12 && Disz >= -25 && Disz <= -15)
{
performattack(self, openborconstant("ANI_FOLLOW1"));
}
}
}
}
@end_script
-------------- velo script
@script
void self = getlocalvar("self");
if ((getentityproperty(self, "direction")==1)&&(frame == 1)){
changeentityproperty(self, "velocity", -2, 0, 0);
}
if ((getentityproperty(self, "direction")==0)&&(frame == 1)){
changeentityproperty(self, "velocity", 2, 0, 0);
}
if (frame == 4){
changeentityproperty(self, "velocity", 0, 0, 0);
}
@end_script
---- previous anim poprzednia animacja
@script
void self = getlocalvar("self");
void prevanim = getentityproperty(self,"prevanimationid");
if(frame == 1 && prevanim == openborconstant("ANI_RUN")){
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
}
@end_script
@script
void self = getlocalvar("self");
void prevanim = getentityproperty(self,"prevanimationid");
if (frame == 1 && prevanim == 40 ){
settextobj(1, 250 , 180 , 1, 1, prevanim , openborvariant("elapsed_time")+2000);
performattack(self, openborconstant("ANI_ATTACK1"));
}
@end_script
---- entityvar
@script
if(frame==8){
void self = getlocalvar("self");
setentityvar(self, 1, openborvariant("elapsed_time"));
}
@end_script
--- text objects
@cmd settextobj 4 290 160 2 -1 getentityproperty(getlocalvar("self"),"animationid") openborvariant("elapsed_time")+500
@cmd settextobj 4 ((openborvariant("hResolution"))/2 -(strwidth("CANCEL" 1))/2 180 0 -1 "CANCEL"
settextobj(1, openborvariant("hResolution")/2 -strwidth("welcome to the palace", 1)/2, 180 , 1, 1, "welcome to the palace" , openborvariant("elapsed_time")+1000);
settextobj(1, 250 , 280 , 0, -1, getglobalvar("fstatus") , openborvariant("elapsed_time")+2000);
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
int x = getentityproperty(self,"x");
int z = getentityproperty(self,"z");
settextobj(1, x-50-openborvariant("xpos") , z-180-openborvariant("ypos") , 0, -1, "COWABUNGA !" , openborvariant("elapsed_time")+2000);
enemies names and anims check then change anim---------------------
@script
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iName; //Entity name.
int iMax = openborvariant("ent_max"); //Entity count.
int animID;
if(frame == 1){
//Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iName = getentityproperty(vEntity, "name"); //Get target name
animID = getentityproperty(vEntity, "animationid");
//Sign?
if(( animID == openborconstant("ANI_WALK") || animID == openborconstant( "ANI_IDLE") || animID == openborconstant( "ANI_ATTACK1" )) && (iName == "ss1" || iName == "ss3" || iName == "Ene2" )&& vEntity!=self){
performattack(vEntity, openborconstant("ANI_BURN"));
}
}
}
@end_script
---------------UPDATE SCRIPT in header
updatescript @script
#import "data/scripts/lib_level.c"
void main() {
int i, num_players = 0;
//drawstring(10, 100, 0, getlevelproperty("scrollspeed"));
if ( getlocalvar("level_flag") == NULL() ) { // It doesn't scroll at level beginning
for (i = 0; i < openborvariant("maxplayers"); ++i) {
void player = getplayerproperty(i, "entity");
if ( !getentityproperty(player, "exists") ) continue;
if ( getentityproperty(player, "animationid") != openborconstant("ANI_SPAWN") ) ++num_players;
}
if ( num_players == openborvariant("count_players") ) {
changelevelproperty("scrollspeed", 1);
setlocalvar("level_flag", 1);
}
}
/*set_min_level_bound(3000,1,"lv_xpos1");
set_min_level_bound(4300,1,"lv_xpos2");
set_min_level_bound(4690,1,"lv_xpos3");
set_min_level_bound(5400,1,"lv_xpos4");*/
// or use blockade {pos} at ...
}
@end_script
----------------------- porownanie var (startz vs nowy z)
@script
void self = getlocalvar("self");
int pindex = getentityproperty(self,"playerindex");
void moveup = playerkeys(pindex, 0, "moveup");
void movedown = playerkeys(pindex, 0, "movedown");
int iDirection = getentityproperty(self, "direction");
int sx = getentityproperty(self,"x");
int sz = getentityproperty(self,"z");
int Vx = getentityproperty(self, "xdir");
int Vz = getentityproperty(self, "zdir");
int a = getentityproperty(self, "a");
int sped = 6.4;
void fX;
void step3;
float x;
float y;
float x;
float y;
float Hasil;
float c;
c = 0.5*2/x;
int Angle = 0 ;
if (iDirection == 0){ //Is entity facing left?
fX = -fX; //Reverse X direction to match facing.
sped = -sped;
}
if (frame == 1 ){
setlocalvar("spos", sz);
}
if (frame >= 1 ){
changeentityproperty(self, "velocity", sped, 0, 0);
setlocalvar("posit", getlocalvar("posi"));
}
if (frame >= 1 && getlocalvar("spos") != sz ){
Angle = -(getlocalvar("spos")-sz )/3;
settextobj(1, 150 , 100 , 1, 1, Angle , openborvariant("elapsed_time")+2000);
}
if ( a != 0){ //Is entityabove?
Angle = 15 + a/9.5;
}
if ( iDirection == 0 ){ //Is entity facing left?
Angle = -Angle;
}
if (frame >= 5 && frame <= 22 ){
clearspawnentry();
setspawnentry("name","step3");
changeentityproperty(step3, "direction", fX );
changedrawmethod(step3, "reset", 1);
changedrawmethod(step3, "rotate", Angle);
changeentityproperty(step3, "position", sx, sz, 0);
step3 = spawn();
}
if (frame >= 22){
changeentityproperty(self, "velocity", 0, 0, 0);
}
if (moveup)
{
changeentityproperty(self, "velocity", NULL(),-2.0,NULL());
}
if (movedown)
{
changeentityproperty(self, "velocity", NULL(),2.0,NULL());
}
@end_script
----------------------------change fglayer
@script
void self = getlocalvar("self");
if(frame == 4){
changelayerproperty("fglayer", 0, "zoffset", 224);
}
if(frame == 11){
changelayerproperty("fglayer", 0, "zoffset", 324);
}
@end_script
changelayerproperty("fglayer", 0, "enabled", 0 );
-------------push by wind
@script
void vSelf = getlocalvar("self"); //Caller.
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iType; //Entity type.
int iMax = openborvariant("ent_max"); //Entity count.
int x = getentityproperty(vSelf, "x");
int Dir = getentityproperty(vSelf, "direction");
int Ex;
//Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iType = getentityproperty(vEntity, "type"); //Get target type.
//Enemy, NPC & player type?
if(iType == openborconstant("TYPE_ENEMY") || iType == openborconstant("TYPE_PLAYER") || iType == openborconstant("TYPE_NPC")){
Ex = getentityproperty(vEntity, "x");
if(Dir==1 && Ex >= x + 1 && Ex <= x + 330){
changeentityproperty(vEntity, "position", Ex+2);
} else if(Dir==0 && Ex <= x - 1 && Ex >= x - 330){
changeentityproperty(vEntity, "position", Ex-2);
}
}
}
@end_script
moving mario jump------------------
@script
void self = getlocalvar("self");
int toss = getentityproperty(self, "tossv");
int xdir = getentityproperty(self, "xdir");
int dir = getentityproperty(self, "direction");
int pindex = getentityproperty(self,"playerindex");
void moveright = playerkeys(pindex, 0, "moveright");
void moveleft = playerkeys(pindex, 0, "moveleft");
void moveup = playerkeys(pindex, 0, "moveup");
void movedown = playerkeys(pindex, 0, "movedown");
void jump = playerkeys(pindex, 0, "jump");
settextobj(1, 420 , 230 , 1, 1, getentityproperty(self, "tossv") , openborvariant("elapsed_time")+2000);
if ( !moveright || !moveleft )
{
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")/1.15 ,NULL());
}
if ( moveright && dir == 1 && toss > 0)
{
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")*1.1 ,NULL());
}
if ( moveleft && dir == 0 && toss > 0)
{
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")*1.1 ,NULL());
}
if ( !jump && toss > 0 )
{
changeentityproperty(self, "velocity", NULL() ,NULL(),getentityproperty(self, "tossv")/3);
}
if ( !jump && toss < 0 )
{
changeentityproperty(self, "velocity", NULL() ,NULL(),getentityproperty(self, "tossv")*2);
}
@end_script
-----------------------
tap script ,must be delay 1
in frames
@script
void self = getlocalvar("self");
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
void a2 = playerkeys(iPIndex, 1, "attack");
void tapa = getglobalvar("tapa");
if (tapa == NULL() ){
setglobalvar("tapa",0);
}
if (a2 ){
setglobalvar("tapa",tapa+1);
settextobj(1, 250 , 280 , 1, 1, tapa ,-1);
}
@end_script
run stop and play runstop( follow) anim:
In your run animation set an entityvar for example
setentityvar(self,"running",1);
then in idle animation insert this script:
@script
void self = getlocalvar("self");
if ( getentityvar(self,"running") == 1 ) {
setentityvar(self,"running",NULL());
performattack(self,openborconstant("ANI_FOLLOWXX"),1);
}
@end_script
------------------ car movement and sinus slowdown
anim follow3
@script
void self = getlocalvar("self");
void turn = loadsample("data/chars/car/turn.wav");
void start = loadsample("data/chars/car/start.wav");
int sped = getentityproperty(self, "speed");
setlocalvar("vsped",getentityproperty(self, "speed"));
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
void a1 = playerkeys(iPIndex, 0, "attack");
void j1 = playerkeys(iPIndex, 0, "jump");
void right = playerkeys(iPIndex, 0, "moveright");
void left = playerkeys(iPIndex, 0, "moveleft");
int rot;
changedrawmethod(self, "enabled", 1);
if (getlocalvar("rot") == NULL() ){
setlocalvar("rot",0);
}
if (getlocalvar("rot") < -40 ){
setlocalvar("rot",315);
}
if (getlocalvar("rot") > 318 ){
setlocalvar("rot",-30);
}
if ( getentityproperty(self, "zdir") > -sped && a1 && getlocalvar("rot")== 0 ){
changeentityproperty(self, "velocity", 0 , getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( a1 && getlocalvar("rot") == 15 ){
changeentityproperty(self, "velocity", sped/3 ,-sped/1.15);
}
if ( a1 && getlocalvar("rot") == 30 ){
changeentityproperty(self, "velocity", sped/2.25 ,-sped/1.25);
}
if ( getentityproperty(self, "xdir") < sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && a1 && getlocalvar("rot")== 45 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*+1.15, getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( a1 && getlocalvar("rot") == 60 ){
changeentityproperty(self, "velocity", sped/1.25 ,-sped/2.25);
}
if ( a1 && getlocalvar("rot") == 75 ){
changeentityproperty(self, "velocity", sped/1.15 ,-sped/3);
}
if ( getentityproperty(self, "xdir") < sped && a1 && getlocalvar("rot")== 90 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*1.15,0);
}
if ( a1 && getlocalvar("rot") == 105 ){
changeentityproperty(self, "velocity", sped/1.15 ,sped/3);
}
if ( a1 && getlocalvar("rot") == 120 ){
changeentityproperty(self, "velocity", sped/1.25 ,sped/2.25);
}
if ( getentityproperty(self, "xdir") < sped/1.35 && getentityproperty(self, "zdir") < sped/1.35 && a1 && getlocalvar("rot")== 135 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*+1.15, getentityproperty(self, "zdir")+0.3*+1.15);
}
if ( a1 && getlocalvar("rot") == 150 ){
changeentityproperty(self, "velocity", sped/2.25 ,sped/1.25);
}
if ( a1 && getlocalvar("rot") == 165 ){
changeentityproperty(self, "velocity", sped/3 ,sped/1.15);
}
if ( getentityproperty(self, "zdir") < sped && a1 && getlocalvar("rot")== 180 ){
changeentityproperty(self, "velocity", 0 , getentityproperty(self, "zdir")+0.3*1.15);
}
if ( a1 && getlocalvar("rot") == 195 ){
changeentityproperty(self, "velocity", -sped/3 ,sped/1.15);
}
if ( a1 && getlocalvar("rot") == 210 ){
changeentityproperty(self, "velocity", -sped/2.25 ,sped/1.25);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") < sped/1.35 && a1 && getlocalvar("rot")== 225 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15, getentityproperty(self, "zdir")+0.3*+1.15);
}
if ( a1 && getlocalvar("rot") == 240 ){
changeentityproperty(self, "velocity", -sped/1.25 ,sped/2.25);
}
if ( a1 && getlocalvar("rot") == 255 ){
changeentityproperty(self, "velocity", -sped/1.15 ,sped/3);
}
if ( getentityproperty(self, "xdir") > -sped && a1 && getlocalvar("rot")== 270 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15,0);
}
if ( a1 && getlocalvar("rot") == 285 ){
changeentityproperty(self, "velocity", -sped/1.15 ,-sped/3);
}
if ( a1 && getlocalvar("rot") == 300 ){
changeentityproperty(self, "velocity", -sped/1.25 ,-sped/2.25);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && a1 && getlocalvar("rot")== 315 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15, getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && a1 && getlocalvar("rot")== -45 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15, getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( a1 && getlocalvar("rot") == -30 ){
changeentityproperty(self, "velocity", -sped/2.25 ,-sped/1.25);
}
if ( a1 && getlocalvar("rot") == -15 ){
changeentityproperty(self, "velocity", -sped/3 ,-sped/1.15);
}
if ( getentityproperty(self, "zdir") < sped && j1 && getlocalvar("rot")== 0 ){
changeentityproperty(self, "velocity", 0 , getentityproperty(self, "zdir")+0.3*+1.15);
}
if ( j1 && getlocalvar("rot") == 15 ){
changeentityproperty(self, "velocity", -sped/3 ,sped/1.15);
}
if ( j1 && getlocalvar("rot") == 30 ){
changeentityproperty(self, "velocity", -sped/2.25 ,sped/1.25);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") < sped/1.35 && j1 && getlocalvar("rot")== 45 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15, getentityproperty(self, "zdir")+0.3*+1.15);
}
if ( j1 && getlocalvar("rot") == 60 ){
changeentityproperty(self, "velocity", -sped/1.25 ,sped/2.25);
}
if ( j1 && getlocalvar("rot") == 75 ){
changeentityproperty(self, "velocity", -sped/1.15 ,sped/3);
}
if ( getentityproperty(self, "xdir") > -sped && j1 && getlocalvar("rot")== 90 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15,0);
}
if ( j1 && getlocalvar("rot") == 105 ){
changeentityproperty(self, "velocity", -sped/1.15 ,-sped/3);
}
if ( j1 && getlocalvar("rot") == 120 ){
changeentityproperty(self, "velocity", -sped/1.25 ,-sped/2.25);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && j1 && getlocalvar("rot")== 135 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*-1.15, getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( j1 && getlocalvar("rot") == 150 ){
changeentityproperty(self, "velocity", -sped/2.25 ,-sped/1.25);
}
if ( j1 && getlocalvar("rot") == 165 ){
changeentityproperty(self, "velocity", -sped/3 ,-sped/1.15);
}
if ( getentityproperty(self, "zdir") > -sped && j1 && getlocalvar("rot")== 180 ){
changeentityproperty(self, "velocity", 0 , getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( j1 && getlocalvar("rot") == 195 ){
changeentityproperty(self, "velocity", sped/3 ,-sped/1.15);
}
if ( j1 && getlocalvar("rot") == 210 ){
changeentityproperty(self, "velocity", sped/2.25 ,-sped/1.25);
}
if ( getentityproperty(self, "xdir") < sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && j1 && getlocalvar("rot")== 225 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*1.15, getentityproperty(self, "zdir")+0.3*-1.15);
}
if ( j1 && getlocalvar("rot") == 240 ){
changeentityproperty(self, "velocity", sped/1.25 ,-sped/2.25);
}
if ( j1 && getlocalvar("rot") == 255 ){
changeentityproperty(self, "velocity", sped/1.15 ,-sped/3);
}
if ( getentityproperty(self, "xdir") < sped && j1 && getlocalvar("rot")== 270 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*+1.15,0);
}
if ( j1 && getlocalvar("rot") == 285 ){
changeentityproperty(self, "velocity", sped/1.15 ,sped/3);
}
if ( j1 && getlocalvar("rot") == 300 ){
changeentityproperty(self, "velocity", sped/1.25 ,sped/2.25);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && j1 && getlocalvar("rot")== 315 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*+1.15, getentityproperty(self, "zdir")+0.3*+1.15);
}
if ( getentityproperty(self, "xdir") > -sped/1.35 && getentityproperty(self, "zdir") > -sped/1.35 && j1 && getlocalvar("rot")== -45 ){
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")+0.3*+1.15, getentityproperty(self, "zdir")+0.3*+1.15);
}
if ( j1 && getlocalvar("rot") == -30 ){
changeentityproperty(self, "velocity", sped/2.25 ,sped/1.25);
}
if ( j1 && getlocalvar("rot") == -15 ){
changeentityproperty(self, "velocity", sped/3 ,sped/1.15);
}
if ( left ){
rot = setlocalvar("rot", getlocalvar("rot")-15);
changedrawmethod(self, "rotate",getlocalvar("rot"));
settextobj(1, 150 , 100 , 1, 1,getlocalvar("rot"), openborvariant("elapsed_time")+2000);
}
if ( right ){
rot = setlocalvar("rot", getlocalvar("rot")+15);
changedrawmethod(self, "rotate",getlocalvar("rot"));
settextobj(1, 150 , 100 , 1, 1,getlocalvar("rot"), openborvariant("elapsed_time")+2000);
}
if ( a1 && left ){
playsample(turn);
}
if ( a1 && right ){
playsample(turn);
}
if ( a1 && getglobalvar("start") != 1){
setglobalvar("start", 1);
playsample(start);
}
if ( j1 && getglobalvar("start") != 1){
setglobalvar("start", 1);
playsample(start);
}
if ( !a1 && !j1 ){
setglobalvar("start", 0);
changeentityproperty(self, "velocity", getentityproperty(self, "xdir")/1.15 ,getentityproperty(self, "zdir")/1.15);
changeentityproperty(self, "animpos", 1);
}
@end_script
loop 1
offset 22 23
bbox 6 5 83 98
delay 7
sound data/chars/car/car.wav
frame data/chars/car/car.gif
frame data/chars/car/car.gif
walllplatform autowalk dirchange--------------------------------
void StayPlat(int Rx, int Vx)
{// Finds platform edge within defined range. Turn around if edge is found
// Rx : Check distance in x axis
// Vx : Velocity to move
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void Plat = checkplatformbelow(x, z, y+2);
void PlatA; void PlatB;
if(Plat){ // on a platform
if(Dir==1){
PlatA = checkplatformbelow(x+Rx, z, y+2);
PlatB = checkplatformbelow(x+Rx, z, y-2);
} else {
PlatA = checkplatformbelow(x-Rx, z, y+2);
PlatB = checkplatformbelow(x-Rx, z, y-2);
}
if(Plat!=PlatA && PlatA==PlatB && Dir==1){
changeentityproperty(self, "velocity", -Vx);
changeentityproperty(self, "direction", 0);
} else if(Plat!=PlatA && PlatA==PlatB && Dir==0){
changeentityproperty(self, "velocity", Vx);
changeentityproperty(self, "direction", 1);
}
}
}
----------platform left right walk
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void Plat = checkplatformbelow(x, z, y+2);
void PlatA; void PlatB;
if(Plat){ // on a platform
if(Dir==1){
PlatA = checkplatformbelow(x+5, z, y+2);
PlatB = checkplatformbelow(x+5, z, y-2);
} else {
PlatA = checkplatformbelow(x-5, z, y+2);
PlatB = checkplatformbelow(x-5, z, y-2);
}
if(Plat!=PlatA && PlatA==PlatB && Dir==1){
changeentityproperty(self, "velocity", -2);
changeentityproperty(self, "direction", 0);
} else if(Plat!=PlatA && PlatA==PlatB && Dir==0){
changeentityproperty(self, "velocity", 2);
changeentityproperty(self, "direction", 1);
}
}
@end_script
-------------------- swall and auto turnaround
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int Wall = checkwall(x,z);
int WallC;
if(Dir==1){
WallC = checkwall(x+10,z);
} else {
WallC = checkwall(x-10,z);
}
if(Wall!=0 && Wall > WallC && Dir==1){
changeentityproperty(self, "velocity", -2);
changeentityproperty(self, "direction", 0);
} else if(Wall!=0 && Wall > WallC && Dir==0){
changeentityproperty(self, "velocity", 2);
changeentityproperty(self, "direction", 1);
}
@end_script
--
wallplatnofall
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
int Width = openborvariant("levelwidth");
void Plat = checkplatformbelow(x, z, y+2);
int Length; int Px; void PlatA; void PlatB; int Wall;
if(x > Width - 10){
changeentityproperty(self, "velocity", -1);
changeentityproperty(self, "direction", 0);
} else if(x < 10){
changeentityproperty(self, "velocity", 1);
changeentityproperty(self, "direction", 1);
} else if(Plat){ // on a platform
Length = getentityproperty(Plat, "antigrab");
Px = getentityproperty(Plat, "x");
if(Dir==1){
PlatA = checkplatformbelow(x+24, z, y+2);
PlatB = checkplatformbelow(x+24, z, y-2);
} else {
PlatA = checkplatformbelow(x-24, z, y+2);
PlatB = checkplatformbelow(x-24, z, y-2);
}
if(x >= Px + Length/2 - 23 && PlatA==PlatB){
changeentityproperty(self, "velocity", -1);
changeentityproperty(self, "direction", 0);
} else if(x <= Px - Length/2 + 23 && PlatA==PlatB){
changeentityproperty(self, "velocity", 1);
changeentityproperty(self, "direction", 1);
}
} else { // on a wall
if(Dir==1){
Wall = checkwall(x+26,z);
} else {
Wall = checkwall(x-26,z);
}
if(y > Wall && Dir==1){
changeentityproperty(self, "velocity", -1);
changeentityproperty(self, "direction", 0);
} else if(y > Wall && Dir==0){
changeentityproperty(self, "velocity", 1);
changeentityproperty(self, "direction", 1);
}
}
@end_script
----
wall bump and turn
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int Dir = getentityproperty(self, "direction");
int sped = getentityproperty(self, "speed");
int Sx = 1;
if(Dir==0){
Sx = -Sx;
changeentityproperty(self, "velocity", 0-sped );
}
if(Dir==1){
changeentityproperty(self, "velocity", sped );
}
void Plat = checkwall(x+Sx, z);
if( Dir == 0 && frame > 0 && x-(x-Plat) > 20 ){
changeentityproperty(self, "direction", 1 );
}
if( Dir == 1 && frame > 0 && x-(x-Plat) > 20 ){
changeentityproperty(self, "direction", 0 );
}
@end_script
---
platform end and turn
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int y = getentityproperty(self, "a");
int Dir = getentityproperty(self, "direction");
int sped = getentityproperty(self, "speed");
void Plat = checkplatformbetween(x, z, y-100, 200);
if(Dir==0){
changeentityproperty(self, "velocity", -1 ,0,0);
}
if(Dir==1){
changeentityproperty(self, "velocity", 1 ,0,0);
}
if(Dir==0 && x+getentityproperty(Plat, "health")/2+2 <= getentityproperty(Plat, "x")){
changeentityproperty(self, "direction", 1 );
}
if(Dir==1 && x-getentityproperty(Plat, "health")/2-2 >= getentityproperty(Plat, "x")){
changeentityproperty(self, "direction", 0 );
}
@end_script
------------------------
platformclimb
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int y = getentityproperty(self, "a");
int Dir = getentityproperty(self, "direction");
int sped = getentityproperty(self, "speed");
int base = getentityproperty(self, "base");
changeentityproperty(self, "antigravity", 0 );
int Sx = 0;
int Sxa = 10;
if(Dir==0){
Sx = -Sx;
Sxa = -Sxa;
}
void Plat = checkplatformbelow(x+Sx, z, y);
void PlatA = checkplatformabove(x+Sxa, z, y);
settextobj(1, 150 , 100 , 1, 1, base, openborvariant("elapsed_time")+2000);
if(Dir==0){
settextobj(1, 150 , 100 , 1, 1, "dir0", openborvariant("elapsed_time")+2000);
settextobj(2, 150 , 120 , 1, 1, getentityproperty(Plat, "x"), openborvariant("elapsed_time")+2000);
settextobj(3, 150 , 140 , 1, 1,"muchax "+x, openborvariant("elapsed_time")+2000);
}
if(Dir==1){
settextobj(1, 150 , 100 , 1, 1, "dir1" , openborvariant("elapsed_time")+2000);
settextobj(2, 150 , 120 , 1, 1, getentityproperty(Plat, "x"), openborvariant("elapsed_time")+2000);
settextobj(3, 150 , 140 , 1, 1,"muchax "+x, openborvariant("elapsed_time")+2000);
}
if(Dir==1 && x-5 <= getentityproperty(PlatA, "x")){
settextobj(1, 150 , 100 , 1, 1, "dirala0", openborvariant("elapsed_time")+2000);
settextobj(2, 150 , 120 , 1, 1, getentityproperty(Plat, "x"), openborvariant("elapsed_time")+2000);
settextobj(4, 150 , 160 , 1, 1, "climbup LEFT", openborvariant("elapsed_time")+100);
}
if(Dir==0&& x-50 >= getentityproperty(PlatA, "x")){
settextobj(1, 150 , 100 , 1, 1, "dirala0", openborvariant("elapsed_time")+2000);
settextobj(2, 150 , 120 , 1, 1, getentityproperty(Plat, "x"), openborvariant("elapsed_time")+2000);
settextobj(4, 150 , 160 , 1, 1, "climbup_RIGHT", openborvariant("elapsed_time")+100);
}
if(Dir==1 && x-40 >= getentityproperty(Plat, "x")&& y+50 >= getentityproperty(Plat, "y")){
settextobj(1, 150 , 100 , 1, 1, "dirala0", openborvariant("elapsed_time")+2000);
settextobj(2, 150 , 120 , 1, 1, getentityproperty(Plat, "x"), openborvariant("elapsed_time")+2000);
settextobj(4, 150 , 160 , 1, 1, "climbdown RIGHT", openborvariant("elapsed_time")+100);
}
if(Dir==0 && x-15 <= getentityproperty(Plat, "x")&& y+50 >= getentityproperty(Plat, "y")){
settextobj(1, 150 , 100 , 1, 1, "dirala0", openborvariant("elapsed_time")+2000);
settextobj(2, 150 , 120 , 1, 1, getentityproperty(Plat, "x"), openborvariant("elapsed_time")+2000);
settextobj(4, 150 , 160 , 1, 1, "climbdown LEFT", openborvariant("elapsed_time")+100);
}
@end_script
-------
sinus velocity
@script
void self = getlocalvar("self");
int counter;
float x,z;
if(frame==0)
{
counter = 0;
}
if (frame>0)
{
x = -sin(counter/1.45)*2;
z = -cos(counter/1.45)/3;
changeentityproperty(self, "velocity", x, z, 0) ;
counter +=5;
}
@end_script
@script
void self = getlocalvar("self");
void time = openborvariant("elapsed_time");
void mTime = time - (openborvariant("elapsed_time")-100);
float a,x,y;
x = -sin(time/1.45)*2;
y = -cos(time/1.45)/3;
changeentityproperty(self, "velocity", x, y, 0) ;
@end_script
-----cosin leftright
@script
void self = getlocalvar("self");
void time = openborvariant("elapsed_time");
void mTime = time - (openborvariant("elapsed_time")-100);
float x;
x = -sin(time/0.45)*5;
changeentityproperty(self, "velocity", x) ;
@end_script
7
var numberOfTicks = 0;
function gameLoop() {
numberOfTicks++;
ufo.y = sin(numberOfTicks * 0.5 * pi);
ufo.x += ufo.xSpeed;
}
------------------------------------- change anim close to WALL
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
int C;
if(Dir == 1){
C = 6;
} else {
C = -6;
}
if(frame > 0 && y <= checkwall(x+C,z)){
changeentityproperty(self, "velocity", 0, 0, 0);
changeentityproperty(self, "subject_to_gravity", 1);
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
}
@end_script
------------------------ stop all enemies and change their anim
@script
void self = getlocalvar("self");
int Enum = openborvariant("count_enemies");
if(Enum == 1){
changeentityproperty(self, "velocity", 0, 0, 0); // Should be omitted if declared in IDLE
performattack(self, openborconstant("ANI_FOLLOW1"));
}
@end_script
----------------------------
@script
if(frame==1){
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iName; //Entity type.
int iHP; //Entity HP
int iMax = openborvariant("ent_max"); //Entity count.
void self = getlocalvar("self");
//Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iName = getentityproperty(vEntity, "name"); //Get target type.
//Enemy type?
if (iName == "BATMAN" ){
settextobj(1, 450-openborvariant("xpos") , 380-openborvariant("ypos") , 0, -1, iName , openborvariant("elapsed_time")+200);
changeentityproperty(self, "custom_target", vEntity );
}
}
}
@end_script
---------------walk slowdown speedup by z position
@script
void self = getlocalvar("self");
int pindex = getentityproperty(self,"playerindex");
float sp = getentityproperty(self,"speed");
float z = getentityproperty(self,"z");
void yVel = getlocalvar("yVel"+self);
int minspeed = 22;
int maxspeed = 55;
void moveup = playerkeys(pindex, 0, "moveup");
void movedown = playerkeys(pindex, 0, "movedown");
void vspeed ;
settextobj(1, 250 , 280 , 1, 1,getentityproperty(self,"speed")/100+"speed", openborvariant("elapsed_time")+2000);
settextobj(2, 250 , 180 , 2, 2, z , openborvariant("elapsed_time")+2000);
if ( !vspeed ){
setlocalvar("vspeed",22*1000);
}
if (getentityproperty(self,"speed") && z >= 600 && moveup ) {
changeentityproperty(self, "speed", (getentityproperty(self,"speed"))- 0.05);
}
if (getentityproperty(self,"speed")&& z <= 800 && movedown ) {
changeentityproperty(self, "speed", (getentityproperty(self,"speed"))+ 0.05);
}
@end_script
---------- slowdown walk
in idle :
@script
void self = getlocalvar("self"); //Get calling entity
void num = getentityvar(self, "num");
void speed = getentityproperty(self, "speed");
void xdir;
void zdir = getentityvar(self, "zdir");
void stop = getentityvar(self, "stop");
if ( frame > 0 ){
}
if( getentityproperty(self, "direction")== 0 ){
speed =-speed;
}
if( getentityvar(self, "num") == NULL()){
setentityvar(self, "num", 1);
changeentityproperty(self, "velocity", getentityvar(self, "xdir"),getentityvar(self, "zdir") );
xdir = getentityproperty(self, "xdir");
zdir = getentityproperty(self, "zdir");
}
if( getentityvar(self, "num") > 30 && getentityvar(self, "stop") == NULL() ){
setentityvar(self, "stop", 1);
changeentityproperty(self, "velocity", 0, 0, 0);
}
if( getentityvar(self, "num") != NULL () && getentityvar(self, "stop") == NULL() ){
setentityvar(self, "num", getentityvar(self, "num")+1);
xdir= xdir*2/2.1;
zdir= zdir/2.2;
changeentityproperty(self, "velocity", xdir, zdir, 0);
}
@end_script
in walk
@script
void self = getlocalvar("self"); //Get calling entity
void stop;
void num;
void zdir;
void xdir;
setentityvar(self, "num", NULL());
setentityvar(self, "stop", NULL());
setentityvar(self, "xdir", getentityproperty(self, "xdir"));
setentityvar(self, "zdir", getentityproperty(self, "zdir"));
@end_script
------------sinus y up down
@script
void self = getlocalvar("self"); //Get calling entity
int Dir = getentityproperty(self, "direction");
float Fram = (getentityproperty(self, "animpos") + 1)*0.0833;
float Vx = 1;
float Vy = 3*cos(Fram*360);
if(Dir==0){
Vx = -Vx;
}
changeentityproperty(self, "velocity", Vx , Vy, 0);
@end_script
@script
void self = getlocalvar("self");
int counter;
float x,z;
if(frame==0)
{
counter = 0;
}
if (frame>0)
{
x = -sin(counter/1.45)*2;
z = -cos(counter/1.45)/3;
changeentityproperty(self, "velocity", x, z, 0) ;
counter +=5;
}
@end_script
------------------------ change anim from idle to follow if health is low
anim idle
@script
void self = getlocalvar("self"); //Get calling entity.
int MHealth = getentityproperty(self,"maxhealth");
int Health = getentityproperty(self,"health");
if(Health <= MHealth*2/3){
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
}
@end_script
loop 1
delay 5
offset 225 198
bbox 207 170 41 28
frame data/chars/misc/chests/jar1101.gif
frame data/chars/misc/chests/jar1101.gif
------------------- check branch and change to according anim
@script
if(frame == 0){
void self = getlocalvar("self");
char branch = openborvariant("current_branch");
if(branch=="Stage6-3"){
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW50"));
} else if(branch=="Stage8-1-3"){
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW51"));
}
}
@end_script
-------------------- invincibility after 17 frame
@script
void self = getlocalvar("self");
if ( getentityproperty(self, "animpos") >= 17 ) {
changeentityproperty(self, "invincible", 1);
changeentityproperty(self, "invinctime", openborvariant("elapsed_time") + (openborvariant("game_speed")*0.3));
changeentityproperty(self, "aiflag", "blink", 0);
}
@end_script
void opp = getentityproperty(self,"opponent"); // Gets who is attacking it
int direction = getentityproperty(opp,"direction"); // Gets opponent facing
if(direction == 1)performattack(self,openborconstant("ANI_FOLLOW1")); //Is entity facing right?
if(direction == 0)performattack(self,openborconstant("ANI_FOLLOW2")); //Is entity facing left?
}
}
------------------ change name script
@script
void self = getlocalvar("self");
char Name = getentityproperty(self,"name");
if(frame == 1){
changeentityproperty(self, "animation", openborconstant(Name));
}
@end_script
and the alias should be "ANI_FREESPECIAL3"
----------- level spawn script
spawn foot
@script
void main(){
void self = getlocalvar("self");
changeentityproperty(self, "position", 1546 , 385);
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW4"));
}
@end_script
flip 1
coords 1546 385
at 0
-------------------- level spawn scriptt
spawn imp
@script
void main(){
void P1 = getplayerproperty(0,"entity");
void P2 = getplayerproperty(1,"entity");
void P3 = getplayerproperty(2,"entity");
void P4 = getplayerproperty(3,"entity");
changeentityproperty(P1, "mp", 0);
changeentityproperty(P2, "mp", 0);
changeentityproperty(P3, "mp", 0);
changeentityproperty(P4, "mp", 0);
}
@end_script
coords 225 598
at 0
--------------- sort id script
spawn pla2
@script void main() {
changeentityproperty(getlocalvar("self"), "sortid", 5);
} @end_script
map 0
coords 0 360 20
at 0
----------- place players opposite each other 490 and -490
spawn empty
@script
void main()
{
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
if(P1){
changeentityproperty(P1, "position", -490,189, 0); // Set position
changeentityproperty(P1, "direction", 1); //Face right
changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW60"));
}
if(P2){
changeentityproperty(P2, "position", -490,189, 0);
changeentityproperty(P2, "direction", 1); //Face right
changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW60"));
}
}
@end_script
coords 180 189
at 0
@script
void self = getlocalvar("self");
void map=getentityproperty(self,"colourmap");
if(frame > 0){
setdrawmethod(self,1,555,555,0,0,0,0,0,0,0,0,0,map);
}
@end_script
changeentityproperty(getlocalvar("self"), "type", openborconstant("TYPE_OBSTACLE"));
--------- sinus movement sc
@script
void self = getlocalvar("self"); //Get calling entity
int Dir = getentityproperty(self, "direction");
float Fram = getentityproperty(self, "animpos") + 1;
float Vx = 1;
float Vz = 2*cos(Fram*30);
if(Dir==0){
Vx = -Vx;
}
changeentityproperty(self, "velocity", Vx, Vz);
@end_script
@script
void self = getlocalvar("self"); //Get calling entity
int Dir = getentityproperty(self, "direction");
float Fram = (getentityproperty(self, "animpos") + 1)*0.05;
float Vx = 12*cos(Fram*160);
float Vy = 1*cos(Fram*160);
if(Dir==0){
Vx = -Vx;
}
changeentityproperty(self, "velocity", Vx , 0, Vy);
@end_script
------------performattack
spawn burnov
@script void main() {
performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW46"));
} @end_script
coords 885 1120 314
spawn DoorG
@script
void main()
{
void self = getlocalvar("self");
int x = getentityproperty(self,"x"); //Get character's x coordinate
int XPos = openborvariant("xpos");
changeentityproperty(self, "position", x - XPos);
}
@end_script
@script
void self = getlocalvar("self");
int Enemy = openborvariant("count_enemies");
if(Enemy == 1){
changeentityproperty(self, "velocity", 0, 0, 0); // Should be omitted if declared in IDLE
performattack(self, openborconstant("ANI_FOLLOW1"));
}
@end_script
header:
@script
void e = getlocalvar("self");
int aid = getentityproperty(e, "animationid");
if(aid==openborconstant("ANI_IDLE") || aid==openborconstant("ANI_WALK"))
changeentityproperty(e, "aiflag", "blocking", 1);
else
changeentityproperty(e, "aiflag", "blocking", 0);
@end_script
void entity = getlocalvar("self");
setentityvar(entity, "birthdate", "2004-01-01");
spawn empty
@script
void main()
{
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
if(P1){
changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW1"));
}
if(P2){
changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW1"));
}
}
@end_script
@script
void self = getlocalvar("self");
void Parent = getentityproperty(self, "parent");
float Health = getentityproperty(Parent,"health");
void animID = getentityproperty(Parent, "animationid");
if( Health > 0){
killentity(self);
}
if(animID == openborconstant("ANI_DIE")){
killentity(self);
}
@end_script
settextobj(1, x-132-openborvariant("xpos") , z-85-openborvariant("ypos") , 1, -1, "DOOOH , WHO PUT THE LIGHT OUT " , openborvariant("elapsed_time")+300);
}
-------- move by keys updown leftright
@script
void self = getlocalvar("self");
int pindex = getentityproperty(self,"playerindex");
void moveright = playerkeys(pindex, 0, "moveright");
void moveleft = playerkeys(pindex, 0, "moveleft");
void moveup = playerkeys(pindex, 0, "moveup");
void movedown = playerkeys(pindex, 0, "movedown");
changeentityproperty(self, "velocity", 0,0,0);
if (moveright)
{
changeentityproperty(self, "velocity", 0.5,NULL(),NULL());
}
if (moveleft)
{
changeentityproperty(self, "velocity", -0.5,NULL(),NULL());
}
if (moveup)
{
changeentityproperty(self, "velocity", NULL(),-0.5,NULL());
}
if (movedown)
{
changeentityproperty(self, "velocity", NULL(),0.5,NULL());
}
@end_script
spawn abobo
@script
void main(){
void self = getlocalvar("self");
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
}
@end_script
coords 230 130
at 1150
@script
if(frame == 0){
void self = getlocalvar("self");
changeentityproperty(self, "setlayer", -10);
}
if(frame == 5){
void self = getlocalvar("self");
changeentityproperty(self, "setlayer", 0);
}
@end_script
void basechange(void Ani)
{// Check altitude. If bomb is on base, change animation!
void self = getlocalvar("self");
int y = getentityproperty(self,"a"); //Get bomb's altitude
int b = getentityproperty(self, "base"); //Get base
if( y <= 1+b ){ // On base?
performattack(self, openborconstant(Ani)); //Change the animation
}
}
changeentityproperty(self, "setlayer", 0);
void makeInv(long invTime)
{
void vSelf = getlocalvar("self");
long iTime = openborvariant("elapsed_time");
changeentityproperty(vSelf, "invincible", 1);
changeentityproperty(vSelf, "invinctime", iTime + invTime);
}
float fY = getentityproperty(vSelf, "a"); //Get Y location.
float fBase = getentityproperty(vSelf, "base"); //Get base height.
if (fY > 1 || fBase < 0){ //Are we still in air or over a pit?
@script
int ran = rand()%3;
void sa1 = loadsample("data/sounds/boom.wav");
void sa2 = loadsample("data/sounds/boom2.wav");
void sa3 = loadsample("data/sounds/boom3.wav");
void sa4 = loadsample("data/sounds/trash.wav");
if ( ran == 1 && frame == 2 ){
playsample(sa1);
}
if ( ran == 2 && frame == 2 ){
playsample(sa2);
}
if ( ran ==-1 && frame == 2 ){
playsample(sa3);
}
if ( ran == -2 && frame == 2 ){
playsample(sa4);
}
@end_script
float base = getentityproperty(player, "base");
if ( a != base ) changeentityproperty(player, "position", x, z, base);
changedrawmethod(self, "tintmode", 2);
changedrawmethod(self, "tintcolor", rgbcolor(250,0,200));
@script
void self = getlocalvar("self");
if( frame == 0){
int r = rand()%30;
if( r > 11){
changeentityproperty(self, "animpos", 1);
} else if( r < -10){
changeentityproperty(self, "animpos", 2);
} else if( r < 0){
changeentityproperty(self, "animpos", 0);
} else if( r > 0){
changeentityproperty(self, "animpos", 3);
}
}
@end_script
#int pindex = getlocalvar("player");
#void pl = getplayerproperty(pindex , "entity");
#changeentityproperty(pl, "health", 0);
#damageentity(pl, self, 10000, 0, openborconstant("ATK_NORMAL"));
damageentity(target, self, 0, 0, openborconstant("ATK_NORMAL"));
//drawstring( 10,190,0,"Var (): "+trunc(xpos));
changedrawmethod(NULL(), "tintmode", 1);
changedrawmethod(NULL(), "tintcolor", color);
//changedrawmethod(NULL(), "clip", 10, 20);
changedrawmethod(NULL(), "cliph", 356);
changedrawmethod(NULL(), "clipw", 256);
changedrawmethod(NULL(), "clipx", x-xpos-clipx);
changedrawmethod(NULL(), "clipy", z-a-ypos-4-clipy);
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, -1);
drawsprite(spr, x-xpos, z-a-ypos-4, z+2, layer);
changedrawmethod(NULL(), "enabled", 1);
changedrawmethod(NULL(), "reset", 1);
setdrawmethod(NULL(), 0);
projectscript
void shoot(void Shot, float dx, float dy, float dz)
{ // Shooting projectile
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void vShot;
if (Direction == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
vShot = projectile(Shot, x+dx, z+dz, y+dy, Direction, 0, 0, 0);
return vShot;
}
void shooter(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Shooting projectile with speed control
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
void vShot;
if (Direction == 0){ //Is entity facing left?
Vx = -Vx; //Reverse Vx direction to match facing
}
vShot = shoot(Shot, dx, dy, dz);
changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
changeentityproperty(vShot, "speed", Vx);
}
@script
void vSelf = getlocalvar("self"); //Caller.
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iType; //Entity type.
int iMax = openborvariant("ent_max"); //Entity count.
int x = getentityproperty(vSelf, "x");
int Dir = getentityproperty(vSelf, "direction");
int Ex;
//Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iType = getentityproperty(vEntity, "type"); //Get target type.
//Enemy, NPC & player type?
if(iType == openborconstant("TYPE_ENEMY") || iType == openborconstant("TYPE_PLAYER") || iType == openborconstant("TYPE_NPC")){
Ex = getentityproperty(vEntity, "x");
if(Dir==1 && Ex >= x + 1 && Ex <= x + 220){
changeentityproperty(vEntity, "position", Ex+2);
} else if(Dir==0 && Ex <= x - 1 && Ex >= x - 220){
changeentityproperty(vEntity, "position", Ex-2);
}
}
}
@end_script
setglobalvar("treej",NULL());
@script
void self = getlocalvar("self");
int r = rand()%3;
if(frame < 1 && r == 1){
changeentityproperty( self , "map", 0);
} else if(frame < 1 && r == 2 ){
changeentityproperty( self , "map", 4);
} else if(frame < 1 && r == -1 ){
changeentityproperty( self , "map", 0);
} else if(frame < 1 && r == -2 ){
changeentityproperty( self , "map", 4);
} else if(frame < 1 && r == 0 ){
changeentityproperty( self , "map", 0);
}
@end_script
spawn king_pig
@script
void main(){
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
if(P1){
performattack(P1, openborconstant("ANI_FREESPECIAL19"));
}
if(P2){
performattack(P2, openborconstant("ANI_FREESPECIAL19"));
}
}
@end_script
health 150
coords 300 150 300
at 1920
header:
@script
void e = getlocalvar("self");
int aid = getentityproperty(e, "animationid");
if(aid==openborconstant("ANI_IDLE") || aid==openborconstant("ANI_WALK"))
changeentityproperty(e, "aiflag", "blocking", 1);
else
changeentityproperty(e, "aiflag", "blocking", 0);
@end_script
@script
void self = getlocalvar("self");
int pos = openborvariant("xpos");
int selfx = getentityproperty(self, "x");
if ((selfx > pos + 480 )&&(frame == 0)){
changeentityproperty(self, "direction", 0);
performattack(self, openborconstant("ANI_FREESPECIAL3"));
}
if ((selfx < pos + 1 )&&(frame == 0)){
changeentityproperty(self, "direction", 1);
performattack(self, openborconstant("ANI_FREESPECIAL3"));
}
@end_script
@script
void self = getlocalvar("self");
void vmap = getentityproperty(self, "map");
if (( vmap ==13 )&&(frame == 1)){
changeentityproperty(self, "velocity", 0, 0, 0);
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW13"));
}
if (( vmap ==14 )&&(frame == 1)){
changeentityproperty(self, "velocity", 0, 0, 0);
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW14"));
}
if (( vmap ==15 )&&(frame == 1)){
changeentityproperty(self, "velocity", 0, 0, 0);
changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW15"));
}
@end_script
@script
void main()
{
jumptobranch("Path1", 0);
}
@end_script
anim waiting
loop 1
delay 1
offset 0 0
@cmd changelight 99999 99999
frame data/chars/1bryan/waiting01.png
delay 20
frame data/chars/1bryan/waiting01.png
frame data/chars/1bryan/waiting02.png
anim select
loop 0
delay 15
offset 0 0
sound data/sounds/sel_bryan.wav
frame data/chars/1bryan/selected.png
delay 10
drawmethod alpha 6
drawmethod channel 0.80
frame data/chars/1bryan/selected.png
drawmethod channel 0.60
frame data/chars/1bryan/selected.png
drawmethod channel 0.40
frame data/chars/1bryan/selected.png
drawmethod channel 0.20
frame data/chars/1bryan/selected.png
drawmethod channel 0.00
frame data/chars/1bryan/selected.png
spawn owl
@script void main() {
changeentityproperty(getlocalvar("self"), "aimove", openborconstant("AIMOVE1_CHASE"));
} @end_script
map 1
coords -150 330
at 0
@script
void self = getlocalvar("self");
if(frame == 1 ){
changeentityproperty(self,"noaicontrol",1);
}
@end_script
@script
void self = getlocalvar("self");
if(getglobalvar("vers")== 2 ){
changeentityproperty(self,"noaicontrol",0);
}
@end_script
@script void main() {
setglobalvar("camoff", 1);
} @end_script
spawn dust
@script
void main()
{
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
if(P1){
changeentityproperty(P1, "position", 630,555, 0);
changeentityproperty(P1, "direction", 1); //Face right
}
if(P2){
changeentityproperty(P2, "position", 630, 575, 0);
changeentityproperty(P2, "direction", 1); //Face right
}
}
@end_script
coords 430 -200
at 0
void bind(int null, float x, float z, float y, int dir){
void self = getlocalvar("self");
void opp = getentityproperty(self, "opponent");
if(null == 1)
{
bindentity(opp, self, x, z, y, dir, 0);
}
else if(null == 0)
{
bindentity(opp, NULL());
}
}
---------------bindentity
@script
void self = getlocalvar("self");
void strail;
if(frame==1){
clearspawnentry();
setspawnentry("name","strail");
strail = spawn();
changeentityproperty(strail,"parent", self);
bindentity(strail, self, -133,0,0,1,0);
}
@end_script
-------------------
void forceanim(int anim){
void self = getlocalvar("self");
void opp = getentityproperty(self, "opponent");
changeentityproperty(opp, "animation", "ANI_FREESPECIAL3" );
}
void cancelgrab()
{// Check grabbed opponent's name
// If it's forbidden to grab him/her, revert to IDLE
void self = getlocalvar("self");
void target = getlocalvar("Target" + self);
if(target==NULL())
{
target = getentityproperty(self, "opponent");
setlocalvar("Target" + self, target);
}
if(target!=NULL())
{
char Tname = getentityproperty(target, "defaultname");
if(Tname == "Goro" || Tname == "Kintaro" || Tname == "Motaro" || Tname == "Kimokahn")
{
setidle(self);
}
}
}
//entity * projectile([0/1], char *name, float x, float z, float a, int direction, int pytype, int type, int map);
@script
void self = getlocalvar("self");
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
int x = getentityproperty(self,"x");
int a = getentityproperty(self,"a");
int z = getentityproperty(self,"z");
void p1 = playerkeys(iPIndex, 0, "attack");
void e;
if ((frame == 5 || frame == 11 || frame == 17)&&(p1)&&(getentityproperty(self, "direction")==0)){
clearspawnentry();
setspawnentry("name","zof");
changeentityproperty(e, "position", x-90, z, a+137);
changeentityproperty(e, "direction", 0);
changeentityproperty(e, "velocity", -6, 0, 0);
e = spawn();
}
if ((frame == 5 || frame == 11 || frame == 17)&&(p1)&&(getentityproperty(self, "direction")==1)){
clearspawnentry();
setspawnentry("name","zof");
changeentityproperty(e, "position", x+90, z, a+137);
changeentityproperty(e, "direction", 1);
changeentityproperty(e, "velocity", 6, 0, 0);
e = spawn();
}
@end_script
@script
void vSelf = getlocalvar("self");
if(frame==1){
int iTime = openborvariant("elapsed_time");
changeentityproperty(vSelf, "tosstime", iTime + 400);
}
@end_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment