-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add utility for straight up using Ghidra byte strings * Clarify some structure in Entity/EntityDB * Add missing members to RenderInfo * Add get_max_rope_length * Add return to spawn_tree, plus typo fixes * Fix in info_dump * Disable static assert for MSVC * First draft of spawn rope * Update docs * Clang fix number one * Formatting fixes * Add missing new line at EOF * MrAuto requests * Second draft for rope spawn * Add interface to disable all hooks * Tag vanilla machine rooms with a special tag * Add util for super lazy people * Crazy code to allow making single entities climbable * Fix wrong param in update_movable * Add base_behavior binding * Split entity.hpp/.cpp into three * Add API to disable turning, useful when doing custom state machines and turning logic fudges with the result * Add missing patterns * Fix CI * clone types, no crazy code * Relax construct and destroy interface on allocators * Change hasher on EntityDB::animations * Automated clang-format changes * Remove set_climbable and other unnecessary stuff * some documentation for EntityDB * Fix for missing _ENV in some callbacks * Update docs * clang clang * Add new line at EOF Co-authored-by: Dregu <[email protected]> Co-authored-by: Clang-Format Bot <[email protected]>
- Loading branch information
1 parent
a887896
commit b442ddd
Showing
48 changed files
with
2,286 additions
and
1,475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Used to store static common data for an ENT_TYPE. You can also clone entity types with the copy constructor to create new custom entities with different common properties. [This tool](https://dregu.github.io/Spelunky2ls/animation.html) can be helpful when messing with the animations. The default values are also listed in [entities.json](https://github.com/spelunky-fyi/overlunky/blob/main/docs/game_data/entities.json). | ||
|
||
> When cloning an entity type, remember to save it in the script for as long as you need it. Otherwise the memory will be freed immediately, which eventually leads to a crash when used or overwritten by other stuff: | ||
```lua | ||
-- Create a special fast snake type with weird animation | ||
special_snake = EntityDB:new(ENT_TYPE.MONS_SNAKE) | ||
special_snake.max_speed = 1 | ||
special_snake.acceleration = 2 | ||
special_snake.animations[2].num_tiles = 1 | ||
|
||
set_post_entity_spawn(function(snake) | ||
-- 50% chance to make snakes special | ||
if prng:random_chance(2, PRNG_CLASS.PROCEDURAL_SPAWNS) then | ||
-- Assign custom type | ||
snake.type = special_snake | ||
-- This is only really needed if types are changed during the level | ||
snake.current_animation = special_snake.animations[2] | ||
end | ||
end, SPAWN_TYPE.ANY, MASK.MONSTER, ENT_TYPE.MONS_SNAKE) | ||
``` | ||
|
||
> You can also use Entity.user_data to store the custom type: | ||
```lua | ||
-- Custom player who is buffed a bit every level | ||
set_callback(function() | ||
-- Doing this to include HH | ||
for i,v in ipairs(get_entities_by_mask(MASK.PLAYER)) do | ||
local player = get_entity(v) | ||
|
||
-- Create new custom type on the first level, based on the original type | ||
if not player.user_data then | ||
player.user_data = {} | ||
player.user_data.type = EntityDB:new(player.type.id) | ||
end | ||
|
||
-- Set the player entity type to the custom type every level | ||
player.type = player.user_data.type | ||
|
||
-- Buff the player every subsequent level | ||
if state.level_count > 0 then | ||
player.type.max_speed = player.type.max_speed * 1.1 | ||
player.type.acceleration = player.type.acceleration * 1.1 | ||
player.type.jump = player.type.jump * 1.1 | ||
end | ||
end | ||
end, ON.POST_LEVEL_GENERATION) | ||
``` | ||
|
||
> Illegal bad example, don't do this: | ||
```lua | ||
set_callback(function() | ||
-- Nobody owns the new type and the memory is freed immediately, eventually leading to a crash | ||
players[1].type = EntityDB:new(players[1].type) | ||
players[1].type.max_speed = 2 | ||
end, ON.POST_LEVEL_GENERATION) | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <type_traits> | ||
|
||
template <class T = void> | ||
struct identity_hasher | ||
{ | ||
[[nodiscard]] size_t operator()(const T& val) const noexcept | ||
{ | ||
return static_cast<size_t>(val); | ||
} | ||
}; | ||
|
||
template <> | ||
struct identity_hasher<void> | ||
{ | ||
template <class T> | ||
[[nodiscard]] size_t operator()(const T& val) const noexcept | ||
{ | ||
return static_cast<size_t>(val); | ||
} | ||
}; |
Oops, something went wrong.