Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Database/World Building

Development::Database/World Building World Building forum, dedicated to the EQEmu MySQL Database. Post partial/complete databases for spawns, items, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-06-2013, 06:42 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

it shouldn't be an issue unless there are areas of the server's source code that select all fields (via *) from the npc_types table and expect them to be in a particular order (or a specific field count). you also want to be aware that it'll probably make any gm (#) commands that might add entries to the npc_types table behave (or fail) unexpectedly.

you could make a separate table entirely and store just the id of any npc_type that you know is a pet. then when you're running queries, you can use "... WHERE npc_type.id IN (SELECT npc_type_id FROM known_pets)" as a filter.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #2  
Old 02-06-2013, 06:48 PM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

The second method sounds better, as I'd prefer to avoid any negative side effects. It could also easily be shared with others this way I think. Just a table such as npc_pets, with petid column and npc_types id column.

By doing this, you are saying that I could make changes in npc_types only to npc's listed in npc_pets table?

Mind giving an example of what this command would look like?

As always, thank you, c0ncrete.
__________________
Disorder
Reply With Quote
  #3  
Old 02-06-2013, 06:59 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

yeah, it's called a subquery.

say for instance you have a table called known_pets that has a column, called npc_type_id. this would obviously store the id for npc types that you know are pets.

if you wanted to double the hitpoints for all pets, you'd use the following query:

Code:
UPDATE
    npc_types
SET
    hp = hp * 2
WHERE
    npc_types.id
IN
    (SELECT npc_type_id FROM known_pets)
if you wanted to do something to everything that isn't a pet, you'd just use NOT IN, instead of IN.

be aware that subqueries can only return a single column from a table. more info can be found here: http://dev.mysql.com/doc/refman/5.0/en/subqueries.html
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #4  
Old 02-06-2013, 07:01 PM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

Very helpful. Thank you very much.

I'm always hesitant to do changes like this. THERE IS NO UNDO BUTTON!!!
__________________
Disorder
Reply With Quote
  #5  
Old 02-06-2013, 07:03 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

http://dev.mysql.com/doc/refman/5.1/...p-methods.html :p
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:48 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3