Jump to content
  • 0

NPC attacks on quest accept & morph problem


marcojacobs

Question

Hello,

I'm currently fixing some bugged quests and I've run into a problem which I can't seem to get fixed.

The NPC Tyrion gives the quest The Attack!.

Once I accept this quest Tyrion turn hostile and starts to attack me. I've looked through the whole database and found 1 entry that changed the NPC flag. I've removed this entry but the NPC keeps getting hostile once I accept the quest. Furthermore I've found nothing else that changes the npcflags, faction and so on for this NPC.

I've also came across another bug. In the quest a NPC get's morphed to another NPC, which works like 50%. The NPC get's the new model, but the name & scale doesn't change. I've made sure everything was correct in the creature_template entry but it still doesn't want to change, except for the model.

Is there something else what would trigger this event? Could really use some help :)

If you need more information feel free to ask and I will deliver!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Having a non-standard NPC behaviour, you need to find what of 4 scripting engines defines it. Eluna script bindings are not in the DB (but in files, for this case under lua_scripts\eastern_kingdoms\elwynn_forest\stormwind), so put it aside for now. We have two involved entities: the NPC and the quest. Below the results from Dev21 branch are shown.

Begin with the quest.

SET @QUEST=434;
SELECT `entry`,`Title`,`id` FROM `quest_template`,`db_scripts` WHERE `entry`=@QUEST AND (`script_type`=0 AND `id`=@QUEST);

The responce is long enough, I do not show it:

14 row(s) returned

These are action defined "at quest start" (enum DBScriptType in ScriptMgr.h, DBS_ON_QUEST_START). Postpone a bit the study of the DB script found and, just to be sure, check NPC also.

SET @ENTRY=7766;
SELECT `entry`,`name`,`AIName`,`ScriptName` FROM `creature_template`,`script_binding` WHERE `entry`=@ENTRY AND (`bind`=@ENTRY AND `type`=0);

The responce:

entry,name,AIName,ScriptName
7766,Tyrion,EventAI,npc_tyrion

At this point we see some overkill here: 3 engines try to handle the NPC and the quest accept event. Non-empty AIName is for the EventAI engine, ScriptName - for the SD3 engine. This is added to the DB script found above. Well, this is a sample of a bad style but it is allowed in case the engines handle different events. Otherwise the priority is given to the SD3 engine. The NPC behaviour you described is exactly one defined within the SD3 script handling the same "quest accept" event as the DB script for the quest. Luckily, EventAI does not participate in this:

SET @ENTRY=7766;
SELECT * FROM `creature_ai_scripts` WHERE `creature_id`=@ENTRY;

that gives only single line with `event_type`=4, i.e. EVENT_T_AGGRO.

So, searching for the solution, we have to study the DB "on quest accept" script.

SET @QUEST=434;
SELECT * FROM `db_scripts` WHERE `script_type`=0 AND `id`=@QUEST ORDER BY `delay`;

At a glance, it is much richer than SD3 script. You might unbind the SD3 script and check what happens:

SET @ENTRY=7766;
DELETE FROM `script_binding` WHERE `type`=0 AND `bind`=@ENTRY;

Link to comment
Share on other sites

Further, the DB script command SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL=23 uses Unit::SetDisplayId() method changing, as intended, only the NPC model. There is another command, SCRIPT_COMMAND_CHANGE_ENTRY=39, using Creature::UpdateEntry() method which seemingly fits better in this place. Though to find this command, you must look into the sources, the wiki documentation is outdated.

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