Page 1 of 1

Stableing Animals?

Posted: Wed Nov 08, 2006 5:25 am
by karther77
I have read through most of the forums and I have not seen anything about stableing animals and if it works. I have tried it in game and it doesn't seem to work. Was wondering has anyone written a script for this yet and if so could you point me to it so that I may add it to my world. Would really appreciate this. I have lots of other requests but I know that scripting takes time and is not always easy. So I will leave this for another time. I hope I can be of some use to this board and helping to keep UOX3 alive.

Thank you in Advanced for your already Great efforts in scripting.

Stable Script

Posted: Wed Nov 08, 2006 6:06 am
by karther77
I was meaning to add this little tid bit of info. Making the stable script should in theory be fairly simple. I see they already have a script to make a statue and then the statue spawns a NPC horse. I figured a stable script would be something like this. Now since I don't know Java very well I will just explain.

Vendor searches area like wandering healer for anyone saying Stable then gives cursor and says which pet? You click on your pet which then records that horses stats into a save file maybe called stable.* and keeps the name of the pet and info. Then refreshes the hunger rate and heals the pet to its standard hit points. Then when you say retrieve (name of pet) it looks in that file for the ID tag or name of the pet then creates statue that will spawn that pet info with that name.

NOW..heh I know it seems simple enough but I just don't know if anyone has really tried this or not. I once saw someone on this board say to another that anything is possible with Java scripting, and this seems to be a simple fix, kinda like the workaround for the live animal in the buying a pet. It doesn't need to be a live animal only needs to be a NPC spawned pet with the same name to make it feel like its working. And money can be given or deducted at the time of retrieval out of bank or off PC or if no good availible no pet statue is spawned in player pack.

Thank you for listening to my ramblings. And now kill me and tell me how hard this really is ...hehehe Thanks again for all your hard work guys I see many good things to come from all who script..

Posted: Thu Nov 09, 2006 4:41 am
by Xuri
The only stablemaster script I've seen so far is an old one which didn't even actually remove the pets, just place them in pre-determined area (on a per-stablemaster-basis) so you could have stables filled with player-owned pets etc. That's generally not a very good approach though, as for one thing there'd have to be limited amount of room in each stable (for lag-reasons).

But it should definitely be possible to conjure up a stabler script of some sort. The problem would be how to save the information. Should each stablemaster be responsible for it's stabled pets, or should all stablemasters share the "database" of stabled pets so the player can stable in one location and release it in another?

If the former, how do we deal with stablemasters that go missing? What of any pets stored with that specific stablemaster?

Stableing

Posted: Thu Nov 09, 2006 5:19 am
by karther77
Good thought. I would go with the stabled pets are only with that one stable location since it makes more RP sense. I put my horse in Britan and it should be in Britan kinda idea. The other part, Hmm.. How about a stablemaster that doesn't wander for one easy to do, this way doesn't go missing. Or another question, why does it have to be a specific stablemaster. Can the game or Java script not tell current stablemaster to look in said file for name tag of animal and then create statue of that type NPC animal and name it with name from tag and put it in player pack.

Kinda like this, I give my horse to stablemaster Joe. Joe takes my pet removes it from game and puts in a file the stats of a NPC horse with my name tag. Then I go to other stablemaster named Tom and ask Retrieve (pet name) Tom (from script) searches file for name tag of pet told to him and if found creates NPC statue of Horse with that name tag and places it in player bag and deducts gold. Again I am only saying this in theory due to I don't know java well. But from other scripts I have seen it shoudl be able to be done. Can the Java not be written to make the global stablemaster script do the same thing that all of them would be doing since it would be global. Let me explain again more detail.

Why couldnt script also (when you click on the horse) it records the name of NPC item , mainly that it is a horse and the tag it uses ( so to give same colour back and all) and then searches the animal.dfn for this type of horse NPC and then puts this info into another file (that we would create and tell script to know) called animalstorage.* then it tags the name of it to the name of the animal same as it was into that new file, then refreshes health stats and hunger stats on template in that file. This way it wouldn't matter what other stablemaster you went to they all run the same script. Because when you went back and said Vendor Retrieve (name of your pet) the NPC would then search said file that we created for the Name of that pet. Then create a statue with said name and deduct gold fomr player and put statue in player bag. When player clicks on NPC statue of horse it spawns that horse with that name. Again I don't know if this is possible but untill someone tries it who will know. I reallt beleive it can be done I just wish I new how to do Java..hehe.... I have seen other scripts for stables for other types of emulators for UO. SO I know it can be done in UOX3 which is what I use.

