Need help with a script

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
kenzu38
Posts: 279
Joined: Sun Dec 02, 2012 8:52 am

Need help with a script

#1 Post by kenzu38 » Wed Dec 19, 2012 3:45 pm

Hi guyz, I'm here again asking for help haha.

Well, I want to modify a script I found here in the forums. I'd like it to check for cooldown of a transport spell and then decide what to do based on the returned value. So if the remaining time is more than 10 minutes, I'd like it to load a waypoint, else I'd like it to just wait and use the spell when it is available.

I found one of lisa's posted code that I think can be the foundation of this script. I just don't know how to proceed from there. Here's the code btw:

Code: Select all

local cooldown, remaining = sendMacro("GetSkillCooldown(1,2);")
if remaining > 1 then
printf("skill on cooldown\n") -- skills on cooldown
else
RoMScript('CastSpellByName("Heffner Camp Transport Spell")') -- use teleport
end
So based on this code, I think the macro returns value in minutes? If so, I think the script should go something like this:

Code: Select all

local cooldown, remaining = sendMacro("GetSkillCooldown(1,2);")
if remaining > 10 then
printf("skill on cooldown\n") -- skills on cooldown
loadPaths("waypointfile")
else
local y = ((remaining+1)*60000)
yrest(y)
RoMScript('CastSpellByName("Heffner Camp Transport Spell")') -- use teleport
end
I'm not even sure if you can put a variable to yrest hehe. But I think I got the right idea here, just don't know the correct syntax.

So can someone help me with this? Thanks.

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Need help with a script

#2 Post by BillDoorNZ » Wed Dec 19, 2012 5:19 pm

http://www.theromwiki.com/API:GetSkillCooldown

Based on that, I'd say that the value returned is the SECONDS not the minutes - given a lot of skills don't have massive cooldowns, minutes would be useless. It may even be milliseconds - not sure tho, you'd have to test it.

You could do something like:

Code: Select all

local cooldown, remaining = sendMacro("GetSkillCooldown(1,2);")
if remaining > 10 then
	printf("skill on cooldown\n") -- skills on cooldown
	loadPaths("waypointfile")
else
	repeat
		yrest(500);
		cooldown, remaining = sendMacro("GetSkillCooldown(1,2);")
	until (1 > remaining)
	RoMScript('CastSpellByName("Heffner Camp Transport Spell")') -- use teleport
end

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Need help with a script

#3 Post by lisa » Wed Dec 19, 2012 6:40 pm

the remaining is in seconds.

Code: Select all

if remaining > 10*60 then -- 10 minutes or did you want it to be 10 seconds??

local y = ((remaining+1)*1000)
with that change it should work, Bill's code would work aswell but it would be doing a macro every half a second for the entire time until the skill is off cooldown.
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

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Need help with a script

#4 Post by BillDoorNZ » Wed Dec 19, 2012 8:50 pm

I'm an habitual 'just-in-case'er :)

kenzu38
Posts: 279
Joined: Sun Dec 02, 2012 8:52 am

Re: Need help with a script

#5 Post by kenzu38 » Wed Dec 19, 2012 9:19 pm

Thanks for that link, Bill. It wasn't really stated there clearly if it is in seconds but from the example the site gave, it seems likely that the returned value is in seconds.

Anyway, Lisa didn't say anything about the yrest(y) syntax, so I assume it's valid?

So my code will now look like this:

Code: Select all

local cooldown, remaining = sendMacro("GetSkillCooldown(1,2);")
if remaining > 600 then
printf("skill on cooldown\n") -- skills on cooldown
loadPaths("waypointfile")
else
local y = remaining
yrest(y)
RoMScript('CastSpellByName("Heffner Camp Transport Spell")') -- use teleport
end
I will test this later and let you guyz know if I encounter some prblems.

Thanks btw for helping me out guyz. Cheers!

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: Need help with a script

#6 Post by Jandrana » Thu Dec 20, 2012 5:18 am

I made a function that will give you the cooldown for a named transport skill. I found this usefull, because the GetSkillCooldown requires an index into the skill book page and depending on the learned skills, this index changes for the transport skill. So if one char did learn mining and another char did not learn mining you can't use the same index.

Code: Select all

        -- returns the max cooldown and remaining cooldown for a transport skill (in seconds)
        -- if a named transport skill is not available for this char cooldown will stay nil
        function GetSkillCoolDownTransport(skillName)
           local cooldown, remaining;
           for i=1,20 do 
           local name, _, icon, _, rank, type, upgradeCost, isSkillable, isAvailable = RoMScript("GetSkillDetail(1,"..tostring(i)..")");
             if name and string.find(name,skillName) ~= nil then 
                cooldown, remaining = RoMScript("GetSkillCooldown(1,"..tostring(i)..")");
             end
           end
           return cooldown, remaining
        end        

        transport = "Transport: Valley of Preparation"; -- change to appropriate transport skill 
        local cooldown, remaining = GetSkillCoolDownTransport(transport);
        if remaining == 0 then
            RoMScript("CastSpellByName(..transport..)");
        end

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Need help with a script

#7 Post by lisa » Thu Dec 20, 2012 5:24 am

thanks for sharing.
Jandrana wrote:I found this usefull, because the GetSkillCooldown requires an index into the skill book page and depending on the learned skills, this index changes for the transport skill. So if one char did learn mining and another char did not learn mining you can't use the same index.
the transport cooldown is shared with recall and recall is always at 1,2 so just doing the cooldown for recall is all that is required for any transport skill =)
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

kenzu38
Posts: 279
Joined: Sun Dec 02, 2012 8:52 am

Re: Need help with a script

#8 Post by kenzu38 » Thu Dec 20, 2012 5:27 am

Haha lisa beat me to it. I was gonna say the same thing. But thanks for posting that code, I think I can use that with other skills.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Need help with a script

#9 Post by rock5 » Thu Dec 20, 2012 6:14 am

You can also do

Code: Select all

local skill = FindSkillBookSkill(nameorid)
local cooldown, remaining = RoMScript("GetSkillCooldown("..skill.skilltab..","..skill.skillnum..")")
But like Lisa said, it's not necessary with transport skills because they all share a cooldown with Recall and Recall is always 1,2.
  • 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

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: Need help with a script

#10 Post by Jandrana » Thu Dec 20, 2012 6:51 am

Ok, then we can keep it for the unlikely situation, that one day the cooldown of the two skills will be different ;-)

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Need help with a script

#11 Post by rock5 » Thu Dec 20, 2012 7:00 am

Well I mentioned it because it could be used for any other skill and kenzu38 mentioned "other skills", although maybe he meant "other transport skills" in which case my post wont be of help. I doubt the transport cooldowns will ever change.
  • 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

kenzu38
Posts: 279
Joined: Sun Dec 02, 2012 8:52 am

Re: Need help with a script

#12 Post by kenzu38 » Thu Dec 20, 2012 9:43 am

Wow, maintenance is sure taking long today. Just when I have a lot of codes I wanna try.

And yeah, by other skills, I meant some offensive ones with long cooldown, I can think of some use for these codes in PVP.

Thanks again guyz for posting those codes.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 23 guests