From 7a6ce3e6fadf422962a094523508aef3a6f8675d Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Sat, 28 Dec 2024 15:44:07 -0600 Subject: [PATCH 1/4] Updated Jsdocs.html Updated OnDrop count for older clients, as well as newer clients and the CUO client. Added another function to OnDropItemOnItem. Fixed FindRootContainer, which was missing its argType parameter. --- docs/jsdocs.html | 103 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 29 deletions(-) diff --git a/docs/jsdocs.html b/docs/jsdocs.html index 8dbe347a8..412be5173 100644 --- a/docs/jsdocs.html +++ b/docs/jsdocs.html @@ -1694,34 +1694,62 @@

January 9th, 2022

Example of usage

function onDrop( iDropped, pDropper )
-{
-	var pSock = pDropper.socket;
+ {
+    var pSock = pDropper.socket;
 
-	//Lets fetch the serial of the target-location
-	var temp1 = pSock.GetByte( 10 );
-	var temp2 = pSock.GetByte( 11 );
-	var temp3 = pSock.GetByte( 12 );
-	var temp4 = pSock.GetByte( 13 );
+    //var packGridIndex = -1;
+    var targSer1 = 0;
+    var targSer2 = 0;
+    var targSer3 = 0;
+    var targSer4 = 0;
 
-	//Check the value of Byte 10 to determine if the target is ground, character or container
-	if( temp1 == 0 ) //Target is a character
-	{
-		var targetChar = CalcCharFromSer( temp1, temp2, temp3, temp4 )
-		pDropper.TextMessage( "I've dropped this item on a character named "+targetChar.name+", let's bounce it back." );
-		return false;
-	}
-	if( temp1 == 0xFF ) //Target is ground or another item
-	{
-		pDropper.TextMessage( "I've dropped this item on the ground or on another item." );
-		return true;
-	}
-	if( temp1 <= 0x40 ) //Target is a container
-	{
-		var targetItem = CalcItemFromItem( temp1, temp2, temp3, temp4 );
-		pDropper.TextMessage( "I've dropped this item in/on a container with ID "+targetItem.id+"." );
-		return true;
-	}
-}

+ if(pSock.clientMajorVer > 6 || ( pSock.clientMajorVer == 6 && pSock.clientSubVer >= 1 && pSock.clientLetterVer >= 7)) + { + // Client version 6.0.1.7+ has an additional byte before serial of target container + // Will contain a value for backpack grid index item was dropped in when using clients that support grid containers + // Will contain a value of -1 in regular 2D UO client and 0 in ClassicUO + //packGridIndex = pSock.GetByte( 10 ); + + targSer1 = pSock.GetByte( 11 ); // 0 = dropped on character, 0xFF = ground/item + targSer2 = pSock.GetByte( 12 ); + targSer3 = pSock.GetByte( 13 ); + targSer4 = pSock.GetByte( 14 ); + } + else + { + // Client versions below 6.0.1.7 has no extra byte + targSer1 = pSock.GetByte( 10 ); // 0 = dropped on character, 0xFF = ground/item + targSer2 = pSock.GetByte( 11 ); + targSer3 = pSock.GetByte( 12 ); + targSer4 = pSock.GetByte( 13 ); + } + + if( targSer1 == 0 ) // Target is a character + { + var targetChar = CalcCharFromSer( targSer1, targSer2, targSer3, targSer4 ) + if( ValidateObject( targetChar )) + { + pDropper.TextMessage( "I've dropped this item on a character, deny if not my own character!!" ); + if( targetChar.serial != pDropper.serial ) + { + pDropper.TextMessage( "DENIED!" ); + return false; + } + } + } + else if( targSer1 == 0xFF ) // Target is ground or another non-container item + { + pDropper.TextMessage( "I've dropped this item on the ground or on another item, let's approve!" ); + } + // Default to allow dropping, let code handle it! + return true; + } + } + + // Default to allow dropping, let code handle it! + return true; +} +

@@ -1768,6 +1796,23 @@

January 9th, 2022

cDropper.TextMessage( "Generic error message!" ); return false; } +} + +function onDropItemOnItem( iDropped, pDropper, iDroppedOn ) +{ + if( !ValidateObject( iDroppedOn )) + return false; + + pDropper.TextMessage( "I've dropped this item in/on a container, deny if it's not my main pack!" ); + var iPack = pDropper.pack; + if( !ValidateObject( iPack ) || iPack.serial != iDroppedOn.serial ) + { + pDropper.TextMessage( "DENIED!" ); + return false; + } + + // Default to allow dropping, let code handle it! + return true; }

@@ -5763,8 +5808,8 @@

January 9th, 2022

Prototype

-

ITEM FindRootContainer( iObj );

-

ITEM FindRootContainer( iObjSerial );

+

ITEM FindRootContainer( iObj, argType );

+

ITEM FindRootContainer( iObjSerial, argType );

Purpose

@@ -5783,7 +5828,7 @@

January 9th, 2022

Example of usage

function onUseChecked( pUser, iUsed )
 {
-	var rootContainer = FindRootContainer( iUsed );
+	var rootContainer = FindRootContainer( iUsed, 0 );
 	if( ValidateObject( rootContainer ))
 		pUser.TextMessage( "The item is in a container! The root container's name is " + rootContainer.name );
 	else

From 415607d673e016c5def650f79e486a9c5263f6f6 Mon Sep 17 00:00:00 2001
From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com>
Date: Sat, 28 Dec 2024 19:54:57 -0600
Subject: [PATCH 2/4] Update jsdocs.html

---
 docs/jsdocs.html | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/jsdocs.html b/docs/jsdocs.html
index 412be5173..09f90d3c1 100644
--- a/docs/jsdocs.html
+++ b/docs/jsdocs.html
@@ -5808,8 +5808,8 @@ 

January 9th, 2022

Prototype

-

ITEM FindRootContainer( iObj, argType );

-

ITEM FindRootContainer( iObjSerial, argType );

+

ITEM FindRootContainer( iObj );

+

ITEM FindRootContainer( iObjSerial );

Purpose

@@ -5828,7 +5828,7 @@

January 9th, 2022

Example of usage

function onUseChecked( pUser, iUsed )
 {
-	var rootContainer = FindRootContainer( iUsed, 0 );
+	var rootContainer = FindRootContainer( iUsed );
 	if( ValidateObject( rootContainer ))
 		pUser.TextMessage( "The item is in a container! The root container's name is " + rootContainer.name );
 	else

From a70c51ed2f9a90a50c631b5ac2ef6290eefd9dbd Mon Sep 17 00:00:00 2001
From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com>
Date: Fri, 24 Jan 2025 10:43:07 -0600
Subject: [PATCH 3/4] update

---
 docs/jsdocs.html | 93 ++++++++++++++++++++----------------------------
 1 file changed, 38 insertions(+), 55 deletions(-)

diff --git a/docs/jsdocs.html b/docs/jsdocs.html
index 09f90d3c1..cde5f824a 100644
--- a/docs/jsdocs.html
+++ b/docs/jsdocs.html
@@ -1693,62 +1693,45 @@ 

January 9th, 2022

Example of usage
-

function onDrop( iDropped, pDropper )
- {
-    var pSock = pDropper.socket;
-
-    //var packGridIndex = -1;
-    var targSer1 = 0;
-    var targSer2 = 0;
-    var targSer3 = 0;
-    var targSer4 = 0;
-
-    if(pSock.clientMajorVer > 6 || ( pSock.clientMajorVer == 6 && pSock.clientSubVer >= 1 && pSock.clientLetterVer >= 7))
-    {
-        // Client version 6.0.1.7+ has an additional byte before serial of target container
-        // Will contain a value for backpack grid index item was dropped in when using clients that support grid containers
-        // Will contain a value of -1 in regular 2D UO client and 0 in ClassicUO
-        //packGridIndex = pSock.GetByte( 10 );
-
-        targSer1 = pSock.GetByte( 11 ); // 0 = dropped on character, 0xFF = ground/item
-        targSer2 = pSock.GetByte( 12 );
-        targSer3 = pSock.GetByte( 13 );
-        targSer4 = pSock.GetByte( 14 );
-    }
-    else
-    {
-        // Client versions below 6.0.1.7 has no extra byte
-        targSer1 = pSock.GetByte( 10 ); // 0 = dropped on character, 0xFF = ground/item
-        targSer2 = pSock.GetByte( 11 );
-        targSer3 = pSock.GetByte( 12 );
-        targSer4 = pSock.GetByte( 13 );
-    }
-
-    if( targSer1 == 0 ) // Target is a character
-    {
-        var targetChar = CalcCharFromSer( targSer1, targSer2, targSer3, targSer4 )
-        if( ValidateObject( targetChar ))
-        {
-            pDropper.TextMessage( "I've dropped this item on a character, deny if not my own character!!" );
-            if( targetChar.serial != pDropper.serial )
-            {
-                pDropper.TextMessage( "DENIED!" );
-                return false;
-            }
-        }
-    }
-    else if( targSer1 == 0xFF ) // Target is ground or another non-container item
-    {
-        pDropper.TextMessage( "I've dropped this item on the ground or on another item, let's approve!" );
-        }
-            // Default to allow dropping, let code handle it!
-            return true;
-        }
-    }
+

+	function onDrop( iDropped, pDropper )
+	{
+	var pSock = pDropper.socket;
+
+	// Client version 6.0.1.7+ has an additional byte before serial of target container
+	// Will contain a value for backpack grid index item was dropped in when using clients that support grid containers
+	// Will contain a value of -1 in regular 2D UO client and 0 in ClassicUO
+	var serOffset = (pSock.clientMajorVer > 6 || ( pSock.clientMajorVer == 6 && pSock.clientSubVer >= 1 && pSock.clientLetterVer >= 7)) ? 11 : 10;
+	targSer1 = pSock.GetByte( serOffset + 0 ); // 0 = dropped on character, 0xFF = ground/item
+	targSer2 = pSock.GetByte( serOffset + 1 );
+	targSer3 = pSock.GetByte( serOffset + 2 );
+	targSer4 = pSock.GetByte( serOffset + 3 )
+
+	if( targSer1 == 0 ) // Target is a character
+	{
+	var targetChar = CalcCharFromSer( targSer1, targSer2, targSer3, targSer4 )
+	if( ValidateObject( targetChar ))
+	{
+	pDropper.TextMessage( "I've dropped this item on a character, deny if not my own character!!" );
+	if( targetChar.serial != pDropper.serial )
+	{
+	pDropper.TextMessage( "DENIED!" );
+	return false;
+	}
+	}
+	}
+	else if( targSer1 == 0xFF ) // Target is ground or another non-container item
+	{
+	pDropper.TextMessage( "I've dropped this item on the ground or on another item, let's approve!" );
+	}
+	// Default to allow dropping, let code handle it!
+	return true;
+	}
+	}
 
-    // Default to allow dropping, let code handle it!
-    return true;
-}
+	// Default to allow dropping, let code handle it!
+	return true;
+	}
 

