Page 1 of 1

Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 7:38 am
by iam_clint
player.lua new function

Code: Select all

function CPlayer:petHeal()
	if ( settings.profile.options.PET_HEAL ) then
		self:update();
		while ((self.petHP/self.petMaxHP*100) < settings.profile.options.PET_HEAL_PCT) do
			cprintf(cli.yellow, "Pet heal! Pet Health [%i/%i]\n", self.petHP, self.petMaxHP);
			self:update();	
			keyboardPress( settings.hotkeys.TARGET_PET.key );
			yrest(50);
			keyboardRelease(settings.hotkeys.MOVE_FORWARD.key);
			keyboardPress( key[settings.profile.options.PET_HEAL_KEY] );
			yrest(4000);
		end;
	end;
end
Mod checkPotions function -- Figured this would be a good place to heal

Code: Select all

function CPlayer:checkPotions()

	self:petHeal();

player.lua, everywhere you see

Code: Select all

target.TargetPtr ~= self.Address
change to

Code: Select all

and target.TargetPtr ~= self.PetPtr
result

Code: Select all

target.TargetPtr ~= self.Address and target.TargetPtr ~= self.PetPtr
check_aggro_before_cast mod

Code: Select all

if( target.TargetPtr == self.Address or target.TargetPtr == self.PetPtr) then	-- it is the right aggressor

in moveto function -- put this directly above the other if self.battling

Code: Select all

self:update();	
		if (self.Battling and self.petTarget~=0 and self.TargetPtr==0) then --assist your pet
			cprintf(cli.yellow, "Assisting Pet\n");
			keyboardPress( settings.hotkeys.TARGET_PET.key );
			yrest(100);
			keyboardPress( settings.hotkeys.ASSIST_KEY.key );
			yrest(100);
			self:fight();
			failreason = WF_COMBAT;
			break;
		end;
modify the inside moveto

Code: Select all

if( self.Battling and self.petTarget~=0	and		-- we have aggro
	 	    self.Fighting == false  and		-- we are not coming from the fight routines (bec. as melee we should move in fight)
	 	    waypoint.Type ~= WPT_RUN  and	-- only stop if not waypoint type RUN
			waypoint.Type ~= WPT_TRAVEL and
	 	    os.difftime(os.time(), player.LastAggroTimout ) > 10 ) then		-- dont stop 10sec after last aggro wait timeout
			keyboardRelease( settings.hotkeys.MOVE_FORWARD.key );
			keyboardRelease( settings.hotkeys.ROTATE_LEFT.key );
			keyboardRelease( settings.hotkeys.ROTATE_RIGHT.key );
			success = false;
			failreason = WF_COMBAT;
			break;
		end;
in update

Code: Select all

self.petTarget =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnTargetPtr_offset), language[41]);

Code: Select all

self.PetPtr = debugAssert(memoryReadInt(getProc(), self.Address + addresses.pawnPetPtr_offset), language[41]);
self.petHP =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnHP_offset), language[41]);
self.petMaxHP =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnMaxHP_offset), language[41]);
self.petTarget =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnTargetPtr_offset), language[41]);


pawn.lua define these variable in the cpawn class

Code: Select all

self.PetPtr = 0;
self.petHP = 0;
self.petMaxHP = 0;
cpawn update

Code: Select all

	self.PetPtr = debugAssert(memoryReadInt(proc, self.Address + addresses.pawnPetPtr_offset), memerrmsg);
	self.petTarget = debugAssert(memoryReadInt(proc, self.Address + addresses.pawnTargetPtr_offset), memerrmsg);
	self.petHP =  debugAssert(memoryReadInt(proc, self.PetPtr + addresses.pawnHP_offset), memerrmsg);
	self.petMaxHP =  debugAssert(memoryReadInt(proc, self.PetPtr + addresses.pawnMaxHP_offset), memerrmsg);

settings.lua hotkeys

Code: Select all

	ASSIST_KEY = {key = _G.key.VK_F, modifier = nil},
	TARGET_PET = {key = _G.key.VK_F2, modifier = nil}
profile options

Code: Select all

			PET_HEAL_PCT=50,
			PET_HEAL_KEY="VK_6",
			PET_HEAL = false,

