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

Update comboSpam plugin #3815

Merged
merged 4 commits into from
Oct 19, 2023
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
120 changes: 85 additions & 35 deletions plugins/needs-review/comboSpam/trunk/comboSpam.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,96 @@ package comboSpam;
use strict;
use Plugins;
use Globals;
use Skills;
use Misc;
use Network;
use Network::Send;
use Utils;
use Time::HiRes qw(time usleep);


Plugins::register('comboSpam', 'spam combo packets', \&on_unload);
my $hook1 = Plugins::addHook('packet/actor_status_active', \&combo);
my $hook2 = Plugins::addHook('AI_pre', \&AI_pre);
my $combo = 0;
my $delay = .2;
my $time = time;

sub on_unload {
# This plugin is about to be unloaded; remove hooks
Plugins::delHook("packet/actor_status_active", $hook1);
Plugins::delHook("AI_pre", $hook1);
}
use Commands;
use Log qw(message);
use List::Util qw(max);
use Time::HiRes qw(&time);

Plugins::register('comboSpam', 'spam combo packets', \&Unload, \&Reload);

my $hooks = Plugins::addHooks(
['AI_pre', \&onLoop],
['is_casting', \&onSkillCast],
['packet_skilluse', \&onSkillUse],
['packet_skillfail', \&onSkillFail]
);

my %report = ();
my %sequence = (
263 => new Skill(idn => 272), # Raging Trifecta Blow > Raging Quadruple Blow
272 => new Skill(idn => 273), # Raging Quadruple Blow > Raging Thrust
273 => new Skill(idn => 371), # Raging Thrust > Glacier Fist
371 => new Skill(idn => 372), # Glacier Fist > Chain Crush Combo
372 => undef
);

sub combo {
my ($packet, $args) = @_;
my ($type, $ID, $flag) = @{$args}{qw(type ID flag)};

if ($skillsStatus{$type} eq "Triple Attack Delay") {
$combo = $flag;
my $time;
my $skillId;
my $delay = 0.2;
my $commands = Commands::register(
['combos', '', sub {
foreach my $skill (sort %sequence) {
next unless defined $skill && $skill->isa('Skill') && $report{$skill->getIDN()};
message sprintf("%s: %s\n", $skill->getName(), $report{$skill->getIDN()}), 'info';
}
}]
);

sub Unload {
foreach my $hook (@{$hooks}) {
Plugins::delHook($hook);
}
Commands::unregister($commands);
undef @{$hooks};
}

sub AI_pre {
sub Reload {
&Unload;
}

sub onLoop {
my ($self, $args) = @_;

if ($combo && main::timeOut($time, $delay)) {
sendSkillUse($net, 272, 5, $accountID); # Chain Combo
if ($char->{spirits}) { # Make sure there is a spirit sphere
sendSkillUse($net, 273, 5, $accountID); # Combo Finish
}
$time = time;
}

return unless Utils::timeOut($time, $delay);
$time = time;

# return if($char->{statuses}->{EFST_POSTDELAY});
return unless defined $skillId && exists $sequence{$skillId};
return unless AI::inQueue('attack');

my $skill = $sequence{$skillId};
return unless defined $skill && $skill->isa('Skill');

my $level = $char->getSkillLevel($skill);
my $handle = $skill->getHandle();
return unless $level > 0;

# SP Cost: (Skill Level + 10) || 2 + (Skill Level × 2)
my $skillSp = $char->{skills}{$handle}{sp} || max(10 + $level, 2 + ($level * 2));
return unless $char->{sp} >= $skillSp;
return unless $handle eq 'MO_CHAINCOMBO' || $char->{spirits} > 0;

$messageSender->sendSkillUse($skill->getIDN(), $level, $accountID);
}

sub onSkillCast {
my ($self, $args) = @_;
undef $skillId;
}

sub onSkillFail {
my ($hookName, $args) = @_;
my $skillId = $args->{skillID};
$args->{warn} = exists $sequence{$skillId} ? 0 : 1;
}

sub onSkillUse {
my ($self, $args) = @_;

$skillId = $args->{skillID};

$report{$skillId} ||= 0;
$report{$skillId}++;
}

1;
15 changes: 9 additions & 6 deletions src/Network/Receive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11800,12 +11800,15 @@ sub skill_use_failed {

delete $char->{casting};

warning TF("Skill %s failed: %s (error number %s)\n", Skill->new(idn => $skillID)->getName(), $errorMessage, $type), "skill";
Plugins::callHook('packet_skillfail', {
skillID => $skillID,
failType => $type,
failMessage => $errorMessage
});
my %hookArgs;
$hookArgs{skillID} = $skillID;
$hookArgs{failType} = $type;
$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});
}

sub open_store_status {
Expand Down
Loading