Skip to content
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
108 changes: 108 additions & 0 deletions src/Commands.pm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ sub initHandlers {
southeast => \&cmdManualMove,
southwest => \&cmdManualMove,
captcha => \&cmdAnswerCaptcha,
refineui => \&cmdRefineUI,

# Skill Exchange Item
cm => \&cmdExchangeItem,
Expand Down Expand Up @@ -6747,4 +6748,111 @@ sub cmdExchangeItem {
"Combination: %s <item #> <amount>,<item #> <amount>,<item #> <amount>\n", $switch, $switch, $switch);
}

##
# refineui select [item_index]
# refineui refine [item_index] [material_id] [catalyst_toggle]
# @author [Cydh]
##
sub cmdRefineUI {
if (!$net || $net->getState() != Network::IN_GAME) {
error TF("You must be logged in the game to use this command '%s'\n", shift);
return;
}
my ($cmd, $args_string) = @_;
if (!defined $refineUI) {
error T("Cannot use RefineUI yet.\n");
return;
}
my @args = parseArgs($args_string, 4);

# refineui close
# End Refine UI state
if ($args[0] eq "cancel" || $args[0] eq "end" || $args[0] eq "no") {
message T("Closing Refine UI.\n"), "info";
undef $refineUI;
$messageSender->sendRefineUIClose();
return;

# refineui select [item_index]
# Do refine
} elsif ($args[0] eq "select") {
#my ($invIndex) = $args =~ /^(\d+)/;
my $invIndex = $args[1];

# Check item
my $item = $char->inventory->get($invIndex);
if (!defined $item) {
warning TF("Item in index '%d' is not exists.\n", $invIndex);
return;
} elsif ($item->{equipped} != 0) {
warning TF("Cannot select equipped %s (%d) item!\n", $item->{name}, $invIndex);
return;
}
$refineUI->{invIndex} = $invIndex;
message TF("Request info for selected item to refine: %s (%d)\n", $item->{name}, $invIndex);
$messageSender->sendRefineUISelect( $item->{ID});
return;

# refineui refine [item_index] [material_id] [catalyst_toggle]
# Do refine
} elsif ($args[0] eq "refine") {
#my ($invIndex, $matInvIndex, $catalyst) = $args =~ /^(\d+) (\d+) (\d+|yes|no)/;
my $invIndex = $args[1];
my $matNameID = $args[2];
my $catalyst = $args[3];

# Check item
my $item = $char->inventory->get($invIndex);
if (!defined $item) {
warning TF("Item in index '%d' is not exists.\n", $invIndex);
return;
} elsif ($item->{equipped} != 0) {
warning TF("Cannot select equipped %s (%d) item!\n", $item->{name}, $invIndex);
return;
}

# Check material
my $material = $char->inventory->getByNameID($matNameID);
if (!defined $material) {
warning TF("You don't have enough '%s' (%d) as refine material.\n", itemNameSimple($matNameID), $matNameID);
return;
}
# Check if the selected item is valid material
my $valid = 0;
foreach my $mat (@{$refineUI->{materials}}) {
if ($mat->{nameid} == $matNameID) {
$valid = 1;
}
}
if ($valid != 1) {
warning TF("'%s' (%d) is not valid refine material for '%s'.\n", itemNameSimple($matNameID), $matNameID, $item->{name});
return;
}

# Check catalyst toggle
my $useCatalyst = 0;
#my $Blacksmith_Blessing = 6635; # 6635,Blacksmith_Blessing,Blacksmith Blessing
my $blessName = itemNameSimple($Blacksmith_Blessing);
if ($refineUI->{bless} > 0 && ($catalyst == 1 || $catalyst eq "yes")) {
my $catalystItem = $char->inventory->getByNameID($Blacksmith_Blessing);
if (!$catalystItem || $catalystItem->{amount} < $refineUI->{bless}) {
warning TF("You don't have %s for RefineUI. Needed: %d!\n", $blessName, $refineUI->{bless});
return;
}
$useCatalyst = 1;
}

my $matStr = $material->{name};
if ($useCatalyst) {
$matStr .= " and ".$refineUI->{bless}."x ".$blessName;
}
message TF("Refining item: %s with material %s.\n", $item->{name}, $matStr);
$messageSender->sendRefineUIRefine($item->{ID}, $matNameID, $useCatalyst);
return;
} else {
error T("Invalid usage!\n");
return;
}
}

