diff --git a/plugins/eventMacro/eventMacro/Condition/Base/ActorNotNear.pm b/plugins/eventMacro/eventMacro/Condition/Base/ActorNotNear.pm index e0baacb394..b1ef70572c 100644 --- a/plugins/eventMacro/eventMacro/Condition/Base/ActorNotNear.pm +++ b/plugins/eventMacro/eventMacro/Condition/Base/ActorNotNear.pm @@ -70,6 +70,7 @@ sub validate_condition { } elsif ($callback_type eq 'recheck') { $self->recheck_all_actor_names; + $self->{is_on_stand_by} = 0; } return $self->SUPER::validate_condition( ( (defined $self->{not_fulfilled_actor} || $self->{is_on_stand_by} == 1) ? 0 : 1 ) ); diff --git a/plugins/eventMacro/eventMacro/Condition/CharCurrentWeight.pm b/plugins/eventMacro/eventMacro/Condition/CharCurrentWeight.pm index 7586800021..b2bd35ec6f 100644 --- a/plugins/eventMacro/eventMacro/Condition/CharCurrentWeight.pm +++ b/plugins/eventMacro/eventMacro/Condition/CharCurrentWeight.pm @@ -7,7 +7,15 @@ use base 'eventMacro::Conditiontypes::NumericConditionState'; use Globals qw( $char ); sub _hooks { - ['packet/stat_info']; + ['inventory_clear','inventory_ready','packet/stat_info']; +} + +sub _parse_syntax { + my ( $self, $condition_code ) = @_; + + $self->{is_on_stand_by} = 1; + + $self->SUPER::_parse_syntax($condition_code); } sub _get_val { @@ -21,11 +29,24 @@ sub _get_ref_val { sub validate_condition { my ( $self, $callback_type, $callback_name, $args ) = @_; - if ($callback_type eq 'hook') { - return $self->SUPER::validate_condition if $callback_name eq 'packet/stat_info' && $args && ( $args->{type} != 24 && $args->{type} != 25 ); - } elsif ($callback_type eq 'variable') { + if ($callback_name eq 'inventory_clear') { + $self->{is_on_stand_by} = 1; + } elsif ($callback_name eq 'inventory_ready') { + $self->{is_on_stand_by} = 0; + } + + if ($callback_type eq 'recheck') { + $self->{is_on_stand_by} = 0; + } + + if ($callback_type eq 'variable') { $self->update_validator_var($callback_name, $args); } + + if ($self->{is_on_stand_by} == 1) { + return $self->SUPER::validate_condition(0); + } + return $self->SUPER::validate_condition( $self->validator_check ); } diff --git a/plugins/eventMacro/eventMacro/Condition/CharMaxWeight.pm b/plugins/eventMacro/eventMacro/Condition/CharMaxWeight.pm index 8a52b44ba3..5140f22bb9 100644 --- a/plugins/eventMacro/eventMacro/Condition/CharMaxWeight.pm +++ b/plugins/eventMacro/eventMacro/Condition/CharMaxWeight.pm @@ -7,7 +7,15 @@ use base 'eventMacro::Conditiontypes::NumericConditionState'; use Globals qw( $char ); sub _hooks { - ['packet/stat_info']; + ['inventory_clear','inventory_ready','packet/stat_info']; +} + +sub _parse_syntax { + my ( $self, $condition_code ) = @_; + + $self->{is_on_stand_by} = 1; + + $self->SUPER::_parse_syntax($condition_code); } sub _get_val { @@ -17,13 +25,24 @@ sub _get_val { sub validate_condition { my ( $self, $callback_type, $callback_name, $args ) = @_; - my $result = 0; + if ($callback_name eq 'inventory_clear') { + $self->{is_on_stand_by} = 1; + } elsif ($callback_name eq 'inventory_ready') { + $self->{is_on_stand_by} = 0; + } - if ($callback_type eq 'hook') { - return $self->SUPER::validate_condition if $callback_name eq 'packet/stat_info' && $args && $args->{type} != 25; - } elsif ($callback_type eq 'variable') { + if ($callback_type eq 'variable') { $self->update_validator_var($callback_name, $args); } + + if ($callback_type eq 'recheck') { + $self->{is_on_stand_by} = 0; + } + + if ($self->{is_on_stand_by} == 1) { + return $self->SUPER::validate_condition(0); + } + return $self->SUPER::validate_condition( $self->validator_check ); } diff --git a/plugins/eventMacro/eventMacro/Condition/InCity.pm b/plugins/eventMacro/eventMacro/Condition/InCity.pm index e8ed4bd6b5..497a4320d1 100644 --- a/plugins/eventMacro/eventMacro/Condition/InCity.pm +++ b/plugins/eventMacro/eventMacro/Condition/InCity.pm @@ -10,9 +10,10 @@ use base 'eventMacro::Condition'; use Globals qw( $field ); sub _hooks { - ['packet_mapChange']; + ['Network::Receive::map_changed','in_game','packet_mapChange']; } + sub _parse_syntax { my ( $self, $condition_code ) = @_; @@ -30,6 +31,10 @@ sub _parse_syntax { sub validate_condition { my ( $self, $callback_type, $callback_name, $args ) = @_; + + unless ( defined $field ) { + $self->SUPER::validate_condition( 0 ); + } $self->{lastMap} = $field->baseName; diff --git a/plugins/eventMacro/eventMacro/Condition/InMap.pm b/plugins/eventMacro/eventMacro/Condition/InMap.pm index 0d1e233d13..3d736f4b9f 100644 --- a/plugins/eventMacro/eventMacro/Condition/InMap.pm +++ b/plugins/eventMacro/eventMacro/Condition/InMap.pm @@ -7,7 +7,7 @@ use base 'eventMacro::Conditiontypes::ListConditionState'; use Globals qw( $field ); sub _hooks { - ['packet_mapChange']; + ['Network::Receive::map_changed','in_game','packet_mapChange']; } sub validate_condition { @@ -17,6 +17,10 @@ sub validate_condition { $self->update_validator_var($callback_name, $args); } + unless ( defined $field ) { + $self->SUPER::validate_condition( 0 ); + } + $self->{lastMap} = $field->baseName; return $self->SUPER::validate_condition( $self->validator_check($self->{lastMap}) ); diff --git a/plugins/eventMacro/eventMacro/Condition/InMapRegex.pm b/plugins/eventMacro/eventMacro/Condition/InMapRegex.pm index ab08b8b077..00983fe878 100644 --- a/plugins/eventMacro/eventMacro/Condition/InMapRegex.pm +++ b/plugins/eventMacro/eventMacro/Condition/InMapRegex.pm @@ -7,7 +7,7 @@ use base 'eventMacro::Conditiontypes::RegexConditionState'; use Globals qw( $field ); sub _hooks { - ['packet_mapChange']; + ['Network::Receive::map_changed','in_game','packet_mapChange']; } sub validate_condition { @@ -17,6 +17,10 @@ sub validate_condition { $self->update_validator_var($callback_name, $args); } + unless ( defined $field ) { + $self->SUPER::validate_condition( 0 ); + } + $self->{lastMap} = $field->baseName; return $self->SUPER::validate_condition( $self->validator_check($self->{lastMap}) ); diff --git a/plugins/eventMacro/eventMacro/Condition/InSaveMap.pm b/plugins/eventMacro/eventMacro/Condition/InSaveMap.pm index 5dbef7f0f8..835180ae8d 100644 --- a/plugins/eventMacro/eventMacro/Condition/InSaveMap.pm +++ b/plugins/eventMacro/eventMacro/Condition/InSaveMap.pm @@ -10,7 +10,7 @@ use base 'eventMacro::Condition'; use Globals qw( $field %config ); sub _hooks { - ['packet_mapChange','configModify','pos_load_config.txt','in_game']; + ['Network::Receive::map_changed','in_game','packet_mapChange','configModify','pos_load_config.txt']; } sub _parse_syntax { @@ -31,24 +31,15 @@ sub _parse_syntax { sub validate_condition { my ( $self, $callback_type, $callback_name, $args ) = @_; - - if ($callback_type eq 'hook') { - - if ($callback_name eq 'configModify' && $args->{key} eq 'saveMap') { - $self->{lastSaveMap} = $args->{val} || ''; - - } elsif ($callback_name eq 'pos_load_config.txt' || $callback_name eq 'in_game') { - $self->{lastSaveMap} = $config{'saveMap'} || ''; - - } elsif ($callback_name eq 'packet_mapChange') { - $self->{lastMap} = $field ? $field->baseName : ''; - } - } elsif ($callback_type eq 'recheck') { + if ($callback_type eq 'hook' && $callback_name eq 'configModify' && $args->{key} eq 'saveMap') { + $self->{lastSaveMap} = $args->{val} || ''; + } else { $self->{lastSaveMap} = $config{'saveMap'} || ''; - $self->{lastMap} = $field ? $field->baseName : ''; } - + + $self->{lastMap} = $field ? $field->baseName : ''; + if ( $self->{lastSaveMap} eq '' || $self->{lastMap} eq '' ) { $self->SUPER::validate_condition( 0 ); } else { diff --git a/plugins/eventMacro/eventMacro/Condition/IsInMapAndCoordinate.pm b/plugins/eventMacro/eventMacro/Condition/IsInMapAndCoordinate.pm index a8f92e8dd1..f45bc8c765 100644 --- a/plugins/eventMacro/eventMacro/Condition/IsInMapAndCoordinate.pm +++ b/plugins/eventMacro/eventMacro/Condition/IsInMapAndCoordinate.pm @@ -191,9 +191,10 @@ sub validate_condition { } } elsif ($callback_type eq 'recheck') { + $self->{is_on_stand_by} = 0; $self->check_location; - } + return $self->SUPER::validate_condition( (defined $self->{fulfilled_coordinate} ? 1 : 0) ); } diff --git a/plugins/eventMacro/eventMacro/Condition/JobID.pm b/plugins/eventMacro/eventMacro/Condition/JobID.pm index 34d5af91f0..0ccc799824 100644 --- a/plugins/eventMacro/eventMacro/Condition/JobID.pm +++ b/plugins/eventMacro/eventMacro/Condition/JobID.pm @@ -8,7 +8,7 @@ use Globals qw( $char ); use eventMacro::Utilities qw( find_variable ); sub _hooks { - ['in_game','packet/player_equipment']; + ['Network::Receive::map_changed','in_game','sprite_job_change']; } sub _parse_syntax { @@ -63,9 +63,7 @@ sub update_vars { sub validate_condition { my ( $self, $callback_type, $callback_name, $args ) = @_; - if ($callback_type eq 'hook') { - return $self->SUPER::validate_condition if ($callback_name eq 'packet/player_equipment' && (!$args || !exists $args->{type} || $args->{type} != 0)); - } elsif ($callback_type eq 'variable') { + if ($callback_type eq 'variable') { $self->update_vars($callback_name, $args); } diff --git a/plugins/eventMacro/eventMacro/Condition/JobIDNot.pm b/plugins/eventMacro/eventMacro/Condition/JobIDNot.pm index 5e857c6348..6e5948ae79 100644 --- a/plugins/eventMacro/eventMacro/Condition/JobIDNot.pm +++ b/plugins/eventMacro/eventMacro/Condition/JobIDNot.pm @@ -8,7 +8,7 @@ use Globals qw( $char ); use eventMacro::Utilities qw( find_variable ); sub _hooks { - ['in_game','packet/player_equipment']; + ['Network::Receive::map_changed','in_game','sprite_job_change']; } sub _parse_syntax { @@ -45,9 +45,7 @@ sub update_vars { sub validate_condition { my ( $self, $callback_type, $callback_name, $args ) = @_; - if ($callback_type eq 'hook') { - return $self->SUPER::validate_condition if ($callback_name eq 'packet/player_equipment' && (!$args || !exists $args->{type} || $args->{type} != 0)); - } elsif ($callback_type eq 'variable') { + if ($callback_type eq 'variable') { $self->update_vars($callback_name, $args); } diff --git a/plugins/eventMacro/eventMacro/Condition/NotInMap.pm b/plugins/eventMacro/eventMacro/Condition/NotInMap.pm index 302b7fdcb8..26a602e7e6 100644 --- a/plugins/eventMacro/eventMacro/Condition/NotInMap.pm +++ b/plugins/eventMacro/eventMacro/Condition/NotInMap.pm @@ -22,6 +22,10 @@ sub validate_condition { $self->update_validator_var($callback_name, $args); } + unless ( defined $field ) { + $self->SUPER::validate_condition( 0 ); + } + $self->{lastMap} = $field->baseName; return $self->eventMacro::Condition::validate_condition( $self->validator_check_opposite($self->{lastMap}) ); diff --git a/src/Network/Receive.pm b/src/Network/Receive.pm index e9b754074c..761520f794 100644 --- a/src/Network/Receive.pm +++ b/src/Network/Receive.pm @@ -4561,6 +4561,7 @@ sub sprite_change { } else { error TF("%s changed unknown sprite type (%d), write about it to OpenKore developer\n", $player, $type), "parseMsg_statuslook"; } + Plugins::callHook('sprite_job_change'); } sub progress_bar {