initial commit

master
Warren Ulrich 2023-07-05 02:36:41 -07:00
commit 5f4e2749c0
3 changed files with 176 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build/
.vscode/

48
CMakeLists.txt Normal file
View File

@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.26)
project(object_debugger)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_SHARED_LINKER_FLAGS "-Os -s -m32 -static-libgcc -static-libstdc++ -static")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
if (NOT DEFINED ALPACABOT_DIR)
set(ALPACABOT_DIR $ENV{USERPROFILE}\\AlpacaBot)
endif()
if (NOT DEFINED ALPACABOT_INCLUDE_DIR)
set(ALPACABOT_INCLUDE_DIR ${ALPACABOT_DIR}\\Include)
endif()
if (NOT DEFINED ALPACABOT_LIB_DIR)
set(ALPACABOT_LIB_DIR ${ALPACABOT_DIR}\\Library)
endif()
if (NOT DEFINED ALPACABOT_SCRIPT_DIR)
set(ALPACABOT_SCRIPT_DIR ${ALPACABOT_DIR}\\Scripts\\Local)
endif()
set(SOURCE_FILES
src/main.cpp
)
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${ALPACABOT_SCRIPT_DIR}/${PROJECT_NAME}
)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${ALPACABOT_INCLUDE_DIR}
)
target_link_directories(${PROJECT_NAME} PRIVATE
${ALPACABOT_LIB_DIR}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
AlpacaLibrary
)

125
src/main.cpp Normal file
View File

@ -0,0 +1,125 @@
#include <filesystem>
#include <fstream>
#include <iostream>
#include <unordered_set>
#include <Game/Core.hpp>
#include <windows.h>
void Setup() {
ScriptInfo Info;
Info.Name = "Object Debugger";
Info.Description = "Debug objects";
Info.Version = "1.00";
Info.Category = "Magic";
Info.Author = "Warren";
Info.UID = "UID";
Info.ForumPage = "forum.alpacabot.org";
SetScriptInfo(Info);
}
bool OnStart() {
SetLoopDelay(5);
return true;
}
std::vector<Interactable::GameObject> get_game_objects() {
return GameObjects::GetAllWithin(10);
}
std::vector<Interactable::WallObject> get_wall_objects() {
return WallObjects::GetAllWithin(10);
}
std::vector<Interactable::GroundObject> get_ground_objects() {
return GroundObjects::GetAllWithin(10);
}
std::vector<Interactable::DecorativeObject> get_decorative_objects() {
return DecorativeObjects::GetAllWithin(10);
}
std::vector<Interactable::NPC> get_npcs() { return NPCs::GetAllWithin(10); }
std::vector<Interactable::Player> get_players() {
return Players::GetAllWithin(10);
}
enum class paint_mode {
game_objects,
wall_objects,
ground_objects,
decorative_objects,
npcs,
players
};
void paint_object(const auto &obj, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
const auto model = obj.GetModel();
Paint::DrawModel(model, r, g, b, a);
}
paint_mode pmode = paint_mode::players;
bool Loop() {
Paint::Clear();
if (GetAsyncKeyState(VK_MENU)) {
pmode = static_cast<paint_mode>((static_cast<int>(pmode) + 1) % 6);
Wait(200);
}
auto paint_objects = [&](const auto &objects, uint8_t r, uint8_t g,
uint8_t b) {
for (const auto &obj : objects) {
const auto name = obj.GetName();
if (name == "")
continue;
const auto tile = obj.GetTile();
if (!tile)
continue;
const auto w2s = Internal::TileToMainscreen(tile, 0, 0, 0);
if (!w2s)
continue;
paint_object(obj, r, g, b, 255);
std::stringstream ss;
ss << name;
ss << ": (" << tile.X << ", " << tile.Y << ", " << tile.Plane << ")";
Paint::DrawString(ss.str(), w2s, 255, 255, 255, 255);
}
};
switch (pmode) {
case paint_mode::game_objects:
paint_objects(get_game_objects(), 255, 0, 0);
break;
case paint_mode::wall_objects:
paint_objects(get_wall_objects(), 0, 255, 0);
break;
case paint_mode::ground_objects:
paint_objects(get_ground_objects(), 0, 0, 255);
break;
case paint_mode::decorative_objects:
paint_objects(get_decorative_objects(), 255, 255, 0);
break;
case paint_mode::npcs:
paint_objects(get_npcs(), 128, 0, 128);
break;
case paint_mode::players:
paint_objects(get_players(), 0, 255, 255);
break;
}
Paint::SwapBuffer();
return true;
}
bool OnBreak() { return true; }
void OnEnd() {}