From 2aec9ad64c2e4790f9b6dcbe6eccfd2a96bc2ec1 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 06:09:26 +0000 Subject: [PATCH] Decompile fn_23481 (CSession::GetWeaponHitWaveName) Batch #7324 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_23481 CSession::GetWeaponHitWaveName: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, alisonrag, willerthal, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Session.h | 1 + Source/Contents/HitSounds.cpp | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 699d037d..7251b9fb 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -768,6 +768,7 @@ public: void NormalizeHead(int* head, int job); int GetDisplayJob(); const char* GetHitWaveName(int job); + const char* GetWeaponHitWaveName(int weapon); void InitJobHitWaveNames(); const char* GetEFSTImgFileName(int efstId, int type); int IsTreeGroupTwo(int job) const; diff --git a/Source/Contents/HitSounds.cpp b/Source/Contents/HitSounds.cpp index dd21b436..7e059ef1 100644 --- a/Source/Contents/HitSounds.cpp +++ b/Source/Contents/HitSounds.cpp @@ -55,6 +55,48 @@ const char* CSession::GetHitWaveName(int job) { return weaponWaves[weapon].c_str(); } +// OFFSET: 0x00DE3680 +// FUNCTION: fn_23481 +const char* CSession::GetWeaponHitWaveName(int weapon) { + const int realWeapon = GetRealWeaponId(weapon); + if (realWeapon == -1) { + switch (std::rand() % 4) { + case 0: + return "_enemy_hit_normal1.wav"; + case 1: + return "_enemy_hit_normal2.wav"; + case 2: + return "_enemy_hit_normal3.wav"; + case 3: + return "_enemy_hit_normal4.wav"; + } + } + + const std::vector& weaponWaves = reinterpret_cast&>(this->unknown_525C[0x18]); + if (weaponWaves.empty() || weaponWaves.size() <= static_cast(realWeapon)) { + return nullptr; + } + + if (this->GetDisplayJob() == 4046 || this->GetDisplayJob() == 4225) { + return weaponWaves[realWeapon].c_str(); + } + + if (realWeapon == 0) { + switch (std::rand() % 4) { + case 0: + return "_hit_fist1.wav"; + case 1: + return "_hit_fist2.wav"; + case 2: + return "_hit_fist3.wav"; + case 3: + return "_hit_fist4.wav"; + } + } + + return weaponWaves[realWeapon].c_str(); +} + // OFFSET: 0x00DE5BD0 // FUNCTION: fn_23494 void CSession::InitJobHitWaveNames() {