From f50bb7a805406bd55d7d1610388d2563d4362ea8 Mon Sep 17 00:00:00 2001 From: Henrybk Date: Thu, 26 Dec 2024 09:20:50 -0300 Subject: [PATCH] Fix skill failed packet (#3918) * Fix skill failed packet * corrected the translation line --------- Co-authored-by: ya4ept --- src/Network/Receive.pm | 26 +++++++++++++------------- src/Network/Receive/ServerType0.pm | 5 ++++- src/Network/Receive/kRO/Sakexe_0.pm | 5 ++++- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/Network/Receive.pm b/src/Network/Receive.pm index 5f4427c000..5287f8c187 100644 --- a/src/Network/Receive.pm +++ b/src/Network/Receive.pm @@ -11686,12 +11686,6 @@ sub isvr_disconnect { sub skill_use_failed { my ($self, $args) = @_; - # skill fail/delay - my $skillID = $args->{skillID}; - my $btype = $args->{btype}; - my $fail = $args->{fail}; - my $type = $args->{type}; - my %basefailtype = ( 0 => $msgTable[160],#"skill failed" 1 => $msgTable[161],#"no emotions" @@ -11740,10 +11734,13 @@ sub skill_use_failed { ); my $errorMessage; - if ($skillID == 1 && $type == 0 && exists $basefailtype{$btype}) { - $errorMessage = $basefailtype{$btype}; - } elsif (exists $failtype{$type}) { - $errorMessage = $failtype{$type}; + if ($args->{skillID} == 1 && $args->{cause} == 0 && exists $basefailtype{$args->{btype}}) { + $errorMessage = $basefailtype{$args->{btype}}; + } elsif (exists $failtype{$args->{cause}}) { + $errorMessage = $failtype{$args->{cause}}; + if ($args->{cause} == 71) { + $errorMessage .= T(' - item ').$args->{itemId}; + } } else { $errorMessage = T('Unknown error'); } @@ -11751,14 +11748,17 @@ sub skill_use_failed { delete $char->{casting}; my %hookArgs; - $hookArgs{skillID} = $skillID; - $hookArgs{failType} = $type; + $hookArgs{skillID} = $args->{skillID}; + $hookArgs{btype} = $args->{btype}; + $hookArgs{itemId} = $args->{itemId}; + $hookArgs{flag} = $args->{flag}; + $hookArgs{cause} = $args->{cause}; $hookArgs{failMessage} = $errorMessage; $hookArgs{warn} = 1; Plugins::callHook('packet_skillfail', \%hookArgs); - warning(TF("Skill %s failed: %s (error number %s)\n", Skill->new(idn => $skillID)->getName(), $errorMessage, $type), "skill") if ($hookArgs{warn}); + warning(TF("Skill %s failed: %s (error number %s)\n", Skill->new(idn => $args->{skillID})->getName(), $errorMessage, $args->{cause}), "skill") if ($hookArgs{warn}); } sub open_store_status { diff --git a/src/Network/Receive/ServerType0.pm b/src/Network/Receive/ServerType0.pm index e668dac8c2..801dca4a1d 100644 --- a/src/Network/Receive/ServerType0.pm +++ b/src/Network/Receive/ServerType0.pm @@ -174,7 +174,10 @@ sub new { '010C' => ['mvp_other', 'a4', [qw(ID)]], '010E' => ['skill_update', 'v4 C', [qw(skillID lv sp range up)]], # range = skill range, up = this skill can be leveled up further '010F' => ['skills_list'], - '0110' => ['skill_use_failed', 'v V C2', [qw(skillID btype fail type)]], + '0110' => ($rpackets{'0110'}{length} == 14) # or 10 + ? ['skill_use_failed', 'v V2 C2', [qw(skillID btype itemId flag cause)]] + : ['skill_use_failed', 'v v2 C2', [qw(skillID btype itemId flag cause)]] + , '0111' => ['skill_add', 'v V v3 Z24 C', [qw(skillID target lv sp range name upgradable)]], '0114' => ['skill_use', 'v a4 a4 V3 v3 C', [qw(skillID sourceID targetID tick src_speed dst_speed damage level option type)]], '0117' => ['skill_use_location', 'v a4 v3 V', [qw(skillID sourceID lv x y tick)]], diff --git a/src/Network/Receive/kRO/Sakexe_0.pm b/src/Network/Receive/kRO/Sakexe_0.pm index ed46959122..49d0a1d5fd 100644 --- a/src/Network/Receive/kRO/Sakexe_0.pm +++ b/src/Network/Receive/kRO/Sakexe_0.pm @@ -180,7 +180,10 @@ sub new { '010D' => ['mvp_item_trow'], # 2 '010E' => ['skill_update', 'v4 C', [qw(skillID lv sp range up)]], # 11 # range = skill range, up = this skill can be leveled up further '010F' => ['skills_list'], # -1 - '0110' => ['skill_use_failed', 'v V C2', [qw(skillID btype fail type)]], # 10 + '0110' => ($rpackets{'0110'}{length} == 14) # or 10 + ? ['skill_use_failed', 'v V2 C2', [qw(skillID btype itemId flag cause)]] + : ['skill_use_failed', 'v v2 C2', [qw(skillID btype itemId flag cause)]] + , '0111' => ['skill_add', 'v V v3 Z24 C', [qw(skillID target lv sp range name upgradable)]], # 39 '0114' => ['skill_use', 'v a4 a4 V3 v3 C', [qw(skillID sourceID targetID tick src_speed dst_speed damage level option type)]], # 31 '0115' => ['skill_use_position', 'v a4 a4 V3 v5 C', [qw(skillID sourceID targetID tick src_speed dst_speed x y damage level option type)]], # 35