Page 1 of 1
bola ball
Posted: Thu Apr 09, 2009 6:54 pm
by dragon slayer
Here is the js for a bola throwing ball
Code: Select all
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
{
var itemOwner = GetPackOwner( iUsed, 0 );
if( itemOwner == null || itemOwner.serial != pUser.serial )
{
pUser.SysMessage( "This must be in your backpack or equipped before it can be used." );
return false;
}
else if( iUsed.type != 500 )
{
var targMsg = GetDictionaryEntry( 462, socket.Language );
socket.CustomTarget( 0, targMsg );
iUsed.Delete();
}
else
return true;
}
return false;
}
function onCallback0( socket, myTarget )
{
var pUser = socket.currentChar;
//If GetWord( 1 ) returns false, an item or a character was targeted
if( !socket.GetWord( 1 ) && myTarget.isChar )
{
myTarget.Dismount();
}
else
pUser.SysMessage( "Not a character! zomg!" );
}
I will let you all know this is version 1 if any one wants to add some more checks or help me get this moving a little more closer to osi just take thecode and repost the additions
I am very new to scirpting js so this is my first script thanks to xuri for the help on the disamount part.
So have fun and enjoy nocking nubs off there mounts
Posted: Thu Apr 09, 2009 7:49 pm
by Jediman
Holy @#$ thank you!
This was on my list for the tribal stuff, along with the paint and perhaps the chanting thing the shamans do when they get together to summon.
Posted: Fri Apr 10, 2009 6:55 pm
by dragon slayer
well i will be posting version 2 hopefully soon as i add sound effects and moving effects for it. and the msg for the other player to know he got hit hehe.
I'm about done with my new js scirpt to make quest npcs.
Posted: Mon Apr 20, 2009 8:55 am
by dragon slayer
Bola Ball Version 2.0
More OSI Style
Code: Select all
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
{
//Check to see if it's locked down
if( iUsed.movable == 2 || iUsed.movable == 3 )
{
socket.SysMessage( GetDictionaryEntry( 774, socket.Language ) ); //That is locked down and you cannot use it
return false;
}
var itemOwner = GetPackOwner( iUsed, 0 );
if( itemOwner == null || itemOwner.serial != pUser.serial )
{
pUser.SysMessage( "The bola must be in your pack to use it." );
return false;
}
else if( pUser.isonhorse )
{
pUser.SysMessage( "You cannot use this while riding a mount." );
return false;
}
if(pUser.GetTag("bola") == null || pUser.GetTag("bola") == 0)
{
socket.tempObj = iUsed;
pUser.SetTag("bola", 1);
pUser.EmoteMessage("* You begin to swing the bola...*");
pUser.StartTimer(3000, 0, true);
}
else if(pUser.GetTag("bola") == 1)
{
pUser.SysMessage("You have to wait a few moments before you can use another bola!");
}
else
return true;
}
return false;
}
function onCallback0( socket, myTarget)
{
var pUser = socket.currentChar;
var iUsed = socket.tempObj;
if( !socket.GetWord( 1 ) && myTarget.isChar )
{
myTarget.Dismount();
pUser.DoAction( 0x11 );
DoMovingEffect( pUser, pUser, 0x26AC, 0x10, 0x00, false, false );
myTarget.SysMessage( "You have been nocked off your mount!" );
iUsed.Delete();
}
else
pUser.SysMessage( "You cannot throw a bola at that." );
}
function onTimer(pUser,timerID)
{
var socket = pUser.socket;
if(timerID == 0)
{
pUser.EmoteMessage( pUser.name + " begins to menacingly swing a bola..");
pUser.StartTimer(1000, 1, true);
}
if(timerID == 1)
{
pUser.SetTag("bola", 0);
socket.CustomTarget(0);
}
}
Known Bugs
action needs adjusted to correct one still working on it
Moving Effect speed is to fast.
Swing Times might be off just by a hair
But sides all that this is the most perfect Bola Ball I really hope it gets added to the UOX as it is UO correct Way for bola.
I am now working on Crafting Bola's
Posted: Mon May 11, 2009 10:28 pm
by Xuri
I did some tweaks to your script and included it on the UOX3 CVS, with DFN entries for bolas and entries in both jse_fileassocations.scp and jse_objectassociations.scp.
Here's the complete modified script, with my changes highlighted:
Code: Select all
function onUseChecked( pUser, iUsed )
{
var socket = pUser.socket;
if( socket && iUsed && iUsed.isItem )
{
//Check to see if it's locked down
if( iUsed.movable == 2 || iUsed.movable == 3 )
{
socket.SysMessage( GetDictionaryEntry( 774, socket.Language ) ); //That is locked down and you cannot use it
return false;
}
var itemOwner = GetPackOwner( iUsed, 0 );
if( itemOwner == null || itemOwner.serial != pUser.serial )
{
pUser.SysMessage( "The bola must be in your pack to use it." );
return false;
}
else if( pUser.isonhorse )
{
pUser.SysMessage( "You cannot use this while riding a mount." );
return false;
}
if(pUser.GetTag("bola") == null || pUser.GetTag("bola") == 0)
{
socket.tempObj = iUsed;
pUser.SetTag("bola", 1);
[color=orange]//the addition of the false-flag in the TextMessage below tells the server to only
//send the message to this character[/color]
pUser.[color=orange]TextMessage[/color]("* You begin to swing the bola...*"[color=orange], false[/color] );
pUser.StartTimer(3000, 0, true);
}
else if(pUser.GetTag("bola") == 1)
{
pUser.SysMessage("You have to wait a few moments before you can use another bola!");
}
else
return true;
}
return false;
}
function onCallback0( socket, myTarget)
{
var pUser = socket.currentChar;
var iUsed = socket.tempObj;
if( !socket.GetWord( 1 ) && myTarget.isChar )
{
[color=orange]if( pUser.InRange( myTarget, 8 ))
{
if( myTarget.isonhorse )
{[/color]
myTarget.Dismount();
pUser.DoAction( [color=orange]0x9[/color] );
[color=orange]DoMovingEffect( pUser, myTarget, 0x26AC, 0x10, 0x00, false );[/color]
myTarget.SysMessage( "You have been [color=orange]k[/color]nocked off your mount!" );
iUsed.Delete();
[color=orange]}
else
pUser.SysMessage( "Your target isn't mounted." );
}
else
pUser.SysMessage( "Your target is out of range." );[/color]
}
else
pUser.SysMessage( "You cannot throw a bola at that." );
}
function onTimer(pUser,timerID)
{
var socket = pUser.socket;
if(timerID == 0)
{
pUser.EmoteMessage( pUser.name + " begins to menacingly swing a bola..");
pUser.StartTimer(1000, 1, true);
}
if(timerID == 1)
{
pUser.SetTag("bola", [color=orange]null[/color]);
socket.CustomTarget(0);
}
}
Posted: Tue May 12, 2009 3:20 am
by dragon slayer
that looks good thanks
i never really thought about all that eheh