Jump to content

C_Timer.After Equivalent


Recommended Posts

Hi all,

In TBC a Hunter's disengage didn't do what it does now, so it can't be used to create distance between the hunter and a mob in melee range.

Instead I'm currently using a MoveBackwardStart() and MoveBackwardStop() function in my FightClass. However, this looks really choppy as it executes a 1 frame key press repeatedly, I want it to move backward smoothly to make it less obvious I'm botting, but the C_Timer.After function didn't exist in TBC.

So I can't do;

MoveBackwardStart() C_Timer.After(200, function() MoveBackwardStop() end)

So, how can I have my FightClass stop moving backward on a timer?

Thanks.

Link to comment
Share on other sites

<?xml version="1.0" encoding="utf-16"?>
<FightClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <FightClassGeneralSettings>
    <FightClassName>BM Hunter 2.4.3</FightClassName>
    <Range>35</Range>
    <Pet>true</Pet>
    <PetCallSpellName>Call Pet</PetCallSpellName>
    <FramePerSecond>60</FramePerSecond>
  </FightClassGeneralSettings>
  <FightClassSpells>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>MeInCombat</ContionType>
          <Param xsi:type="FightClassConditionBool" />
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool" />
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>DistanceMeToPet</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>10</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>if GetPetHappiness() == 3 then DEFAULT_CHAT_FRAME:AddMessage("Pet Happy - Don't Feed") else RunMacroText("/cast Feed Pet"); RunMacroText("/use Clefthoof Ribs") end</SpellName>
      <Priority>10</Priority>
      <CombatOnly>false</CombatOnly>
      <CheckIfKnow>false</CheckIfKnow>
      <CheckSpellDistance>false</CheckSpellDistance>
      <AddToSettings>true</AddToSettings>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <Timer>120000</Timer>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
      <CanMoveDuringCast>Yes</CanMoveDuringCast>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>PetHealthPercent</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>70</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>Mend Pet</SpellName>
      <Priority>9</Priority>
      <IsBuff>true</IsBuff>
      <CombatOnly>false</CombatOnly>
      <Timer>15100</Timer>
      <CastOn>pet</CastOn>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions />
      <SpellName>Aspect of the Hawk</SpellName>
      <Priority>8</Priority>
      <IsBuff>true</IsBuff>
      <CombatOnly>false</CombatOnly>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetHealthPercent</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>BiggerOrEqual</Type>
            <Value>1</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetIsPlayer</ContionType>
          <Param xsi:type="FightClassConditionBool" />
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>Smaller</Type>
            <Value>100</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>Bigger</Type>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>RunMacroText('/startattack') RunMacroText("/cast Hunter's Mark") RunMacroText('/petattack') UIErrorsFrame:Clear();</SpellName>
      <Priority>7</Priority>
      <CombatOnly>false</CombatOnly>
      <CheckSpellDistance>false</CheckSpellDistance>
      <CheckIfView>false</CheckIfView>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
      <OncePerTarget>true</OncePerTarget>
      <WaitDuringCasting>false</WaitDuringCasting>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetTargetingMe</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>IsSpellUsable</ContionType>
          <Param xsi:type="FightClassConditionStringBool">
            <Name>27047</Name>
            <Need>true</Need>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>DistancePetToTarget</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>5</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>CastSpell(7,'pet') UIErrorsFrame:Clear();</SpellName>
      <Priority>6</Priority>
      <CheckIfSpellUsable>false</CheckIfSpellUsable>
      <CheckIfView>false</CheckIfView>
      <AddToSettings>true</AddToSettings>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
      <DescriptionSpell>Use Taunt Logic (Turn Off Taunt Auto-Cast Ingame)</DescriptionSpell>
      <WaitDuringCasting>false</WaitDuringCasting>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>DistancePetToTarget</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>45</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>Kill Command</SpellName>
      <WaitDuringCasting>false</WaitDuringCasting>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>12</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetTargetingMyPet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>DistanceMeToPet</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>12</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>local waitTable = {}; local waitFrame = nil; function WaitToCall(delay, func, ...) if(type(delay)~="number" or type(func)~="function") then return false; end if(waitFrame == nil) then waitFrame = CreateFrame("Frame","WaitFrame", UIParent); waitFrame:SetScript("onUpdate",function (self,elapse) local count = #waitTable; local i = 1; while(i&lt;=count) do local waitRecord = tremove(waitTable,i); local d = tremove(waitRecord,1); local f = tremove(waitRecord,1); local p = tremove(waitRecord,1); if(d&gt;elapse) then tinsert(waitTable,i,{d-elapse,f,p}); i = i + 1; else count = count - 1; f(unpack(p)); end end end); end tinsert(waitTable,{delay,func,{...}}); return true; end MoveBackwardStart() WaitToCall(2, function() MoveBackwardStop() end)</SpellName>
      <Priority>4</Priority>
      <AddToSettings>true</AddToSettings>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <Timer>2</Timer>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
      <DescriptionSpell>Create Distance if Target in Melee Range</DescriptionSpell>
      <WaitDuringCasting>false</WaitDuringCasting>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HavePet</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>BiggerOrEqual</Type>
            <Value>12</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>DistanceMeToPet</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>BiggerOrEqual</Type>
            <Value>12</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>UnitAttackPlayerNear</ContionType>
          <Param xsi:type="FightClassConditionUnitNear">
            <Number>1</Number>
            <Type>BiggerOrEqual</Type>
            <Radius>10</Radius>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>IsSpellUsable</ContionType>
          <Param xsi:type="FightClassConditionStringBool">
            <Name>Freezing Trap</Name>
            <Need>true</Need>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>RunMacroText("/Cast Freezing Trap") UIErrorsFrame:Clear();</SpellName>
      <Priority>3</Priority>
      <CheckIfKnow>false</CheckIfKnow>
      <CheckSpellDistance>false</CheckSpellDistance>
      <CheckIfView>false</CheckIfView>
      <AddToSettings>true</AddToSettings>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
      <DescriptionSpell>Cast Freezing Trap if &gt;1 Hostile Unit in Melee Range</DescriptionSpell>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>GlobalCooldownEnabled</ContionType>
          <Param xsi:type="FightClassConditionBool" />
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>GlobalCooldownTimeLeft</ContionType>
          <Param xsi:type="FightClassConditionNumber" />
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>BiggerOrEqual</Type>
            <Value>6</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>35</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>MeInCombat</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>Arcane Shot</SpellName>
      <Priority>2</Priority>
      <AddToSettings>true</AddToSettings>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <Timer>100</Timer>
    </FightClassSpell>
    <FightClassSpell>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>TargetDistance</ContionType>
          <Param xsi:type="FightClassConditionNumber">
            <Type>SmallerOrEqual</Type>
            <Value>35</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>HaveTarget</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
        <FightClassCondition>
          <ContionType>MeInCombat</ContionType>
          <Param xsi:type="FightClassConditionBool">
            <Value>true</Value>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <SpellName>RunMacroText("/startattack") UIErrorsFrame:Clear();</SpellName>
      <Priority>1</Priority>
      <AddToSettings>true</AddToSettings>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <Timer>200</Timer>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
    </FightClassSpell>
  </FightClassSpells>
</FightClass>

 

Link to comment
Share on other sites

  • 11 months later...
-- backport C_Timer from WoD to 5.4.8
C_Timer = CreateFrame("Frame", "C_Timer")
C_Timer.schedule = {}
C_Timer:SetScript("OnUpdate", function(self, elapsed)
	for timestamp,callback in pairs(self.schedule) do
		if timestamp <= GetTime() then
			callback()
			self.schedule[timestamp] = nil
		end
	end
end)

C_Timer.After = function(duration, callback)
	C_Timer.schedule[GetTime() + duration] = callback
end

 

Link to comment
Share on other sites

  • 1 month later...

Can someone please TEACH me how to do this timer thing for hunter to move from target a certain distance??? I have no idea what to do. PLEASE someone explain in the simplest way..!

Link to comment
Share on other sites

All the info is here

You need to implement exactly what code I posted in you fightclass as Lua. Then you can use the sample code that OP posted and said he couldn't use. 

Just be aware that this will make you start backpedalling for a certain amount of time and definitely look like a bot or a retard. 

I recommend converting your existing fightclass to C# and adding movement through the movement manager. 

If you are unable to do this, you can pay someone to create a custom fightclass for you. Discord is full of people, but beware of someone scamming you. If they have never posted anything on the forums, don't trust them blindly. 

I haven't tested it, but that's basically the entirety of the code you'd need to use.

local C_Timer = CreateFrame("Frame", "C_Timer")
C_Timer.schedule = {}
C_Timer:SetScript("OnUpdate", function(self, elapsed)
	for timestamp,callback in pairs(self.schedule) do
		if timestamp <= GetTime() then
			callback()
			self.schedule[timestamp] = nil
		end
	end
end)

C_Timer.After = function(duration, callback)
	C_Timer.schedule[GetTime() + duration] = callback
end
                                
MoveBackwardStart()
C_Timer.After(800, function() MoveBackwardStop() end)

 

Link to comment
Share on other sites

8 hours ago, Matenia said:

All the info is here

You need to implement exactly what code I posted in you fightclass as Lua. Then you can use the sample code that OP posted and said he couldn't use. 

Just be aware that this will make you start backpedalling for a certain amount of time and definitely look like a bot or a retard. 

I recommend converting your existing fightclass to C# and adding movement through the movement manager. 

If you are unable to do this, you can pay someone to create a custom fightclass for you. Discord is full of people, but beware of someone scamming you. If they have never posted anything on the forums, don't trust them blindly. 

I haven't tested it, but that's basically the entirety of the code you'd need to use.


local C_Timer = CreateFrame("Frame", "C_Timer")
C_Timer.schedule = {}
C_Timer:SetScript("OnUpdate", function(self, elapsed)
	for timestamp,callback in pairs(self.schedule) do
		if timestamp <= GetTime() then
			callback()
			self.schedule[timestamp] = nil
		end
	end
end)

C_Timer.After = function(duration, callback)
	C_Timer.schedule[GetTime() + duration] = callback
end
                                
MoveBackwardStart()
C_Timer.After(800, function() MoveBackwardStop() end)

 

Ok so I copy / paste this thing inside the box where I put spell name. And make do the rest of the settings? If so, I did that, nothing seem to be executed or happening. Sorry I am noob with these things :S

Link to comment
Share on other sites

On 6/2/2016 at 4:26 AM, bael666 said:

Hi all,

In TBC a Hunter's disengage didn't do what it does now, so it can't be used to create distance between the hunter and a mob in melee range.

Instead I'm currently using a MoveBackwardStart() and MoveBackwardStop() function in my FightClass. However, this looks really choppy as it executes a 1 frame key press repeatedly, I want it to move backward smoothly to make it less obvious I'm botting, but the C_Timer.After function didn't exist in TBC.

So I can't do;

MoveBackwardStart() C_Timer.After(200, function() MoveBackwardStop() end)

So, how can I have my FightClass stop moving backward on a timer?

Thanks.

I am having this exact problem and can't figure out how to make the character to move backward smoothly.

Link to comment
Share on other sites

23 hours ago, lonellywolf said:

I am having this exact problem and can't figure out how to make the character to move backward smoothly.

I literally posted here, what OP asked for. He said he'd like to do MoveBackwardStart() C_Timer.After(200, function() MoveBackwardStop() end).
I posted everything required to call that EXACT code. The only exception being that I would stop backwardsmoving after 800 milliseconds, not 200.

 

Link to comment
Share on other sites

8 hours ago, Matenia said:

I literally posted here, what OP asked for. He said he'd like to do MoveBackwardStart() C_Timer.After(200, function() MoveBackwardStop() end).
I posted everything required to call that EXACT code. The only exception being that I would stop backwardsmoving after 800 milliseconds, not 200.

 

Hello, Thank you for your reply. I do really appreciate the efforts and the time you guys put into helping.

I used your script and yes it move backward, but my problem is that it is stuttering during that. It is as if you spam clicking backward.

Link to comment
Share on other sites

That is likely because you're calling it several times a second, instead of only once. If you use it over and over, of course it'll stutter. So use it only once. Play around with the 800ms timer instead. 

Link to comment
Share on other sites

  • 3 weeks later...
On 7/11/2017 at 11:52 PM, Matenia said:

That is likely because you're calling it several times a second, instead of only once. If you use it over and over, of course it'll stutter. So use it only once. Play around with the 800ms timer instead. 

I did try many ways, I even put timer as CD. Played around with that number, I tried 2000 and 9000, but still it stutter. It does not do one whole move all the way to desired range. I ran the code with the development tool and yes it move backward non-stop. But I think the reason it doesn't do that during combat is because the bot keeps trying to autoattack every second (the rotation of the bot) which makes it stop to do so. 

 

Sorry I am giving you all a hard time by my lack of knowledge, but I am trying :P

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...