Pastebin

New pastes are no longer accepted · Stats

Latest Pastes

NPC.CPP Spell Shop

this->skill_name = static_cast<std::string>(map->world->spells_config[util::to_string(this->id) + ".name"]);
    Config::iterator spells = map->world->spells_config.find(util::to_string(this->id) + ".learn");
    if (spells != map->world->spells_config.end())
	{
		std::vector<std::string> parts = util::explode(',', static_cast<std::string>((*spells).second));

		if (parts.size() > 1)
		{
			if (parts.size() % 14 != 0)
			{
				Console::Wrn("skipping invalid trade spell data for NPC #%i", id);
				return;
			}

			this->spell_shop.resize(parts.size() / 14);

			for (std::size_t i = 0; i < parts.size(); i += 14)
			{
			    NPC_Spell_Trade *spell(new NPC_Spell_Trade);
				spell->id = util::to_int(parts[i]);
				spell->gold = util::to_int(parts[i+1]);
				spell->level = util::to_int(parts[i+2]);
				spell->clas = util::to_int(parts[i+3]);
				spell->spell1 = util::to_int(parts[i+4]);
				spell->spell2 = util::to_int(parts[i+5]);
				spell->spell3 = util::to_int(parts[i+6]);
				spell->spell4 = util::to_int(parts[i+7]);
				spell->str = util::to_int(parts[i+8]);
				spell->intt = util::to_int(parts[i+9]);
				spell->wis = util::to_int(parts[i+10]);
				spell->agi = util::to_int(parts[i+11]);
				spell->con = util::to_int(parts[i+12]);
				spell->cha = util::to_int(parts[i+13]);

				this->spell_shop[i/14] = spell;
			}
		}
	}