party healing on the fly

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
SpiralV
Posts: 72
Joined: Sat Jun 25, 2011 10:37 am
Location: Germany

party healing on the fly

#1 Post by SpiralV » Thu Aug 18, 2011 7:19 am

I usually let my bots under the control of the wp files, but there is no real possibility to let one of them healing the party.
I've written a function as a part of party.lua and I hope it is not difficult to understand

Code: Select all

function PartyHealsEvent()
	-- return the average party health
	local function getpartyHP()
		local cupartyHP = 0
		local numPartyPawns = 0
		for i,v in ipairs(partymemberpawn) do
			v:update()
			local hp = v.HP/v.MaxHP*100
			-- cumulate partyHP
			cupartyHP = cupartyHP + hp
			numPartyPawns = numPartyPawns + 1
		end
		return cupartyHP/numPartyPawns
	end
	-- return partymemberpawn Index with the lowest health
	local function getlowestHpIndex()
		local lowestHpIndex
		for i,v in ipairs(partymemberpawn) do
			v:update()
			local lowestHp
			local hp = v.HP/v.MaxHP*100
			-- get the lowestHP index number
			if lowestHp == nil or hp < lowestHp then
				lowestHp = hp
				lowestHpIndex = i
			end
		end
		return lowestHpIndex
	end


	PartyTable()
	local saveTargetPawn = player:getTarget()
	local targetLost

	while( getpartyHP() < 95 ) do
		local lowestHpIndex = getlowestHpIndex()						
		player:target(partymemberpawn[lowestHpIndex])
		targetLost = true
		player:cast("PRIEST_URGENT_HEAL")
	end

	if targetLost then
		player:target(saveTargetPawn)
	end
end
a small correction to partymemberpawn Table because findNearestNameOrId returns nil if the party character is too far away

Code: Select all

		if GetPartyMemberName(i) then
			table.insert(partymemberName,i + 1, GetPartyMemberName(i))
			table.insert(partymemberObj,i + 1, player:findNearestNameOrId(partymemberName[i + 1]))
			if partymemberObj[i + 1] then
				table.insert(partymemberpawn,i + 1, CPawn(partymemberObj[i + 1].Address))
			end
		end
and finally calling the function

Code: Select all

	<onSkillCast><![CDATA[
		-- Additional Lua code to execute when casting a skill
		-- Note: arg1 contains the skill being used.
		-- i.e. arg1.Name will be the name of the skill being cast
		PartyHealsEvent()
	]]></onSkillCast>
It works perfectly for me :P

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

Re: party healing on the fly

#2 Post by lisa » Thu Aug 18, 2011 10:47 am

Had to read over it a few times to fully understand how it works =)

I see you want to heal party while still following a WP file instead of just following a party member, I like it =)

I am going to test the adjustment you made to partymemberpawn and see how it goes, I never had any issues with it myself but others may have I guess.

If I might add one suguestion, instead of using the

Code: Select all

player:cast("PRIEST_URGENT_HEAL")
to go with the 95 > hp you could use

Code: Select all

player:checkSkills(true);

Which will use the skills in profile and the profile settings aswell, so it can work with all priest skills and also druid skills, the "true" means friendly skills, such as heals and buffs. I notice you don't update buffs though. Since you target the player anyway it wouldn't take much to check buffs, just need to add in a

Code: Select all

 partymemberpawn[lowestHpIndex]:updateBuffs() 
So I guess it would look like this

Code: Select all

  while( 95 > getpartyHP() ) do
      local lowestHpIndex = getlowestHpIndex()                  
      player:target(partymemberpawn[lowestHpIndex])
      targetLost = true
      partymemberpawn[lowestHpIndex]:updateBuffs() 
      player:checkSkills(true)
   end
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

azzi_x
Posts: 15
Joined: Tue May 24, 2011 10:58 am

Re: party healing on the fly

#3 Post by azzi_x » Tue Aug 23, 2011 11:42 pm

hi lisa!

i tried searching for a bot script that follows me around and auto heal / buff me but no luck. wonder if u could share coz it looks like you have it. :)

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

Re: party healing on the fly

#4 Post by lisa » Wed Aug 24, 2011 12:12 am

Just to follow and heal?

just start MM with

Code: Select all

rom/bot path:partyhealer
It's part of the default bot, so you have all the code required already.

It's all explained here
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

azzi_x
Posts: 15
Joined: Tue May 24, 2011 10:58 am

Re: party healing on the fly

#5 Post by azzi_x » Wed Aug 24, 2011 4:42 am

no wonder i couldnt find that coz im still using 473. thanks a bunch!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests