From 5b53cf5d9834ce5b9f555fc7212128235e015b4b Mon Sep 17 00:00:00 2001 From: Alison Date: Mon, 16 Dec 2024 08:08:42 -0300 Subject: [PATCH] feat: add support to AP (#3902) * feat: ap support --------- Co-authored-by: ya4ept --- control/config.txt | 6 ++++++ src/Actor/You.pm | 41 ++++++++++++++++++++++++++--------------- src/Commands.pm | 10 +++++++--- src/Misc.pm | 18 ++++++++++++++++++ 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/control/config.txt b/control/config.txt index 8945eada52..05fc49daaa 100644 --- a/control/config.txt +++ b/control/config.txt @@ -529,6 +529,7 @@ attackSkillSlot { minCastTime 0 hp sp > 10 + ap homunculus homunculus_hp homunculus_sp @@ -608,6 +609,7 @@ attackComboSlot { doCommand { hp sp + ap homunculus homunculus_hp homunculus_sp @@ -657,6 +659,7 @@ useSelf_skill { minCastTime 0 hp sp + ap homunculus homunculus_hp homunculus_sp @@ -710,6 +713,7 @@ partySkill { minCastTime 0 hp sp + ap homunculus homunculus_hp homunculus_sp @@ -809,6 +813,7 @@ equipAuto { whileSitting 0 hp sp + ap homunculus homunculus_hp homunculus_sp @@ -849,6 +854,7 @@ equipAuto { useSelf_item { hp sp + ap homunculus homunculus_hp homunculus_sp diff --git a/src/Actor/You.pm b/src/Actor/You.pm index 72f36a1318..eedf44e425 100644 --- a/src/Actor/You.pm +++ b/src/Actor/You.pm @@ -88,23 +88,23 @@ sub new { sub has_homunculus { my ($self) = @_; - + if ($self && $self->{homunculus} && $self->{slaves} && scalar(keys(%{$self->{slaves}})) && $self->{homunculus}{ID} && exists $self->{slaves}{$self->{homunculus}{ID}}) { return 1; } - + return 0; } sub has_mercenary { my ($self) = @_; - + if ($self && $self->{mercenary} && $self->{slaves} && scalar(keys(%{$self->{slaves}})) && $self->{mercenary}{ID} && exists $self->{slaves}{$self->{mercenary}{ID}}) { return 1; } - + return 0; -} +} sub nameString { my ($self, $otherActor) = @_; @@ -189,6 +189,17 @@ sub sp_percent { return main::percent_sp($self); } +## +# float $char->ap_percent() +# +# Returns your AP percentage (between 0 and 100). +sub ap_percent { + my ($self) = @_; + + return main::percent_ap($self); +} + + ## # float $char->weight_percent() # @@ -199,7 +210,7 @@ sub weight_percent { if ($self->{weight_max}) { return $self->{weight} / $self->{weight_max} * 100; } - + return 0; } @@ -209,11 +220,11 @@ sub weight_percent { # Returns your base exp percentage (between 0 and 100). sub exp_base_percent { my ($self) = @_; - + if ($self->{exp_max}) { return ($self->{exp} / $self->{exp_max} * 100); } - + return 0; } @@ -223,11 +234,11 @@ sub exp_base_percent { # Returns your job exp percentage (between 0 and 100). sub exp_job_percent { my ($self) = @_; - + if ($self->{exp_job_max}) { return ($self->{exp_job} / $self->{exp_job_max} * 100); } - + return 0; } @@ -272,11 +283,11 @@ sub dequeue { shift; goto &AI::dequeue } sub attack { my ($self, $targetID) = @_; - + return unless $self->SUPER::attack($targetID); - + my $target = Actor::get($targetID); - + $startedattack = 1; Plugins::callHook('attack_start', {ID => $targetID}); @@ -296,7 +307,7 @@ sub attack { next; } - if (existsInList($config{"autoSwitch_$i"}, $monsters{$targetID}{'name'}) || + if (existsInList($config{"autoSwitch_$i"}, $monsters{$targetID}{'name'}) || existsInList($config{"autoSwitch_$i"}, $monsters{$targetID}{nameID})) { message TF("Encounter Monster : %s\n", $monsters{$targetID}{'name'}); if ($config{"autoSwitch_$i"."_rightHand"}) { @@ -431,7 +442,7 @@ sub attack { } #END OF BLOCK AUTOEQUIP } -sub sendSit { +sub sendSit { if ($config{'sitTensionRelax'} > 0 && $char->{skills}{LK_TENSIONRELAX}{lv} > 0) { my $skill = new Skill(handle => 'LK_TENSIONRELAX'); AI::ai_skillUse2($skill, $char->{skills}{LK_TENSIONRELAX}{lv}, 1, 0, $char, "LK_TENSIONRELAX"); diff --git a/src/Commands.pm b/src/Commands.pm index 59524227b3..77cb0d2bc2 100644 --- a/src/Commands.pm +++ b/src/Commands.pm @@ -5450,7 +5450,7 @@ sub cmdStats { "Sta: \@<<< #\@<< S.Matk: \@<<< Mres: \@<<<\n" . "Wis: \@<<< #\@<< H.Plus: \@<<<\n" . "Spl: \@<<< #\@<< C.Rate: \@<<<\n" . - "Con: \@<<< #\@<< T.Status Points: \@<<<\n" . + "Con: \@<<< #\@<< T.Status Points: \@<<<\n" . "Crt: \@<<< #\@<<" ), [$char->{'pow'} ? $char->{'pow'} : 0, $char->{'need_pow'}, $char->{'patk'}, $char->{'res'}, $char->{'sta'} ? $char->{'sta'} : 0, $char->{'need_sta'}, $char->{'smatk'}, $char->{'mres'}, @@ -5491,7 +5491,7 @@ sub cmdStatus { } - my ($hp_string, $sp_string, $base_string, $job_string, $weight_string, $job_name_string, $zeny_string); + my ($hp_string, $sp_string, $ap_string, $base_string, $job_string, $weight_string, $job_name_string, $zeny_string); $hp_string = $char->{'hp'}."/".$char->{'hp_max'}." (" .int($char->{'hp'}/$char->{'hp_max'} * 100) @@ -5499,6 +5499,9 @@ sub cmdStatus { $sp_string = $char->{'sp'}."/".$char->{'sp_max'}." (" .int($char->{'sp'}/$char->{'sp_max'} * 100) ."%)" if $char->{'sp_max'}; + $ap_string = $char->{'ap'}."/".$char->{'ap_max'}." (" + .int($char->{'ap'}/$char->{'ap_max'} * 100) + ."%)" if $char->{'ap_max'}; $base_string = formatNumber($char->{'exp'})."/".formatNumber($char->{'exp_max'})." /$baseEXPKill (" .sprintf("%.2f",$char->{'exp'}/$char->{'exp_max'} * 100) ."%)" @@ -5522,6 +5525,7 @@ sub cmdStatus { swrite( TF("\@<<<<<<<<<<<<<<<<<<<<<<< HP: \@>>>>>>>>>>>>>>>>>>\n" . "\@<<<<<<<<<<<<<<<<<<<<<<< SP: \@>>>>>>>>>>>>>>>>>>\n" . + " AP: \@>>>>>>>>>>>>>>>>>>\n" . "Base: \@<< \@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" . "Job : \@<< \@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" . "Zeny: \@<<<<<<<<<<<<<<<<< Weight: \@>>>>>>>>>>>>>>>>>>\n" . @@ -5530,7 +5534,7 @@ sub cmdStatus { "Total Time spent (sec): \@>>>>>>>>\n" . "Last Monster took (sec): \@>>>>>>>", (exists $char->{spirits} && $char->{spirits} != 0 ? ($char->{amuletType} ? $char->{spirits} . "\tType: " . $char->{amuletType} : $char->{spirits}) : 0)), - [$char->{'name'}, $hp_string, $job_name_string, $sp_string, + [$char->{'name'}, $hp_string, $job_name_string, $sp_string, $ap_string, $char->{'lv'}, $base_string, $char->{'lv_job'}, $job_string, $zeny_string, $weight_string, $totaldmg, $dmgpsec_string, $totalelasped_string, $elasped_string]). ('-'x56) . "\n"; diff --git a/src/Misc.pm b/src/Misc.pm index 678a32d7b8..959494418d 100644 --- a/src/Misc.pm +++ b/src/Misc.pm @@ -186,6 +186,7 @@ our @EXPORT = ( qw/lineIntersection percent_hp percent_sp + percent_ap percent_weight/, # Misc Functions @@ -4164,6 +4165,15 @@ sub percent_sp { } } +sub percent_ap { + my $r_hash = shift; + if (!$$r_hash{'ap_max'}) { + return 0; + } else { + return ($$r_hash{'ap'} / $$r_hash{'ap_max'} * 100); + } +} + sub percent_weight { my $r_hash = shift; if (!$$r_hash{'weight_max'}) { @@ -4614,6 +4624,14 @@ sub checkSelfCondition { } } + if ($config{$prefix . "_ap"}) { + if ($config{$prefix."_ap"} =~ /^(.*)\%$/) { + return 0 if (!inRange($char->ap_percent, $1)); + } else { + return 0 if (!inRange($char->{ap}, $config{$prefix."_ap"})); + } + } + if ($config{$prefix."_weight"}) { if ($config{$prefix."_weight"} =~ /^(.*)\%$/) { return 0 if $char->{weight_max} && !inRange($char->weight_percent, $1);