Crafting

janpastuch
Posts: 6
Joined: Wed Mar 08, 2017 1:36 pm
Has thanked: 1 time

Crafting

Post by janpastuch » Fri Mar 24, 2017 3:02 pm

Hello, im kinda new to bot. Wanted to use AS to lvlup crafting (alchemy), is there any way to do it?

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Crafting

Post by nucular » Fri Mar 24, 2017 3:23 pm

Yes there was an way. ;-)
Wait for the weekend, i'll try to add it here.

sapibuntinx
VIP
Posts: 25
Joined: Fri Jan 20, 2017 1:58 pm
Has thanked: 8 times
Been thanked: 14 times

Re: Crafting

Post by sapibuntinx » Mon Mar 27, 2017 5:18 pm

crafting script from the good old days. however need to fix current AS offset related with getting HTML ID on the dialog. haven't got the time to fix it now.

Code: Select all

--[[

	--------------------------------------------------
	Copyright (C) 2011 TheyRot

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
	--------------------------------------------------
	
	--------------------------------------------------
	Material List : http://www.mmoelites.com/topic/233-information-craft-material-1-399/
	--------------------------------------------------

--]]

--- OnLoad is called when the script initially loads.
--
-- @return	void
function OnLoad()

	Write( "Make sure you have sufficient items in your inventory" )
	Write( "Your starting position should be in the crafting area" )
	Write( "Close all work orders in progress before starting" )
	Write( "" )
	Write( "Guide: http://www.aionscript.com/index.php/topic,234.0.html")
	Write( "Material List: http://www.mmoelites.com/topic/233-information-craft-material-1-399/")
	
	-- Script settings, never go below 500 milliseconds. Increase for higher latency.
	click_wait_time = 1000			-- Wait time in milliseconds after each click.
	move_via_auto_approach = true	-- Set to true when you want to use auto approach for move to NPC.
	
	-- Script settings, do not touch
	learning = 1 					-- Initially the script needs to learn the htmls
	first_screen = 0				-- First screen html index
	timer = 0						-- Restrict clicking using this timer.
	crafting_step = 0				-- Crafting step
	enable_craft = 0				-- The script determines if the starting position is correct to start crafting
	abandon_workorder = 0;			-- Used to select work order in the journal to close failed work orders
	learned = 0;					-- Check if the screens have been learned
	enough_materials = 0			-- Material check
	
	-- Check which NPC with workorders is closest to you and do the work orders.
    NPC_name = CheckWorkorder()
	
	-- Non-configurable variables, do not touch any of these.
    start_location = Player:GetPosition();	-- Starting position to run to. This HAS to be in the crafting area!
	
end

--- OnRun is called each frame.
--
-- @return	void

