void SpawnShell::killSpawn(const newCorpseStruct* deadspawn) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::killSpawn(id=%d, kid=%d)\n", deadspawn->spawnId, deadspawn->killerId); #endif Item* item; Item* killer; item = m_spawns.find(deadspawn->spawnId); if (item != NULL) { Spawn* spawn = (Spawn*)item; killer = m_spawns.find(deadspawn->killerId); // ZBTEMP: This is temporary until we can find a better way // set the last kill info on the player (do this before changing name) m_player->setLastKill(spawn->name(), spawn->level()); spawn->killSpawn(); updateFilterFlags(item); updateRuntimeFilterFlags(item); emit killSpawn(item, killer, deadspawn->killerId); if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tKillSpawn); } }
Spawn::Spawn(Spawn& s, uint16_t id) : Item(tSpawn, id) { setName(s.name()); setLastName(s.lastName()); Item::setPoint(s.x(), s.y(), s.z()); setPetOwnerID(s.petOwnerID()); setLight(s.light()); setGender(s.gender()); setDeity(s.deity()); setRace(s.race()); setClassVal(s.classVal()); setHP(s.HP()); setMaxHP(s.maxHP()); setGuildID(s.GuildID()); setLevel(s.level()); for (int i = 0; i <= tLastCoreWearSlot; i++) setEquipment(i, s.equipment(i)); setEquipment(tUnknown1, 0); setTypeflag(s.typeflag()); setNPC(s.NPC()); setAnimation(s.animation()); setDeltas(s.deltaX(), s.deltaY(), s.deltaZ()); setHeading(s.heading(), s.deltaHeading()); setConsidered(s.considered()); // the new copy will own the spawn track list m_spawnTrackList.setAutoDelete(false); m_spawnTrackList = s.m_spawnTrackList; s.m_spawnTrackList.setAutoDelete(false); m_spawnTrackList.setAutoDelete(true); }
Spawn* SpawnShell::findSpawnByName(const QString& name) { ItemIterator it(m_spawns); Spawn* spawn; for (; it.current(); ++it) { // the item and coerce it to the Spawn type spawn = (Spawn*)it.current(); if (name == spawn->name()) return spawn; } if (name == m_player->name()) return m_player; return NULL; }