Skip to content

Commit

Permalink
10/27/2007 - grimson
Browse files Browse the repository at this point in the history
	Split onUse into onUseChecked and onUseUnChecked.
  • Loading branch information
grimson committed Oct 27, 2007
1 parent 923b782 commit f0c3bfa
Show file tree
Hide file tree
Showing 122 changed files with 311 additions and 228 deletions.
22 changes: 19 additions & 3 deletions docs/JavaScripting/events.html
Expand Up @@ -915,13 +915,29 @@ <h3>API and Event handling</h3>
</pre></table>

<p>&nbsp;</p><table border="1" width="100%" cellspacing="0">
<tr><th colspan=2 bgcolor="maroon"><a name="OnUseEvent">onUse</a>
<tr><td valign="top" width="25%"><b>Prototype</b><td><pre>function onUse( pUser, iUsed )
<tr><th colspan=2 bgcolor="maroon"><a name="OnUseCheckedEvent">onUseChecked</a>
<tr><td valign="top" width="25%"><b>Prototype</b><td><pre>function onUseChecked( pUser, iUsed )
</pre><tr><td valign="top" width="25%"><b>When triggered</b><td>When pUser uses iUsed.
<tr><td valign="top" width="25%"><b>Notes</b><td>if return value from script is true, it continues on executing with hard coded implementation<br>if return value is false, then no hard code is executed
<tr><td valign="top" width="25%"><b>Purpose</b><td>To allow greater customization on using items.
<tr><td valign="top" width="25%"><b>Example of Usage</b><td><pre>
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var trgSock = pUser.socket;
if(pUser.InRange( iUsed, 8 ))
pUser.OpenBank(trgSock);
return false;
}
</pre></table>

<p>&nbsp;</p><table border="1" width="100%" cellspacing="0">
<tr><th colspan=2 bgcolor="maroon"><a name="OnUseUnCheckedEvent">onUseUnChecked</a>
<tr><td valign="top" width="25%"><b>Prototype</b><td><pre>function onUseUnChecked( pUser, iUsed )
</pre><tr><td valign="top" width="25%"><b>When triggered</b><td>When pUser uses iUsed.
<tr><td valign="top" width="25%"><b>Notes</b><td>Unlike the onUseChecked event this one runs without any hardcoded checks.
<tr><td valign="top" width="25%"><b>Purpose</b><td>To allow greater customization on using items.
<tr><td valign="top" width="25%"><b>Example of Usage</b><td><pre>
function onUseUnChecked( pUser, iUsed )
{
var trgSock = pUser.socket;
if(pUser.InRange( iUsed, 8 ))
Expand Down
3 changes: 2 additions & 1 deletion docs/JavaScripting/eventsToC.html
Expand Up @@ -71,7 +71,8 @@
<li><a href="events.html#OnTransferEvent">onTransfer</a>
<li><a href="events.html#OnUnequipEvent">onUnequip</a>
<li><a href="events.html#OnUnknownTriggerEvent">onUnknownTrigger</a>
<li><a href="events.html#OnUseEvent">onUse</a>
<li><a href="events.html#OnUseCheckedEvent">onUseChecked</a>
<li><a href="events.html#OnUseUnCheckedEvent">onUseUnChecked</a>
<li><a href="events.html#OnXYZEvent">onXYZEvent</a>
<li><a href="events.html#OutOfRange">OutOfRange</a>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion js/item/archerybutte.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseUnChecked( pUser, iUsed )
{
var pSock = pUser.socket;
var lastUsedBy = iUsed.GetTag( "lastUsedBy" );
Expand Down
2 changes: 1 addition & 1 deletion js/item/axe.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
Expand Down
2 changes: 1 addition & 1 deletion js/item/bankcheck.js
Expand Up @@ -2,7 +2,7 @@
// v1.00
// Last Updated: 16. August 2006

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var bankBox = pUser.FindItemLayer( 29 );
if( bankBox && iUsed.container && iUsed.container.serial == bankBox.serial )
Expand Down
2 changes: 1 addition & 1 deletion js/item/clock.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var pSock = pUser.socket;
TriggerEvent( 1052, "TellTime", pSock );
Expand Down
4 changes: 2 additions & 2 deletions js/item/doors.js
Expand Up @@ -4,7 +4,7 @@ doorTypes = new Array (
0x084C, 0x0866, 0x190E, 0x1FED
);

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket )
Expand Down Expand Up @@ -152,7 +152,7 @@ function onUse( pUser, iUsed )
if( LinkedDoor )
{
pUser.socket.clickY = 1;
onUse( pUser, LinkedDoor );
onUseChecked( pUser, LinkedDoor );
}
}
else if( pUser.socket.clickY == 1 )
Expand Down
2 changes: 1 addition & 1 deletion js/item/food.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
Expand Down
2 changes: 1 addition & 1 deletion js/item/key.js
Expand Up @@ -23,7 +23,7 @@ var KeyringID3 = 0x176b; //full keyring
var KeyScriptID = 5013; //Script-ID from JSE_FILEASSOCIATIONS.SCP! Change to match your own setting.

// Adding keys to keyrings
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.socket.tempObj = iUsed;
if(( iUsed.id >= keyID1 && iUsed.id <= keyID3 ) || iUsed.id == keyID4 || iUsed.id == keyID5 )
Expand Down
2 changes: 1 addition & 1 deletion js/item/kindling.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var pSock = pUser.socket;

