How do i make this more cleaner? :P

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
sauhard
Posts: 130
Joined: Wed Mar 05, 2014 10:30 am

How do i make this more cleaner? :P

#1 Post by sauhard » Thu Mar 05, 2015 11:33 pm

Ok i made this script , i wanted to use housemaid buffs at every step so i put those there. I want to know if this script can be made more cleaner or not:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
settings.profile.mobs = {"Haze Harpy"};
</onload>
	<!-- #  1 --><waypoint x="16561" z="25602" y="178">	
	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end
	</waypoint>
	<!-- #  2 --><waypoint x="16554" z="25565" y="186">	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end
	</waypoint>
	<!-- #  3 --><waypoint x="16540" z="25496" y="189">
if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end	</waypoint>
	<!-- #  4 --><waypoint x="16532" z="25421" y="192">
if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end	</waypoint>
	<!-- #  5 --><waypoint x="16608" z="25310" y="197">if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end	</waypoint>
	<!-- #  6 --><waypoint x="16680" z="25302" y="188">	
	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end</waypoint>
	<!-- #  7 --><waypoint x="16800" z="25331" y="189">if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end	</waypoint>
	<!-- #  8 --><waypoint x="16839" z="25403" y="184">	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end</waypoint>
	<!-- #  9 --><waypoint x="16860" z="25460" y="191">if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end
	</waypoint>
	<!-- # 10 --><waypoint x="16848" z="25592" y="188">if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end	</waypoint>
	<!-- # 11 --><waypoint x="16747" z="25708" y="172">	
	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end</waypoint>
	<!-- # 12 --><waypoint x="16623" z="25738" y="164">	
	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end</waypoint>
	<!-- # 13 --><waypoint x="16531" z="25664" y="164">	if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end</waypoint>
	<!-- # 14 --><waypoint x="16519" z="25531" y="189">if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end  

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end 

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
	
	if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end	</waypoint>
</waypoints>
Satisfaction is the end of desire!!

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How do i make this more cleaner? :P

#2 Post by rock5 » Fri Mar 06, 2015 1:56 am

The logic looks right enough. But if you are repeating code and want to reduce the repitition you can create a function in the onload then use the function throughout the waypoint, eg.

Code: Select all

function checkBuffs()
  if (not player:hasBuff("506634")) then
    inventory:useItem(207200);
    end 

 if (not player:hasBuff("506680")) then
    inventory:useItem(207216);
    end

 if (not player:hasBuff("506686")) then
    inventory:useItem(207202);end
   
   if (not player:hasBuff("506685")) then
    inventory:useItem(207201);end
end
Then where you want it to check your buffs just use

Code: Select all

checkBuffs()
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
sauhard
Posts: 130
Joined: Wed Mar 05, 2014 10:30 am

Re: How do i make this more cleaner? :P

#3 Post by sauhard » Fri Mar 06, 2015 10:14 am

Ehm ok ty for the reply. What i am doing atm is farming some mobs. But even when the buff is over the bot doesn't recast for the new one. Any logic behind it?
Satisfaction is the end of desire!!

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How do i make this more cleaner? :P

#4 Post by rock5 » Fri Mar 06, 2015 10:53 am

The logic looks correct. Are you sure the ids are correct? I checked to see if hasBuff can accept ids as strings like you are doing. It can. It should check the buffs when it reaches those waypoints. Are you perhaps fighting so many monsters that it never gets to the next waypoint? You can test the commands individually using the commandline waypoint file. Just run it and then test each command to make sure it does what you expect.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
sauhard
Posts: 130
Joined: Wed Mar 05, 2014 10:30 am

Re: How do i make this more cleaner? :P

#5 Post by sauhard » Fri Mar 06, 2015 11:27 am

rock5 wrote:Are you perhaps fighting so many monsters that it never gets to the next waypoint?
Well i think ye i am indeed farming too many mobs, the bot just keeps on targeting mobs and doesn't move to the next waypoint. Any way to fix this?
Satisfaction is the end of desire!!

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How do i make this more cleaner? :P

#6 Post by rock5 » Fri Mar 06, 2015 12:17 pm

Yes. You can put the buff check in the onLeaveCombat section of your profile. That way it will check your buffs after every battle. If you need to do this from the waypoint file you can do that too. Eg.

Code: Select all

<onload>
   oldOnLeaveCombat = settings.profile.events.onLeaveCombat
   function settings.profile.events.onLeaveCombat()
      if oldOnLeaveCombat then
         oldOnLeaveCombat()
      end
      if (not player:hasBuff("506634")) then
         inventory:useItem(207200);
      end

      if (not player:hasBuff("506680")) then
         inventory:useItem(207216);
      end

      if (not player:hasBuff("506686")) then
         inventory:useItem(207202);end
   
      if (not player:hasBuff("506685")) then
         inventory:useItem(207201);end
   end
</onload>
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
sauhard
Posts: 130
Joined: Wed Mar 05, 2014 10:30 am

Re: How do i make this more cleaner? :P

#7 Post by sauhard » Mon Mar 09, 2015 12:01 am

Ah thanks man. Solved alot of problems for me :D

Just incase if someone needs Xp/tp farm in lvl 90 region starts near harpies spwan.

Edit the buffs accordingly you want to use.
Attachments
Harpy farm.xml
Xp/tp Farm waypoint
(1.57 KiB) Downloaded 150 times
Satisfaction is the end of desire!!

User avatar
Bot_romka
Posts: 96
Joined: Tue Apr 05, 2011 2:59 am
Location: Russia

Re: How do i make this more cleaner? :P

#8 Post by Bot_romka » Tue Mar 17, 2015 7:22 pm

Code: Select all

	-- Зелья: неукротимый энтузиазм, ясные мысли, удача, горячая любовь, вкуснейший салат
	CL_HmaidItems = {207200,207202,207203,207206,207215}

Code: Select all

-- House Servant
	function HouseServant()
		-- ChoiceOption: 0 --chat, 1 -magic, 2 -battle, 3 -protection, 4 -cooking, 5 -crafting.
		local Nr
		if( player.Name == Ki_Name ) then
			Nr = 1
		elseif( player.Name == Po_Name ) then
			Nr = 2
		elseif( player.Name == Bt_Name ) then
			Nr = 3
		elseif( player.Name == Gu_Name ) then
			Nr = 4
		end
		-- Hmaid1
		player:target_NPC(CL_Hmaid1[Nr]) yrest(1000)
		for i = 1,4 do
			if( RoMScript("HouseServantValueBar3StatusBar:GetValue();") > 75 ) then break end
			RoMScript("ChoiceListDialogOption(5);") yrest(1000)	-- crafting
		end
		-- Hmaid2
		player:target_NPC(CL_Hmaid2[Nr]) yrest(1000)
		for i = 1,4 do
			if( RoMScript("HouseServantValueBar3StatusBar:GetValue();") > 75 ) then break end
			RoMScript("ChoiceListDialogOption(5);") yrest(1000)	-- crafting
		end
		-- Hmaid3
		player:target_NPC(CL_Hmaid3[Nr]) yrest(1000)
		for i = 1,4 do
			if( RoMScript("HouseServantValueBar3StatusBar:GetValue();") > 75 ) then break end
			RoMScript("ChoiceListDialogOption(4);") yrest(1000)	-- cooking
		end
		-- Hmaid4
		player:target_NPC(CL_Hmaid4[Nr]) yrest(1000)
		for i = 1,4 do
			if( player:hasBuff(CL_BuffFA[Nr]) or RoMScript("HouseServantValueBar3StatusBar:GetValue();") > 75 ) then break end
			if( player.Name == Gu_Name ) then
				RoMScript("ChoiceListDialogOption(1);") yrest(1000)	-- magic
			else
				RoMScript("ChoiceListDialogOption(2);") yrest(1000)	-- battle
			end
		end
		-- Hmaid5
		player:target_NPC(CL_Hmaid5[Nr]) yrest(1000)
		for i = 1,4 do
			if( RoMScript("HouseServantValueBar3StatusBar:GetValue();") > 85 ) then break end
			if( 100 > RoMScript("HouseServantValueBar1StatusBar:GetValue();") ) then
				RoMScript("ChoiceListDialogOption(0);") yrest(1000)	-- chat
			else
				RoMScript("ChoiceListDialogOption(5);") yrest(1000)	-- crafting
			end
		end
		-- Sort House Servant items
		inventory:update()
		for i = 1, 5 do
			local item = inventory.BagSlot[5+i]
			if item.Available and not item.Empty then
				RoMScript("PickupBagItem(5"..i..");"); yrest(500);
			end
			for slot = 61, 240 do
				item = inventory.BagSlot[slot]
				if item.Available and (item.Id == CL_HmaidItems[i] or (i == 5 and item.Id == 207213)
					or (i == 5 and player.Name == Gu_Name and item.Id == 207216)) then
					RoMScript("PickupBagItem("..item.BagId..");"); yrest(500);
					if not RoMScript("CursorHasItem()") then
						RoMScript("PickupBagItem("..item.BagId..");"); yrest(500);
					end
					if( bot.ClientLanguage == "RU" ) then
						item.Name = utf82oem_russian(item.Name);
					end
					cprintf(cli.white, "Pickup: %s Id: %s Name: %s\n", item.SlotNumber, item.Id, item.Name)
				end
			end
			RoMScript("PickupBagItem(5"..i..");"); yrest(500);
		end
		-- Clean Bag Items
		--CleanBagItems();
	end;

Code: Select all

	--Hmaids for Kifdrwerk, Posjuasdg, Bitwetrsf, Guuilfsd
	CL_Hmaid1 = {113789,113809,113785,113807}	-- Горничная 1 на зелья,  Hmaid for Potions
	CL_Hmaid2 = {113809,113782,113789,113786}	-- Горничная 2 на зелья, Hmaid for Potions
	CL_Hmaid3 = {113788,113803,113788,113788}	-- Горничная 3 на еду, Hmaid for food
	CL_Hmaid4 = {113806,113786,113807,"Сьюзен Пэйн"}	-- Горничная 4 на баф Сила физ. атаки, Hmaid for Buff Phisical\Mage attack
	CL_Hmaid5 = {113807,113808,113807,113805}	-- Горничная 5 на зелья, Hmaid for Potions
	CL_BuffFA = {506637,506637,506694,506633}	-- Бафф Сила физ. атаки, Second Hmaid for Buff Phisical\Mage attack
Potions

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests