Skip to content

Commit

Permalink
Merge pull request UOX3DevTeam#319 from DragonSlayer62/Doc-updates
Browse files Browse the repository at this point in the history
Improve JSDocs for OnDrop
  • Loading branch information
Xoduz authored Jan 28, 2025
2 parents dbd376d + 61a64cc commit 724085e
Showing 1 changed file with 47 additions and 22 deletions.
69 changes: 47 additions & 22 deletions docs/jsdocs.html
Original file line number Diff line number Diff line change
Expand Up @@ -1704,36 +1704,44 @@ <h4>January 9th, 2022</h4>
</ul>
</div>
<div class="settingsDiv">
<p><span class="hl">Example of usage</span><br>
<p>
<span class="hl">Example of usage</span><br>
<pre><code class="language-javascript">function onDrop( iDropped, pDropper )
{
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 );
// 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 )

//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
if( targSer1 == 0 ) // Target is a character
{
pDropper.TextMessage( "I've dropped this item on the ground or on another item." );
return true;
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;
}
}
}
if( temp1 <= 0x40 ) //Target is a container
else if( targSer1 == 0xFF ) // Target is ground or another non-container item
{
var targetItem = CalcItemFromItem( temp1, temp2, temp3, temp4 );
pDropper.TextMessage( "I've dropped this item in/on a container with ID "+targetItem.id+"." );
return true;
pDropper.TextMessage( "I've dropped this item on the ground or on another item, let's approve!" );
}
}</code></pre></p>

// Default to allow dropping, let code handle it!
return true;
}
</code></pre>
</p>
</div>
</div>
</div> <!-- cd-faq__content -->
Expand Down Expand Up @@ -1780,6 +1788,23 @@ <h4>January 9th, 2022</h4>
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;
}</code></pre></p>
</div>
</div>
Expand Down Expand Up @@ -5805,7 +5830,7 @@ <h4>January 9th, 2022</h4>
<div class="settingsDiv">
<p><span class="hl">Prototype</span></p>
<p><em>ITEM FindRootContainer( iObj );</em></p>
<p><em>ITEM FindRootContainer( iObjSerial );</em></p>
<p><em>ITEM FindRootContainer( iObjSerial );</em></p>
</div>
<div class="settingsDiv">
<p><span class="hl">Purpose</span></p>
Expand Down

0 comments on commit 724085e

Please sign in to comment.