PDA

View Full Version : Removing NPCs


AdrianD
08-13-2015, 06:09 PM
Pretty straightforward question:

I want to remove certain npc_types from the DB I use, we'll call it live_db because I would make blanket changes to the main DB.

Is it better to delete the npc_types I want to remove or to change whether or not they spawn?

I understand the issues with sharing a spawngroupid. My concern is if there are continual queries searching for an npc that doesn't exist.

For expample, those filthy iksars:


use live_db;
delete from npc_types where race = 128;

or

use live_db;
update spawnentry set chance = 0 select spawnentry.* from npc_types join spawnentry
where spawnentry.npcid = npc_types.id and npc_types.race = 128;


My application of this idea is a little different.

If there is an even more efficient way to do this, please divulge.

Shendare
08-13-2015, 06:22 PM
IIRC, you can log in with a GM account, target the NPC, and type #npcspawn delete.

Removes the npc_type and all spawning references to it.

Alternatively, #npcspawn remove clears all spawns for the npc_type, but leaves the npc_type in the database.

AdrianD
08-13-2015, 07:43 PM
Thanks Shendare.

That will be useful to me for immediate resolution.

I build expansions from a main DB with a set of queries to isolate rows based on various criteria. In a few tables, I added a column to assist with isolation.

Here is a specific example for what I am doing with anything before Luclin; I don't update every time:


use main_db;
update npc_types set expansion = 3 where race = 130;

run all expansion_build queries

use live_db;
update spawnentry set chance = 0 select spawnentry.* from npc_types join spawnentry
where spawnentry.npcid = npc_types.id and npc_types.race = 130;

ALTER TABLE npc_types DROP column `expansion`;


This won't remove the npc_types entries for the zones where race = 130 but, it will disable the spawn from occuring. My concern/question was if there is a better or more efficient way.

Shendare
08-13-2015, 07:58 PM
Ahh, bulk removal/deactivation of a bunch of npc_types by certain criteria, and the spawns associated with them. Gotcha. I'd likely go about it like this:

1. Remove the spawnentry records for the npc_types that fit the criteria.


DELETE * FROM spawnentry WHERE npcid IN (SELECT id FROM npc_types WHERE race=130);


2. Delete any spawngroups that are now empty:


DELETE FROM spawngroup WHERE (SELECT COUNT(*) FROM spawnentry WHERE spawnentry.spawngroupid=spawngroup.id)=0;


I'd also look for references to the doomed npc_types in other tables to be cleared out similarly to the first query before deleting the npc_types altogether.

AdrianD
08-13-2015, 08:07 PM
Thanks again.

I've thought about doing it that way. My concern with doing that is: if I want to add an expansion later, progression-style, it would be more difficult or less efficient to isolate the removed entries from the zone in the main_db than it would be to turn them off in the live_db * based on the extra column, `expansion`.

* My queries are set up to take the spawn2 from the zone, the spawnentry and spawngroup from the spawn2 and finally the npc_types from the spawnentry.

I could simply replace everything in that table, which I think would work.

Quick response, I may have other thoughts momentarily.

Shendare
08-13-2015, 09:05 PM
Aha, you want to be able to undo it. I would think easiest would be to change the spawns all to, say, instance 99. Then when you want them back in, you could reset them to instance 0 and they'd *poof* back in at the next repop.

AdrianD
08-13-2015, 09:24 PM
A switch would be nice for spawnentry. I'm kinda creating one in a roundabout way.

Fabled creatures, for example, usually have the same spawngroupid as their weaker counterparts. Some spawngroups, as you know, have a half dozen or more npc_types associated with it.

Disabling these spawngroups is not ideal. Desired is disabling the single npc associated with the spawngroup while being efficient about it.

Thanks Shendare.