function OnRun()

	-- Delay to skip YAY-crafted-an-item-animation
	if DialogList:GetDialog( "making_dialog" ):IsVisible() then
		timer = Time() + 4000 
		return
	end

	if Time() > timer and not Player:IsMoving() then

		if InventoryList:GetSlotCurrent() == InventoryList:GetSlotMaximum() then
			Write("Your inventory is full, aborting script")
			Close()
		end
		
		-- Initial set-up of closing all screens
		if crafting_step == 0 then 
		
			if DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- close dialog screen
				stop_chat();
			elseif DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- Crafting screen
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else
				if learned == 0 then
					crafting_step = 1
				else
					crafting_step = 2
				end
			end
			
		-- Learn first screen dialog code
		elseif crafting_step == 1 then
				Write("1")
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc
				Write("1.1")
				start_chat()
			elseif first_screen == 0 then -- Learn the html code of the first screen
				Write("1.2")
				first_screen = DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML()
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
				Write("first_screen: " .. first_screen)
			elseif DialogList:GetDialog( "dlg_dialog/accept" ):IsVisible() then -- Accepting quest
				Write("1.3")
				DialogList:GetDialog( "dlg_dialog/accept" ):Click()
				learned = 1
				crafting_step = 4
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Already have the crafting quest accepted
				Write("1.4")
				stop_chat();
				crafting_step = 3 -- stop the current work order
			else
				Write("1.5")
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		-- Aquiring the work order
		elseif crafting_step == 2 then 
				Write("2")
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc (trying to make it idiot proof)
				start_chat()
			elseif DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML() == first_screen then -- First screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/accept" ):IsVisible() then -- Accepting quest
				DialogList:GetDialog( "dlg_dialog/accept" ):Click()
				crafting_step = 4 -- go to starting position and close dialogs
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Already have the crafting quest accepted
				stop_chat();
				crafting_step = 3 -- stop the current work order
			else -- second screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		-- Stop the current work order (failed to craft everything)
		elseif crafting_step == 3 then
				Write("3")
			
			if not DialogList:GetDialog( "quest_dialog" ):IsVisible() then -- Journal is not opened
				DialogList:GetDialog( "quest_dialog" ):SetVisible(true)
			else -- Journal is open
				if not DialogList:GetDialog( "quest_dialog/1/working_page/task_tab" ):IsVisible() then -- work order is not yet selected
					DialogList:GetDialog( "quest_dialog/quest_tabframe/quest_tab_task" ):Click()
				elseif not DialogList:GetDialog( "quest_dialog/giveup" ):IsEnabled() then -- work order tab is selected, work order is not selected
					local hDialog = DialogList:GetDialog( "quest_dialog/1/working_page/task_tab/working_list/0/1" )
					PlayerInput:Click( hDialog:GetPosition().X + ( 0.5 * hDialog:GetSize().X ), hDialog:GetPosition().Y + 5 )
				else
					local DidFindMatch = false;
					-- Iterate through the dialog to find a non-named confirmation dialog.
					for i = 0, DialogList:GetDialogSize() - 1 do
						-- Retrieve the dialog.
						local CurrentDialog = DialogList:GetDialogIndex( i, false );
						-- Check if the dialog matches expectations.
						if CurrentDialog ~= nil and CurrentDialog:GetName() == "" then
							-- Check if the dialog is visible and the OK button can be clicked.
							if CurrentDialog:IsVisible() and CurrentDialog:GetDialog( "ok" ) ~= nil then
								CurrentDialog:GetDialog( "ok" ):Click()
								DialogList:GetDialog( "quest_dialog" ):SetVisible(false)
								crafting_step = 2
								DidFindMatch = true;
							end
						-- Otherwise break from the iteration.
						else
							break;
						end
					end
					-- If a match was not found, the quest has to be abandoned.
					if not DidFindMatch then
						DialogList:GetDialog( "quest_dialog/giveup" ):Click()
					end
				end
			end

		-- Close dialogs and move to starting position
		elseif crafting_step == 4 then
				Write("4")

			if DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- close dialog screen
				stop_chat();
			elseif DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- Crafting screen
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else 
				Player:SetMove( start_location )
				crafting_step = 5
			end
			
		-- Crafting
		elseif crafting_step == 5 then
				Write("5")
			if DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- craft screen is open
			
				if enable_craft == 0 then -- initially click the correct work order
					local hDialog = DialogList:GetDialog( "tool_making_dialog/making_scroll/making_ext0/making_list0" )
					PlayerInput:Click( hDialog:GetPosition().X + ( 0.5 * hDialog:GetSize().X ), hDialog:GetPosition().Y + 5 )
					enable_craft = 1
				else
				
					-- Check if you have enough materials on you
					if not DialogList:GetDialog( "tool_making_dialog/button_start_all" ):IsEnabled() and enough_materials == 0 then
						Write("Not enough materials/Incorrect starting position")
						Close()
						return
					else
						enough_materials = 1
					end
				
					if DialogList:GetDialog( "tool_making_dialog/button_start_all" ):IsEnabled() then
						DialogList:GetDialog( "tool_making_dialog/button_start_all" ):Click()
					else
						if enable_craft then -- reset script for next crafting iteration
							enable_craft = 0
							enough_materials = 0
							crafting_step = 6
							timer = Time() + 1000
						else
							Write( "Your starting location is not in a crafting area/nor you do not have the required items" )
							Close()
						end
					end
				end
			-- Craft screen has to be opened
			else
				if NPC_name == "Lainita" or NPC_name == "Hestia" then -- Cooking
					PlayerInput:Console("/skill Cooking")
				elseif NPC_name == "Honir" or NPC_name == "Diana" then -- Alchemy
					PlayerInput:Console("/skill Alchemy")
				elseif NPC_name == "Zyakia" or NPC_name == "Daphnis" then -- Tailoring
					PlayerInput:Console("/skill Tailoring")
				elseif NPC_name == "Kinterun" or NPC_name == "Vulcanus" then -- Armorsmithing
					PlayerInput:Console("/skill Armorsmithing")
				elseif NPC_name == "Logi" or NPC_name == "Anteros" then -- Weaponsmithing
					PlayerInput:Console("/skill Weaponsmithing")
				elseif NPC_name == "Lanse" or NPC_name == "Utsida" then -- Handicrafting
					PlayerInput:Console("/skill Handicrafting")
				end
			end
			
		-- Close crafting dialog
		elseif crafting_step == 6 then 
				Write("6")
		
			if DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- craft screen is open
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else
				crafting_step = 7
			end
			
		-- hand in work order
		elseif crafting_step == 7 then
				Write("7")
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc
				start_chat()
			elseif DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML() == first_screen then
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Hand in the work order
				DialogList:GetDialog( "dlg_dialog/ok" ):Click()
				crafting_step = 2 -- Blastradius: No need for Step #0, we can go to Step #2 and avoid dialog bugs.
			else -- second screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		end
		
		timer = Time() + click_wait_time

	end
	
end

function start_chat()

	local Entity = EntityList:GetEntity( NPC_name )
		
	if Player:GetTargetID() ~= Entity:GetID() then -- Move to the target NPC
		Player:SetTarget( Entity )
		if not move_via_auto_approach then
			Player:SetMove( Entity:GetPosition())
		end
	else -- start dialog
		PlayerInput:Ability( 'Attack/Chat' )
	end

end	

function stop_chat()

	-- Get the information for the dialog.
	local DlgDialog = DialogList:GetDialog( "dlg_dialog" );
	local DlgPosition = DlgDialog:GetPosition();
	local DlgSize = DlgDialog:GetSize();
	
	-- Get the information for the cancel button. Avoid names, there are two similar named buttons.
	local CnlDialog = DialogList:GetDialog( "dlg_dialog/8" );
	local CnlSize = CnlDialog:GetSize();
	
	-- Calculate the real position on the X- and Y-axis.
	local Real_X = DlgPosition.X + DlgSize.X - ( DlgSize.X / 100 * 4 );
	local Real_Y = DlgPosition.Y + CnlSize.Y - ( CnlSize.Y / 100 * 4 );

	-- Click the button and continue.
	PlayerInput:Click( Real_X, Real_Y );
	
end

function CheckWorkorder()

	local NPCs = {"Lainita", "Honir", "Zyakia", "Kinterun", "Logi", "Lanse", "Diana", "Vulcanus", "Hestia", "Utsida", "Daphnis", "Anteros"}
	local Distance1 = 100
	local Distance2 = 100
	local NPC_name = ""
	
	for ID, Entity in DictionaryIterator( EntityList:GetList()) do
		for i = 1, #NPCs, 1 do
			if Entity:GetName() == NPCs[i] then
				Distance2 = Entity:GetPosition():DistanceToPosition( Player:GetPosition());
				if Distance2 <= Distance1 then
				Write("Setting " .. NPCs[i] );
				Write(Distance2);
					NPC_name = NPCs[i]
					Distance1 = Distance2
				end
			end
		end
	end
	
	-- Visual verification
	if Distance1 == 100 then
		Write("No NPC nearby to do crafting")
		Close()
	else
		Write("NPC found with name " .. NPC_name)
		Write("with distance of " .. Distance1 .. " units")
		
		return NPC_name
	end

end

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Crafting

Post by nucular » Mon Mar 27, 2017 6:13 pm

Hi, sorry for the delay.

I already fixed the offset and made a workaround for an bug in Aion. This is also a cause for some crashes or deaths for the bot.

What does the bug in aion?
Sometimes you have selected a target but the target id is not set correctly.
So Aionscript tries to reselect the target because it thinks the game has no target selected and that always fails because the correct target is already selected.

And this bug causes the crafting script to not work properly.
I made an workaround for the crafting script, which looks like this:

Code: Select all

	if Player:GetTargetID() == 0 then
		PlayerInput:Escape()
	end
Attached is AionInterface.dll and OfficialCrafting.lua for EU only.
I will add NA support later as soon as i made a proper fix for the targeting issue.

So if you are from EU just replace AionInterface with the one attached and add OfficialCrafting.lua inside the scripting folder.
Attachments
CraftingEU.zip
(150.85 KiB) Downloaded 14 times

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Crafting

Post by nucular » Tue Mar 28, 2017 9:42 pm

Added Crafting Support for EU & NA with latest update (28.03.2017)

skript
Posts: 7
Joined: Fri Mar 10, 2017 6:32 pm
Has thanked: 6 times

Re: Crafting

Post by skript » Wed Mar 29, 2017 6:28 pm

Hello, can you guys tell me how to use the crafting bot, because in mine it's not working. I do not know why the script don't works. He selects the work order but does not start crafting

skript
Posts: 7
Joined: Fri Mar 10, 2017 6:32 pm
Has thanked: 6 times

Re: Crafting

Post by skript » Wed Mar 29, 2017 6:49 pm

skript wrote:
Wed Mar 29, 2017 6:28 pm
Hello, can you guys tell me how to use the crafting bot, because in mine it's not working. I do not know why the script don't works. He selects the work order but does not start crafting
did find the error. it was missing the u in the Armorsmithing already fixed mine it's working now :)
elseif NPC_name == "Kinterun" or NPC_name == "Vulcanus" then -- Armorsmithing
PlayerInput:Console("/skill Armorsmithing")

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Crafting

Post by nucular » Wed Mar 29, 2017 7:22 pm

Oh ok, i will fix it in next release. :lol:

nampa
Posts: 6
Joined: Sun Feb 19, 2017 2:30 pm

Re: Crafting

Post by nampa » Fri Apr 07, 2017 1:39 pm

hi, got a bug

the crafting skill works "it takes order" but doesn't go craft, if i go manualy and open the windows, it works and it goes to the npc to give back the quest

how can i fix this please ?

thank you

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Crafting

Post by nucular » Fri Apr 07, 2017 3:51 pm

read what it says in the beginning.
you have to stand in the crafting area where crafting is possible and near the npc.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests