Condensing code

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Mushroomstamp
Posts: 210
Joined: Wed Oct 27, 2010 11:34 am

Condensing code

#1 Post by Mushroomstamp » Thu Aug 25, 2011 9:12 am

Code: Select all

		if arg1.Name == "WARRIOR_MOON_CLEAVE" or arg1.Name == "WARRIOR_BLASTING_CYCLONE" or
		arg1.Name == "WARRIOR_WHIRLWIND" or arg1.Name == "WARRIOR_SHOUT" then
			if 2 > CountAggroTargets() then	
				return false
			end	
		end
Can I bracket all the skills in some way, or do I have to leave the "arg1.Name ==" for every one, just like it is now? Or is there a totally different and better way to code this?

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Condensing code

#2 Post by lisa » Thu Aug 25, 2011 10:21 am

for 4 skills I would probably just leave it as is.

If you were thinking you needed more skills then you could probably add them to a table, like if you did something for all classes I guess.

profile onload

Code: Select all

aoeskills = {"WARRIOR_MOON_CLEAVE", "WARRIOR_BLASTING_CYCLONE", "WARRIOR_WHIRLWIND", "WARRIOR_SHOUT"}
profile onpreskillcast

Code: Select all

 
for k,v in pairs(aoeskills) do
if arg1.Name == v then
         if 2 > CountAggroTargets() then   
            return false
         end 
end
end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

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

Re: Condensing code

#3 Post by rock5 » Thu Aug 25, 2011 10:23 am

You could flip it

Code: Select all

if 2 > CountAggroTargets() then
    if (arg1.Type == STYPE_DAMAGE or arg1.Type == STYPE_DOT) and arg1.Name ~= "WARRIOR_AOENAME" then
        return false
    end
end
It's nearly as long but this way it doesn't matter how many attack skills you have, it will work. Your way you would have to add every new skill.

What do you think?
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Condensing code

#4 Post by lisa » Thu Aug 25, 2011 10:31 am

I think he was just trying to stop using aoe attacks unless there were multiple mobs, so would need to add in a new thing to skill database for aoe skill to be able to use it with just 1 bit of code for all skills.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Mushroomstamp
Posts: 210
Joined: Wed Oct 27, 2010 11:34 am

Re: Condensing code

#5 Post by Mushroomstamp » Thu Aug 25, 2011 7:08 pm

rock5 wrote:You could flip it

Code: Select all

if 2 > CountAggroTargets() then
    if (arg1.Type == STYPE_DAMAGE or arg1.Type == STYPE_DOT) and arg1.Name ~= "WARRIOR_AOENAME" then
        return false
    end
end
It's nearly as long but this way it doesn't matter how many attack skills you have, it will work. Your way you would have to add every new skill.

What do you think?
I'm having trouble understanding what this is accomplishing. Why denote damage or dot? And wouldn't I still need to put each skill name in there?
lisa wrote:I think he was just trying to stop using aoe attacks unless there were multiple mobs
Yes, this is what I'm using it for. Thanks for the table example... I think I'm going to go that route so it'll cover all the classes. 8-)

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Condensing code

#6 Post by lisa » Thu Aug 25, 2011 7:43 pm

If you intend to use in different profiles, I'd suguest making it a userfunction and just call it from onpreskillcast
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

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

Re: Condensing code

#7 Post by rock5 » Thu Aug 25, 2011 9:59 pm

Mushroomstamp wrote:I'm having trouble understanding what this is accomplishing. Why denote damage or dot? And wouldn't I still need to put each skill name in there?
What this means is if multiple mobs are attacking you and the skill isn't your AOE spell then skip it. I'm assuming you don't want to skip Heals and buffs so I added the check to skip it only if it's an attack skill.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Condensing code

#8 Post by lisa » Thu Aug 25, 2011 10:24 pm

I think he was confused because it seemed like he would still need to add in all the aoe skills

"WARRIOR_AOENAME"

Best way would be to add an aoe tag to skills in database and use that.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

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

Re: Condensing code

#9 Post by rock5 » Fri Aug 26, 2011 6:29 am

That code assumes 1 aoe skill. I was debating saying "if you have more than one aoe skill you would have to add them all" but I didn't.

I was just looking to help with a solution with how the coding is now. I don't really want to add functionallity for aoe skills to the bot considering they all seem to work differently. It would be a bit of a nightmare.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Condensing code

#10 Post by lisa » Fri Aug 26, 2011 8:21 am

prob just do up a userfunction, adding in usual aoe skills to a table. That will do for now.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest