Ammunition Setting Spam

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Ammunition Setting Spam

#1 Post by Bill D Cat » Tue Jun 16, 2015 8:58 pm

From bot.lua at around line 755

Code: Select all

		-- reloading ammunition
		if ( settings.profile.options.RELOAD_AMMUNITION ) then
			local ammo = string.lower(settings.profile.options.RELOAD_AMMUNITION);
			if  ammo == "thrown" and (player.Class1 == CLASS_ROGUE or (player.Class2 == CLASS_ROGUE and player.Level > 11 and player.Level2 > 11)) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			else
			    print("RELOAD_AMMUNITION can only be false, arrow or thrown!");
			end
		end
Situation goes like this. Create a new Rogue and set RELOAD_AMMUNITION to "thrown" or a new Scout and set it to "arrow" and start playing. So far so good. Get to level 10, pick a second class that isn't Rogue or Scout and the spam begins. "RELOAD_AMMUNITION can only be false, arrow or thrown!" in the MM window every waypoint. Would this be better coded as follows to avoid the spam?

Code: Select all

		-- reloading ammunition
		if ( settings.profile.options.RELOAD_AMMUNITION ) then
			local ammo = string.lower(settings.profile.options.RELOAD_AMMUNITION);
			if ammo ~= "thrown" and ammo ~= "arrow" and ammo ~= "false" then
			    print("RELOAD_AMMUNITION can only be false, arrow or thrown!");
			end
			if  ammo == "thrown" and (player.Class1 == CLASS_ROGUE or (player.Class2 == CLASS_ROGUE and player.Level > 11 and player.Level2 > 11)) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
				if inventory:getAmmunitionCount() == 0 then
					inventory:reloadAmmunition(ammo);
				end
			end
		end
Yeah, I know I can just edit the profile when I change classes to avoid it, but sometimes I just use the default profile and set whichever applies to my classes. My actual playing characters each have their own profiles so that's no problem. It's just when I'm making a new character to work on zone waypoint files.

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

Re: Ammunition Setting Spam

#2 Post by rock5 » Wed Jun 17, 2015 4:27 am

The way you have it it will still try to load the ammo though. Maybe you should use an elseif. Also you don't have to check for false because ammo can't equal false in the block of code because of the first 'if' statement.

Code: Select all

      -- reloading ammunition
      if ( settings.profile.options.RELOAD_AMMUNITION ) then
         local ammo = string.lower(settings.profile.options.RELOAD_AMMUNITION);
         if ammo ~= "thrown" and ammo ~= "arrow" then
             print("RELOAD_AMMUNITION can only be false, arrow or thrown!");
         elseif  ammo == "thrown" and (player.Class1 == CLASS_ROGUE or (player.Class2 == CLASS_ROGUE and player.Level > 11 and player.Level2 > 11)) then
            if inventory:getAmmunitionCount() == 0 then
               inventory:reloadAmmunition(ammo);
            end
         elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
            if inventory:getAmmunitionCount() == 0 then
               inventory:reloadAmmunition(ammo);
            end
         end
      end
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: Ammunition Setting Spam

#3 Post by Bill D Cat » Wed Jun 17, 2015 6:18 am

Actually, you could do away with the check altogether if you wanted. I mean, you could set RELOAD_AMMUNITION = "Banana" and it won't try to load ammo because it fails the checks later on. Mostly this is only going to be an issue where you have a Rogue secondary and have not raised your primary class to 12 yet. Actually, if you only got to level 10 Rogue and took a second class it'll keep spamming until you've raised the Rogue to level 12 as well. I guess it doesn't effect Scout like I originally posted, since it doesn't have a level check. The class check in the statements below would be sufficient to control what ammunition was reloaded. Setting RELOAD_AMMUNITION to "thrown" or "arrow" when you don't have Rogue or Scout as one of your active classes would have spammed the warning message, but my change to the code block fixed that.

Code: Select all

elseif  ammo == "thrown" and (player.Class1 == CLASS_ROGUE or (player.Class2 == CLASS_ROGUE and player.Level > 11 and player.Level2 > 11)) then

elseif ammo == "arrow" and (player.Class2 == CLASS_SCOUT or player.Class1 == CLASS_SCOUT) then
I just don't see there is a need to have the check for "thrown", "arrow" or "false" linked into a conditional with the class/ammo check later. If the warning message is triggered, both the following checks will fail anyway based on the first conditional statement, and no ammo will be loaded. I don't think there will be any speed difference between my code and your suggestion either.

And if you take out the check for "false" then you could pretty much just do away with the whole check anyway. Setting RELOAD_AMMUNITION = "None" would work just as well since any string other than "thrown" or "arrow" would effectively be ignored.

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

Re: Ammunition Setting Spam

#4 Post by rock5 » Wed Jun 17, 2015 7:00 am

You're right that your code should work and and the elseif isn't strictly needed but the elseif stops the unnecessary further comparisons. It's just neater programming.

We do need the message. The purpose of the message is to inform the user that they used an invalid value. You are right that the problem is if the value is correct but you are the wrong level then you get the message anyway and your fix fixes this.

You don't need to check for false because if it's false then it wont pass the first if statement.

Code: Select all

if ( settings.profile.options.RELOAD_AMMUNITION ) then
If you are inside this 'if' statement then you already know that that value isn't false (or nil) so you don't have to check if it's false because you already know it isn't.
  • 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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests