Jump to content

Can i set the 'timer' with lua?


Ordush
 Share

Recommended Posts

Hey all! Is there any way that i can set the "timer" for an ability with lua?
Example: I want to be able to change the timer on steady shot, so it matches gun/bow/crossbow speed. Instead of having to adjust the Class Profile, i'd like to make it so you can set your speed with lua. Now this can be edited in many ways an example could be if i set the timer as a variable: timer = WeaponSpeed

Then one would be able to change the weapon speed in-game with /run WeaponSpeed = 3.5

Link to comment
Share on other sites

CS rotation only perhaps. Some kind of pseudo code ( to prevent double cast of immolate in this example )
 

public long immolate_StartTime;
public bool immolate_ResetTimer = true;
public bool immolate_CanCast = true;
public long immolate_Time = 1500;
.....
wManager.wManagerSetting.CurrentSetting.EventsLuaWithArgsWaitTime = 1;
EventsLuaWithArgs.OnEventsLuaWithArgs += (id, args) =>
{
if (id == wManager.Wow.Enums.LuaEventsId.UNIT_SPELLCAST_START)
{
if (args.Count >= 2 && args[0] == "player" && args[1] == "Immolate")
{
if (immolate_ResetTimer == true)
{
immolate_StartTime = GetTime();
immolate_ResetTimer = false;
}
}

}

if ((GetTime() - immolate_StartTime) > immolate_Time)
{
immolate_CanCast = true;
immolate_ResetTimer = true;
}
else
{
immolate_CanCast = false;
}

public long GetTime()
{
long startTick = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
return startTick;
}

In this example the immolate will be casted again only after 1500 ms ( and this is preventing to overcasting ) To check when something start and count the time to push the event again. Well. IDK :) Or maybe its not about that at all :)

Link to comment
Share on other sites

3 minutes ago, forerun said:

CS rotation only perhaps. Some kind of pseudo code ( to prevent double cast of immolate in this example )
 

public long immolate_StartTime;
public bool immolate_ResetTimer = true;
public bool immolate_CanCast = true;
public long immolate_Time = 1500;
.....
wManager.wManagerSetting.CurrentSetting.EventsLuaWithArgsWaitTime = 1;
EventsLuaWithArgs.OnEventsLuaWithArgs += (id, args) =>
{
if (id == wManager.Wow.Enums.LuaEventsId.UNIT_SPELLCAST_START)
{
if (args.Count >= 2 && args[0] == "player" && args[1] == "Immolate")
{
if (immolate_ResetTimer == true)
{
immolate_StartTime = GetTime();
immolate_ResetTimer = false;
}
}

}

if ((GetTime() - immolate_StartTime) > immolate_Time)
{
immolate_CanCast = true;
immolate_ResetTimer = true;
}
else
{
immolate_CanCast = false;
}

public long GetTime()
{
long startTick = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
return startTick;
}

In this example the immolate will be casted again only after 1500 ms ( and this is preventing to overcasting ) To check when something start and count the time to push the event again. Well. IDK :)

Thank you for the quick answer!
If i use lua script to cast my spell with SpellInfo, couldn't i in theory also use the GetTime in lua to achieve this? :)

Link to comment
Share on other sites

if vUAflag==nil then vUAflag=0 end; 
-- If we're CURRENTLY casting UA and the timestamp isn't already set...
if ({UnitCastingInfo("player")})[1]=="Unstable Affliction" and vUAts==nil then 
	-- Record that UA is being cast and record the time at which we observed the ongoing cast.
	-- Setting the flag to 1 will prevent UA from being cast again.
	vUAflag=1 vUAts=GetTime() 
end;
-- If the flag is set...but the time at which it was set was more than 2 seconds ago...
if vUAflag==1 and GetTime()-vUAts>2 then 
	-- Reset the flag and timestamp to allow UA again.
	vUAflag=0 vUAts=nil 
end

Ripped example - here you see how to cast Unstable Affliction when the time difference between start and now is > 2.

If vUaFlag=0 then cast

Link to comment
Share on other sites

6 minutes ago, forerun said:
if vUAflag==nil then vUAflag=0 end; 
-- If we're CURRENTLY casting UA and the timestamp isn't already set...
if ({UnitCastingInfo("player")})[1]=="Unstable Affliction" and vUAts==nil then 
	-- Record that UA is being cast and record the time at which we observed the ongoing cast.
	-- Setting the flag to 1 will prevent UA from being cast again.
	vUAflag=1 vUAts=GetTime() 
end;
-- If the flag is set...but the time at which it was set was more than 2 seconds ago...
if vUAflag==1 and GetTime()-vUAts>2 then 
	-- Reset the flag and timestamp to allow UA again.
	vUAflag=0 vUAts=nil 
end

Ripped example - here you see how to cast Unstable Affliction when the time difference between start and now is > 2.

If vUaFlag=0 then cast

Perfect! Thank you so much! <3

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
 Share

×
×
  • Create New...