Close life bar when out the line of sight

Open discussion forum. For topics that do not fit anywhere else.

Moderator: POL Developer

Post Reply
Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Close life bar when out the line of sight

Post by Skinny » Wed Oct 19, 2016 10:56 am

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:
Image
When i out the line of sight:
Image

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.

Harley
Forum Regular
Posts: 313
Joined: Sat Mar 18, 2006 1:41 am
Location: Germany

Re: Close life bar when out the line of sight

Post by Harley » Wed Oct 19, 2016 3:37 pm

+1
It will be very nice to resolve this moment..

User avatar
CWO
POL Expert
Posts: 1141
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA
Contact:

Re: Close life bar when out the line of sight

Post by CWO » Sun Oct 23, 2016 3:23 am

I don't think this is possible because these bars are handled on the client side and aren't even known by the server.

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Mon Nov 07, 2016 1:15 am

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

Code: Select all

enabled 1
name deletehook
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.

Yukiko
Distro Developer
Posts: 2508
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Close life bar when out the line of sight

Post by Yukiko » Mon Nov 07, 2016 11:45 pm

Which client version is this working with? I am testing on version 7 and it doesn't close the health bar.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Tue Nov 08, 2016 6:22 am

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).

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Tue Nov 08, 2016 10:07 am

See the test that i made and saved on Youtube:
https://youtu.be/ieiWNSbiJm0

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Tue Nov 08, 2016 1:22 pm

I tested now with client version 7.0.53.1 and works too.

Harley
Forum Regular
Posts: 313
Joined: Sat Mar 18, 2006 1:41 am
Location: Germany

Re: Close life bar when out the line of sight

Post by Harley » Tue Nov 08, 2016 4:15 pm

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?

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Tue Nov 08, 2016 4:56 pm

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:
Image
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

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Tue Nov 08, 2016 5:07 pm

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.

Harley
Forum Regular
Posts: 313
Joined: Sat Mar 18, 2006 1:41 am
Location: Germany

Re: Close life bar when out the line of sight

Post by Harley » Wed Nov 09, 2016 5:12 am

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(

Yukiko
Distro Developer
Posts: 2508
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Close life bar when out the line of sight

Post by Yukiko » Sat Nov 12, 2016 7:01 pm

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.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Skinny
Journeyman Poster
Posts: 65
Joined: Wed Dec 19, 2012 10:27 pm

Re: Close life bar when out the line of sight

Post by Skinny » Sun Nov 13, 2016 8:01 pm

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.

Yukiko
Distro Developer
Posts: 2508
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Close life bar when out the line of sight

Post by Yukiko » Mon Nov 14, 2016 11:56 pm

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.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Post Reply