Profile XML for your character

Code: Select all

		<option name="PET_HEAL"			value="true" />
		<option name="PET_HEAL_KEY"			value="VK_2" />
		<option name="PET_HEAL_PCT"			value="95" />


I believe I got all the modifications posted in here to make you assist your pet and heal your pet.

Another mod i've made myself.

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 1:24 pm
by Exempt
What are you using to open the .lua files?

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 2:44 pm
by iam_clint
i'm using notepad++

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 5:26 pm
by InadequateCoder
iam_clint wrote:i'm using notepad++
I forget where to download that from. Post a link?

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 5:28 pm
by iam_clint
InadequateCoder wrote:
iam_clint wrote:i'm using notepad++
I forget where to download that from. Post a link?
http://notepad-plus.sourceforge.net/uk/site.htm

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 8:55 pm
by InadequateCoder
Tyvm :D

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 11:17 pm
by Administrator
You'll notice that player.PetPtr and player.Pet already exist (inherited from CPawn). It would make more sense to use these instead of reimplementing them. For instance, instead of making a copy of petHP in the player class, just grab it out of the pet's class.

Code: Select all

if( self.PetPtr ) then
  if( self.Pet.HP/self.Pet.MaxHP*100 < somePercentage ) then
    -- do something
  end
end
Also, I think petHeal() could be improved. Here's some pseudo-code:

Code: Select all

if( self.PetPtr == 0 ) then
  return; -- We don't have a pet
end;

local origTarget = self.TargetPtr; -- the target we are attacking
self.TargetPtr = self.PetPtr; -- target our pet


for i,v in pairs(settings.profile.skills) do
  if( this skill is a pet heal skill ) then
    self:cast(v); -- cast it
  end
end

self.TargetPtr = origTarget; -- we're back to our original target
This would require less configuration on the users' part (as they won't have to set up specific hotkeys for the heals; they just add them to their skill list in the profile). Plus, it should be less buggy, as the target swapping is almost guaranteed to be accurate and on-time.

Re: Warden Pet [Heavy Mod]

Posted: Sun Jan 24, 2010 11:41 pm
by iam_clint
Administrator wrote:You'll notice that player.PetPtr and player.Pet already exist (inherited from CPawn). It would make more sense to use these instead of reimplementing them. For instance, instead of making a copy of petHP in the player class, just grab it out of the pet's class.

Code: Select all

if( self.PetPtr ) then
  if( self.Pet.HP/self.Pet.MaxHP*100 < somePercentage ) then
    -- do something
  end
end
Also, I think petHeal() could be improved. Here's some pseudo-code:

Code: Select all

if( self.PetPtr == 0 ) then
  return; -- We don't have a pet
end;

local origTarget = self.TargetPtr; -- the target we are attacking
self.TargetPtr = self.PetPtr; -- target our pet


for i,v in pairs(settings.profile.skills) do
  if( this skill is a pet heal skill ) then
    self:cast(v); -- cast it
  end
end

self.TargetPtr = origTarget; -- we're back to our original target
This would require less configuration on the users' part (as they won't have to set up specific hotkeys for the heals; they just add them to their skill list in the profile). Plus, it should be less buggy, as the target swapping is almost guaranteed to be accurate and on-time.

Thanks for the suggestions.. I haven't entirely been through the code i've just been adding in what i've needed figured I would post.


I tried manually changing the target pointer for myself and it didn't seem to change my target is that what you are doing here?

Code: Select all

self.TargetPtr = self.PetPtr; -- target our pet
if so thats great didn't know I could do that.


I probably should have looked through the classes before implementing my own changes but what can I say I downloaded the bot 2 days ago heh. Nice development on micromacro btw.

Re: Warden Pet [Heavy Mod]

Posted: Mon Jan 25, 2010 1:13 am
by Administrator
Actually, yeah, don't know what I was thinking there. It should be more like this:

Code: Select all

local origTarget = self.TargetPtr; -- the target we are attacking
memoryWriteInt(getProc(), self.Address + addresses.pawnTargetPtr_offset, self.PetPtr); -- target our pet

memoryWriteInt(getProc(), self.Address + addresses.pawnTargetPtr_offset, origTarget); -- target our original target

Re: Warden Pet [Heavy Mod]

Posted: Thu Aug 19, 2010 3:15 pm
by fred55555
ok So looks kind of confusing

Can anyone simplify it for me so I can add it to my character.xml

just need check pet health if it is lower than 75% then ill cast a druid recover on it, not worried about targeting the last target just want the pet healed up over 75% and move onto next mob.

pretty please and thnx

Re: Warden Pet [Heavy Mod]

Posted: Thu Aug 19, 2010 3:24 pm
by sdude13
healing another party member should also be possible that way no ?
;)

Re: Warden Pet [Heavy Mod]

Posted: Fri Aug 20, 2010 2:13 pm
by fred55555
from what i read there is not function to call or target another person builkd in.

but there is a function call for the pet to be targeted.

would like to still get a simplified syntax of

check pet health
heal with "recover" if pet hp below 75%
continue on

Re: Warden Pet [Heavy Mod]

Posted: Fri Aug 20, 2010 8:24 pm
by Valleyguy
sdude13 wrote:healing another party member should also be possible that way no ?
;)
I wish this was possible and youd think it would be a easy mod ... I just dont have a clue where to start ...

i.e. profile option "HealBot" = "true/false" (tells it if its gonna fight like normal bot or just be a healbot and only fight back the aggros on the bot (Something like what RBAssist allready does)

"HealBotName" = "playerName" of the player the bot will constantly /follow and monitor health

rest is allready there in the skills options if hppr="50" would mean if either your HP or the Targets HP falls below 50% cast the skill.

I just don't know how to add the functions for the follow and heal monitor as well as incorporating what RBAssist allready is doing with maintaining the HP monitor..

Re: Warden Pet [Heavy Mod]

Posted: Fri Aug 20, 2010 8:49 pm
by Valleyguy
another thought to start forget even fighting back just maintain a target on the character you have the healbot on monitor its HP hen low cast a heal ... .. shoudl be possible cause all the code is allready in there monitoring a targets HP for fighting just reverse it with some calls for healing ... himm brain hurts lol ...

Re: Warden Pet [Heavy Mod]

Posted: Sat Aug 21, 2010 7:42 pm
by Valleyguy
Admin:

in this code i assume hes pulling down the memory addresses to assign to the self.pet functions? this is the part i am foggy with :

Code: Select all

self.PetPtr = debugAssert(memoryReadInt(getProc(), self.Address + addresses.pawnPetPtr_offset), language[41]);
self.petHP =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnHP_offset), language[41]);
self.petMaxHP =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnMaxHP_offset), language[41]);
self.petTarget =  debugAssert(memoryReadInt(getProc(), self.PetPtr + addresses.pawnTargetPtr_offset), language[41]);
is there memory addresses to pull down (there must be cause healbot 2 and those other addons pull down HP checks on raids and party's.. ) i just dont understand how these calls are being made to add my own for party...

I think most of the work here specially the assignment of the F2 key which by default is party member 1 (he must change it in his config to target his pet... )

if i could just learn this faster heh but basically reusing most of this work to monitor party member 1 instead of a pet would make a heal-bot that assists in a 2 man team wouldn't it?

sorry I am a 3rd rate noob with basic code skills ....

Re: Warden Pet [Heavy Mod]

Posted: Mon Aug 23, 2010 8:52 am
by sdude13
fred55555 wrote:from what i read there is not function to call or target another person builkd in.

but there is a function call for the pet to be targeted.

would like to still get a simplified syntax of

check pet health
heal with "recover" if pet hp below 75%
continue on
there is a modification of the rombot assist script i found (posted by Bubi, just search for it),
which goes through all players in a group, checking if it need heal or not.

I can't get it to work, but it seems like that way it sholud work...

Re: Warden Pet [Heavy Mod]

Posted: Tue Aug 24, 2010 2:54 pm
by fred55555
So hate being a pain, but still confused.

Could someone simplify this for the warden pet.

if pet health below 75% then cast pet heal

not worrying about last target or anything just get the heal off and then continue

:)

thnx