Page 1 of 1
How to detect if a hit was critical?
Posted: Fri Aug 05, 2011 7:42 pm
by botje
Since i am knight/rogue, i got myself a nice attack "Smash", which is only usable aftera critical attack.
does anybody know of a way to make this happen with the bot?
Botje
sorry, posted in wrong section, could a mod please move this?
Re: How to detect if a hit was critical?
Posted: Sun Aug 07, 2011 7:40 am
by lisa
Have a look for a buff next time you see the skill is usable, my guess is there will be one.
Re: How to detect if a hit was critical?
Posted: Tue Jan 21, 2014 1:27 pm
by BlubBlab
I'm optimizing the use of skills for my char/bot at the moment, so I came across this old thread.
So I had the same idea I can tell you their is no buff on player or target side.
Code: Select all
player:update()
for k,v in pairs(player.Buffs) do print(v.Id, v.Name) end
local target = player:getTarget();
if(target)then
print("target");
target:update()
for k,v in pairs(target.Buffs) do print(v.Id, v.Name) end
end
I could read the battle log but that is really a dirty solution. Has anyone a better idea?
Re: How to detect if a hit was critical?
Posted: Wed Jan 22, 2014 3:18 am
by rock5
Maybe use GetActionUsuable? I don't know if it's usable for this case but you can try it.
http://runesofmagic.gamepedia.com/API:GetActionUsable
Re: How to detect if a hit was critical?
Posted: Wed Jan 22, 2014 5:39 am
by lisa
costs 7% HP, wouldn't want to use it to often lol
lvl 20 elite, I might be able to lvl up a 20/20 char to check it out, if I get time.
There is more than likely something in memory that says if it's usable or not.
Re: How to detect if a hit was critical?
Posted: Wed Jan 22, 2014 8:45 am
by BlubBlab
I tried to dig a little deeper.
I had the idea what if the buff has no name ?
I checked it out in true the bot can't read a buff without name.
First I changed a small line of code(in updateBuffs() the read them all in and then I found:
The player has always the buff with the number of 508709 and sometimes the target has a buff with the number 500666.
Next I changed getBuff so that it works also with numbers which has no name.
I can tell adding 500666 as requirement for the the skill doesn't bring anything(possible wrong)
I don't know what 508709 means perhaps that the char is alive or not swimming. I would love to read the counters to dig a little deeper but the counters a read by phrasing the text of the buff.(possible counters works as a flag).
Re: How to detect if a hit was critical?
Posted: Fri Jan 31, 2014 8:06 pm
by Bot_romka
For check this in Bot code maybe like this
Code: Select all
<onLoad>
G_Crit_Smash = false;
EventMonitorStart("CombatChecker", "COMBATMETER_DAMAGE");
function CombatChecker()
local time, moreToCome, _source, _type = EventMonitorCheck("CombatChecker", "1,5")
if time ~= nil then
if _source == player.Name and _type == "CRITIAL" then
G_Crit_Smash = true
else
G_Crit_Smash = false
end
end
end;
</onLoad>
"COMBATMETER_DAMAGE" event is fired every time the player or a partymember takes damage or causes damage.
This event doesn't use arg1, arg2, etc. It uses pre-defined global variables. These variables are as follows:
_source
The name of the source of the damage, usually the name of the player dealing it.
_target
The name of the target for the damage.
Example: "Cow Beetle"
_damage
The amount of damage done.
Example: 69
_skill
The name of the skill that was used to cause the damage. If it's just an auto-attack, this variable will have the value "ATTACK"
Example: "Fireball"
_type
The type of damage done.
Example: "NORMAL"
Re: How to detect if a hit was critical?
Posted: Fri Jan 31, 2014 10:10 pm
by lisa
I can't get that event to print any messages, does it actually work for you ?
Re: How to detect if a hit was critical?
Posted: Sat Feb 01, 2014 2:29 am
by lisa
Ok got it worked out, thanks to rock.
anytime your hp changes or something elses hp changes because of you or party, or some other reason.
The in game globals change.
_source, _target, _damage, _skill, _type
Code: Select all
Command> local ll = RoMScript("_type") print(ll)
CRITIAL
Keep in mind it is only the very last change and you can't get previous changes, so the code you want might work in an addon but would be unrealistic inside bot.
Re: How to detect if a hit was critical?
Posted: Sat Feb 01, 2014 5:56 am
by lisa
Give this a test run.
it is in the folder
runes of magic/interface/addons/ingamefunction/
then you will need a little code in your profile.
Code: Select all
<onPreSkillCast><![CDATA[
if arg1.Name == "KNIGHT_SMASH" and RoMScript("criticalevent") == false then
return false
end
]]> </onPreSkillCast>
Basically I have added in a variable as part of the game which is true or false for when you do a critical hit, it "should" reset to false 3 seconds after the last critical.
Tested and works fine.
Re: How to detect if a hit was critical?
Posted: Sat Feb 01, 2014 6:08 am
by rock5
Should that be onPreSkillCast?
Re: How to detect if a hit was critical?
Posted: Sat Feb 01, 2014 6:34 am
by lisa
rock5 wrote:Should that be onPreSkillCast?
Probably, my memory is bad and it's been a while since I played with skill stuff
--=== Added ===--
Tested and edited in the working code.