Skip to content

Commit

Permalink
Fix job weight map conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrybk committed Jan 10, 2025
1 parent 6917fa0 commit a35cc1e
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 36 deletions.
25 changes: 21 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,20 @@ 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 '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
25 changes: 20 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,20 @@ 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 ($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
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

0 comments on commit a35cc1e

Please sign in to comment.