Hope I didnt run it together to much and I hope someone will try to tackle this and at least check it out. I talked with a few friends of mine that do java and they said it sounds like a good idea and seems like it could be done but since they are from my work I could not really have them help with this. SO I am asking here my home away from home...

One last thought on this idea, You could do single locations as a per stablemaster location not being linked to the stablemaster but a global script they all follow, but to make it so you could only get the horse at britan and not in vesper you could use a tag something like a region tag or cooridnates couldnt you.? Like a IF at (x...y...) Then Get Info from file. If not then TellChar Sorry your horse is not at this stable. I don't know something like that..:) God I wish I knew Java.. Reading up on it now to learn more.

Thank you all again for at least reading this and listening to me again.. For what its worth...Thank You

Posted: Thu Nov 09, 2006 11:07 am
by Xuri
Ideally we'd just skip the "pet statue" part and just spawn the pet character directly when the player retrieves it from the stables. When you buy a new pet from an animal trainer it adds a pet statue because the Javascript event which is supposed to trigger when you purchase something from an NPC shopkeeper doesn't work properly (or isn't even implemented at all). But for stablemaster scripts we don't have to add those statues since we're in control of everything that happens and can spawn the pet directly.

Your idea of using regional tags for local stablemasters is good, if the data is saved in a global file accecssible to all stablemaster. That way it won't matter if a stablemaster is accidentally killed/removed from the game somehow, as a new one will be able to read from the datafile which pets are stabled in his region.

The only thing I'm currently missing to be able to write a script like this is knowledge of how the file i/o in the javascript engine is supposed to work :P I have no idea how to write stuff to a file and read it again later on.

Posted: Thu Nov 09, 2006 4:44 pm
by karther77
ok I think I might have been able to help with the writing to a file and reading from it again. Here is what I found. I don't know if this will help but I hope so,- to give you an idea of how to do this so maybe you could write this into what you have as an idea for the other part of it.


//Writing to a file.

import java.io.*;

public class MyFirstFileWritingApp
{
// Main method
public static void main (String args[])
{
// Stream to write file
FileOutputStream fout;

try
{
// Open an output stream
fout = new FileOutputStream ("myfile.txt");

// Print a line of text
new PrintStream(fout).println ("hello world!");

// Close our output stream
fout.close();
}
// Catches any error conditions
catch (IOException e)
{
System.err.println ("Unable to write to file");
System.exit(-1);
}
}
}


//Reading from a file

import java.io.*;

public class MyFirstFileReadingApp
{
// Main method
public static void main (String args[])
{
// Stream to read file
FileInputStream fin;

try
{
// Open an input stream
fin = new FileInputStream ("myfile.txt");

// Read a line of text
System.out.println( new DataInputStream(fin).readLine() );

// Close our input stream
fin.close();
}
// Catches any error conditions
catch (IOException e)
{
System.err.println ("Unable to read from file");
System.exit(-1);
}
}
}

Posted: Thu Nov 09, 2006 6:49 pm
by Xuri
Ahh.. Something needs clearing up. The scripting engine in UOX3 isn't Java-based. It's C Javascript-based (SpiderMonkey). =) So Java-specific io-code won't do much good I'm afraid.

And I'm unsure whether or not the current implementation in UOX3 supports native javascript file i/o, or if it's only the uox3-specific file i/o methods mentioned under the "File I/O Methods" section in the UOX3 Javascript Docs. Those appeared to be somewhat limited in function the last time I tried them. :|

So..whats next

Posted: Fri Nov 10, 2006 11:57 pm
by karther77
Hmm.. thats no good. So with this knowledge then what's next. There has to be a way with Java to write this Stable script. I was wondering what server you run for your server or if you even run one.? And what scripts you run if any for your UOX3 server.? Also using UOgateway I see that there are no poeple running UOX3 they all sphere*.* or RunUO why is that.? Just wondering because I always thought that UOX3 was the better one. But I don't know of any servers out there with them running it.

Well I hope that someone takes this and runs with it. A stable would be a Main item to be in the game to make it a better place along with many other items but it seems like getting the main building working would be a starter.

Well I will keep looking for answers for this problem. And hope to find more scripts for UOX...