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 eventmacro inventory #3936

Merged
merged 1 commit into from
Jan 9, 2025
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
8 changes: 6 additions & 2 deletions plugins/eventMacro/eventMacro/Condition/Base/InInventory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ use strict;
use base 'eventMacro::Condition::Base::Inventory';

sub _hooks {
['inventory_ready','item_gathered','inventory_item_removed','packet/item_list_end'];
['inventory_clear','inventory_ready','item_gathered','inventory_item_removed','packet/item_list_end'];
}

sub validate_condition {
my ( $self, $callback_type, $callback_name, $args ) = @_;


if ($callback_type eq 'hook') {
if ($callback_name eq 'inventory_ready'
if ($callback_name eq 'inventory_clear') {
$self->{is_on_stand_by} = 1;

} elsif ($callback_name eq 'inventory_ready'
|| ($callback_name eq 'item_list_end' && $args->{type}== 0x0)) # INVTYPE_INVENTORY
{
$self->{is_on_stand_by} = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use base 'eventMacro::Conditiontypes::NumericConditionState';
use Globals qw( $char );

sub _hooks {
['packet_mapChange','inventory_ready','item_gathered','inventory_item_removed'];
['inventory_clear','inventory_ready','item_gathered','inventory_item_removed'];
}

sub _get_val {
Expand All @@ -22,7 +22,7 @@ sub validate_condition {
my ( $self, $callback_type, $callback_name, $args ) = @_;

if ($callback_type eq 'hook') {
return $self->SUPER::validate_condition(0) if ($callback_name eq 'packet_mapChange');
return $self->SUPER::validate_condition(0) if ($callback_name eq 'inventory_clear');
} elsif ($callback_type eq 'variable') {
$self->update_validator_var($callback_name, $args);
}
Expand Down
15 changes: 8 additions & 7 deletions plugins/eventMacro/eventMacro/Condition/IsEquippedID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use base 'eventMacro::Condition';
use eventMacro::Utilities qw( find_variable );

sub _hooks {
['packet_mapChange','equipped_item','unequipped_item','inventory_ready'];
['inventory_clear','equipped_item','unequipped_item','inventory_ready'];
}

#slot_index to index_name: %equipSlot_lut
Expand Down Expand Up @@ -142,9 +142,9 @@ sub update_vars {
}
}

if (!defined $self->{fulfilled_slot} || $changed_fulfilled_index) {
#if (!defined $self->{fulfilled_slot} || $changed_fulfilled_index) {
$self->check_all_equips($recheck_index);
}
#}
}

sub check_all_equips {
Expand Down Expand Up @@ -178,14 +178,15 @@ sub validate_condition {

if ($callback_type eq 'hook') {
if ($callback_name eq 'equipped_item') {
return $self->SUPER::validate_condition if (defined $self->{fulfilled_slot} || !exists $self->{slot_name_to_member_to_check_array}{$args->{slot}});
$self->check_slot($args->{slot}, $args->{item});
#return $self->SUPER::validate_condition if (defined $self->{fulfilled_slot} || !exists $self->{slot_name_to_member_to_check_array}{$args->{slot}});
#$self->check_slot($args->{slot}, $args->{item});
$self->check_all_equips($self->{slot_name_to_member_to_check_array});

} elsif ($callback_name eq 'unequipped_item') {
return $self->SUPER::validate_condition unless (defined $self->{fulfilled_slot} || $self->{fulfilled_slot} ne $args->{slot});
#return $self->SUPER::validate_condition unless (defined $self->{fulfilled_slot} || $self->{fulfilled_slot} ne $args->{slot});
$self->check_all_equips($self->{slot_name_to_member_to_check_array});

} elsif ($callback_name eq 'packet_mapChange') {
} elsif ($callback_name eq 'inventory_clear') {
$self->{fulfilled_slot} = undef;
$self->{fulfilled_item} = undef;
$self->{fulfilled_member_index} = undef;
Expand Down
33 changes: 19 additions & 14 deletions plugins/eventMacro/eventMacro/Condition/IsNotEquippedID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use base 'eventMacro::Condition';
use eventMacro::Utilities qw( find_variable );

sub _hooks {
['packet_mapChange','equipped_item','unequipped_item','inventory_ready'];
['inventory_clear','equipped_item','unequipped_item','inventory_ready'];
}

#slot_index to index_name: %equipSlot_lut
Expand Down Expand Up @@ -141,9 +141,9 @@ sub update_vars {
}
}

if (!defined $self->{fulfilled_slot} || $changed_fulfilled_slot) {
#if (!defined $self->{fulfilled_slot} || $changed_fulfilled_slot) {
$self->check_all_equips($recheck_index);
}
#}
}

sub check_all_equips {
Expand Down Expand Up @@ -180,23 +180,28 @@ sub validate_condition {

if ($callback_type eq 'hook') {
if ($callback_name eq 'equipped_item') {
return $self->SUPER::validate_condition unless (defined $self->{fulfilled_slot});
return $self->SUPER::validate_condition unless ($args->{slot} eq $self->{fulfilled_slot} && $self->{is_fulfilled_empty} == 1);
#return $self->SUPER::validate_condition unless (defined $self->{fulfilled_slot});
#return $self->SUPER::validate_condition unless ($args->{slot} eq $self->{fulfilled_slot} && $self->{is_fulfilled_empty} == 1);
$self->{fulfilled_slot} = undef;
$self->{is_fulfilled_empty} = undef;
$self->check_slot($args->{slot}, $args->{item});
#$self->check_slot($args->{slot}, $args->{item});
$self->check_all_equips($self->{slot_name_to_member_to_check_array});

} elsif ($callback_name eq 'unequipped_item') {
return $self->SUPER::validate_condition unless (exists $self->{slot_name_to_member_to_check_array}{$args->{slot}});
if (defined $self->{fulfilled_slot}) {
return $self->SUPER::validate_condition if ($self->{fulfilled_slot} ne $args->{slot});
} else {
$self->{fulfilled_slot} = $args->{slot};
}
$self->{is_fulfilled_empty} = 1;
#return $self->SUPER::validate_condition unless (exists $self->{slot_name_to_member_to_check_array}{$args->{slot}});
#if (defined $self->{fulfilled_slot}) {
# return $self->SUPER::validate_condition if ($self->{fulfilled_slot} ne $args->{slot});
#} else {
# $self->{fulfilled_slot} = $args->{slot};
#}
#$self->{is_fulfilled_empty} = 1;
$self->{fulfilled_slot} = undef;
$self->{is_fulfilled_empty} = undef;
$self->check_all_equips($self->{slot_name_to_member_to_check_array});

} elsif ($callback_name eq 'packet_mapChange') {
} elsif ($callback_name eq 'inventory_clear') {
$self->{fulfilled_slot} = undef;
$self->{is_fulfilled_empty} = undef;
$self->{is_on_stand_by} = 1;

} elsif ($callback_name eq 'inventory_ready') {
Expand Down
7 changes: 7 additions & 0 deletions src/InventoryList/Inventory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ sub onitemListEnd {
}
}

sub clear {
my ($self) = @_;
Plugins::callHook('inventory_clear');
$self->SUPER::clear();
}


1;
Loading