Page 1 of 1
Close life bar when out the line of sight
Posted: Wed Oct 19, 2016 10:56 am
by Skinny
Hi everyone.
Anybody know how to close life bar when out the line of sight both NPC and player?
Example:
When i see the NPC (or player) life bar:

When i out the line of sight:
is there anyway to auto close life bar when out the line of sight?
I'm using the client UO 6.0.1.7.
Thanks for any help.
Re: Close life bar when out the line of sight
Posted: Wed Oct 19, 2016 3:37 pm
by Harley
+1
It will be very nice to resolve this moment..
Re: Close life bar when out the line of sight
Posted: Sun Oct 23, 2016 3:23 am
by CWO
I don't think this is possible because these bars are handled on the client side and aren't even known by the server.
Re: Close life bar when out the line of sight
Posted: Mon Nov 07, 2016 1:15 am
by Skinny
Hello.
I found a way to make this works.
Let create a packethook to check 0x1D packet.
Create a 'delete_hook' folder inside /pkg/
Example:
/pol/pkg/delete_hook/
And put this files inside folder:
Create the file: uopacket.cfg
Code: Select all
Packet 0x1D
{
Length 5
SendFunction deletehook:deletehook
}
Create the file: pkg.cfg
Create the file: deletehook.src
Code: Select all
//Close life bar when a player out the line of sight
//By Skinny/Nix 11/07/2016
//ChaosAge Shard - www.chaosage.com.br
use uo;
use polsys;
program DeleteObjectFromScene()
return 1;
endprogram
exported function deletehook(who, byref packet)
var chr := SystemFindObjectBySerial(packet.GetInt32(1));
if(!chr)
return 0;
endif
if(chr.acctname AND (Distance(who, chr) > 18))
var packet1 := CreatePacket(0xAF, 13);
packet1.SetInt32(1, chr.serial);
packet1.SetInt32(5, 0);
packet1.SetInt32(9, 0);
packet1.SendPacket(who);
var packet2 := CreatePacket(0xAF, 13);
packet2.SetInt32(1, who.serial);
packet2.SetInt32(5, 0);
packet2.SetInt32(9, 0);
packet2.SendPacket(chr);
return 1;
endif
return 0;
endfunction
Compile the src file to ecl.
This script was tested and worked!
Thanks to Nando for help me in the packet hook.
[]'s.
Re: Close life bar when out the line of sight
Posted: Mon Nov 07, 2016 11:45 pm
by Yukiko
Which client version is this working with? I am testing on version 7 and it doesn't close the health bar.
Re: Close life bar when out the line of sight
Posted: Tue Nov 08, 2016 6:22 am
by Skinny
Yukiko wrote:Which client version is this working with? I am testing on version 7 and it doesn't close the health bar.
I've tested with client version 6.0.1.7.
This script has been configured to close the health bar only players. NPCs not then configured.
If you test with a character staff, you need do unhide the character (chr.hidden := 0).
Re: Close life bar when out the line of sight
Posted: Tue Nov 08, 2016 10:07 am
by Skinny
See the test that i made and saved on Youtube:
https://youtu.be/ieiWNSbiJm0
Re: Close life bar when out the line of sight
Posted: Tue Nov 08, 2016 1:22 pm
by Skinny
I tested now with client version 7.0.53.1 and works too.
Re: Close life bar when out the line of sight
Posted: Tue Nov 08, 2016 4:15 pm
by Harley
Skinny, thank you for your decision!
I'll try and tell here.
You said that Nando helped with packets.
Tell me please some tricks with it, 'cause I don't really understand how to make packethooks.
With best regards!
UPD:
With 7.0.3 it works!
Interesting, what about NPC? What we have to do, that this works with NPC bar?
Re: Close life bar when out the line of sight
Posted: Tue Nov 08, 2016 4:56 pm
by Skinny
Harley wrote:Skinny, thank you for your decision!
I'll try and tell here.
You said that Nando helped with packets.
Tell me please some tricks with it, 'cause I don't really understand how to make packethooks.
With best regards!
Hi.
Well, a traditional way that the health bar close is when the npc/player die.
So, I analyzed the packets logs with Razor enabling packet logging:

Then, I realized that the POL (server side) sends the
"0xAF" packet, which is the death animation, and it is this packet that makes the health bar close. So when someone leaves the line of sight (more than 18 tiles), the POL (server side) sends the
"0x1D" packet to the client delete the object.
Commenting on the code:
Code: Select all
(...)
exported function deletehook(who, byref packet)
// packet.GetInt32(1) is the serial player that POL sent to delete the object.
var chr := SystemFindObjectBySerial(packet.GetInt32(1)); //Get the Object reference
if(!chr)
return 0; //Send 0x1D packet (Delete Object) to player.
endif
if(chr.acctname AND (Distance(who, chr) > 18)) //if object is a player and the distance between player and another player is more than 18 tiles
var packet1 := CreatePacket(0xAF, 13); //Create the Display Death Action
packet1.SetInt32(1, chr.serial); //the serial player that out the line of sight
packet1.SetInt32(5, 0);
packet1.SetInt32(9, 0);
packet1.SendPacket(who); //Send to player that was asked to delete the object
//Well, if out the line of sight for a player, also out the line of sight to the another player.
var packet2 := CreatePacket(0xAF, 13); //Create the Display Death Action
packet2.SetInt32(1, who.serial); //the serial player that out the line of sight
packet2.SetInt32(5, 0);
packet2.SetInt32(9, 0);
packet2.SendPacket(chr); //Send to player that was asked to delete the object
return 1; //And do not send 0x1D packet to player.
endif
return 0; //Send 0x1D packet (Delete Object) to player.
endfunction
Re: Close life bar when out the line of sight
Posted: Tue Nov 08, 2016 5:07 pm
by Skinny
Harley wrote:
Interesting, what about NPC? What we have to do, that this works with NPC bar?
Hum... I think if you change this line:
Code: Select all
if(chr.acctname AND (Distance(who, chr) > 18))
to this:
Code: Select all
if((chr.acctname OR chr.npctemplate) AND (Distance(who, chr) > 18))
Then it should work.
Re: Close life bar when out the line of sight
Posted: Wed Nov 09, 2016 5:12 am
by Harley
Awesome and very helpful!!!
About packets, this is analog algorithm to all of them?
Skinny wrote:
Hum... I think if you change this line:
Code: Select all
if(chr.acctname AND (Distance(who, chr) > 18))
to this:
Code: Select all
if((chr.acctname OR chr.npctemplate) AND (Distance(who, chr) > 18))
Then it should work.
mm.. with this it doesn't work(
Re: Close life bar when out the line of sight
Posted: Sat Nov 12, 2016 7:01 pm
by Yukiko
I used a logged in player character to test it. I was using Assist UO which allows me to run multiple instances of a client on the same computer. Perhaps Assist UO or having two clients open on the same machine conflicts with the packets being sent from the Core. I'll test it again using two different machines for log-in.
Re: Close life bar when out the line of sight
Posted: Sun Nov 13, 2016 8:01 pm
by Skinny
Yukiko wrote:I used a logged in player character to test it. I was using Assist UO which allows me to run multiple instances of a client on the same computer. Perhaps Assist UO or having two clients open on the same machine conflicts with the packets being sent from the Core. I'll test it again using two different machines for log-in.
Yukiko, i tested with two clients with Razor on the same machine and it works.
Re: Close life bar when out the line of sight
Posted: Mon Nov 14, 2016 11:56 pm
by Yukiko
Maybe Assist UO is the problem then. I'll try it with Razor and also with clients patched that don't perform the check for instances of an open UO client.