From 0ac3b58c4c5079f22e6bf4b0efba7f5fe99565cd Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Wed, 21 May 2008 21:44:27 +0000 Subject: Merged revisions 4013,4027,4043,4174,4250,4254 via svnmerge from https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk ........ r4013 | crush_tmw | 2008-04-01 01:18:19 +0200 (Di, 01 Apr 2008) | 1 line Implemented NPC XML database which maps NPC IDs to one or more animation files and thus enables animated NPCs. ........ r4027 | crush_tmw | 2008-04-02 01:34:14 +0200 (Mi, 02 Apr 2008) | 1 line misspelled filename ........ r4043 | b_lindeijer | 2008-04-07 10:37:23 +0200 (Mo, 07 Apr 2008) | 3 lines Added XML::Document class which simplifies parsing an XML document and automatically cleans it up again. ........ r4174 | b_lindeijer | 2008-04-23 14:57:45 +0200 (Mi, 23 Apr 2008) | 2 lines Fixed svn:keywords properties and added header to guild.h. ........ r4250 | crush_tmw | 2008-05-19 18:18:38 +0200 (Mo, 19 Mai 2008) | 1 line Added the possibility to add particle effects to NPCs in npcs.xml. ........ r4254 | crush_tmw | 2008-05-20 15:58:26 +0200 (Di, 20 Mai 2008) | 1 line fixed some filename confusion messup in the last commit. ........ NOTE: This was my first commit using svnmerge. Please check if I did everything correctly. --- src/npc.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/npc.cpp') diff --git a/src/npc.cpp b/src/npc.cpp index e490b3cf..2177aedc 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -25,9 +25,11 @@ #include "animatedsprite.h" #include "graphics.h" +#include "particle.h" #include "net/messageout.h" #include "net/protocol.h" +#include "resources/npcdb.h" #include "gui/gui.h" @@ -36,8 +38,30 @@ NPC *current_npc = 0; NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network): Being(id, job, map), mNetwork(network) { - mSprites[BASE_SPRITE] = AnimatedSprite::load("graphics/sprites/npc.xml", - job - 100); + NPCInfo info = NPCDB::get(job); + + //setup NPC sprites + int c = BASE_SPRITE; + for (std::list::const_iterator i = info.sprites.begin(); + i != info.sprites.end(); + i++) + { + if (c == VECTOREND_SPRITE) break; + + std::string file = "graphics/sprites/" + (*i)->sprite; + int variant = (*i)->variant; + mSprites[c] = AnimatedSprite::load(file, variant); + c++; + } + + //setup particle effects + for (std::list::const_iterator i = info.particles.begin(); + i != info.particles.end(); + i++) + { + Particle *p = particleEngine->addEffect(*i, 0, 0); + this->controlParticle(p); + } } Being::Type -- cgit v1.2.3-70-g09d2