Sign in to follow this  
tmarchuk

[RELEASED] StableMaster Mod (Server) - v0.5 (May 20)

Recommended Posts

A server mod to add a stable master on the server-side which can exchange animals for animal tokens which can then be loaded onto boats for transport. It requires the latest version of Ago's server modloader, v0.18.

 

Trade/Sell On Personal Merchants

  • Added in version 0.4 it should now be possible to trade animal tokens and thus animals.

 

Server transfers

  • Added in version 0.3 is the ability to transfer animal tokens (and the associated animals) between servers. I would consider this capability beta and in need of further testing as if there is a bug it can make a mess of the database on both sides. If you intend to use this feature please wait until more testing occurs or use only for test. The other features from 0.2 haven't really changed outside of resizing the stable master payment dialog. I consider this functionality to be stable and released. I will update this post when testing completes on server transferring.
  • Note that brands and village permissions are lost on transferring animals attached to tokens because they are tied to villages that don't exist in the new server.
  • In version 0.5 additional server transfer logging has been added and there is an option to disable transfers but if a player transfers with tokens on a boat (despite the warning) those tokens will be lost. Tokens on the player will be available when the player comes back to the originating server.

 

This mod was created because I thought it was an interesting idea when I read Razor's request in this thread. I am providing it for no charge and have removed all donation links.

 

Release

Latest Release on github

Readme on github

Changelog on github

 

Credits

  • ago for making the modloader, posting all his code, and posting useful information about wurm unlimited modding. It was very helpful.
  • Razor for requesting the mod, showing there was interest and providing good ideas.
 

Instructions (Copied from Readme link above)

  • Download StableMaster.zip
  • Extract StableMaster.zip into Wurm Unlimited server folder (for example, C:/Program Files/SteamLibrary/SteamApps/common/Wurm Unlimited Dedicated Server). The StableMaster.jar file should end up in mods/StableMaster/StableMaster.jar.
  • Optionally modify the properties.
  • Start the server and connect.
 

Effects (Copied from Readme link above)

  • Adds a new NPC to the game, Stable Master.
    • By default the Stable Master is assigned an auto-generated template ID. This can be overridden to set a specific ID by setting "specifyStableMasterId=true" and setting the ID as "stableMasterId=".
  • You can right-click the Stable Master while leading one or more animals and use the "Exchange animal" action to have the animals exchanged for Animal Tokens.
    • There is a fee (configurable) associated with exchanging each animal into an Animal Token.
    • The Animal Token weighs what the animal weighs (which can be excessive). There are configuration options to limit this to a minimum ("animalTokenMinimumWeightGrams") and a maximum ("animalTokenMaximumWeightGrams") value. Note that the maximum is applied after the minimum in case the minimum is larger than the maximum.
    • The Animal Token takes up the volume of a corpse by default but is configurable (X, Y, Z in centimeters.)
    • By default the Animal Token is assigned an auto-generated template ID. This can be overridden to set a specific ID by setting "specifyAnimalTokenId=true" and setting the ID as "animalTokenId=".
  • You can right-click on the Animal Token and use the "Redeem animal token" action to turn the token back into a animal at your current location.
  • The Animal Token can be loaded onto boats by activating the token, right-clicking the boat and selecting the "Load animal token" action.
    • By default the token cannot be loaded onto rowboats or sailboats but this is configurable with 'enableSmallBoatsLoad=true'.
  • The Animal Token can be unloaded from a boat by right-clicking on the token in the boat inventory and selecting the "Unload animal token" action.
  • Disabled by default, there is an option to enable directly right-clicking on a led animal and using the "Exchange animal" action for no cost. To enable set "enableNoNpcExchange=true"
 

Video

Youtube video showing partial usage from an early release when it uses mounts not lead animals (I need to update this at some point but it takes time to make good short videos):

 

Have fun!

-Tyson

Edited by tmarchuk
Update to v0.5
  • Like 6

Share this post


Link to post
Share on other sites

Added to test server for testing. 

Testing the following

1. More than one ticket in inventory

2. Storage of ticket

3. cluster transfer

4. DB cleanup after claimed ticket has been restored to a creature.

5. Testing with any mounted creature, bulls, etc.

 

Will keep you up to date on what we find.    Great work!

We plan to use this for a trade Pact system as part of livestock orders.   I take it you did mounts because it was easy to ID a mounted creature as the on_target function, since there is no real way to target say sheep, hens, etc.  

 

Share this post


Link to post
Share on other sites

Thanks. I appreciate all the effort testing. It's hard to know what should/shouldn't work sometimes because I am not a longtime Wurm player.

 

Mount=> Yes, unfortunately the action system in Wurm only really allows a few combinations of things to be 'selected' at once. Even though in the HUD you can select a horse and then right-click on the stable master in the server code you are only told that the user is 'targeting' the stable master and there is no mention of the horse. Maybe Ago knows of a better way to do this though, I'm open to suggestions. I was also a bit worried about the ability for someone to select someone else's animal and then turn it into a token by just selecting it. If you are mounted there is at least some implication of a right to use that animal. There is a branding system that might be possible to use to establish ownership I suppose. Again, I'm open to suggestions on how to modify it.

 

Livestock=> I didn't realize you were thinking of transporting bulk livestock versus mounts, I should have asked. If you want I can see if I can make it so that the right-click on the animal will work if there is a stable master within 'x' tiles and bring up the same exchange dialog for payment?

 

Weight=> Note that the server considers horses at least to be very heavy. I think around 1600kg when I checked. It's possible sheep and pigs and such are much lighter though.

  • Like 1

Share this post


Link to post
Share on other sites

Also, you might want to test across server restarts for your own peace of mind. I have tested across server restarts and haven't run into any issues but it's always better if more people take a swing at it. :)

 

For those that care, this essentially works by half-way killing the animal. The animal is marked as dead in the DB (but not deleted) and is removed from the game code that handles what a given creature (including players) 'see'. A token item is created with the appropriate size/weight/name and then the ID of the animal is stored as data on the new token item. When the token is redeemed the code looks up the stored ID and 'un-kills' the animal (marks as non-dead in the DB and adds to game code 'vision' system) and deletes the token item. It seems to work across server restarts because the server mostly loads all the creatures but doesn't do the final step of making them visible if they are marked as 'dead'. Hence the mod can just later mark them as not 'dead' and force them to be loaded into the vision system as normal.

 

Feel free to ask questions and or request changes. Here or PM or whatever you prefer.

  • Like 1

Share this post


Link to post
Share on other sites

I think it could work like hitching. You lead an animal then right click the stablemaster, he will take the first lead creature or give a list of all lead creatures.

 

I haven't really looked at the code, but does this handle cross server transfers in any way?

 

Also what happens with multi-player mounts (e.g. unicorns) if you convert it while another players is in the second seat? :P

  • Like 1

Share this post


Link to post
Share on other sites
37 minutes ago, tmarchuk said:

Also, you might want to test across server restarts for your own peace of mind. I have tested across server restarts and haven't run into any issues but it's always better if more people take a swing at it. :)

 

For those that care, this essentially works by half-way killing the animal. The animal is marked as dead in the DB (but not deleted) and is removed from the game code that handles what a given creature (including players) 'see'. A token item is created with the appropriate size/weight/name and then the ID of the animal is stored as data on the new token item. When the token is redeemed the code looks up the stored ID and 'un-kills' the animal (marks as non-dead in the DB and adds to game code 'vision' system) and deletes the token item. It seems to work across server restarts because the server mostly loads all the creatures but doesn't do the final step of making them visible if they are marked as 'dead'. Hence the mod can just later mark them as not 'dead' and force them to be loaded into the vision system as normal.

 

Feel free to ask questions and or request changes. Here or PM or whatever you prefer.

 

 

Testing all kinds of stress on it. I think its a great start!     

