Maybe some simple DM scripts?

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Maybe some simple DM scripts?

Post by stranf »

Ok, I've been posting similar stuff on the "Posses NPCs?" post in the general discussion. It has got me thinking of a few scripts that would let me do some make-shift quests that could make things interesting for a bit.

If these scripts don't seem to difficult, maybe some of you genious' could whip 'em out for me. (and I can learn the tricks by observing.) If my requests are too difficult, don't bother, as I'm still working on some stand-alone quests as time allows.

Here my (I hope) simple DM function requests: (function names are arbitrary, I just gave a short example of how it might go.

'npct (string) = Function asks for a target object (animal, object (for emoting), monsters, etc. and then places the text string above that object.

'npcw = Function asks for a target npc/monster, and if a movable object, causes the NPC to walk to a specified location (also used by targeting arrow)

'npcr = Function same as npcw, but if possible, causes the NPC to run.

'npca = Function causes a target npc or monster to initiate an attack on the specified target. (it would be smart to make unique NPCs and monsters blue so that they won't attack the party (too allow big-evil dudes to monologue before the big battle and all that jazz). (Note: this function may want to automatically cause the npc/monster to go grey to allow party members to join in the attack without penalty)

'npca2 = Same as npca function exept this function will make both the agressor and PC a neutral grey or guild war color. That way, you can have an assasination attempt on a pub or in an inn where the party members must fight there way out without simply calling "guards" and have the omnipotent guys in plate kill your unique PC quickly.



If I'm not mistaken, combining these functions with the 'add and 'setai would give a DM/GM the opprotunity to remotley conduct quests from his/her window without complicated possesing and we could start giving some plots and stories to our worlds. Again if anyone wants to tackle this, it would be sweet, if it's too complicated in our scripting engine, just let me know.[/code]
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 »

'npct (string) already exists in the form of 'XSAY (string).

'npcw/npcr exists on my own harddrive, but isn't usable atm because of a broken feature in UOX3.

I'll see what I can cook up concerning 'npca and 'npca2.
-= Ho Eyo He Hum =-
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

hahah, I created a 'nt function on my own, I didn't know there was 'xsay. Oh well, it was good practice coding, so now I know I can do things! (it was very simple.

I got npcw/npcr to work on my machine, however, the NPC ONLY goes the maximum steps in the walkto function. no matter how close I click to the npc, he will still walk my default 25 steps. Here is the function if you can find my bug. Thanks for the support!

Code: Select all

function CommandRegistration()
{
	RegisterCommand( "nw", 0, true );
	RegisterCommand( "nr", 0, true);  

}
function command_NW( socket, cmdString )
{
	
	socket.CustomTarget( 0, "Select NPC" );

	
}

function onCallback0( socket, ourObj)
{	
  
	socket.tempObj = ourObj;
	socket.CustomTarget(1, "Select location");



}

function onCallback1(socket, ourObj)
{		var nWalk = socket.tempObj;
                var x 		= socket.GetWord( 11 );
		var y 		= socket.GetWord( 13 );
		
		nWalk.WalkTo( x,y, 10 );


}





function command_NR( socket, cmdString )
{
	
	socket.CustomTarget( 0, "Select NPC" );

	
}

function onCallback0( socket, ourObj)
{	
  
	socket.tempObj = ourObj;
	socket.CustomTarget(1, "Select location");



}

function onCallback1(socket, ourObj)
{		var nWalk = socket.tempObj;
                var x 		= socket.GetWord( 11 );
		var y 		= socket.GetWord( 13 );
		
		nWalk.RunTo( x,y, 10 );



}

Oh yeah, I must not understand the callback function....ever since I added the nr function, my NPCs will only run regardless of if I specify NR or NW.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

You're essentially defining the functions onCallback0 and onCallback1 twice. Frankly, I'm surprised it compiles without issue, to be honest. Change command_NR so that it looks like

Code: Select all

socket.CustomTarget( 2, "Select NPC" );
The onCallback0 for command_NR becomes onCallback2, and you change the (newly named) onCallback2 to look like

Code: Select all

socket.tempObj = ourObj;
socket.CustomTarget( 3, "Select Location" );
And the second onCallback1 becomes renamed to onCallback3.
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 »

In this thread I've written some details on what else is wrong with WalkTo/RunTo. Feel free to add your own discoveries.

You might also want to change onCallback0 to the following, which will add a check to make sure the target actually is a character:

Code: Select all

function onCallback0( socket, ourObj) 
{    
	if( !socket.GetWord( 1 ) && ourObj.isChar )
	{
   		socket.tempObj = ourObj; 
   		socket.CustomTarget(1, "Select location");
	}
	else
		socket.SysMessage8 "You must target a character!" );
}
-= Ho Eyo He Hum =-
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 »

Remote NPC Attack - a command which allows you to order NPCs to attack other characters :) They will turn "grey" if they attack innocent characters.
-= Ho Eyo He Hum =-
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Hey, thanks a ton. I'm at school so it will be awhile before I can compile and use your new scripts/edits. I'm looking forward to it.

This weekend (holiday break in US), I actually had some fun with basic quests using NPCwander 0 (to keep the NPCs in place), and my "nt" function (same as your xtext.) It was actually a lot of fun and added a lot of depth. I'm looking forward to adding more storyline to quests with the xattack.
Post Reply