Another suggestion: Skill is only used above %HP

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
Starrider
Posts: 164
Joined: Sat May 01, 2010 7:04 am
Location: Germany

Another suggestion: Skill is only used above %HP

#1 Post by Starrider » Tue Jun 01, 2010 3:42 pm

Hello, I found that on function is "targethpper" that allows to use a skill when the target is below this value.

My suggestion ist to have the same function to set a skill who is used only when the target is above %HP. I don't know how to code or how it ist possible to work with the "targethpper" that i can rewrite it to an "above hp" function.

After you (Admin) helped me to make the Knight_punishment skill is working I found the problem, that:

Reasons:
1. I cant work with "maxuse", because it depends on the enemy how often I need the strong Punishment Skill.
2. It costs to much mana and makes no sense when the bot cast this skill and the target has 100 HP left but the skill makes 950HP damage an costs 300 mana
I hope you understand what I mean, so this new function to set how long a skill can be used would be awsome!

Sincerly

KillerTHC
Posts: 63
Joined: Tue May 25, 2010 8:49 pm

Re: Another suggestion: Skill is only used above %HP

#2 Post by KillerTHC » Tue Jun 01, 2010 8:11 pm

Put this in your onPreSkillCast section of your profile I have not tested it but it should work.

Code: Select all

local targetPawn = CPawn(player.TargetPtr);
local attackPercent = 50; -- Percent that their health must be above
if( arg1.Name == "KNIGHT_PUNISHMENT" ) then
	if( targetPawn ~= nill and targetPawn ~= 0 and player.TargetPtr ~= player.Address ) then -- Make sure we have a valid target to get info from
		if( (targetPawn.HP/targetPawn.MaxHP*100) > attackPercent ) then -- Test the targets HP if below the attackPercent
			return true; -- Cast spell
		else
			return false; -- Don't cast spell
		end
	else -- Incase we get a bad target just return true and let the bot deal with it
		return true;
	end
else
	return true; -- Cast spell since it is not the spell we want
end

Starrider
Posts: 164
Joined: Sat May 01, 2010 7:04 am
Location: Germany

Re: Another suggestion: Skill is only used above %HP

#3 Post by Starrider » Wed Jun 02, 2010 1:36 pm

I have no <onPreSkillCast> section can i make my own or do you mean <onSkillCast>?

Starrider
Posts: 164
Joined: Sat May 01, 2010 7:04 am
Location: Germany

Re: Another suggestion: Skill is only used above %HP

#4 Post by Starrider » Wed Jun 02, 2010 1:45 pm

Sry for Doubleposting i have tested it, it works fine for me, mabye this code could be added to the bot as a function...
many Thanks

KillerTHC
Posts: 63
Joined: Tue May 25, 2010 8:49 pm

Re: Another suggestion: Skill is only used above %HP

#5 Post by KillerTHC » Wed Jun 02, 2010 3:25 pm

For clarification for anyone else who wants to use this code, onPreSkillCast was a new event added to the RoM-Bot recently so in your profiles you can add the following code to execute lua scripts before casting spells/skills.

Code: Select all

<onPreSkillCast>
-- This event receives the skill your going to cast and is accessible using arg1
-- Ex arg1.Name is the name of the skill
-- Add lua code you want to execute here
</onPreSkillCast>
Properly setup onPreSkillCast event with cast if above %HP

Code: Select all

<onPreSkillCast>
local targetPawn = CPawn(player.TargetPtr);
local attackPercent = 50; -- Percent that their health must be above
if( arg1.Name == "KNIGHT_PUNISHMENT" ) then
   if( targetPawn ~= nill and targetPawn ~= 0 and player.TargetPtr ~= player.Address ) then -- Make sure we have a valid target to get info from
      if( (targetPawn.HP/targetPawn.MaxHP*100) > attackPercent ) then -- Test the targets HP if below the attackPercent
         return true; -- Cast spell
      else
         return false; -- Don't cast spell
      end
   else -- Incase we get a bad target just return true and let the bot deal with it
      return true;
   end
else
   return true; -- Cast spell since it is not the spell we want
end
</onPreSkillCast>

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

Re: Another suggestion: Skill is only used above %HP

#6 Post by rock5 » Wed Jun 02, 2010 10:36 pm

This has been talked about before but nothing has been done about it yet.

I wish they would add it as I'd like to use some skills and debuffs only if the targets maxhp is a high number. No use casting dots and big slow attack spells on a low level mob.

At the moment I have to change the skills every time I change from a hard zone to an easy zone.

I wish we could just put in a symbol to make the meaning opposite.

eg.
hpper=!60 -- would caste only if above 60
targethp=!2000 -- would caste only if target hp is above 2000

Or just use different variables. I don't care. As long as it is implemented.

Please.
  • 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
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Another suggestion: Skill is only used above %HP

#7 Post by rock5 » Wed Jun 02, 2010 11:16 pm

I been thinking. What if we change lines like this (eg. line 264 of skill.lua)

Code: Select all

if( target  and  target.HP > self.TargetMaxHp ) then
to

Code: Select all

if( target  and (( self.TargetMaxHp > 0 and target.HP > self.TargetMaxHp ) or ( self.TargetMaxHp < 0 and - target.HP > self.TargetMaxHp ))) then
Then you could use a hyphen "-" to make the meaning opposite and wouldn't require any parsing of values.

Eg. Lets say the targets hp is 200.
If TargetMaxHp is positive 300 (ie. target hp has to be below 300) then that evaluates to 'if 200>300 then don't caste'. 200 is not greater than 300 so it castes.
if TargetMaxHp is -300 (ie. target hp has to be above 300) then that evaluates to 'if -200>-300 then don't caste'. -200 is greater than -300 so it doesn't caste.

You should be able to do the same with the other similar checks.

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
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Another suggestion: Skill is only used above %HP

#8 Post by Administrator » Thu Jun 03, 2010 4:26 am

If it works, then I guess it could be added. The problem is that it is kind of counter-intuitive. Most people would see having -300 as meaning "the target needs to have more than 300 HP." Constantly adding new variables isn't exactly a great solution, either, so this might be more practical.

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

Re: Another suggestion: Skill is only used above %HP

#9 Post by rock5 » Thu Jun 03, 2010 6:12 am

Administrator wrote:If it works, then I guess it could be added.
Tested with the example above. Works correctly.

What I did was set my skills like so;

Code: Select all

		<skill name="MAGE_FIREBALL"             hotkey="MACRO" priority="80" targethp="-500"/>
		<skill name="MAGE_PLASMA_ARROW"         hotkey="MACRO" priority="70" targethp="500"/>
Then attacked level 8 and 9 mobs that were below and above 500 hp.
When attacking the level 8 mobs it used Plasma Arrow. When attacking the level 9 mobs it used Fireball.
Administrator wrote:The problem is that it is kind of counter-intuitive. Most people would see having -300 as meaning "the target needs to have more than 300 HP."
I thought that's what I said? Please see the example above for clarification.
Administrator wrote:Constantly adding new variables isn't exactly a great solution, either, so this might be more practical.
That's what I thought.

If you like this idea are you alright to apply it to the other values? Or would you like me to do it for you?
  • 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
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Another suggestion: Skill is only used above %HP

#10 Post by rock5 » Thu Jun 03, 2010 6:46 am

I worked out a more compressed way of doing it;

Code: Select all

	if( target  and  ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
  • 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
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Another suggestion: Skill is only used above %HP

#11 Post by Administrator » Thu Jun 03, 2010 10:54 am

rock5 wrote:
Administrator wrote:The problem is that it is kind of counter-intuitive. Most people would see having -300 as meaning "the target needs to have more than 300 HP."
I thought that's what I said? Please see the example above for clarification.
I meant wouldn't. My mistake.
Administrator wrote:Constantly adding new variables isn't exactly a great solution, either, so this might be more practical.
That's what I thought.

If you like this idea are you alright to apply it to the other values? Or would you like me to do it for you?[/quote]
Feel free to experiment. Just how many options would you like to apply it to?

if( target and ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
What are you trying to do here? I don't think that does what you think it does.

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

Re: Another suggestion: Skill is only used above %HP

#12 Post by rock5 » Thu Jun 03, 2010 11:34 am

Administrator wrote:The problem is that it is kind of counter-intuitive. Most people wouldn't see having -300 as meaning "the target needs to have more than 300 HP."
At the moment 300 means it has to be lower than 300. You can't change that without making people's current profiles stop working as intended. So that leaves -300 meaning it has to be greater than 300. I don't see any other choice. Unless you want to use another symbol. You would have to parse the value with something like a string.find command though. Maybe we should, as "!" would be the obvious choice as it has been used elsewhere to mean "not".
Administrator wrote:Feel free to experiment. Just how many options would you like to apply it to?
Well the obvious ones would be hpper, manaper, targethp, targethpper.
Administrator wrote:
if( target and ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
What are you trying to do here? I don't think that does what you think it does.
First off, I tested it it works.

If TargetMaxHp is negative then "self.TargetMaxHp < 0 and -1" returns -1 else it returns 1 (or 1) which it multiplies by target.HP. So in effect, if TargetMaxHp is negative then it changes target.HP to negative as well, which is what my original example did. My original example said if TargetMaxHp is positive then compare it to target.HP or if it is negative, compare it to -target.HP.

I hope that's cleared it up. It was a bit difficult to explain. If you want me to further explain it let me know.
  • 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
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Another suggestion: Skill is only used above %HP

#13 Post by rock5 » Mon Jun 07, 2010 1:20 am

I thought about what you said about it being counter-intuitive so I made another change to use "!" instead of "-".

In settings.lua I changed line 695 to

Code: Select all

			targetmaxhp = tonumber((string.gsub(v:getAttribute("targethp") or "","!","-")));
It changes the "!" to a "-" so the previous changes still function the same.

So to recap:
As well as the above code I've changed line 264 of skill.lua to;

Code: Select all

	if( target  and  ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
Although you can use this instead if you like. They do the same thing;

Code: Select all

if( target  and (( self.TargetMaxHp > 0 and target.HP > self.TargetMaxHp ) or ( self.TargetMaxHp < 0 and - target.HP > self.TargetMaxHp ))) then
So now I can use targethp="!500" to mean targets hp has to be above 500.

This has been tested and works. If you are happy with this let me know and I can apply the same to the other attributes I mentioned previously.

1 question I need to ask, I noticed that line 37 of database.lua is similar,

Code: Select all

targetmaxhp = v:getAttribute("targetmaxhp");
Does this need to be changed as well? It seems to work without changing it.
  • 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
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Another suggestion: Skill is only used above %HP

#14 Post by Administrator » Mon Jun 07, 2010 9:43 am

Yes, I think the '!' would be a much better choice here. And yes, the targetmaxhp and targethp stuff also would need to be changed.

Let me know how the other changes work. I've committed this small change for now so others are able to test it as well.

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

Re: Another suggestion: Skill is only used above %HP

#15 Post by rock5 » Mon Jun 07, 2010 10:38 am

I'm not sure what you mean by
Administrator wrote:targetmaxhp and targethp stuff also would need to be changed.
Aren't they the same thing? targethp is the setting you set and targetmaxhp is the "tonumber" value added to the skills database from targethp. Isn't it?

Or did you mean I need to change that value in database.lua as well?
  • 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
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Another suggestion: Skill is only used above %HP

#16 Post by Administrator » Mon Jun 07, 2010 12:33 pm

After quickly reviewing it again, I think you're right. It might not need any more changes. I mean, if it's working, it's working, right? The code has become such a big mess that it's hard to keep track of all these things.

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

Re: Another suggestion: Skill is only used above %HP

#17 Post by rock5 » Mon Jun 07, 2010 2:07 pm

Administrator wrote:After quickly reviewing it again, I think you're right. It might not need any more changes. I mean, if it's working, it's working, right? The code has become such a big mess that it's hard to keep track of all these things.
Really? I always thought that the code for rombot was well organized, well compared to my coding. :)

Anyway, I applied the changes to the other values as well. They're a bit harder to test but the changes are the same so they should work.

So here's summary:

Lines 693-696 of settings;

Code: Select all

			maxhpper = tonumber((string.gsub(v:getAttribute("hpper") or "","!","-")));
			targetmaxhpper = tonumber((string.gsub(v:getAttribute("targethpper") or "","!","-")));
			targetmaxhp = tonumber((string.gsub(v:getAttribute("targethp") or "","!","-")));
			maxmanaper = tonumber((string.gsub(v:getAttribute("manaper") or "","!","-")));
Lines 178, 184, 258 and 264 of skill.lua;

Code: Select all

	if( (self.MaxHpPer < 0 and -1 or 1) * (player.HP / player.MaxHP * 100) > self.MaxHpPer ) then

Code: Select all

	if( (self.MaxManaPer < 0 and -1 or 1) * (player.Mana/player.MaxMana*100) > self.MaxManaPer ) then

Code: Select all

	if( target  and  ((self.TargetMaxHpPer < 0 and -1 or 1) * (target.HP/target.MaxHP*100)) > self.TargetMaxHpPer ) then

Code: Select all

	if( target  and  ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
  • 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
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Another suggestion: Skill is only used above %HP

#18 Post by Administrator » Mon Jun 07, 2010 3:18 pm

Ok, changes committed.

S3v3n11
Posts: 91
Joined: Thu Jul 09, 2009 7:37 am

Re: Another suggestion: Skill is only used above %HP

#19 Post by S3v3n11 » Sat Aug 28, 2010 11:14 am

I noticed that this code was not in the default.xml profile. This is really good stuff and an example should be put in the default profile.

Thanks for all the hard work!

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

Re: Another suggestion: Skill is only used above %HP

#20 Post by rock5 » Sat Aug 28, 2010 12:20 pm

S3v3n11 wrote:I noticed that this code was not in the default.xml profile. This is really good stuff and an example should be put in the default profile.

Thanks for all the hard work!
I'm not sure if it's appropriate to add this to the default profile but I did add a not about it to the romwiki under the appropriate values.
http://www.solarstrike.net/wiki/index.p ... e_-_Skills
  • 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] and 3 guests