1;
7 changes: 4 additions & 3 deletions src/Globals.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use Modules 'register';
# Do not use any other Kore modules here. It will create circular dependancies.

our %EXPORT_TAGS = (
config => [qw(%arrowcraft_items %avoid @chatResponses %cities_lut %config %consoleColors %directions_lut %equipTypes_lut %equipSlot_rlut %equipSlot_lut %haircolors @headgears_lut @msgTable %items_control %items_lut %itemSlotCount_lut %itemsDesc_lut %itemTypes_lut %jobs_lut %maps_lut %masterServers %monsters_lut %npcs_lut %packetDescriptions %portals_lut @portals_lut_missed %responses %sex_lut %shop %skillsDesc_lut %lookHandle %skillsArea %skillsEncore %spells_lut %emotions_lut %timeout $char %mon_control %priority %routeWeights %pickupitems %rpackets %itemSlots_lut %statusHandle %statusName %effectName %hatEffectHandle %hatEffectName %portals_los %stateHandle %ailmentHandle %mapTypeHandle %mapPropertyTypeHandle %mapPropertyInfoHandle %elements_lut %mapAlias_lut %quests_lut)],
config => [qw(%arrowcraft_items %avoid @chatResponses %cities_lut %config %consoleColors %directions_lut %equipTypes_lut %equipSlot_rlut %equipSlot_lut %haircolors @headgears_lut @msgTable %items_control %items_lut %itemSlotCount_lut %itemsDesc_lut %itemTypes_lut %jobs_lut %maps_lut %masterServers %monsters_lut %npcs_lut %packetDescriptions %portals_lut @portals_lut_missed %responses %sex_lut %shop %skillsDesc_lut %lookHandle %skillsArea %skillsEncore %spells_lut %emotions_lut %timeout $char %mon_control %priority %routeWeights %pickupitems %rpackets %itemSlots_lut %statusHandle %statusName %effectName %hatEffectHandle %hatEffectName %portals_los %stateHandle %ailmentHandle %mapTypeHandle %mapPropertyTypeHandle %mapPropertyInfoHandle %elements_lut %mapAlias_lut %quests_lut $Blacksmith_Blessing)],
ai => [qw(@ai_seq @ai_seq_args %ai_v %targetTimeout)],
state => [qw($accountID $cardMergeIndex @cardMergeItemsID $charID @chars @chars_old @friendsID %friends %incomingFriend $field %homunculus $itemsList @itemsID %items $monstersList @monstersID %monsters @npcsID %npcs $npcsList @playersID %players @portalsID @portalsID_old %portals %portals_old $portalsList $storeList $currentChatRoom @currentChatRoomUsers @chatRoomsID %createdChatRoom %chatRooms @skillsID $storageTitle @arrowCraftID %guild %incomingGuild @spellsID %spells @unknownPlayers @unknownNPCs $useArrowCraft %currentDeal %incomingDeal %outgoingDeal @identifyID @partyUsersID %incomingParty @petsID %pets $venderItemList $venderID $venderCID @venderListsID @buyerItemList @selfBuyerItemList $buyerID $buyingStoreID @buyerListsID @articles $articles %venderLists %buyerLists %monsters_old @monstersID_old %npcs_old %items_old %players_old @playersID_old @servers $sessionID $sessionID2 $accountSex $accountSex2 $map_ip $map_port $KoreStartTime $secureLoginKey $initSync $lastConfChangeTime $petsList $playersList $portalsList @playerNameCacheIDs %playerNameCache %pet $pvp @cashList $slavesList @slavesID %slaves %cashShop $skillExchangeItem)],
state => [qw($accountID $cardMergeIndex @cardMergeItemsID $charID @chars @chars_old @friendsID %friends %incomingFriend $field %homunculus $itemsList @itemsID %items $monstersList @monstersID %monsters @npcsID %npcs $npcsList @playersID %players @portalsID @portalsID_old %portals %portals_old $portalsList $storeList $currentChatRoom @currentChatRoomUsers @chatRoomsID %createdChatRoom %chatRooms @skillsID $storageTitle @arrowCraftID %guild %incomingGuild @spellsID %spells @unknownPlayers @unknownNPCs $useArrowCraft %currentDeal %incomingDeal %outgoingDeal @identifyID @partyUsersID %incomingParty @petsID %pets $venderItemList $venderID $venderCID @venderListsID @buyerItemList @selfBuyerItemList $buyerID $buyingStoreID @buyerListsID @articles $articles %venderLists %buyerLists %monsters_old @monstersID_old %npcs_old %items_old %players_old @playersID_old @servers $sessionID $sessionID2 $accountSex $accountSex2 $map_ip $map_port $KoreStartTime $secureLoginKey $initSync $lastConfChangeTime $petsList $playersList $portalsList @playerNameCacheIDs %playerNameCache %pet $pvp @cashList $slavesList @slavesID %slaves %cashShop $skillExchangeItem $refineUI)],
network => [qw($remote_socket $net $messageSender $charServer $conState $conState_tries $encryptVal $ipc $bus $masterServer $lastSwitch $packetParser $clientPacketHandler $bytesSent $incomingMessages $outgoingClientMessages $enc_val1 $enc_val2 $captcha_state)],
interface => [qw($interface)],
misc => [qw($quit $reconnectCount @lastpm %lastpm @privMsgUsers %timeout_ex $shopstarted $dmgpsec $totalelasped $elasped $totaldmg %overallAuth %responseVars %talk $startTime_EXP $startingzeny @monsters_Killed $bExpSwitch $jExpSwitch $totalBaseExp $totalJobExp $shopEarned %itemChange $XKore_dontRedirect $monkilltime $monstarttime $startedattack $firstLoginMap $sentWelcomeMessage $versionSearch $monsterBaseExp $monsterJobExp %descriptions %flags %damageTaken $logAppend @sellList $userSeed $taskManager $repairList $mailList $rodexList $rodexWrite $auctionList $questList $achievementList $hotkeyList $devotionList $cookingList %charSvrSet @deadTime)],
Expand Down Expand Up @@ -471,6 +471,7 @@ our %playerNameCache;
our %pet;
our @cashList;
our $skillExchangeItem;
our $refineUI;

# Network
our $remote_socket; # Unused, but required for outdated plugins
Expand Down Expand Up @@ -560,7 +561,7 @@ our $cookingList;
our %charSvrSet;
our $questList;
our $achievementList;

our $Blacksmith_Blessing = 6635;
our $captcha_state = 0;

our %quests_lut;
Expand Down
56 changes: 56 additions & 0 deletions src/Network/Receive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4165,4 +4165,60 @@ sub skill_exchange_item {
$skillExchangeItem = $args->{type} + 1;
}

# Allowed to RefineUI by server
# '0AA0' => ['refineui_opened', '' ,[qw()]],
# @author [Cydh]
sub refineui_opened {
my ($self, $args) = @_;
message TF("RefineUI is opened. Type 'i' to check equipment and its index. To continue: refineui select [ItemIdx]\n"), "info";
$refineUI->{open} = 1;
}

# Received refine info for selected item
# '0AA2' => ['refineui_info', 'v v C a*' ,[qw(index bless materials)]],
# @param args Packet data
# @author [Cydh]
sub refineui_info {
my ($self, $args) = @_;

if ($args->{len} > 7) {
$refineUI->{itemIndex} = $args->{index};
$refineUI->{bless} = $args->{bless};

my $item = $char->inventory->[$refineUI->{invIndex}];
my $bless = $char->inventory->getByNameID($Blacksmith_Blessing);

message T("========= RefineUI Info =========\n"), "info";
message TF("Target Equip:\n".
"- Index: %d\n".
"- Name: %s\n",
$refineUI->{invIndex}, $item ? itemName($item) : "Unknown."),
"info";

message TF("%s:\n".
"- Needed: %d\n".
"- Owned: %d\n",
#itemNameSimple($Blacksmith_Blessing)
"Blacksmith Blessing", $refineUI->{bless}, $bless ? $bless->{amount} : 0),
"info";

@{$refineUI->{materials}} = map { my %r; @r{qw(nameid chance zeny)} = unpack 'v C V', $_; \%r} unpack '(a7)*', $args->{materials};

my $msg = center(T(" Possible Materials "), 53, '-') ."\n" .
T("Mat_ID % Zeny Material \n");
foreach my $mat (@{$refineUI->{materials}}) {
my $myMat = $char->inventory->getByNameID($mat->{nameid});
my $myMatCount = sprintf("%d ea %s", $myMat ? $myMat->{amount} : 0, itemNameSimple($mat->{nameid}));
$msg .= swrite(
"@>>>>>>>> @>>>>> @>>>>>>>>>>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
[$mat->{nameid}, $mat->{chance}, $mat->{zeny}, $myMatCount]);
}
$msg .= ('-'x53) . "\n";
message $msg, "info";
message TF("Continue: refineui refine %d [Mat_ID] [catalyst_toggle] to continue.\n", $refineUI->{invIndex}), "info";
} else {
error T("Equip cannot be refined, try different equipment. Type 'i' to check equipment and its index.\n");
}
}

1;
2 changes: 2 additions & 0 deletions src/Network/Receive/ServerType0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ sub new {
'09E7' => ['unread_rodex', 'C', [qw(show)]], # 3
'0A05' => ['rodex_add_item', 'C a2 v2 C4 a8 a25 v a5', [qw(fail ID amount nameID type identified broken upgrade cards options weight unknow)]], # 53
'0A7D' => ['rodex_mail_list', 'v C3', [qw(len type amount isEnd)]], # -1
'0AA0' => ['refineui_opened', '' ,[qw()]],
'0AA2' => ['refineui_info', 'v v C a*' ,[qw(len index bless materials)]],
};

# Item RECORD Struct's
Expand Down
14 changes: 14 additions & 0 deletions src/Network/Receive/kRO/RagexeRE_2016_12_07e.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ package Network::Receive::kRO::RagexeRE_2016_12_07e;
use strict;
use base qw(Network::Receive::kRO::RagexeRE_2016_07_06c);

sub new {
my ($class) = @_;
my $self = $class->SUPER::new(@_);

my %packets = (
'0AA0' => ['refineui_opened', '' ,[qw()]],
'0AA2' => ['refineui_info', 'v v C a*' ,[qw(len index bless materials)]],
);

foreach my $switch (keys %packets) { $self->{packet_list}{$switch} = $packets{$switch}; }

return $self;
}


1;
=pod
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Receive/kRO/Sakexe_0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ sub new {
'09E7' => ['unread_rodex', 'C', [qw(show)]], # 3
'0A05' => ['rodex_add_item', 'C a2 v2 C4 a8 a25 v a5', [qw(fail ID amount nameID type identified broken upgrade cards options weight unknow)]], # 53
'0A7D' => ['rodex_mail_list', 'v C3', [qw(len type amount isEnd)]], # -1
'0AA0' => ['refineui_opened', '' ,[qw()]],
'0AA2' => ['refineui_info', 'v v C a*' ,[qw(len index bless materials)]],
};

# Item RECORD Struct's
Expand Down
41 changes: 40 additions & 1 deletion src/Network/Send.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use Carp::Assert;
use Digest::MD5;
use Math::BigInt;

use Globals qw(%config $encryptVal $bytesSent $conState %packetDescriptions $enc_val1 $enc_val2 $char $masterServer $syncSync $accountID %timeout %talk %masterServers $skillExchangeItem);
use Globals qw(%config $encryptVal $bytesSent $conState %packetDescriptions $enc_val1 $enc_val2 $char $masterServer $syncSync $accountID %timeout %talk %masterServers $skillExchangeItem $refineUI);
use I18N qw(bytesToString stringToBytes);
use Utils qw(existsInList getHex getTickCount getCoordString makeCoordsDir);
use Misc;
Expand Down Expand Up @@ -1195,4 +1195,43 @@ sub reconstruct_item_list_window_selected {
$args->{itemInfo} = pack '(a4)*', map { pack 'v2', @{$_}{qw(itemIndex amount)} } @{$args->{items}};
}

# Select equip for refining
# '0AA1' => ['refineui_select', 'a2' ,[qw(index)]],
# @param itemIndex OpenKore's Inventory Item Index
# @author [Cydh]
sub sendRefineUISelect {
my ($self, $itemIndex) = @_;
$self->sendToServer($self->reconstruct({
switch => 'refineui_select',
index => $itemIndex,
}));
debug "Checking item for RefineUI\n", "sendPacket";
}

# Continue to refine equip
# '0AA3' => ['refineui_refine', 'a2 v C' ,[qw(index catalyst bless)]],
# @param itemIndex OpenKore's Inventory Item Index
# @param materialNameIDMaterial's NameID
# @param useCatalyst Catalyst (Blacksmith Blessing) toggle. 0 = Not using, 1 = Use catalyst
# @author [Cydh]
sub sendRefineUIRefine {
my ($self, $itemIndex, $materialNameID, $useCatalyst) = @_;
$self->sendToServer($self->reconstruct({
switch => 'refineui_refine',
index => $itemIndex,
catalyst => $materialNameID,
bless => $useCatalyst,
}));
debug "Refining using RefineUI\n", "sendPacket";
}

# Cancel RefineUI usage
# '0AA4' => ['refineui_close', '' ,[qw()]],
# @author [Cydh]
sub sendRefineUIClose {
my $self = shift;
$self->sendToServer($self->reconstruct({switch => 'refineui_close'}));
debug "Closing RefineUI\n", "sendPacket";
}

1;
3 changes: 3 additions & 0 deletions src/Network/Send/ServerType0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ sub new {
'0A08' => ['rodex_open_write_mail', 'Z24', [qw(name)]], # 26 -- RodexOpenWriteMail
'0A13' => ['rodex_checkname', 'Z24', [qw(name)]], # 26 -- RodexCheckName
'0A6E' => ['rodex_send_mail', 'v Z24 Z24 V2 v v V a* a*', [qw(len receiver sender zeny1 zeny2 title_len body_len char_id title body)]], # -1 -- RodexSendMail
'0AA1' => ['refineui_select', 'a2' ,[qw(index)]],
'0AA3' => ['refineui_refine', 'a2 v C' ,[qw(index catalyst bless)]],
'0AA4' => ['refineui_close', '' ,[qw()]],
);
$self->{packet_list}{$_} = $packets{$_} for keys %packets;

Expand Down
5 changes: 4 additions & 1 deletion src/Network/Send/kRO/RagexeRE_2016_12_07e.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ sub new {
'0875' => ['storage_item_add', 'a2 V', [qw(ID amount)]],
'091D' => ['storage_item_remove', 'a2 V', [qw(ID amount)]],
'095D' => ['storage_password'],
'035F' => ['sync', 'V', [qw(time)]],
'035F' => ['sync', 'V', [qw(time)]],
'0AA1' => ['refineui_select', 'a2' ,[qw(index)]],
'0AA3' => ['refineui_refine', 'a2 v C' ,[qw(index catalyst bless)]],
'0AA4' => ['refineui_close', '' ,[qw()]],
);

$self->{packet_list}{$_} = $packets{$_} for keys %packets;
Expand Down
3 changes: 3 additions & 0 deletions src/Network/Send/kRO/Sakexe_0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ sub new {
'0848' => ['cash_shop_buy_items', 's s V V s', [qw(len count item_id item_amount tab_code)]], #item_id, item_amount and tab_code could be repeated in order to buy multiple itens at once
'084A' => ['cash_shop_close'],#2
'08B8' => ['send_pin_password','a4 Z*', [qw(accountID pin)]],
'0AA1' => ['refineui_select', 'a2' ,[qw(index)]],
'0AA3' => ['refineui_refine', 'a2 v C' ,[qw(index catalyst bless)]],
'0AA4' => ['refineui_close', '' ,[qw()]],
);
$self->{packet_list}{$_} = $packets{$_} for keys %packets;

Expand Down
1 change: 1 addition & 0 deletions src/functions.pl
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ sub initMapChangeVars {
undef $rodexList;
undef $rodexWrite;
undef $skillExchangeItem;
undef $refineUI;
$captcha_state = 0;

$itemsList->clear();
Expand Down