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 job, weight and map conditions of eventMacro #3942

Merged
merged 2 commits into from
Jan 11, 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
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
29 changes: 25 additions & 4 deletions plugins/eventMacro/eventMacro/Condition/CharCurrentWeight.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 );
}

Expand Down
29 changes: 24 additions & 5 deletions plugins/eventMacro/eventMacro/Condition/CharMaxWeight.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 );
}

Expand Down
7 changes: 6 additions & 1 deletion plugins/eventMacro/eventMacro/Condition/InCity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) = @_;

Expand All @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion plugins/eventMacro/eventMacro/Condition/InMap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}) );
Expand Down
6 changes: 5 additions & 1 deletion plugins/eventMacro/eventMacro/Condition/InMapRegex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}) );
Expand Down
23 changes: 7 additions & 16 deletions plugins/eventMacro/eventMacro/Condition/InSaveMap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
}

Expand Down
6 changes: 2 additions & 4 deletions plugins/eventMacro/eventMacro/Condition/JobID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 2 additions & 4 deletions plugins/eventMacro/eventMacro/Condition/JobIDNot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions plugins/eventMacro/eventMacro/Condition/NotInMap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}) );
Expand Down
1 change: 1 addition & 0 deletions src/Network/Receive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading