need assistance with my healerhelper script

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

need assistance with my healerhelper script

#1 Post by noobbotter » Thu Aug 13, 2015 7:42 am

Hi everyone. I was creating a custom healer function to use when farming easy mode bosses. I would run this script on my healer and it does a real good job of following the payer I'm playing manually and keeping us both healed (I didn't use the default party healer script because I also use this in other areas when we're not necessarily in a party together, and also because I wanted to change the distance at which the healer follows). I plan to make a different copy of this for different instances and customizing each for that specific instance requirements (such as if need serenstum before boss fight or at certain boss HP percentages).

The problem I'm faced with right now is when after I kill the boss if I decide to run out of instance to come back in (farming it). I run my DPS char out of instance and of course now my healer doesn't see him so he stops. I don't have a problem alt tabbing to manually move the healer out of instance and back in, but the script always errors out when I do so. I'm assuming it's because the healer's address changes after porting out? What would you suggest for how to fix that?

I just thought about the possibility of adding a part in the spot where when party member (calling it that, though not always in a party) is not found to check for a nearby portal and if there is one, to go through it. I wonder if that would fix the problem?

Here's my script in case anyone wants to dissect it to help me figure out how to fix it.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
--=============== My follow/heal member Script ====================
--===============================================================
--================================================================

<onLoad><![CDATA[
	loadProfile("myhealerprofile")
	whoToFollow = "toonnametofollow" --changed to protect the innocent
	--============ Disable skills and enable Healing ====================
	
	for k,v in pairs(settings.profile.skills) do
		v.AutoUse = false
	end
	useMySkills = false
	
	settings.profile.options.LOOT = false
	settings.profile.options.LOOT_ALL = false
	settings.profile.options.EGGPET_ENABLE_ASSIST = true
		
	speed()

	function toggleSkills(status)	-- toggleSkills is to be called when the healer running this script needs to enable or disable certain skills (when player being followed dies or gets revived)
		if player.Class1 == CLASS_PRIEST then
			if status == false	then 	-- if status == false this means called the command to disable skills
				if useMySkills == true then		--useMySkills is basically the current status of the skills: true = enabled, false = disabled
					changeProfileSkill("PRIEST_URGENT_HEAL" , "AutoUse", false)
					changeProfileSkill("PRIEST_ICEWIND_BLADE" , "AutoUse", false)
					changeProfileSkill("MAGE_FIREBALL" , "AutoUse", false)
					changeProfileSkill("MAGE_LIGHTNING" , "AutoUse", false)
					changeProfileSkill("MAGE_SILENCE" , "AutoUse", false)
					useMySkills = false
				end		
			else	-- want to turn skills on so if they are currently disabled, enable them
				if useMySkills == false then
					changeProfileSkill("PRIEST_URGENT_HEAL" , "AutoUse", true)
					changeProfileSkill("PRIEST_ICEWIND_BLADE" , "AutoUse", true)
					changeProfileSkill("MAGE_FIREBALL" , "AutoUse", true)
					changeProfileSkill("MAGE_LIGHTNING" , "AutoUse", true)
					changeProfileSkill("MAGE_SILENCE" , "AutoUse", true)
					useMySkills = true
				end
			end
		elseif player.Class1 == CLASS_MAGE then -- same as above except this is if mage class is primary (priest class secondary)
			if status == false	then
				if useMySkills == true then
					changeProfileSkill("PRIEST_URGENT_HEAL" , "AutoUse", false)
					changeProfileSkill("MAGE_FLAME" , "AutoUse", false)
					changeProfileSkill("MAGE_FIREBALL" , "AutoUse", false)
					changeProfileSkill("MAGE_LIGHTNING" , "AutoUse", false)
					changeProfileSkill("MAGE_PURGATORY_FIRE" , "AutoUse", false)
					changeProfileSkill("MAGE_SILENCE" , "AutoUse", false)
					changeProfileSkill("MAGE_INTENSIFICATION" , "AutoUse", false)
					changeProfileSkill("MAGE_ELEMENTAL_CATALYSIS" , "AutoUse", false)
					useMySkills = false
				end		
			else
				if useMySkills == false then
					changeProfileSkill("PRIEST_URGENT_HEAL" , "AutoUse", true)
					changeProfileSkill("MAGE_FLAME" , "AutoUse", true)
					changeProfileSkill("MAGE_FIREBALL" , "AutoUse", true)
					changeProfileSkill("MAGE_LIGHTNING" , "AutoUse", true)
					changeProfileSkill("MAGE_PURGATORY_FIRE" , "AutoUse", true)
					changeProfileSkill("MAGE_SILENCE" , "AutoUse", true)
					changeProfileSkill("MAGE_INTENSIFICATION" , "AutoUse", true)
					changeProfileSkill("MAGE_ELEMENTAL_CATALYSIS" , "AutoUse", true)
					useMySkills = true
				end
			end
		end
	end
	
	function findFriend(friendName)
		localfriend = player:findNearestNameOrId(friendName)
		if not localfriend then
			-- my new section for when party member not found:
			repeat
				localfrienddistance = 1000
				localfriend = player:findNearestNameOrId(friendName)
				yrest(500)
				if localfriend then
					localfriend = CPawn(localfriend.Address)
					localfrienddistance = distance(localfriend.X,localfriend.Z,player.X,player.Z)
				end
			until localfriend and 999 > localfrienddistance 
			
			--==================================================
		else
			localfriend = CPawn(localfriend.Address)
		end
		return true
	end
	
	
	
	-- updated custom follow function:
	function hb_getNameFollow()
		player:updateXYZ()
		local whofollow
		whofollow = player:findNearestNameOrId(whoToFollow)
		if not whofollow then
			-- my new section for when party member not found:
			repeat		-- going to repeat this loop until party member is found and is relatively close by (less than 1000)
				whofollowdistance = 1000
				whofollow = player:findNearestNameOrId(whoToFollow)
				yrest(500)
				if whofollow then
					whofollow = CPawn(whofollow.Address)
					whofollowdistance = distance(whofollow.X,whofollow.Z,player.X,player.Z)
				end
			until whofollow and 999 > whofollowdistance 
			
			--==================================================
		else 	-- this runs if party member is found:
			whofollow = CPawn(whofollow.Address)
		end
		if whofollow then
			if distance(whofollow.X,whofollow.Z,player.X,player.Z) > 225 then		-- this is the follow function. seems to work well... stay way back from party member but within heal range.
				player:moveTo(CWaypoint(whofollow.X,whofollow.Z),true,nil,200)
			end
			-- player:target(whofollow)
			-- RoMCode("FollowUnit('target');"); -- disabled these lines. the in-game follow follows too close for my comfort (Boss AOE hits healer)
			-- Mount()
			local mounted = whofollow.Mounted
			printf("mounted = %s\n",mounted)
			--mounted = bitAnd(attackableFlag, 0x10000000)
			if not player.Mounted then
				if mounted then
					player:mount()
				end
			end
			if not mounted then
				if player.Mounted then
					player:dismount()
				end
			end
			
		end
	end
	
		
	--============= main routine starting: =====================
	while(true) do
		useGoodie("Casting")
		if findFriend(whoToFollow) then
			char = CPawn(player:findNearestNameOrId(whoToFollow).Address)
			char:updateHP()			-- char is always the person I'm following
			char:updateAlive()
			player:updateHP()		-- player is the healer running this script
			player:updateAlive()
			charHPpct = (char.HP/char.MaxHP*100)
			playerHPpct = (player.HP/player.MaxHP*100)
			if player:isAlive() then
				if char:isAlive() then -- if party member is alive:
					toggleSkills(false)			
					if playerHPpct >= 98 and charHPpct >= 98 then
						yrest(50)
					elseif playerHPpct > charHPpct then 	-- if healer has more hp% than party member, heal party member first
						if 30 > charHPpct then	-- had this line because was going to use soul source but disabled it for now
							--player:cast("PRIEST_SOUL_SOURCE");
							player:target(char)
							player:cast("PRIEST_HEAL");
						elseif 60 > charHPpct then
							player:target(char)
							player:cast("PRIEST_HEAL");
						elseif 98 > charHPpct then
							player:target(char)
							player:cast("PRIEST_URGENT_HEAL");
						elseif 60 > playerHPpct then		
							player:target(player)
							player:cast("PRIEST_HEAL");
						elseif 98 > playerHPpct then
							player:target(player)
							player:cast("PRIEST_URGENT_HEAL");
						end
					elseif charHPpct >= playerHPpct then  	-- if healer has fewer HP, heal self first
						if 30 > playerHPpct then
							player:cast("PRIEST_SOUL_SOURCE");
							player:target(player)
							player:cast("PRIEST_HEAL");
						elseif 60 > playerHPpct then
							player:target(player)
							player:cast("PRIEST_HEAL");
						elseif 98 > playerHPpct then
							player:target(player)
							player:cast("PRIEST_URGENT_HEAL");
						elseif 60 > charHPpct then
							player:target(char)
							player:cast("PRIEST_HEAL");
						elseif 98 > charHPpct then
							player:target(char)
							player:cast("PRIEST_URGENT_HEAL");
						end
					end
					hb_getNameFollow() -- run command to make sure I'm following party member
				else 	-- party member is not alive... enable skills buff self, heal and fight
					toggleSkills(true)
					repeat
						if not player:hasBuff(500527) then
							player:cast("PRIEST_HEALING_SALVE");
						end	
						if 30 > playerHPpct then -- if low on HP, first save self
							player:cast("PRIEST_HOLY_AURA");
							useGoodie("casting")
							player:cast("PRIEST_URGENT_HEAL");
						elseif 75 > playerHPpct then -- if low on HP, first save self
							useGoodie("casting")
							player:cast("PRIEST_URGENT_HEAL");
						else					-- once my HP is high enough, increase casting speed and then burn target with flame.
							player:findTarget()
							player:fight()
						end
					until not player:isAlive() or player.Battling == false
					
				end
				
				
				yrest(50)
			else
				sleep() -- if healer dies, script goes to sleep
			end
		end
		
	end
]]></onLoad>
</waypoints>

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: need assistance with my healerhelper script

#2 Post by Bill D Cat » Thu Aug 13, 2015 8:24 am

I'm at work right now, so I can't really help with specific code. But the idea I had was to have the bot listen for specific party/whisper commands from your manual character. You could send a command to leave the instance when you are done with the run, and another to enter the instance when you are starting the next one. Should be easy enough to target the nearest portal with the bot and enter/leave. Then you'd just have to make a macro on your manual character so you could send those messages.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: need assistance with my healerhelper script

#3 Post by beanybabe » Thu Aug 13, 2015 9:14 am

is there a way to monitor for the address change then do a player update?

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: need assistance with my healerhelper script

#4 Post by noobbotter » Thu Aug 13, 2015 9:19 am

yeah i thought of that (adding a listener and using a macro to tell it to go through portal) but didn't really want to have an active listener. Maybe I'll try it where if it doesn't see the other character, it just goes through the nearest portal. That might work for my needs. Also, just in the case of a game crash, i could 1: limit the portal distance, and 2: after going through the portal, if player still not found, go to sleep.

beanybabe, not sure but that sounds like it would be the easiest solution. But if I can implement what I mentioned above, it will remove my requirement for doing any Alt+Tabbing.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: need assistance with my healerhelper script

#5 Post by beanybabe » Thu Aug 13, 2015 10:55 am

I don't have a leveled up healer to try this kind of coding. I have read follower code others have created. It has intrigued me and I often thought of working on a script to have few alts follow and be able to break away on there own for short times to fight then drop back into follow.
Like you the follow distance bothered me. I often thought of using a separate wp for the followers with notification points they move to on a signal from the main. The only instances I have coded was gobs and nom and they are a work in progress. The main even though you play it manual, could have a bit of code monitoring its movements then send path points to the alts.

Nom I gave up on as portal problems in the bot at that time made it unstable but those seem to work well now I may revise it..

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

Re: need assistance with my healerhelper script

#6 Post by lisa » Thu Aug 13, 2015 8:51 pm

pretty much every question you have is done in party.lua, I'm not saying you need to use party bot I am saying the code exists for what you want.

To look for if the address has changed and do an update.

Code: Select all

		local address = memoryReadRepeat("uintptr", getProc(), addresses.staticbase_char, addresses.charPtr_offset)
		if address ~= player.Address then
			player:update()
		end

The function partyCommands() already looks for things in party chat, you can just add the function call to your code and it will react in the same way party bot does.
com"portal"
if you type that in party chat it will tell the following bot to go through portal, this required rocks userfunction GoThroughPortal.

I think that answers the questions/problems you posted, like I said though have a browse through party.lua because there is a good chance any issue you may come up against has already been dealt with =)
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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest