Another suggestion: Skill is only used above %HP
Another suggestion: Skill is only used above %HP
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
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
Re: Another suggestion: Skill is only used above %HP
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
Re: Another suggestion: Skill is only used above %HP
I have no <onPreSkillCast> section can i make my own or do you mean <onSkillCast>?
Re: Another suggestion: Skill is only used above %HP
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
many Thanks
Re: Another suggestion: Skill is only used above %HP
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.
Properly setup onPreSkillCast event with cast if above %HP
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>
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>
Re: Another suggestion: Skill is only used above %HP
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.
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
Re: Another suggestion: Skill is only used above %HP
I been thinking. What if we change lines like this (eg. line 264 of skill.lua)
to
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?
Code: Select all
if( target and target.HP > self.TargetMaxHp ) then
Code: Select all
if( target and (( self.TargetMaxHp > 0 and target.HP > self.TargetMaxHp ) or ( self.TargetMaxHp < 0 and - target.HP > self.TargetMaxHp ))) then
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
- Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Another suggestion: Skill is only used above %HP
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.
Re: Another suggestion: Skill is only used above %HP
Tested with the example above. Works correctly.Administrator wrote:If it works, then I guess it could be added.
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"/>
When attacking the level 8 mobs it used Plasma Arrow. When attacking the level 9 mobs it used Fireball.
I thought that's what I said? Please see the example above for clarification.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."
That's what I thought.Administrator wrote:Constantly adding new variables isn't exactly a great solution, either, so this might be more practical.
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
Re: Another suggestion: Skill is only used above %HP
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
- Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Another suggestion: Skill is only used above %HP
I meant wouldn't. My mistake.rock5 wrote:I thought that's what I said? Please see the example above for clarification.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."
That's what I thought.Administrator wrote:Constantly adding new variables isn't exactly a great solution, either, so this might be more practical.
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?
What are you trying to do here? I don't think that does what you think it does.if( target and ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
Re: Another suggestion: Skill is only used above %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: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."
Well the obvious ones would be hpper, manaper, targethp, targethpper.Administrator wrote:Feel free to experiment. Just how many options would you like to apply it to?
First off, I tested it it works.Administrator wrote:What are you trying to do here? I don't think that does what you think it does.if( target and ((self.TargetMaxHp < 0 and -1 or 1) * target.HP) > self.TargetMaxHp ) then
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
Re: Another suggestion: Skill is only used above %HP
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 toIt 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; Although you can use this instead if you like. They do the same thing;
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,Does this need to be changed as well? It seems to work without changing it.
In settings.lua I changed line 695 to
Code: Select all
targetmaxhp = tonumber((string.gsub(v:getAttribute("targethp") or "","!","-")));
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
Code: Select all
if( target and (( self.TargetMaxHp > 0 and target.HP > self.TargetMaxHp ) or ( self.TargetMaxHp < 0 and - target.HP > self.TargetMaxHp ))) then
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");
- 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
- Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Another suggestion: Skill is only used above %HP
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.
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.
Re: Another suggestion: Skill is only used above %HP
I'm not sure what you mean by
Or did you mean I need to change that value in database.lua as well?
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?Administrator wrote:targetmaxhp and targethp stuff also would need to be changed.
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
- Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Another suggestion: Skill is only used above %HP
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.
Re: Another suggestion: Skill is only used above %HP
Really? I always thought that the code for rombot was well organized, well compared to my coding.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.
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 "","!","-")));
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
- Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Another suggestion: Skill is only used above %HP
Ok, changes committed.
Re: Another suggestion: Skill is only used above %HP
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!
Thanks for all the hard work!
Re: Another suggestion: Skill is only used above %HP
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.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!
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
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 0 guests