Skip to content

Commit

Permalink
widget message, bomb despawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Aug 10, 2024
1 parent 8d5f9a5 commit 7190318
Show file tree
Hide file tree
Showing 27 changed files with 704 additions and 144 deletions.
6 changes: 6 additions & 0 deletions Megaton.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ sources = [
]
includes = [
"src",
"libs/botw/src",
"libs/botw/lib/agl/include",
"libs/botw/lib/gsys/include",
"libs/exlaunch/source",
"libs/sead/include",
"libs/nnheaders/include",
Expand Down Expand Up @@ -42,6 +45,9 @@ extra = [
"-DEXL_PROGRAM_ID=$(MEGATON_MODULE_TITLE_ID)",
"-DEXL_MODULE_NAME='\"$(MEGATON_MODULE_NAME)\"'"
]},
{ CXXFLAGS = [
"-Wno-invalid-offsetof",
]},
]

[check]
Expand Down
27 changes: 27 additions & 0 deletions data/message_tips.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# idx => msg_id mapping for MessageTipsRuntime, and there respective flag
# source: sinitScreenMessageTipsRuntime
# 0x17 is added in 1.6. It's the VR message and potentially doesn't have a flag
0x00,"0000",GuideSPlus_GurdJust
0x01,"0001",GuideSPlus_KaihiJust
0x02,"0003",GuideS_HeadShoot
0x03,"0002",GuideSPlus_Surfing
0x04,"0004",GuideS_WarningGanbari
0x05,"0005",GuideS_WarningCold
0x06,"0006",GuideS_WarningHot
0x07,"0007",GuideS_StealthAttack
0x08,"0008",GuideS_WeaponDestruction
0x09,"0009",GuideS_WeaponThrowAttack
0x0A,"0010",GuideS_WarningBurn
0x0B,"0013",GuideS_ClimbSlip
0x0C,"0014",GuideS_WeaponBurning
0x0D,"0015",GuideSPlus_Squat
0x0E,"0017",GuideS_WorfLead
0x0F,"0016",GuideS_SandSealError
0x10,"0018",GuideS_Recipe
0x11,"0019",GuideS_ElectricDamage
0x12,"0020",GuideS_WarningColdLv2
0x13,"0021",GuideS_WarningHotLv2
0x14,"0022",GuideS_WarningBurnLv2
0x15,"0023",GuideS_RelicControl
0x16,"0024",GuideS_MotocycleGasOff
0x17,"0025",
File renamed without changes.
7 changes: 5 additions & 2 deletions link.ld
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

main_memory = 0x0 - 0x3483000;
botw_show_info_overlay = 0x1238680 - 0x3483000; /* 0x1238680 (0000007100A95924) in 1.5.0 */
botw_get_message_string = 0x123DEA0 - 0x3483000;
ksys_ui_showInfoOverlayWithString = 0x1238680 - 0x3483000;
ScreenMessageTipsRuntime_doShowMessageTip = 0x0119C750 - 0x3483000;
ksys_ui_screen_mgr_instance = 0x2CC2490 - 0x3483000;
/* botw_get_message_string = 0x123DEA0 - 0x3483000; */
ksys_ui_runtime_tips = 0x02CBA3B0 - 0x3483000;
1 change: 1 addition & 0 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Command Controller::update() {
clear_hold();
return Command::SwitchMode;
}
return Command::None;
}

if (m_mode == Mode::Setting) {
Expand Down
8 changes: 4 additions & 4 deletions src/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ class Controller {
void get_key_name(util::StringBuffer<30>& out_buffer, Key* key) const {
out_buffer.clear();
if (key == &m_key_save) {
out_buffer.append("SaveStateToMemory");
out_buffer.append("SaveToMem");
} else if (key == &m_key_save_file) {
out_buffer.append("SaveStateToFile");
out_buffer.append("SaveToFile");
} else if (key == &m_key_restore) {
out_buffer.append("RestoreStateFromMemory");
out_buffer.append("RestoreMem");
} else if (key == &m_key_restore_file) {
out_buffer.append("RestoreStateFromFile");
out_buffer.append("RestoreFile");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
#include <Game/UI/uiPauseMenuDataMgr.h>
#include <prim/seadScopedLock.h>

#include "util/scoped_lock.hpp"

namespace uking::ui {

void PauseMenuDataMgr::updateEquippedItemArray() {
// offset of array: 0x44E70
mEquippedWeapons.fill({});
// Removed lock since we are duplicating the impl anyway. Dangerous

// since sead::CriticalSection is inlined in 1.6
// our own scoped lock implementation is provided
botwsavs::util::ScopedLock lock(&mCritSection.mCriticalSectionInner);
// const auto lock = sead::makeScopedLock(mCritSection);
for (auto& item : getItems()) {
if (item.getType() > PouchItemType::Shield)
Expand All @@ -16,4 +21,5 @@ void PauseMenuDataMgr::updateEquippedItemArray() {
mEquippedWeapons[u32(item.getType())] = &item;
}
}

} // namespace uking::ui
16 changes: 16 additions & 0 deletions src/impl/sead/SafeStringImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,20 @@ template <>
SafeStringBase<char16>&
SafeStringBase<char16>::operator=(const SafeStringBase<char16>& other) = default;

template <>
BufferedSafeStringBase<char>&
BufferedSafeStringBase<char>::operator=(const SafeStringBase<char>& other)
{
copy(other);
return *this;
}

template <>
BufferedSafeStringBase<char16>&
BufferedSafeStringBase<char16>::operator=(const SafeStringBase<char16>& other)
{
copy(other);
return *this;
}

} // namespace sead
6 changes: 2 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
extern "C" void exl_main(void* x0, void* x1) {
exl::hook::Initialize();
nn::fs::MountSdCardForDebug("sd");

// patch message system for displaying custom info overlay
exl::patch::CodePatcher patcher { 0x010D2DC4 };
patcher.BranchLinkInst(reinterpret_cast<void*>(botwsavs::util::msg::get_message_string_hook));

botwsavs::util::msg::install_hooks();

botwsavs::start_worker_thread();
}
Expand Down
45 changes: 23 additions & 22 deletions src/raw_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ struct PouchItem;
namespace botwsavs::raw_ptr {
// Health and Stam
inline util::safe_ptr<u32> health() {
// [[main+2CA1A78]+80]+848
return _main[0x2CA1A78][0x80] + 0x848;
}
inline util::safe_ptr<float> stamina() {
// [[main+2c9fd70]+38]+2ac
return _main[0x2c9fd70][0x38] + 0x2ac;
}
// Max Stam Amount (unused): [[main+2c9fd70]+38]+2b0
Expand All @@ -30,58 +28,61 @@ inline util::safe_ptr<float> stamina() {
// Set Bomb cool down to 360 in float (43350000)
// Set Stasis cool down to 1 in float (3F800000)
inline util::safe_ptr<float> round_bomb_cooldown() {
// [[main+2CA3AD8]+30]+80
return _main[0x2CA3AD8][0x30] + 0x80;
}
inline util::safe_ptr<float> square_bomb_cooldown() {
// [[main+2CA3AD8]+30]+98
return _main[0x2CA3AD8][0x30] + 0x98;
}
inline util::safe_ptr<float> stasis_cooldown() {
// [[main+2CA3AD8]+30]+144
return _main[0x2CA3AD8][0x30] + 0x144;
}

// Position and Camera
inline util::safe_ptr<float> havok_position() {
// [[main+2D37AF0]+F0]+D28]+5E0
return _main[0x2D37AF0][0xF0][0xD28] + 0x5E0;
}
inline util::safe_ptr<float> main_position_matrix() {
// [[main+2CA1140]+60]+398
return _main[0x2CA1140][0x60] + 0x398;
}
inline util::safe_ptr<float> camera_pan_matrix() {
// [[main+2CE1090]+60]+20
return _main[0x2CE1090][0x60] + 0x20;
}
inline util::safe_ptr<float> camera_zoom() {
// [[[main+2CA5520]+20]+558]+D48
return _main[0x2CA5520][0x20][0x558] + 0xD48;
}
inline util::safe_ptr<float> camera_tilt() {
// [[[main+2CA5520]+20]+558]+D14
return _main[0x2CA5520][0x20][0x558] + 0xD14;
}

// Fall Damage (need to figure out how to make FDC work)
inline util::safe_ptr<float> fall_damage_y() {
// [[main+2CA1140]+60]+20D0
return _main[0x2CA1140][0x60] + 0x20D0;
}

// Overworld Durability
/* GamePtrDefine(u32, MenuEquippedArrowCount, main[0x2CA6D48][0x447E8] + 0x20) // [[main+2CA6D48]+447E8]+20 only works when in menu */
/* GamePtrDefine(u32, OverworldWeaponDurability, main[0x2CC4768][0xc0][-0xA0][0x48] + 0xD4c) // [[[[main+2CC4768]+c0]-A0]+48]+D4C */
/* GamePtrDefine(u32, OverworldBowDurability, main[0x2CC4768][0xc0][-0x70][0x48] + 0xD4c) // [[[[main+2CC4768]+c0]-70]+48]+D4C */
/* GamePtrDefine(u32, OverworldShieldDurability, main[0x2CC4768][0xc0][-0x88][0x48] + 0xD4c) // [[[[main+2CC4768]+c0]-88]+48]+D4C */
/* GamePtrDefine(ksys::act::BaseProc, OverworldWeaponActor, main[0x2CC4768][0xc0][-0xA0][0x48]) */
/* GamePtrDefine(ksys::act::BaseProc, OverworldBowActor, main[0x2CC4768][0xc0][-0x70][0x48]) */
/* GamePtrDefine(ksys::act::BaseProc, OverworldShieldActor, main[0x2CC4768][0xc0][-0x88][0x48]) */
// Inventory Weapon: [[main+2CA6D48]+447D8]+20
// Inventory Bow: [[main+2ca6d48]+447E0]+20
// Inventory Shield: [[main+2ca6d48]+447F0]+20
// Don't use Inventory equipment. Requires restoring in menu + unequip and re-equip to work. Just use overworld instance.
inline util::safe_ptr<ksys::act::BaseProc> overworld_weapon_actor() {
return _main[0x2CC4768][0xc0][-0xA0][0x48];
}

inline util::safe_ptr<ksys::act::BaseProc> overworld_bow_actor() {
return _main[0x2CC4768][0xc0][-0x70][0x48];
}

inline util::safe_ptr<ksys::act::BaseProc> overworld_shield_actor() {
return _main[0x2CC4768][0xc0][-0x88][0x48];
}

inline util::safe_ptr<u32> overworld_weapon_durability() {
return _main[0x2CC4768][0xc0][-0xA0][0x48] + 0xD4C;
}

inline util::safe_ptr<u32> overworld_bow_durability() {
return _main[0x2CC4768][0xc0][-0x70][0x48] + 0xD4C;
}

inline util::safe_ptr<u32> overworld_shield_durability() {
return _main[0x2CC4768][0xc0][-0x88][0x48] + 0xD4C;
}

// Time
/* GamePtrDefine(f32, TimeOfDayPaused, main[0x2CC5FE0][0xBE0][0x30][0xF8] + 0x18) // [[[[main+2CC5FE0]+BE0]+30]+F8]+18 */
Expand Down
23 changes: 21 additions & 2 deletions src/state/lv_1.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <KingSystem/ActorSystem/actBaseProcMgr.h>
#include <KingSystem/ActorSystem/actBaseProc.h>

#include "raw_ptr.hpp"
#include "named.h"
#include "util/data_reader.hpp"
Expand All @@ -6,7 +9,6 @@
#include "./lv_1.hpp"
#include "./reporter.hpp"


namespace botwsavs::state {

void Lv1::read_from_game(Reporter& r) {
Expand All @@ -32,7 +34,24 @@ void Lv1::write_to_game(Reporter& r, bool hold) const {
r.report("RdBombCD", raw_ptr::round_bomb_cooldown().set(0.0F));
r.report("SqBombCD", raw_ptr::square_bomb_cooldown().set(0.0F));
r.report("StasisCD", raw_ptr::stasis_cooldown().set(0.0F));
// TODO: despawn bombs

auto* proc_mgr = ksys::act::BaseProcMgr::instance();
if (!proc_mgr) {
r.report("DespBomb", false);
} else {
for (const char* bomb_name: {
"RemoteBomb",
"RemoteBomb2",
"RemoteBombCube",
"RemoteBombCube2",
}) {
auto* bomb = proc_mgr->getProc(bomb_name, {});
if (bomb) {
bomb->deleteLater(ksys::act::BaseProc::DeleteReason::_0);
}
}
}

// TODO: fall damage cancel
}

Expand Down
23 changes: 23 additions & 0 deletions src/state/lv_1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ class Lv1 {
// Extras:
// reset rune cooldown
// TODO reset fall damage

float m_tod_paused;
float m_tod_unpaused;
float m_blood_moon_timer;
float m_temperature_damage_timer;
float m_flame_timer;
float m_gale_timer;
float m_fury_timer;
float m_protection_timer;
float m_grace_timer;
u32 m_ability_uses[3];
float m_master_sword_cooldown;

float m_speed_potion_timer_1;
float m_speed_potion_timer_2;
float m_speed_potion_timer_3;
float m_attack_potion_timer;
float m_defense_potion_timer;
float m_heat_resist_potion_timer;
float m_cold_resist_potion_timer;
float m_flame_resist_potion_timer;
float m_shock_resist_potion_timer;
float m_stealth_potion_timer;
};

} // namespace botwsavs::core
Loading

0 comments on commit 7190318

Please sign in to comment.