Yes this is phase one of a trade pact system we'll be using on Ages of Urath to promote travel, economy, business growth, and a stock market type exchange, and supports an RvR combat, political system, and pirate activity.    Its a very large project and all ties in together.     Once we get all the bugs hashed out we need to get you paid :)   

 

Im very excited you picked up one of our projects and hope you take a look at the other short list here and the long project list on our forums if you enjoy this type of work.    Projects range from $50 to $1000 depending on the complexity.  

 

 

Share this post


Link to post
Share on other sites

Yes leading is another option which should be easy to do. 

 

Cross server transfers are are not supported. My guess is that you would arrive in the new server with a token that wouldn't work and the animal would remain on the old server forever hidden. I think it would probably take a lot of effort to do cross server unless there is a nice function in the server somewhere to 'pack up' an entire creature. That's why I didn't delete/recreate the mount. There were brands and equipment and permissions, etc. that would take a lot of effort to serialize and I didn't even know where to serialize the data to. A new DB table? File? Open to help/thoughts here too. 

 

All players mounted should get dismounted (I call some sort of 'kick all passengers' function) but I haven't tested it. 

 

Lots of edge cases. ;)

 

Thanks for your insight bdew and your mods. :)

 

  • Like 1

Share this post


Link to post
Share on other sites

I tested the cross cluster.  You're correct.   

I really need this as Trade Pacts are run across 16 maps and 4 realm servers.  Maybe ago might provide some incite on how this could work.

 

Leading is a perfect solution for target.   Thanks bdew!  

Share this post


Link to post
Share on other sites

Ok. I will change to use leading instead of mounted tonight. I assume you want it to find out how many animals are being led, show the number and the charge for all (cost per exchange times animals being led?) 

 

I'll also look at cross server transfer possibilities. I haven't even looked at that code but they transfer players so it must be possible somehow. 

 

Given my misunderstanding 'mount token' seems inappropriate and confusing. I'll change it to 'animal token' but be aware this will break any existing tokens unless you change their template name in the DB manually. 

Edited by tmarchuk
Weird format. Changing template ID won't help.
  • Like 1

Share this post


Link to post
Share on other sites
17 minutes ago, tmarchuk said:

Ok. I will change to use leading instead of mounted tonight. I assume you want it to find out how many animals are being led, show the number and the charge for all (cost per exchange times animals being led?) 

   Correct. 

I'll also look at cross server transfer possibilities. I haven't even looked at that code but they transfer players so it must be possible somehow. 

   yea i know it has to be possible as I am now able to transfer between characters, Even tested placing on a vendor ... worked fine.

 

Given my misunderstanding 'mount token' seems inappropriate and confusing. I'll change it to 'animal token' but be aware this will break any existing tokens unless you change their template name in the DB manually. 

   Perfect!

 

Share this post


Link to post
Share on other sites
1 hour ago, conmcb25 said:

This is exciting. Razor has a new toy :lol:

 

You know i love toys!!!

Share this post


Link to post
Share on other sites

Ok, I've released v0.2 that changes the terminology to 'animal token' and allows N led animals versus 1 mounted animal. I tested it with a sheep and horse simultaneously and it seemed to work. I will investigate the cross-server issue now and let you know what I find. I will update the first post shortly to contain the updated version and notes.

  • Like 1

Share this post


Link to post
Share on other sites

The good news is that I think I know where to add the code to send/receive the animals associated with the tokens. The bad news is that it looks like there might be a ton of data to send. Essentially the entire Creature information would be required I think. I'll look at it more tomorrow though to see how much of the data is unique and how much is just template or boilerplate. Perhaps I can just send the template plus the unique data and recreate the animal on the other side.

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, tmarchuk said:

The good news is that I think I know where to add the code to send/receive the animals associated with the tokens. The bad news is that it looks like there might be a ton of data to send. Essentially the entire Creature information would be required I think. I'll look at it more tomorrow though to see how much of the data is unique and how much is just template or boilerplate. Perhaps I can just send the template plus the unique data and recreate the animal on the other side.

 

and you said this was not worth $500 bucks.   I told you you'd earn your money coding this :P    

Great work!  

 

Edit:   new version on test server.  I'll post anything I find. 

Edited by razoreqx
test server

Share this post


Link to post
Share on other sites

Looking good!  I am looking forward to this!

Share this post


Link to post
Share on other sites

Crashed my server :(  Will wait for another update..

 

Share this post


Link to post
Share on other sites
2 hours ago, SuperFly said:

Crashed my server :(  Will wait for another update..

 

Hi SuperFly,

Could you perhaps send me the server.log file that is generated when you run the server and it crashes? It should be in the same directory you run the server from. Or alternatively if you can copy the part of it that shows the stacktrace (lots of text about line numbers and classes and stuff) that would be the next best thing. Also, make sure you're using the latest version of the server loader v0.18. I had Ago make some changes for me in that version and the mod won't work with previous versions.

 

Sorry to hear it crashed, I'll do my best to find/fix it if you can help me find the bug! :)

Share this post


Link to post
Share on other sites

As an update on the server transfer... I've spent a bunch of time today working on it but there is a lot to do. I think I mostly understand what needs to be done and I've added over half of that but this is going to need some serious testing and feedback and I don't have multiple servers setup to test on yet. I'll keep plugging away at it but it'll probably be a week plus before it's ready to beta-test.

Share this post


Link to post
Share on other sites

on the test server cooking now.. I'll post the log files when i see anything out of the usual.   I did get a crash on the .2 but i didnt capture the log file.. I was waiting on .3  and cluster change ability  :)  

Edited by razoreqx

Share this post


Link to post
Share on other sites
5 hours ago, tmarchuk said:

As an update on the server transfer... I've spent a bunch of time today working on it but there is a lot to do. I think I mostly understand what needs to be done and I've added over half of that but this is going to need some serious testing and feedback and I don't have multiple servers setup to test on yet. I'll keep plugging away at it but it'll probably be a week plus before it's ready to beta-test.

 

If you need access to my test login and cluster server i can set that up for you.

Share this post


Link to post
Share on other sites

Hmm. I just tried again on my server and I can't get it to crash. Not sure if it's different mods loaded or I've just been lucky or something else. If you could reproduce the crash and send me the server.log that would be the best. If you didn't see the crash with 0.1 then it's probably something I did in 0.2. Mostly I just renamed things but I did add a bunch of permissions and weight checks and such and it's possible one of those is throwing an exception I'm not catching that depends on your character or server or something. Do you remember when the crash happened?

1. First running the server program.

2. Starting the server (pick server from dropdown and click one of the green buttons)

3. Converting an animal to a token (and what kind/how many of animal if you remember)

4. Loading a token on a boat (and what kind of boat/permissions if you remember)

5. Unloading a token from a boat.

6. Converting a token to an animal (and how far you were away from the place you exchanged it and anything you can remember you did between converting and exchanging it.)

 

Sorry for the long request. If I can't reproduce it I can't fix it and nothing in 0.3 is being done to change what happens in 0.2 right now so it's unlikely I'll fix it by accident. Thanks.

Share this post


Link to post
Share on other sites

My crash was after putting on a personal merchant.   Buying on another character.    And attempting to activate on the new owner of the ticket.    I stripped off all my mods before testing.  

Next round of testing will include mods.

 

 

Share this post


Link to post
Share on other sites

Thanks Razor. I definitely didn't test that and I'm surprised you were able to get it onto the personal merchant to start with because I thought I flagged the item as NOTRADE, NOBANK, etc. Sounds like you want to sell them though so I'll look into it, thanks.

Share this post


Link to post
Share on other sites
22 minutes ago, tmarchuk said:

Thanks Razor. I definitely didn't test that and I'm surprised you were able to get it onto the personal merchant to start with because I thought I flagged the item as NOTRADE, NOBANK, etc. Sounds like you want to sell them though so I'll look into it, thanks.

 

 I'm testing down a long list of functions to see what works and what doesn't.  I try just about anything a player can do as possible exploit of mechanical issue.

Edited by razoreqx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this