From 0548225ea1103f69af6a93ef8f66a264f9e54ccb Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Mon, 27 Jan 2025 12:58:37 -0600 Subject: [PATCH 4/4] Update jsdocs.html --- docs/jsdocs.html | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/docs/jsdocs.html b/docs/jsdocs.html index cde5f824a..b3647694d 100644 --- a/docs/jsdocs.html +++ b/docs/jsdocs.html @@ -1692,10 +1692,10 @@

January 9th, 2022

-

Example of usage
-


-	function onDrop( iDropped, pDropper )
-	{
+							

+ Example of usage
+

function onDrop( iDropped, pDropper )
+{
 	var pSock = pDropper.socket;
 
 	// Client version 6.0.1.7+ has an additional byte before serial of target container
@@ -1709,30 +1709,27 @@ 

January 9th, 2022

if( targSer1 == 0 ) // Target is a character { - var targetChar = CalcCharFromSer( targSer1, targSer2, targSer3, targSer4 ) - if( ValidateObject( targetChar )) - { - pDropper.TextMessage( "I've dropped this item on a character, deny if not my own character!!" ); - if( targetChar.serial != pDropper.serial ) - { - pDropper.TextMessage( "DENIED!" ); - return false; - } - } + var targetChar = CalcCharFromSer( targSer1, targSer2, targSer3, targSer4 ) + if( ValidateObject( targetChar )) + { + pDropper.TextMessage( "I've dropped this item on a character, deny if not my own character!!" ); + if( targetChar.serial != pDropper.serial ) + { + pDropper.TextMessage( "DENIED!" ); + return false; + } + } } else if( targSer1 == 0xFF ) // Target is ground or another non-container item { - pDropper.TextMessage( "I've dropped this item on the ground or on another item, let's approve!" ); - } - // Default to allow dropping, let code handle it! - return true; - } + pDropper.TextMessage( "I've dropped this item on the ground or on another item, let's approve!" ); } // Default to allow dropping, let code handle it! return true; - } -

+} +
+