I have used this packethook in pol 97.
Code: Select all
use uo;
include "include/attributes";
include "include/poisons";
include ":combat:weapon";
include ":containers:include/specialChest";
const OFFSET_CLILOC_ID:= 0x0F;
const OFFSET_LENGTH_ID:= 0x13;
const OFFSET_OBJECT_SERIAL:= 0x05;
const OFFSET_UNICODE_TEXT:= 0x14;
var MAGICBOOK_TYPES:= array {0x1940, 0x0efa, 0x241d, 0x241e, 0x241f, 0x9982, 0x6594, 0x996f};
program Install()
Print ("INSTALLING: Outgoing Tooltip PH...");
return 1;
endprogram
exported function MegaCliloc(who, byref packet)
var hersteller:= "";
var xObject:= SystemFindObjectBySerial (packet.GetInt32 (OFFSET_OBJECT_SERIAL));
if (xObject)
// We don't need anything else but the first half of the packet,
// since we're gonna add everything else it needs.
packet.SetSize(15);
var Object_Name;
if (xObject.IsA (POLCLASS_MOBILE))
Object_Name:= xObject.name;
// Let's get the characters hightlight color.
// This is just an example, NPC's and stuff will still have to be added
// ofcourse. :)
// Setting the text color for the object's name will only show
// if the object's name has changed. So it's been left commented out for now.
//if (xObject.murderer)
// Text_Color:= "FF0000";
//elseif (xObject.criminal)
// Text_Color:= "666666";
//else
// Text_Color:= "00CCFF";
//endif
elseif (xObject.IsA (POLCLASS_ITEM))
// Wenn exceptional, Name aufspliiten in Bezeichnung und Hersteller
var klammer1:= find (xObject.desc, "[hergestellt", 1);
// alte Gegenstände?
if (!klammer1)
klammer1:= find (xObject.desc, "[crafted", 1);
endif
if (klammer1)
var klammer2:= find (xObject.desc, "]", klammer1);
hersteller:= xObject.desc[klammer1, (klammer2 - klammer1) + 1];
Object_Name:= xObject.desc[1, klammer1 - 1];
else
Object_Name:= xObject.desc;
endif
endif
// If you try to break a new line in the first cliloc(below) it doesn't
// display right for some reason.
// If you want to change the color of the Object's name.
// Use this.
// Object_Name:= CAscZ ("<BASEFONT COLOR=#" + Text_Color + "><C>" + Object_Name);
Object_Name:= CAscZ (Object_Name);
packet.SetInt32 (OFFSET_CLILOC_ID, 1042971);
packet.SetUnicodeString(OFFSET_UNICODE_TEXT, Object_Name, 1);
// I've noticed that this packet is only sent if this value has changed
// from the last time it was checked. And using html to change the size doesn't work
// for some reason. Maybe a core/client issue?
packet.SetInt16 (OFFSET_LENGTH_ID, Object_Name.Size () * 2);
// Start of Loop.
// This is where you'll be putting all your properties. <br> to break a new line.
// You wont need to add anymore cliloc id's because you can just add all the props
// into one string.
var Html:= "<BASEFONT COLOR=#CBA300><C>";
var xDesc:= Html;
// Hersteller angegeben?
if (hersteller != "")
xDesc:= xDesc + hersteller + "<br>";
endif
if (xObject.isA (POLCLASS_CONTAINER) &&
!xObject.locked &&
!(xObject.objtype in MAGICBOOK_TYPES))
if (xObject.item_count == 2)
xDesc:= xDesc + "enthält 1 Gegenstand<br>";
elseif (xObject.item_count > 2)
xDesc:= xDesc + "enthält " + (xObject.item_count - 1) + " Gegenstände<br>";
else
xDesc:= xDesc + "enthält nichts<br>";
endif
endif
// Infos zu Waffen und Rüstungen
if (xObject.isA (POLCLASS_WEAPON) || xObject.isA (POLCLASS_ARMOR))
// Zustand angeben?
if (GetAttribute (who, ATTRIBUTEID_ARMSLORE) >= 40)
// altes System zum Berechnen des Zustandes
// xDesc:= xDesc + "Zustand: " + CInt (CDbl (xObject.hp) / CDbl (xObject.maxhp + xObject.maxhp_mod) * 100) + "%<br>";
// neues System zum Berechnen des Zustandes: Basierend auf den CProps der Waffe.
xDesc:= xDesc + "Zustand: " + GetHealthStatus(xObject) + "%<br>";
endif
// Veredelt/veredelbar?
var veredelung:= GetObjProperty (xObject, "Veredelung");
if (veredelung)
var i:= 0;
xDesc:= xDesc + "Veredelung:";
for (i:= 1; i <= veredelung[1]; i:= i + 1)
if (veredelung[2][veredelung[2].keys ()[i]])
xDesc:= xDesc + " [" + veredelung[2][veredelung[2].keys ()[i]] + "]";
else
xDesc:= xDesc + " [ ]";
endif
endfor
xDesc:= xDesc + "<br>";
endif
endif // Ende Waffeninfo
// locked down or secured?
if (GetObjProperty (xObject, "lockeddown"))
xDesc:= xDesc + "*befestigt*<br>";
elseif (GetObjProperty (xObject, "secure"))
xDesc:= xDesc + "*gesichert*<br>";
elseif (isASpecialChest(xObject))
xDesc:= xDesc + "*SpecialChest*<br>";
endif
// invul?
if (xObject.IsA (POLCLASS_MOBILE) &&
xObject.enabled ("invul"))
xDesc:= xDesc + "*unverwundbar*<br>";
endif
// gesegnet?
if (xObject.newbie)
xDesc:= xDesc + "*gesegnet*<br>";
endif
// Leerzeile unterbinden wenn keine weiteren Infos
if (xDesc == Html)
xDesc:= "";
endif
xDesc:= CAscZ (xDesc);
if (xDesc.Size() > 0)
// Cliloc ID if these two ID's match it'll only show one line.
packet.SetInt32 (packet.GetSize () - 1, 1070722);
// Get the offset of where the next text size
var Length_ID:= packet.GetSize ();
packet.SetUnicodeString(packet.GetSize () + 1, xDesc, 1);
// SetUnicodeString adds 00 BYTE[1] at the start of the Unicode offset, which messes with the length offset.
// Setting the length of the unicode text below will fix that issue. Same deal as above.
packet.SetInt16 (Length_ID, xDesc.Size () * 2);
endif
// End of loop.
packet.SetInt32(packet.GetSize(), 0);
endif
return 0;
endfunction
exported function handlePacket(who, byref packet )
//Verhindert die Fehlermeldung "Expected packet hook function for msg d6 but was null" im serverlog
//Angeblich sendet Razor ein 0xd6 Packet. RunUO weiß was damit anzufangen, wir brauchen das nicht.
return 1;
endfunction