Page 1 of 1

Condensing code

Posted: Thu Aug 25, 2011 9:12 am
by Mushroomstamp

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?

Re: Condensing code

Posted: Thu Aug 25, 2011 10:21 am
by lisa
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

Re: Condensing code

Posted: Thu Aug 25, 2011 10:23 am
by rock5
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?

Re: Condensing code

Posted: Thu Aug 25, 2011 10:31 am
by lisa
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.

Re: Condensing code

Posted: Thu Aug 25, 2011 7:08 pm
by Mushroomstamp
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-)

Re: Condensing code

Posted: Thu Aug 25, 2011 7:43 pm
by lisa
If you intend to use in different profiles, I'd suguest making it a userfunction and just call it from onpreskillcast

Re: Condensing code

Posted: Thu Aug 25, 2011 9:59 pm
by rock5
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.

Re: Condensing code

Posted: Thu Aug 25, 2011 10:24 pm
by lisa
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.

Re: Condensing code

Posted: Fri Aug 26, 2011 6:29 am
by rock5
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.

Re: Condensing code

Posted: Fri Aug 26, 2011 8:21 am
by lisa
prob just do up a userfunction, adding in usual aoe skills to a table. That will do for now.