Welcome to the Builder Academy

Question Objects resetting to prototype on oedit save

More
26 Feb 2015 05:09 #5236 by cosine_omerta
Hey folks. I was just working on randomizing object stats on load, and realized that whenever I saved an object, all instances of that object would reset to the values of the prototype.

To stop that from happening, I found a function in genobj.c, named update_all_objects(), which is called in add_obj(). Update_all_objects() basically goes through and does that resetting of objects to the prototypes that I wanted to get rid of.

I'm curious if anybody has any experience with this, and if just getting rid of update_all_objects() is a decent way of managing this, or if there are better ways, or if this is a bad idea. Any thoughts or advice is appreciated. Thanks.

Please Log in or Create an account to join the conversation.

More
26 Feb 2015 22:07 #5237 by thomas
Look into the UNIQUE flag - it should make the object save with the current values instead of the prototype's.

Please Log in or Create an account to join the conversation.

More
28 Feb 2015 01:30 #5238 by cosine_omerta
What do you mean by a UNIQUE flag? I don't see anything of the sort in the tbaMUD code. Is this just an object flag? I wouldn't want to have to set every object with a flag for this, I'm more interested in none of them ever being reset to the prototype.

Please Log in or Create an account to join the conversation.

More
28 Feb 2015 13:25 #5239 by thomas
My bad - it seems the unique flag got the boot some years ago.

Anyhow - the call to update_all_objects() is necessary to make the changes you make in olc stick. It doesn't change EVERY objecvt, just the ones that are from this prototype.

If you remove this call, all existing items in the world carried by monsters, players or lying around in inventories, etc. will not be updated when you save the object.
If you wish for items to keep specific stats to keep them after a save, I'd suggest you rewrite this function to check those specific situations. Those values would then be impossible to update in existing objects (!) through OLC. In my opinion a better solution would be to add another option in the OLC menu, along the lines of "update prototype but leave existing items alone". This version could then set necessary flags to avoid calling this function.

Please Log in or Create an account to join the conversation.

More
28 Feb 2015 19:08 #5240 by cosine_omerta

If you remove this call, all existing items in the world carried by monsters, players or lying around in inventories, etc. will not be updated when you save the object.

That's exactly what I'm trying to do. When I update a prototype in OLC and then save, I want no instances of that object, anywhere, to update to the new prototype, ever.

I was just trying to figure out if this function was the key to that, or if it was used in some other way that I didn't see.

Thanks for your help.

Please Log in or Create an account to join the conversation.

More
06 Mar 2015 13:36 #5241 by cunning
First off, you want the prototype to update. Do you really want all those version of the object to be going on? It is really tough to keep up with.

If you want some sort of uniqueness like I do, I referenced "The Rasputin code" from here. I added the unique flag and code snippets to make it work.

Now it updates a stock item to match the prototype, but for unique items that have been "enhanced" you can save them out and not worry about having them come back in as like the prototype.

The main reason the Tbamud base code does this is because it saves on memory and size of rent files. It just saves out the obj VNUM and upon logging in, it references the prototype for that VNUM. Walla, now the object is loaded into the players inventory or in its last EQ position.

Please Log in or Create an account to join the conversation.

Time to create page: 0.204 seconds