Skip to content

Commit

Permalink
small random stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Oct 31, 2023
1 parent 91c3c2e commit be56a7d
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 31 deletions.
16 changes: 9 additions & 7 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions docs/src/includes/_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -1735,8 +1735,7 @@ function change_layer(layer_to, load_time)

state.layer_transition_timer = load_time
state.transition_to_layer = layer_to
-- actual layer change after time delay
set_timeout(function() state.camera_layer = layer_to end, load_time)
state.camera_layer = layer_to
end

```
Expand Down Expand Up @@ -3676,7 +3675,7 @@ Use `get_entities_overlapping_hitbox` instead
#### int get_entity_ai_state(int uid)

As the name is misleading. use entity `move_state` field instead
As the name is misleading. use [Movable](#Movable).`move_state` field instead

### set_arrowtrap_projectile

Expand Down
16 changes: 9 additions & 7 deletions docs/src/includes/_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ tuple<int, int, int, int> | [get_rgba()](https://github.com/spelunky-fyi/o
[Color](#Color) | [set_rgba(int red, int green, int blue, int alpha)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_rgba) | Changes color based on given RGBA colors in 0..255 range
[uColor](#Aliases) | [get_ucolor()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_ucolor) | Returns the `uColor` used in `GuiDrawContext` drawing functions
[Color](#Color) | [set_ucolor(uColor color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_ucolor) | Changes color based on given [uColor](#Aliases)
[Color](#Color) | [set(Color other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set) | Copies the values of different [Color](#Color) to this one

### CutsceneBehavior

Expand Down Expand Up @@ -1303,6 +1304,7 @@ float | [red](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=red) |
float | [green](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=green) |
float | [blue](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=blue) |
float | [size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=size) |
[Color](#Color) | [as_color()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=as_color) | Returns [LightParams](#LightParams) as [Color](#Color), note that size = alpha

## Liquid types

Expand Down Expand Up @@ -2819,12 +2821,12 @@ Can be accessed via global [state](#state)

Type | Name | Description
---- | ---- | -----------
int | [screen_last](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen_last) | Previous [SCREEN](#SCREEN), used to check where we're coming from when loading another [SCREEN](#SCREEN)
int | [screen](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen) | Current [SCREEN](#SCREEN), generally read-only or weird things will happen
int | [screen_next](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen_next) | Next [SCREEN](#SCREEN), used to load the right screen when loading. Can be changed in PRE_LOAD_SCREEN to go somewhere else instead. Also see `state.loading`.
[SCREEN](#SCREEN) | [screen_last](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen_last) | Previous [SCREEN](#SCREEN), used to check where we're coming from when loading another [SCREEN](#SCREEN)
[SCREEN](#SCREEN) | [screen](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen) | Current [SCREEN](#SCREEN), generally read-only or weird things will happen
[SCREEN](#SCREEN) | [screen_next](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen_next) | Next [SCREEN](#SCREEN), used to load the right screen when loading. Can be changed in PRE_LOAD_SCREEN to go somewhere else instead. Also see `state.loading`.
int | [ingame](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ingame) | Is 1 when you in a game, is set to 0 or 1 in main menu, can't be trusted there, normally in a level is 1 unless you go to the options
int | [playing](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=playing) | Is 1 when you are in a level, but going to options sets it to 0 and does not set it back to 1 after the way back, don't trust it
[PAUSE](#PAUSE) | [pause](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause) | 8bit flags, multiple might be active at the same time<br/>1: Menu: Pauses the level timer and engine. Can't set, controller by the menu.<br/>2: Fade/Loading: Pauses all timers and engine.<br/>4: Cutscene: Pauses total/level time but not engine. Used by boss cutscenes.<br/>8: Unknown: Pauses total/level time and engine. Does not pause the global counter so set_global_interval still runs.<br/>16: Unknown: Pauses total/level time and engine. Does not pause the global counter so set_global_interval still runs.<br/>32: Ankh: Pauses all timers, engine, but not camera. Used by the ankh cutscene.
[PAUSE](#PAUSE) | [pause](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause) | 8bit flags, multiple might be active at the same time<br/>1: Menu: Pauses the level timer and engine. Can't set, controlled by the menu.<br/>2: Fade/Loading: Pauses all timers and engine.<br/>4: Cutscene: Pauses total/level time but not engine. Used by boss cutscenes.<br/>8: Unknown: Pauses total/level time and engine. Does not pause the global counter so set_global_interval still runs.<br/>16: Unknown: Pauses total/level time and engine. Does not pause the global counter so set_global_interval still runs.<br/>32: Ankh: Pauses all timers, engine, but not camera. Used by the ankh cutscene.
int | [width](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width) | level width in rooms (number of rooms horizontally)
int | [height](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=height) | level height in rooms (number of rooms vertically)
int | [kali_favor](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kali_favor) |
Expand All @@ -2841,7 +2843,7 @@ int | [level_next](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=leve
int | [level_start](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=level_start) | Level number to start new runs in
[THEME](#THEME) | [theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme) | Current [THEME](#THEME) number, used to pick the music and by some game logic like choosing the next level on transition
[THEME](#THEME) | [theme_next](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme_next) | Next [THEME](#THEME) number, used when loading a new level or transition
int | [theme_start](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme_start) | [THEME](#THEME) to start new runs in
[THEME](#THEME) | [theme_start](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme_start) | [THEME](#THEME) to start new runs in
[ThemeInfo](#ThemeInfo) | [current_theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=current_theme) | Points to the current [ThemeInfo](#ThemeInfo)
nil | [force_current_theme(int t)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=force_current_theme) | This function should only be used in a very specific circumstance (forcing the exiting theme when manually transitioning). Will crash the game if used inappropriately!
int | [shoppie_aggro](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=shoppie_aggro) | Current shoppie aggro
Expand All @@ -2868,7 +2870,7 @@ int | [saved_hamsters](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=
int | [win_state](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=win_state) | 0 = no win 1 = tiamat win 2 = hundun win 3 = CO win; set this and next doorway leads to victory scene
[Illumination](#Illumination) | [illumination](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=illumination) | The global level illumination, very big and bright.
int | [money_last_levels](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=money_last_levels) |
int | [money_shop_total](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=money_shop_total) | Total negative amount spent in shops during the run<br><br/>The total money currently available (in single player) is `players[1].inventory.money + players[1].inventory.collected_money_total + state.money_shop_total`
int | [money_shop_total](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=money_shop_total) | Total amount spent in shops and sold idols during the run<br><br/>The total money currently available is `loop (players[].inventory.money + players[].inventory.collected_money_total) + state.money_shop_total`
[PlayerInputs](#PlayerInputs) | [player_inputs](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=player_inputs) | Access the player inputs even when no player entities are available
[QuestsInfo](#QuestsInfo) | [quests](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=quests) | [NPC](#NPC) quest states
[Camera](#Camera) | [camera](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=camera) | [Camera](#Camera) bounds and position
Expand Down Expand Up @@ -2923,7 +2925,7 @@ array&lt;[JournalProgressStickerSlot](#JournalProgressStickerSlot), 40&gt; | [jo
int | [journal_progress_stain_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_stain_count) |
array&lt;[JournalProgressStainSlot](#JournalProgressStainSlot), 30&gt; | [journal_progress_stain_slots](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_stain_slots) | blood splats and paw prints in journal progress page
int | [journal_progress_theme_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_theme_count) |
array&lt;int, 9&gt; | [journal_progress_theme_slots](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_theme_slots) | visited themes in journal progress page
array&lt;[THEME](#THEME), 9&gt; | [journal_progress_theme_slots](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_theme_slots) | visited themes in journal progress page
[ThemeInfo](#ThemeInfo) | [theme_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme_info) | Points to the current [ThemeInfo](#ThemeInfo)
[LogicList](#LogicList) | [logic](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=logic) | Level logic like dice game and cutscenes
[LiquidPhysics](#LiquidPhysics) | [liquid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=liquid) |
Expand Down
6 changes: 6 additions & 0 deletions src/game_api/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ struct Color
uint8_t alpha = (color >> 24U) & 0xFF;
return set_rgba(red, green, blue, alpha);
}
/// Copies the values of different Color to this one
Color& set(Color other)
{
*this = other;
return *this;
}

float r{0.0f};
float g{0.0f};
Expand Down
2 changes: 1 addition & 1 deletion src/game_api/entities_chars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#include <vector> // for vector

#include "aliases.hpp" // for ENT_TYPE
#include "color.hpp" // for Color
#include "containers/custom_map.hpp" //
#include "movable.hpp" // for Movable

struct Illumination;
struct PlayerInputs;
struct Inventory;
struct PlayerSlot;
struct Color;
class Entity;

class Ai
Expand Down
2 changes: 1 addition & 1 deletion src/game_api/entity_lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ std::vector<uint32_t> get_entities_at(std::vector<ENT_TYPE> entity_types, uint32
for (auto& item : entities.entities())
{
auto [ix, iy] = item->position();
float distance = std::sqrt(std::pow(x - ix, 2.0f) + std::pow(y - iy, 2.0f));
float distance = (float)std::sqrt(std::pow(x - ix, 2) + std::pow(y - iy, 2));
if (distance < radius && entity_type_check(proper_types, item->type->id))
{
found.push_back(item->uid);
Expand Down
6 changes: 3 additions & 3 deletions src/game_api/game_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

struct Renderer
{
uint32_t render_width; // sam as window size unless resolution scale is set
uint32_t render_width; // same as window size unless resolution scale is set
uint32_t render_height;

uint32_t fps; // changing it doesn't seam to do anything
uint32_t fps_denominator;

uint32_t render_width2; // repeat
uint32_t render_width2; // repeat?
uint32_t render_height2;

uint8_t flags1;
Expand All @@ -36,7 +36,7 @@ struct Renderer

size_t swap_chain;

// somewhere there should be shareds stored
// somewhere there should be shaders stored

// added just to have the vtable
virtual ~Renderer() = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/game_api/illumination.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ struct LightParams // it's probably just Color
float green;
float blue;
float size;

/// Returns LightParams as Color, note that size = alpha
Color* as_color()
{
return reinterpret_cast<Color*>(this);
};
};

struct Illumination
Expand Down
1 change: 1 addition & 0 deletions src/game_api/script/usertypes/entity_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void register_usertypes(sol::state& lua)
color_type["set_rgba"] = &Color::set_rgba;
color_type["get_ucolor"] = &Color::get_ucolor;
color_type["set_ucolor"] = &Color::set_ucolor;
color_type["set"] = &Color::set;

/// Used in EntityDB
lua.new_usertype<Animation>(
Expand Down
4 changes: 3 additions & 1 deletion src/game_api/script/usertypes/state_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ void register_usertypes(sol::state& lua)
"blue",
&LightParams::blue,
"size",
&LightParams::size);
&LightParams::size,
"as_color",
&LightParams::as_color);

/// Generic obcject for lights in the game, you can make your own with [create_illumination](#create_illumination)<br/>
/// Used in StateMemory, Player, PlayerGhost, BurningRopeEffect ...
Expand Down
Loading

0 comments on commit be56a7d

Please sign in to comment.