[APPROVED] bola ball

Want to contribute to the Ultima Offline eXperiment? Submit your JS/DFN/Code fixes and/or other UOX3 improvements here!
Locked
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

bola ball

Post 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
User avatar
Jediman
UOX3 Apprentice
Posts: 177
Joined: Fri Jul 16, 2004 1:38 am
Location: New England
Has thanked: 0
Been thanked: 0
Contact:

Post 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.
Realms of Valor
- -=- http://www.realmsofvalor.com -=-
-=-Powered By UOX3-=-

Have you read the installation documentation?
http://www.uox3.org/documentation.shtml

'I have a moongate in my backpack' sounds like a bad Brittanian pickup line!
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post 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.
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post 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
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post 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);
	}
}
-= Ho Eyo He Hum =-
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

that looks good thanks

i never really thought about all that eheh
Locked