Jump to content

NPC Gossip/Text from SQL


antiroot

Recommended Posts

I know currently its not possible. But how difficult does anyone think it would be to have a special NPC that when a player talks to them they would pull their text straight from the database rather than from what mangos pulled at startup.

The idea is that there will be an NPC (we'll call him <High Record Master>) whenever a player speaks with this NPC, the NPC will then return data stored in a table just for this special purpose. the data would then be updated automatically by a script that would find all the highest statistic records for the players.

Example, Player talks to <High Record Master>, and sees the following in a dialog

Most Deaths - Player 1 (148)

Most times Fished - Player 4 (500)

Most gold looted - Player 5 (200000)

And so on. There's two ways I can think to handle this, one have this NPC pull data straight from the DB every time the player asks for dialog. or have the NPC use the core cache but update his data in the core at timed intervals, say every 15-30 minutes.

The second would not give real time results but would be less load on the server since the data will only be fetched from the DB once (every 15-30 minutes) and then stored in memory

Link to comment
Share on other sites

Yes, I completely agree that having the NPC query the database every time a player accessed it would be very bad on the server, especially with a very full world.

So lets not even consider that idea, I only stated it because it was only 1 of 2 ways i can see accomplishing this

I believe all that needs to be done is at timed intervals just reload the NPCs cached text. There is console command reload page_text (i don't see one for npc_text, and I have not looked at the code to see if its loaded by another command argument) but if its possible to reload all texts, how difficult would it be to reload and replace a single record.

I'm thinking If a new RA/console command could accomplish this where you'd just pass for example

.reloadsingle [npc_text|] [id]

then it would very few changes to the core itself and would not change anything that other parts of the core depend on. this command could then be executed from a cronjob or similar every 15-30 minutes

Edit: The other benefit to making a command would be that the core would only run this feature if the Admin told it to.

The Async query (like character loading) would be nice, but then it would run all the time on its own, I'd rather be in control of when this feature were to be active or not

Another Edit: I already know that the functions for reloading the tables/cache works by freeing/deleting the data and then reloading it. So the current functions would not be able to handle what I want. But I'm hoping it should still be doable

Link to comment
Share on other sites

Good point to absent reload command. No reason for absent in fact. So i will add it.

Also described way must work fine also

not sure that single reload so wide need, and i just lazy implement it for all tables that expected from command ;)

but as custom command it can work fine. For discussed table need just reassign single value to structure

Link to comment
Share on other sites

in case you want to follow such an idea more closely:

In wintergrasp there must be a book with pagetext counting the wins for alliance and horde.

So this might be a good point to take a sniff if in such a case the SendTexts opcodes are sent with special arguments which are used there.

As such information suggests used world-states I think it might be possible that this is a more advanced place to go,

This also reminds me to some points we talked about some SD2-instance like scripts for normal maps which might give a good frontend to store and load such datas

Link to comment
Share on other sites

@Schmoozerd, thanks I had no idea there was anything in official that functioned that way, although this "book" object sounds like it is for world stats and not player stats. The concept there is still intriguing and I'll look into it a little when I have time

@VladimirMangos, well it's good to know this thread found an absent command.

As far as my custom function for reloading single records, I don't believe any developer should spend too much time on it if they choose to, because what we have currently works for the core and such a command serves no real purpose to the rest of the core (yet?)

I'm sure I could get make the function on my own, just wanted to get some developer insight before starting. I'm also working on getting stats/achievements for creature kills, although its very hacky and I don't think it will appear in the core the way i'm doing it because i'm using hardcoded values for the creatures since they don't seem to exist in the dbc (these are for the stats like "NPCs Killed, Critters Killed, Beasts, Undead, etc")

My goal is to have a sort of mini-game/competition in the world, so players can compete at beating each others stats. And have these custom <High Record Masters> located in a few cities towns where players can check who hold the highest record. Maybe use custom gossip menus and have it display bracketed records so level 1-10, 11-20, and so on

thanks to both of you for your ideas and opinions

Link to comment
Share on other sites

@VladimirMangos thanks for the feedback about the text being cached. Would this also be the case for page_texts? if not then I can drop the npc idea and create a custom item that operates as a book.

I would assume page_texts would be cached by client as well, but since there is a reload page_texts command I thought I would ask anyways

Edit: I just saw pagetextcache file on my client, it's empty however (possibly because i've not accessed any page text on this client machine, need to check on another machine later)

So I guess back to the drawing board for this idea

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use