Jump to content

[MaNGOS University] Freshman Walkthrough 1: Prevent NPC from offering a quest


golond

Recommended Posts

Hello all,

I know SQL, and I know a bit of C++, but the MaNGOS project is of such a scope that it's difficult to just jump in and start contributing to the project. I read the first installment of the Mangos University, and thought it was fantastic information, but there just isn't enough content yet to really explain to a newbie like myself whats really going on. So, rather than wait for another stellar installment from TheLuda (you're amazing), I'm going to try to document my stumbling efforts to figure out how to sail this ship! Some of what I try works, some of it doesn't, but I document it all in the hope that my fumblings will show how failures can eventually lead to success.

In this first installment I'll walk you through my attempt at preventing an NPC from offering a quest that they really have nothing to do with. Please note that this glitch may not apply to the version of MaNGOS that you are running, so this might not be something that you can really follow along with on your own rig.

Goal:

Prevent "Watcher Callahan" in Duskwood from offering the quest 'A Warden of the Alliance', which is usually a quest given by an orphan that you've escorted around the world during orphan week.

Step 1 - Determine the id of 'watcher callahan'

Step 2 - Determine the id of the quest 'A Warden of the Alliance'

Step 3 - Determine how the NPC and quest are linked in the database

Step 4 - Break the link

Bonus 1 - Determine who SHOULD give the quest

Bonus 2 - Create that link

========================================

Preliminary Requirement:

You must be able to interact with your database. If you've installed MaNGOS and have a server running, you should be able to do this. If not, you'll have to do some additional research elsewhere before this post will be of much help.

Note:

I'm using mysql on a Linux operating system (Ubuntu), all commands work there but may need to be modified based on your db engine.

Tips & Tricks:

If this is your first foray into the database, here are some things that will be extremely helpful in your exploration:

list the databases:

show databases;

tell mysql which database you will be running queries against:

use <database>;

list the tables in the database you are 'use'ing:

show tables;

setting results pager so you can scroll back and forth or quit out of huge results:

pager less;

TheLuda has been working on documenting the database (I'm currently running mangostwo, but a lot of the tables are the same as mangoszero which he is working on at the time I'm writing)

https://bitbucket.org/danielsreichenbach/mangos-zero-database/wiki/Home

=========================================

Step 1 - Identify the NPC

All creatures (including NPCs) have the bulk of their persona stored in the 'creature_template' table in the mangos database. This includes their name, armor attributes, race, etc. I searched this table for a creature named 'Watcher Callahan'.

use mangos;

SELECT * FROM creature_template WHERE name = 'Watcher Callahan';

This returned one result with an 'entry' column of '2142', which will be the identifying id that will links to other tables in the database.

We should also make sure that this NPC only shows up in one spot in the world.

SELECT * FROM creature WHERE guid = 2142;

There is only one entry there too, with an id of '1142', so I'm pretty guaranteed that the instance of 'Watcher Callahan' that I ran into in Westfall is the guy I've found in the database.

To recap, the template for the npc has guid 2142 and one copy gets generated in the world, and that copy has an id of 1142.

==========================================

Step 2 - Identify the quest

Using the show tables; command I found the quest_template table, which looked too similarly named to creature_template to be a coincedence. Looking through the table fields there were several that stood out as important. 'entry', 'Title', 'Details', 'Objectives' all look like things that might be useful in identifying the quest I'm looking for.

Select * from quest_template where Title = 'A Warden of the Alliance';

Bingo. entry 171 is our quest.

==========================================

Step 3 - Identify why the NPC is offering this quest

So, I stumbled across the proper table "creature_questrelation" after having missed it several times and scouring lots of the other tables in the database (like creature_template and quest_template) for some sort of linkage. creature_questrelation indicates which creature will offer which quests. The logic behind that gets more complex as quest chains, world events, etc. become involved, but for the straightforward quests, this table links a creature_template.entry value with a quest_template.entry value to determine which NPC will offer a given quest. In this case, there was an id column '2142' (which is the id of 'Watcher Callahan' as we saw in step 1) and a quest column '171'(which is the id of the 'A Warden of the Alliance' quest from Step 2). This database row caused the quest to be offered by the wrong NPC. For the longer messier version of how that information came to light, read the Bonus sections, since I actually picked up there when I couldn't find the 'creature_questrelation' table while initially trying to solve step 3.

==========================================

Bonus 1 - Try to determine who the quest SHOULD be offering the quest.

In the 'OfferRewardText' field of the quest (entry 171) the quest reward giver (Orphan Matron Nightingale) refers to the orphan who is supposed to give the quest as 'Randis'. Randis must be the orphan who shold give the quest, right?

Select * from creature_template where name = 'Randis';

No results. Hmm. The orphan Randis sort of acts like a vanity pet, following you, around as you do things, and each player could potentially have their own 'Randis'. Maybe there is a pet table somewhere that has him in it, and that entry could be linked to the quest? The mangos database tables don't have anything related to vanity pets, just combat pets... Possibly the quest item 'Human Orphan Whistle' mentioned in the quest, and that supposedly summons the orphan 'Randis' can lead us to where he is in the game data? Lets check the gameobject_template table for that item:

Select * from gameobject_template where name = 'Human Orphan Whistle';

no results. The gameobject_template looks more like physical world objects like doors and such than inventory items like a whistle. Inventory items must not be in the gameobject_template table.

Select * from item_template where name = 'Human Orphan Whistle';

Yes! entry = 18598. Other field of note looks like 'spell_id' which is '23013', and must be the spell that summons 'Randis'.

select * from spell_template where id = 23013

no results. hmm.

Going back to the game, I use a gm command to give myself the item in question

.additem 'Human Orphan Whistle'

Right clicking it casts the spell 'Summon Orphan', and sure enough, a Human Orphan appears next to me. He's not named 'Randis', though. That's probably why we couldn't find him in the database. Right clicking on him does pop up a dialog with quests including "Jaina's Autograph" and "You Scream, I Scream". We may be able to use those, and the creature name 'Human Orphan' to figure out how this creature behaves.

Select * from creature_template where name = 'Human Orphan'

returns entry = '14305' but nothing specific about MY orphan.

Select * from creature where guid = 14305

gets one result. Is that the guy I just summoned? He has map = 1, zone = no such field?, position_x = -1803, position_y = -3174 Lets compare that to my

own map/zone/position...

use characters;

select * from character where name = 'golond';

map = 0, zone = 40, position_x = -0546, position_y = 1197

Soooo, it doesn't seem like that's the same creature/pet/whatever.

but wait, I saw a 'character_pet' table.

Select * from character_pet;

Sadly, only hunter pets seem to be stored here.

It sort of seems likely that the spawning of vanity pets is completely in game memory and they don't have an actual entry in the database. Actual vanity pets (not one called with an inventory object) are probably stored as character spells. I don't know. Yet.

Anyway, lets take a look at the quests and see if we can get anywhere from that angle.

use mangos;

Select * from quest_template where title = 'Jaina''s Autograph';

We get a hit with entry = 558! Unfortunately none of the database fields look like they relate to anything like quest giver NPC or quest turn-in NPC. Weird. Except that I'm looking in a _template table, which means it isn't an actual instance of the quest. Lets try searching the creature_questrelation table that I just now noticed:

select * from creature_questrelation where quest = 558;

That returns creature id 14305

According to the mangos zero database wiki (see link in preliminary section), that id is a creature_template id. It also happens to be the id we already know belongs to 'Human Orphan'.

So, to see all quests that the orphan gives PLUS the quest that we think he should give, lets run:

select creature_template.name, quest_template.title from creature_questrelation, quest_template, creature_template where (creature_questrelation.id = 14305 or creature_questrelation.quest = 171) and creature_questrelation.quest = quest_template.entry and creature_template.entry = creature_questrelation.id;

+------------------+---------------------------+

| name | title |

+------------------+---------------------------+

| Watcher Callahan | A Warden of the Alliance |

| Human Orphan | Jaina's Autograph |

| Human Orphan | The Bough of the Eternals |

| Human Orphan | The Stonewrought Dam |

| Human Orphan | Spooky Lighthouse |

| Human Orphan | You Scream, I Scream... |

+------------------+---------------------------+

It looks like there should be some quest chaining action involved here, with one quest leading to another, but thats well beyond the scope of just removing the exclamation point from over Watcher Callahan's head.

update creature_questrelation set id = 14305 where quest = 171 and id = 2142;

That at least moves the quest to the proper NPC, even if the sequencing of that quest is not correct.

Checking both the human orphan 'pet' and Watcher Callahan, the quest was still being given by the wrong NPC. I restarted the server, and the quest had switched from Watcher Callahan to the Human Orphan, indicating that the quest data is loaded into memory at server start.

=========================================

New questions:

Once I've found something wrong in the database, where do I submit my changes so the community can benifit? (once I've fixed the quest chain, of course!)

