Page 1 of 1

Warden Pet Problems

Posted: Tue Nov 16, 2010 6:36 pm
by KiwiGuy
I've been trying to write the code to summon my warden pet and then turn on its defend and Punch ability.

This is what I have :

This section checks if there is a pet active and if not casts one. Now I want it to use the default key location binds of Ctrl 5 and Ctrl 6 to turn on defence and attack skill respectively.
This isnt working, I'm not sure if its actioning the hotkeys before the pet is fully active and this skipping over it. So I tried to make it check if pet is active before trying, but thats not working.

Also if I heal myself or my pet it doesnt seem to reaquire last target and finishes the combat and moves off to continue leaving pet to continue the fight on its own.

This isn't turning the skills on yet [Under Development]

Code: Select all

<onLoad><![CDATA[
			if( player.PetPtr == 0 or ( player.Pet.HP/player.Pet.MaxHP*100 ) < 20 ) then
				player:cast("WARDEN_SUMMON_SPIRIT_OF_THE_OAK");
				yrest(50);
			  if ( player.PetPtr == 1 ) then
				keyboardPress( key.VK_5, key.VK_CONTROL );
				yrest(50);
				keyboardPress( key.VK_6, key.VK_CONTROL );
				yrest(50);
			  end;
			end;
	]]></onLoad>
Your character will check that the pet is active after each battle : [WORKING

Code: Select all

<onLeaveCombat><![CDATA[
		if( player.PetPtr == 0 or ( player.Pet.HP/player.Pet.MaxHP*100) < 20 ) then
			player:cast("WARDEN_SUMMON_SPIRIT_OF_THE_OAK");
		end;
	]]></onLeaveCombat>
And during the fight it checks the pets and your own health and heals accordingly: [WORKING]

Code: Select all

<onSkillCast><![CDATA[
		mob = player.TargetPtr
                player:target( player.Pet );
                         if  60 > ( player.Pet.HP/player.Pet.MaxHP*100 ) then
                             player:target( player.Pet );
                             player:cast("DRUID_RECOVER")
                             yrest(3000);
                        end;
               player:target(mob)
		
		if( 65 > player.HP/player.MaxHP*100 ) then
		    player:cast("DRUID_RECOVER");
		elseif( 25 > player.HP/player.MaxHP*100 ) then
		    player:cast("DRUID_RECOVER");
		    player:cast("DRUID_RECOVER");
		end;
	]]></onSkillCast>
My code is probably really messy, as I've only started using this a few days ago and teaching myself some XML as I go :)

Re: Warden Pet Problems

Posted: Tue Nov 16, 2010 8:47 pm
by rock5
KiwiGuy wrote:

Code: Select all

<onLoad><![CDATA[
			if( player.PetPtr == 0 or ( player.Pet.HP/player.Pet.MaxHP*100 ) < 20 ) then
				player:cast("WARDEN_SUMMON_SPIRIT_OF_THE_OAK");
				yrest(50);
			  if ( player.PetPtr == 1 ) then
				keyboardPress( key.VK_5, key.VK_CONTROL );
				yrest(50);
				keyboardPress( key.VK_6, key.VK_CONTROL );
				yrest(50);
			  end;
			end;
	]]></onLoad>
I see a few problems here.
1. If the pet is already summoned and healthy then the keyboard presses won't happen. Maybe they need to be separate "if" statements?
2. Also if ctrl-5 and ctrl-6 have already been presses then pressing them will turn them off. You might need to check their status first. Although I don't like to use RoMScript when I can avoid it, this might work.

Code: Select all

icon, auto = GetPetActionInfo(5);
if not auto then
    	keyboardPress( key.VK_5, key.VK_CONTROL );
	yrest(50);
end
icon, auto = GetPetActionInfo(6);
if not auto then
    	keyboardPress( key.VK_6, key.VK_CONTROL );
	yrest(50);
end
3. player.PetPtr holds the pets address. I don't think "( player.PetPtr == 1 )" will ever be true. Did you mean "if player.PetPtr ~= 0 then"?
4. I'm not sure the modifiers are working. I recently tried "keyboardPress(key.VK_Z, key.VK_CONTROL )" to disable the user interface in response to another post but it didn't work. It only pressed Z.

Re: Warden Pet Problems

Posted: Tue Nov 16, 2010 10:27 pm
by KiwiGuy
rock5 wrote:I see a few problems here.
1. If the pet is already summoned and healthy then the keyboard presses won't happen. Maybe they need to be separate "if" statements?
2. Also if ctrl-5 and ctrl-6 have already been presses then pressing them will turn them off. You might need to check their status first. Although I don't like to use RoMScript when I can avoid it, this might work.

Code: Select all

icon, auto = GetPetActionInfo(5);
if not auto then
    	keyboardPress( key.VK_5, key.VK_CONTROL );
	yrest(50);
end
icon, auto = GetPetActionInfo(6);
if not auto then
    	keyboardPress( key.VK_6, key.VK_CONTROL );
	yrest(50);
end
3. player.PetPtr holds the pets address. I don't think "( player.PetPtr == 1 )" will ever be true. Did you mean "if player.PetPtr ~= 0 then"?
4. I'm not sure the modifiers are working. I recently tried "keyboardPress(key.VK_Z, key.VK_CONTROL )" to disable the user interface in response to another post but it didn't work. It only pressed Z.
Thank you your idea had merits and it pushed me in a new direction, however I believe after trying for a bit that the GetPet is for actual pets not summons as the GetPetActionInfo(6) is returning a nil value.

However I've used your help and created :

Code: Select all

mob = player.TargetPtr
	player:target( player.Pet );
		if  60 > ( player.Pet.HP/player.Pet.MaxHP*100 ) then
			player:target( player.Pet );
			player:cast("DRUID_RECOVER")
			yrest(3000);
		end;
	player:target(mob)
This is now successfully, switching to my summon and healnig it and then flicking back the mob. I still cannot get it to turn on the abilities, so I'm going to see if an ingame script can be written for now and just use it once after summons, to avoid turning the abilities off.

Re: Warden Pet Problems

Posted: Wed Nov 17, 2010 1:40 am
by rock5
Oops. GetPetActionInfo is an in game function so we need to use RoMScript. The funny thing is I commented that I didn't like using RoMScipt then I forgot to add it. lol

This should work.

Code: Select all

icon, auto = RoMScript("GetPetActionInfo(5)")
if not auto then
       keyboardPress( key.VK_5, key.VK_CONTROL );
   yrest(50);
end
icon, auto = RoMScript("GetPetActionInfo(6)")
if not auto then
       keyboardPress( key.VK_6, key.VK_CONTROL );
   yrest(50);
end

Re: Warden Pet Problems

Posted: Sat Dec 18, 2010 9:15 am
by JackBlonder

Code: Select all

player.PetPtr == 0
doesn't work for me as the pointer has an adress although the pet is not summoned.
Is there any player.pet.summoned or some other ideas?

By the way, to activate auto mode for summoner skills you have to rightclick not to press CTRL+x