Skip to content
Open
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
65 changes: 33 additions & 32 deletions weaponRefine.pl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ package weaponRefine;

# i'll put regex here so it's easier to update
#our $weaponMatch = qr/\+?(\d+)?\s*([A-Za-z\s\-\']+(?:\[\d*\])?)/;
our $weaponMatch = qr/\+?(\d+)?\s*([A-Za-z\s\-\']+(?:\[[A-za-z]*\d*\])?)/;
our $weaponMatch = qr/\+?(\d+)?\s*([A-Za-z\s\-\']+(?:\[[A-Za-z]*\d*\])?)/;

sub onUnload {
Plugins::delHooks($hooks);
Expand Down Expand Up @@ -130,7 +130,7 @@ sub setWeapon {
$refineAmount = undef;

if (!$arg) {
if ($weapon && $weaponlist && ($weaponInInventory ne FALSE)) {
if ($weapon && $weaponlist && ($weaponInInventory != FALSE)) {
message "\tThe current weapon(s) available for refinement: ", "system";
message "$weapon\n", "success";
debug "$weaponSetStatus\n";
Expand All @@ -140,7 +140,7 @@ sub setWeapon {
}
} else {
findAndSetWeapon($arg);
if (($weaponInInventory eq TRUE) && ($arg eq $weapon)) {
if (($weaponInInventory == TRUE) && ($arg eq $weapon)) {
message "Available weapons to be refined:\n\tItemID\tWeapon\n", "system";
message $weaponlist, "success";
$weaponSetStatus = TRUE;
Expand All @@ -149,35 +149,36 @@ sub setWeapon {
debug "Fail2\n";
debug "$weapon\n";
message "\tWeapon not found\n", "drop";
undef $weaponInInventory;
}
}
}
$weaponInInventory = FALSE;
}
}

}

sub findAndSetWeapon {
# TODO/FIXME:
# - yeah might change this but it works for now.
my ($arg) = @_;
undef $weaponlist;
foreach my $equip (@{$char->inventory->getItems}) {
if ($equip->name =~ $weaponMatch) {
if ($2 eq $arg) {
$weaponlist .= "\t[$equip->{binID}]\t$equip\n";
$weapon = $arg;
$weaponInInventory = TRUE if !$weaponInInventory;
$weaponSetStatus = TRUE if !$weaponSetStatus;
}
} else {
$weaponInInventory = FALSE if !$weaponInInventory;
$weaponSetStatus = FALSE;
last;
}
}
}

sub setRefineAmount {
our ($refineAmount) = @_[1];
$weaponInInventory = FALSE;
$weaponSetStatus = FALSE;

foreach my $equip (@{$char->inventory->getItems}) {
if ($equip->name =~ $weaponMatch) {
if ($2 eq $arg) {
$weaponlist .= "\t[$equip->{binID}]\t$equip\n";
$weapon = $arg;
$weaponInInventory = TRUE if !$weaponInInventory;
$weaponSetStatus = TRUE if !$weaponSetStatus;
}
}
}
}

sub setRefineAmount {
my ($arg) = @_[1];

$refineAmount = $arg;

if ($refineAmount =~ /^\d+$/ && $refineAmount >= 1 && $refineAmount <= 10) {
message "Refine Limit set to: +$refineAmount.\n", "success";
Expand All @@ -186,8 +187,8 @@ sub setRefineAmount {
}
}

sub startRefine {
if (($weaponSetStatus eq TRUE) && ($refineAmount)) {
sub startRefine {
if (($weaponSetStatus == TRUE) && ($refineAmount)) {
message "Weapon Refining start!\n", "success";
$refiningStatus = TRUE;
$actionState = REFINESTART;
Expand All @@ -206,7 +207,7 @@ sub itemRemoved {
$actionState = REFINESTART;
}

sub refineList {
sub refineList {
my ($self, $args) = @_;
my $refine_list = $args->{upgrade_list};
my @upgradeList = @$refine_list;
Expand All @@ -215,7 +216,7 @@ sub refineList {
$common_time = time;
foreach my $weaponData (@upgradeList) {
my ($refineID, $itemName, $itemID) = @$weaponData;
if (($itemName =~ $weaponMatch) && ($actionState eq REFINESELECT) && ($refiningStatus eq TRUE)) {
if (($itemName =~ $weaponMatch) && ($actionState == REFINESELECT) && ($refiningStatus == TRUE)) {
debug "$itemName\n";
if (($1 < $refineAmount) && ($2 eq $weapon)) {
debug "weapon $weapon is refined to $1\n";
Expand All @@ -226,8 +227,8 @@ sub refineList {
}
}

sub refineMain {
while ((timeOut($common_time, REFINE_DELAY)) && ($refiningStatus eq TRUE) && ($actionState eq REFINESTART)) {
sub refineMain {
while ((timeOut($common_time, REFINE_DELAY)) && ($refiningStatus == TRUE) && ($actionState == REFINESTART)) {
$common_time = time;
message "Refining ", 'system';
message "$weapon ", 'success';
Expand Down