Buffing yourself - question on some code

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
CrazyGuy
Posts: 63
Joined: Mon Mar 23, 2009 10:41 am

Buffing yourself - question on some code

#1 Post by CrazyGuy » Thu Mar 26, 2009 5:45 pm

So i was looking at the code, and wanted to know if this would work, because i wasn't sure how/where it would reset self.Buff1LastUseTime, it was just rewritten from self.PotionLastUseTime. Just modified the potion usage so that instead of checking to see if the potion timer had run out, if the timer on the buff had run out. I wasn't sure how to access the skills that are listed, so if anyone has a better way or any suggestions feel free to post them. This one was for something that would be on a set timer that would expire after x seconds.

So my main questions for this is where would i call the function so that it would buff me the first time. i tried to put in a line so when it started it just used "keyboardPress(settings.profile.hotkeys.Buff1.key);" but then every second it would try to cast the buff. Then once it casts the buff, how do you start the timer so that it starts to count down (or will this happen based on what i have). Sorry havent done much with lua, most of my experience has come from AutoIt.

In player.lua

Code: Select all

-- Check if you need to rebuff
function CPlayer:checkBuff1()
	-- Still cooling down, don't use.
	if( os.difftime(os.time(), self.Buff1LastUseTime) < settings.profile.options.Buff1_DURATION ) then
		return;
	else
		local modifier = settings.profile.hotkeys.Buff1_Duration
		if( modifier ) then keyboardHold(modifier); end
		keyboardPress(settings.profile.hotkeys.Buff1.key);
		if( modifier ) then keyboardRelease(modifier); end

	end


end
In character.xml

Code: Select all

<option name="Buff1_DURATION" value="1800" />

<hotkey name="Buff1" key="VK_0" modifier="" />
in Pawn.lua

Code: Select all

self.Buff1LastUseTime = 0;

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Buffing yourself - question on some code

#2 Post by Administrator » Thu Mar 26, 2009 5:55 pm

You can access all of the player's skills through the profile table. Here's a few examples:

Code: Select all

settings.profile.skills["MAGE_LIGHTNING"]:use(); -- cast the skill. automatically sets cooldown.
settings.profile.skills["MAGE_LIGHTNING"].LastCastTime = 0; -- force it to be cooled down.
settings.profile.skills["MAGE_LIGHTNING"].LastCastTime = os.time(); -- force it to start cooldown timer now, without actually using the skill.

if( settings.profile.skills["MAGE_LIGHTNING"]:canUse() ) then
    -- check if the skill is currently usable. code here will be called if it is.
end

CrazyGuy
Posts: 63
Joined: Mon Mar 23, 2009 10:41 am

Re: Buffing yourself - question on some code

#3 Post by CrazyGuy » Thu Mar 26, 2009 7:43 pm

Great thanks, that makes it a lot easier to figure this out.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 20 guests