How to detect if a hit was critical?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

How to detect if a hit was critical?

#1 Post 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?
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to detect if a hit was critical?

#2 Post by lisa »

Have a look for a buff next time you see the skill is usable, my guess is there will be one.
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
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: How to detect if a hit was critical?

#3 Post 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?
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to detect if a hit was critical?

#4 Post 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
  • 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: How to detect if a hit was critical?

#5 Post 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.
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
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: How to detect if a hit was critical?

#6 Post 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).
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
User avatar
Bot_romka
Posts: 96
Joined: Tue Apr 05, 2011 2:59 am
Location: Russia

Re: How to detect if a hit was critical?

#7 Post 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"
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to detect if a hit was critical?

#8 Post by lisa »

I can't get that event to print any messages, does it actually work for you ?
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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to detect if a hit was critical?

#9 Post 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.
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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to detect if a hit was critical?

#10 Post by lisa »

Give this a test run.
igf_events.lua
(7.58 KiB) Downloaded 169 times
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.
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: How to detect if a hit was critical?

#11 Post by rock5 »

Should that be onPreSkillCast?
  • 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: How to detect if a hit was critical?

#12 Post 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.
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