Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skill failed packet #3918

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Network/Receive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -11740,25 +11734,31 @@ 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');
}

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 {
Expand Down
5 changes: 4 additions & 1 deletion src/Network/Receive/ServerType0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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)]],
Expand Down
5 changes: 4 additions & 1 deletion src/Network/Receive/kRO/Sakexe_0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading