Page 1 of 1

Interrupting casts

Posted: Sun Aug 21, 2011 12:47 pm
by Dsanchez
I found UNIT_CASTINGTIME while looking through the glossary and was wondering how I could use it to stun/interrupt a mob that starts casting a spell while I am fighting it.


Thanks

Re: Interrupting casts

Posted: Sun Aug 21, 2011 1:12 pm
by rock5
I would think the easiest way to interrupt would be to check if the mob is casting in the onpreskillcast or onskillcast profile event and then act.

Something like

Code: Select all

<onPreSkillCast>
local target = player:getTarget()
if target and target.Casting then
    player:cast("interrupting skill")
end
</onPreSkillCast>

Re: Interrupting casts

Posted: Sun Aug 21, 2011 1:54 pm
by Dsanchez
this works great! a couple other things... to add skills from all three of my classes, would i have to make a conditional for each skill or is there a shorter way? also, is there a way to check what the target is casting so that i can only interrupt certain casts (like heals) and not others?


thanks

Re: Interrupting casts

Posted: Sun Aug 21, 2011 2:46 pm
by rock5
Dsanchez wrote: to add skills from all three of my classes, would i have to make a conditional for each skill or is there a shorter way?
Unfortunately yes. You can use something like this

Code: Select all

if player.Class1 == CLASS_PRIEST then
Dsanchez wrote:also, is there a way to check what the target is casting so that i can only interrupt certain casts (like heals) and not others?
We don't save that information. You would have to look for an ingame function that will give you that info. I had an initial look at the rom wiki but couldn't see one.

Re: Interrupting casts

Posted: Tue Aug 23, 2011 8:40 am
by Dsanchez
works great, and doesn't give an error and stop now with that added.


thanks!

Re: Interrupting casts

Posted: Wed Aug 24, 2011 1:51 am
by Dsanchez
hi, i have another question about this. i have two stuns on my paladin, shock and charge. i'd like to use shock first and then alternate to charge when shock is on cd and vice versa. is this possible?

Code: Select all

	<onPreSkillCast>
	local target = player:getTarget()
	if target and target.Casting then
		if player.Class1 == CLASS_KNIGHT then
			player:cast("KNIGHT_SHOCK")
		end
	end
	</onPreSkillCast>




thanks!

Re: Interrupting casts

Posted: Wed Aug 24, 2011 8:15 am
by rock5
That should be

Code: Select all

	<onPreSkillCast>
	if player.Class1 == CLASS_KNIGHT then
		local target = player:getTarget()
		if target and target.Casting then
			player:cast("KNIGHT_SHOCK")
		end
	end
	</onPreSkillCast>

Saves you getting the target and checking casting if you are not a knight.

Checking the cooldown is a bit more difficult.

I think this will work.

Code: Select all

	<onPreSkillCast>
	if player.Class1 == CLASS_KNIGHT then
		local target = player:getTarget()
		if target and target.Casting then
			-- Look up Shock skill
			if ShockIndex == nil then -- So it only does it once
				for k,v in pairs(settings.profile.skills) do 
					if v.Name = "KNIGHT_SHOCK" then ShockIndex = k break end
				end
			end
			
			-- Check cooldown
			local cd = deltaTime(getTime(), settings.profile.skills[ShockIndex].LastCastTime)/1000 break end
			if cd > 30 then
				player:cast("KNIGHT_SHOCK")
			else
				player:cast("KNIGHT_CHARGE")
			end
		end
	end
	</onPreSkillCast>

Re: Interrupting casts

Posted: Thu Aug 25, 2011 1:09 am
by Dsanchez
I receive a failed to compile error when using the latter.

Re: Interrupting casts

Posted: Thu Aug 25, 2011 2:11 am
by lisa
try

Code: Select all

<onPreSkillCast>
   if player.Class1 == CLASS_KNIGHT then
      local target = player:getTarget()
      if target and target.Casting then
         -- Look up Shock skill
         if ShockIndex == nil then -- So it only does it once
            for k,v in pairs(settings.profile.skills) do 
               if v.Name = "KNIGHT_SHOCK" then ShockIndex = k break end
            end
         end
         
         -- Check cooldown
         local cd = deltaTime(getTime(), settings.profile.skills[ShockIndex].LastCastTime)/1000
         if cd > 30 then
            player:cast("KNIGHT_SHOCK")
         else
            player:cast("KNIGHT_CHARGE")
         end
      end
   end
   </onPreSkillCast>
there was a "break end" that didn't look right to me.

Re: Interrupting casts

Posted: Thu Aug 25, 2011 2:28 am
by Dsanchez
same error

Re: Interrupting casts

Posted: Thu Aug 25, 2011 2:43 am
by lisa

Code: Select all

   if player.Class1 == CLASS_KNIGHT then
      local target = player:getTarget()
      if target and target.Casting then
         -- Look up Shock skill
         if ShockIndex == nil then -- So it only does it once
            for k,v in pairs(settings.profile.skills) do 
               if v.Name == "KNIGHT_SHOCK" then ShockIndex = k break end
            end
         end
         
         -- Check cooldown
         local cd = deltaTime(getTime(), settings.profile.skills[ShockIndex].LastCastTime)/1000
         if cd > 30 then
            player:cast("KNIGHT_SHOCK")
         else
            player:cast("KNIGHT_CHARGE")
         end
      end
   end
was a = when needed a ==

Re: Interrupting casts

Posted: Thu Aug 25, 2011 2:01 pm
by Dsanchez
TY, no more error with the == instead of =

Now I'd like to add interrupts for my warrior. I'm choosing Shout and Terror since Thunder requires a 1h weapon (would it be possible to use Thunder instead if I had a 1h weapon equipped?).

Code: Select all

   <onPreSkillCast>
   if player.Class1 == CLASS_KNIGHT then
      local target = player:getTarget()
      if target and target.Casting then
         -- Look up Shock skill
         if ShockIndex == nil then -- So it only does it once
            for k,v in pairs(settings.profile.skills) do
               if v.Name == "KNIGHT_SHOCK" then ShockIndex = k break end
            end
         end
         
         -- Check cooldown
         local cd = deltaTime(getTime(), settings.profile.skills[ShockIndex].LastCastTime)/1000
         if cd > 30 then
            player:cast("KNIGHT_SHOCK")
         else
            player:cast("KNIGHT_CHARGE")
         end
      end
   end

   if player.Class1 == CLASS_WARRIOR then
      local target = player:getTarget()
      if target and target.Casting then
         -- Look up Shout skill
         if ShoutIndex == nil then -- So it only does it once
            for k,v in pairs(settings.profile.skills) do
               if v.Name == "WARRIOR_SHOUT" then ShoutIndex = k break end
            end
         end
         
         -- Check cooldown
         local cd = deltaTime(getTime(), settings.profile.skills[ShoutIndex].LastCastTime)/1000
         if cd > 120 then
            player:cast("WARRIOR_SHOUT")
         else
            player:cast("WARRIOR_TERROR")
         end
      end
   end
   </onPreSkillCast>
I've used the same format previous with a few changes but I am getting an error saying 'TERROR' is not in the database.

Re: Interrupting casts

Posted: Thu Aug 25, 2011 7:03 pm
by lisa
do you mean
WARRIOR_TERRORIZE
which is the skill in database.

Re: Interrupting casts

Posted: Thu Aug 25, 2011 7:30 pm
by Dsanchez
lisa wrote:do you mean
WARRIOR_TERRORIZE
which is the skill in database.
I'll give this a try, the actual skill name in my spellbook says "Terror".


Thanks

Re: Interrupting casts

Posted: Thu Aug 25, 2011 7:34 pm
by Mushroomstamp
Dsanchez wrote:Now I'd like to add interrupts for my warrior. I'm choosing Shout and Terror since Thunder requires a 1h weapon (would it be possible to use Thunder instead if I had a 1h weapon equipped?).

Code: Select all

         -- Check cooldown
         local cd = deltaTime(getTime(), settings.profile.skills[ShoutIndex].LastCastTime)/1000
         if cd > 120 then
            player:cast("WARRIOR_SHOUT")
         elseif not inventory.EquipSlots[17].Empty then
            player:cast("WARRIOR_THUNDER")
         else
            player:cast("WARRIOR_TERROR")
         end
      end
   end
   </onPreSkillCast>
I've used the same format previous with a few changes but I am getting an error saying 'TERROR' is not in the database.
With this code, Thunder will cast if there is something in the offhand, (as there should be, if you're using a 1-H weapon). Also, I would probably check the cooldown on all of them, not only the first in line, I hate seeing the skill called in MM, then the error message in the game that the skill is on CD.
lisa wrote:do you mean
WARRIOR_TERRORIZE
which is the skill in database.
He's right, it's WARRIOR_TERROR, and no, it's not in the database... I thought I had posted before asking for it to be added, but perhaps not. I manually added it a long time ago and have just continued to update it.

Code: Select all

	<skill name="WARRIOR_TERROR" id="490142" rage="30" range="90" cooldown="45" type="damage" target="enemy" />	

Re: Interrupting casts

Posted: Thu Aug 25, 2011 7:38 pm
by lisa
This is in database

Code: Select all

<skill name="WARRIOR_TERRORIZE" id="490142" rage="30" range="90" cooldown="45" type="damage" target="enemy" />

Re: Interrupting casts

Posted: Thu Aug 25, 2011 8:09 pm
by Mushroomstamp
Yes it is, and everything is right except for the name, which should be Terror... skilltab 4, skill 13.

Re: Interrupting casts

Posted: Thu Aug 25, 2011 9:44 pm
by lisa
It was probably just a different name from different language, no idea.
Not sure who added the skill to database.

Re: Interrupting casts

Posted: Fri Aug 26, 2011 5:58 am
by rock5
Maybe the name changed at some stage.