Expand Down
2 changes: 1 addition & 1 deletion js/item/moongate.js
Expand Up @@ -27,7 +27,7 @@ var enableIlshenar = 1;
var enableMalas = 1;
var enableTokuno = 1;

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
// get users socket
var srcSock = pUser.socket;
Expand Down
2 changes: 1 addition & 1 deletion js/item/moonstone.js
Expand Up @@ -26,7 +26,7 @@ function onCreateDFN( objMade, objType )
}
}

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
// If moonstone has become a moongate already, act as if user has collided with moongate upon doubleclick
if( iUsed.id == 0x0f6c )
Expand Down
2 changes: 1 addition & 1 deletion js/item/oilcloth.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var itemOwner = GetPackOwner( iUsed, 0 );
if( itemOwner == null || itemOwner != pUser )
Expand Down
2 changes: 1 addition & 1 deletion js/item/pickpocketdip.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var pSock = pUser.socket;

Expand Down
2 changes: 1 addition & 1 deletion js/item/potion.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
Expand Down
2 changes: 1 addition & 1 deletion js/item/spyglass.js
@@ -1,6 +1,6 @@
var moonPhase = new Array( "a full moon", "waning gibbous", "in it's last quarter", "waning crescent", "a new moon", "waxing crescent", "in it's first quarter", "waxing gibbous" );

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.TextMessage( "You peer into the heavens, seeking the moons...", false, 0x03b2 );
pUser.TextMessage( "Trammel : " + moonPhase[Moon( 1 )], false, 0x03b2 );
Expand Down
2 changes: 1 addition & 1 deletion js/item/sword.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
Expand Down
2 changes: 1 addition & 1 deletion js/item/teleporter.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
Expand Down
2 changes: 1 addition & 1 deletion js/item/teleportrune.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
Expand Down
2 changes: 1 addition & 1 deletion js/item/trainingdummy.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var pSock = pUser.socket;

Expand Down
2 changes: 1 addition & 1 deletion js/magic/level1targ.js
Expand Up @@ -458,7 +458,7 @@ function MagicDamage( p, amount, attacker, mSock, element )
{
//p.TextMessage( "Vulnerable, here comes the damage" );
var hitLoc = CalculateHitLoc();
var damage = ApplyDamageBonuses( element, attacker, p, 25, hitLoc, amount);
var damage = ApplyDamageBonUseCheckeds( element, attacker, p, 25, hitLoc, amount);
//p.TextMessage( "Damage after the bonus: " + damage);
damage = ApplyDefenseModifiers( element, attacker, p, 25, hitLoc, damage, true);
//p.TextMessage( "Damage after the defense: " + damage);
Expand Down
2 changes: 1 addition & 1 deletion js/npc/pets/static_horse.js
Expand Up @@ -4,7 +4,7 @@
// untill stablekeepers are changed to sell living animals these scripts create NPCs from sold statics
// horse

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
// randomize the horse given
var look = RollDice( 1, 4, 0 );
Expand Down
2 changes: 1 addition & 1 deletion js/npc/pets/static_llama.js
Expand Up @@ -4,7 +4,7 @@
// untill stablekeepers are changed to sell living animals these scripts create NPCs from sold statics
// llama

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var nSpawned = SpawnNPC( "llama", pUser.x, pUser.y, pUser.z, pUser.worldnumber );
if( nSpawned == null )
Expand Down
2 changes: 1 addition & 1 deletion js/npc/pets/static_ostard.js
Expand Up @@ -4,7 +4,7 @@
// untill stablekeepers are changed to sell living animals these scripts create NPCs from sold statics
// ostard

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
// randomize the ostard given
var look = RollDice( 1, 3, 0 );
Expand Down
2 changes: 1 addition & 1 deletion js/npc/pets/static_packhorse.js
Expand Up @@ -4,7 +4,7 @@
// untill stablekeepers are changed to sell living animals these scripts create NPCs from sold statics
// pack horse

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var nSpawned = SpawnNPC( "packhorse", pUser.x, pUser.y, pUser.z, pUser.worldnumber );
if( nSpawned == null )
Expand Down
2 changes: 1 addition & 1 deletion js/npc/pets/static_packllama.js
Expand Up @@ -4,7 +4,7 @@
// untill stablekeepers are changed to sell living animals these scripts create NPCs from sold statics
// pack llama

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
var nSpawned = SpawnNPC( "packllama", pUser.x, pUser.y, pUser.z, pUser.worldnumber );
if( nSpawned == null )
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candelabra01_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x0A27;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candelabra01_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x0B1D;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candelabra02_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x0A29;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candelabra02_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true);
iUsed.id = 0x0B26;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle01_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x09FB;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle01_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true);
iUsed.id = 0x09FD;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle02_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x0A00;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle02_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x0A02;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle03_off.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x0A26;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle03_on.js
@@ -1,4 +1,4 @@
function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x0B1A;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle04_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect(0x0147, true );
iUsed.id = 0x0A28;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle04_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x0A0F;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle05_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x1853;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle05_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x1854;
Expand Down
6 changes: 3 additions & 3 deletions js/server/light/candle06_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x1857;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle06_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x1858;
Expand Down
6 changes: 3 additions & 3 deletions js/server/light/candle07_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x142F;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle07_on.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0047, true );
iUsed.id = 0x142C;
Expand Down
2 changes: 1 addition & 1 deletion js/server/light/candle08_off.js
@@ -1,7 +1,7 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUse( pUser, iUsed )
function onUseChecked( pUser, iUsed )
{
pUser.SoundEffect( 0x0147, true );
iUsed.id = 0x1433;
Expand Down

0 comments on commit f0c3bfa

Please sign in to comment.