Odessey.lua
*No download available for this library yet.*
Odessey.lua is an API that mimics the ability to possess enemy in Super Mario Odyssey. The API contains plenty of customizable features.
How to use
To load the API, place this line in your script.
local odessey = API.load("odessey")
This API requires a folder called odessey. The is a required file in this folder must be a PNG file called hat
Documentation
ai
You may customize the AI of the NPC when it is possessed. To make an AI function you set it up as:
local odessey = API.load("odessey")
odessey.ai[NPCID] = function(npc)
--Here you can customize the AI
end
This function is organized by NPC's IDs and will get called during onTick() and will pass npc as an NPC object. The NPC passed is the current enemy that is possessed.
Example:
local odessey = API.load("odessey")
local inputs2 = API.load("inputs2")
--SMB3 Brown Goomba
odessey.ai[1] = function(npc)
if inputs2.state[1].left == inputs2.PRESS then
npc.speedX = -3
elseif inputs2.state[1].right == inputs2.PRESS then
npc.speedX = 3
end
if inputs2.state[1].jump == inputs2.PRESS and npc:mem(0x0A,FIELD_WORD) == 2 then
npc.speedY = -6
playSFX(1)
end
end
If an enemy is possessed and it does not find a defined function it will instead use ai[0]. ai[0] is the only ai that is defined in the API and it is the function showed below. The API will only use this AI if it does not find an AI for the set ID. You may redefine this AI if needed too.
odessey.ai[0] = function(v)
if inputs2.state[1].left == inputs2.HOLD then
v.speedX = -1*math.abs(v.speedX)
if v.speedX == 0 then
v.speedX = -3
end
elseif inputs2.state[1].right == inputs2.HOLD then
v.speedX = math.abs(v.speedX)
if v.speedX == 0 then
v.speedX = 3
end
end
end
hat
The hat is an object that is activated with the alt-run key. You can customize the hat by changing some of these values.
| Name | Default Value | Description |
|---|---|---|
| img | LuaImgResource
"hat.png" found inside the Odessey folder |
The image of the hat. |
| x | Number
0 (Automatically moves to the player when the hat is activated) |
The X coordinate of the hat. |
| y | Number
0 (Automatically moves to the player when the hat is activated) |
The Y coordinate of the hat. |
| gfxOffsetX | Number
0 |
The X offset of the image. |
| gfxOffsetY | Number
0 |
The Y offset of the image. |
| speedX | Number
0 |
The current x-speed of the hat. |
| speedY | Number
0 |
The current y-speed of the hat. |
| speedXMax | Number
7.5 |
The maximum x-speed of the hat.
Will automatically cap negative numbers too (setting speed -8 will turn into -7.5) |
| speedYMax | Number
4 |
The maximum y-speed of the hat.
Will automatically cap negative numbers too (setting speed -8 will turn into -4) |
| speedXIni | Number
6 |
The initial x-speed of the hat when it is activated.
Will automatically flip the number to negative if the player is facing left. |
| speedYIni | Number
0 |
The initial y-speed of the hat when it is activated. |
| width | Number
32 |
The width of the hat. |
| height | Number
32 |
The height of the hat. |
| facing | Number
1 (Will either turn to -1[left] or 1[right] when activated. The direction facing will match the direction the player is facing. |
The initial direction of the hat when it is activated. |
| frame | Number
1 |
The current frame that is being drawn. |
| frames | Number
8 |
The total amount of frames. |
| frameSpeed | Number
8 |
The number of frames it should wait until the next frame appears. |
| animationTimer | Number
0 |
The timer that counts the frames passed between frames. When this number reaches frameSpeed, it will reset to 0 and increment frame by 1. |
| timer | Number
0 |
The number of frames that have passed since when the hat was activated. |
playerIMG
playerIMG is a table that contains all of the characters images of them in their normal and hatless value.
The structure of the table is as follows:
playerIMG[CHARACTER] = {
-- All of the images featuring the character with his hat
[0] = {
[0] = LuaImageResource -- Death Effect
[1] = LuaImageResource -- Powerup 1
[2] = LuaImageResource -- Powerup 2
...
[n] = LuaImageResource -- Powerup n
}
-- All of the images featuring the character with his hat
[1] = {
[0] = LuaImageResource -- Death Effect
[1] = LuaImageResource -- Powerup 1
[2] = LuaImageResource -- Powerup 2
...
[n] = LuaImageResource -- Powerup n
}
}
By default, it will load the player images inside the "Odyssey" folder. File names with an h stand for files that represent the player hatless. For example, placing an image called "mario-1.png" will make mario be that image when he has a hat, and setting an image called "mario-1h.png" will make Mario turn into that image when he activates his hat. If the image is not found inside the folder, it will automatically use the default player's image. The images supported are all of the powerup files (mario-1.png, luigi-2.png, megaman-1.png), and all of the death effects (3,5,129,130,134,149,150,151,152,153,154,155,156,157,158,159,160,161).
killwithNPC
The API by default kills the player if they are possessing an enemy as it is dying. killwithNPC is a table of booleans that allow you to set if the player should die if the enemy dies.