Is Watcher Callahan providing access to all the quests he should be?

Is the orphan quest chain correctly configured? (No!)

When is orphan week, and how is it designated in the database?

Why can I summon an orphan with the whistle when it isn't orphan week?

Where are vanity pets stored in the database?

Ripples in the pool... Who knows where they'll lead?

Link to comment
Share on other sites

Is the orphan quest chain correctly configured? (No!)

The rquiered fields to define quest chains are PrevQuestId, NextQuestId and NextQuestInChain and can be found in the table quest_template. All the fields are well explained in the mentioned documentation.

When is orphan week, and how is it designated in the database?

Game events like the orphan week (ID 10) are defined in the table game_event. All related creatures and gameobjects which should spawn and despawn at the start and end of an event are stored in game_event_creature and game_event_gameobject. There is also game_event_quest for quests which become available during an event and therefore they will be added to an existing creature.

Why can I summon an orphan with the whistle when it isn't orphan week?

The whistle has a tag in its description which states "Requires: orphan week". This means the item will be removed from the players inventory, once the event is over. But you're a gamemaster and savour special benefits.

Where are vanity pets stored in the database?

Since they're summoned the instance of them are stored in the memory. But you can find them in the table creature_template. Summon a non combat pet, select it and type .npc info. You get a list of information inter alia an entry, which refers to creature_template.entry.

Link to comment
Share on other sites

  • 2 years later...

Hello Everyone,

Sorry to Necro this post, but I figured it would be beneficial to have the answer for my question in this threat since it's related.

I'm trying to create a custom quest.

I used the "Your Place in the World" as a template. It follows the same patterns you get a quest to go turn in at another NPC, no other requirements.

Created it in quest_template and linked it to the appropriate NPC in creature_questrelation.

However, I can't seem to find the database or field to turn this quest into.

There is only the quest giver link in creature_questrelation.

Thank you,

Tri

EDIT: Apparently I jumped the gun on asking the question, and found the answer. I'll keep the post as it relates to this topic and for the purpose of others looking for the answer. The answer is creature_involvedrelation table.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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