Pastebin

New pastes are no longer accepted · Stats

Latest Pastes

StatSkill.cpp Spell Shop/Data

case PACKET_OPEN: // Talked to a skill master NPC
		{
		   if (this->state < EOClient::Playing) return false;
			CLIENT_QUEUE_ACTION(0.0)

			short id = reader.GetShort();

			UTIL_PTR_VECTOR_FOREACH(this->player->character->map->npcs, NPC, npc)
			{
			    if (npc->index == id && (npc->spell_shop.size() > 0 || npc->spell_shop.size() > 0))
				{

				    this->player->character->npc = *npc;
					this->player->character->npc_type = ENF::Skills;

                    reply.SetID(PACKET_STATSKILL, PACKET_OPEN);
                    reply.AddShort(npc->id);
                    reply.AddBreakString(npc->skill_name.c_str());

                    UTIL_PTR_VECTOR_FOREACH(npc->spell_shop, NPC_Spell_Trade, spell)
					{
						reply.AddShort(spell->id);
						reply.AddShort(spell->level);
						reply.AddInt(spell->gold);
						reply.AddShort(spell->spell1);
						reply.AddShort(spell->spell2);
						reply.AddShort(spell->spell3);
						reply.AddShort(spell->spell4);
						reply.AddShort(spell->str);
						reply.AddShort(spell->wis);
						reply.AddShort(spell->intt);
						reply.AddShort(spell->agi);
						reply.AddShort(spell->con);
						reply.AddShort(spell->cha);
					}
                    CLIENT_SEND(reply);
                }
			}
		}
		break;

		case PACKET_TAKE:
		{

		    int amount = reader.GetInt();
		    int spell = reader.GetShort();

            if (this->player->character->npc_type == ENF::Skills)
			{
				UTIL_PTR_VECTOR_FOREACH(this->player->character->npc->spell_shop, NPC_Spell_Trade, checkspell)
				{
					if (checkspell->id == spell && this->player->character->HasItem(1) >= checkspell->gold)
					{
						this->player->character->DelItem(1, checkspell->gold);
						this->player->character->AddSpell(spell, 0);

                        PacketBuilder builder(PACKET_STATSKILL, PACKET_TAKE);
                        builder.AddShort(spell);
                        builder.AddInt(this->player->character->HasItem(1));
                        CLIENT_SEND(builder);
						break;
					}
				}
			}
		}
		break;

		case PACKET_REMOVE:
		{

		    int data1 = reader.GetInt();
		    int spellid = reader.GetShort();
		    int data3 = reader.GetChar();

            if(this->player->character->HasSpell(spellid))
            {
                UTIL_PTR_LIST_FOREACH(this->player->character->spells, Character_Spell, spl)
                {
                    if(spellid == spl->id)
                    {
                        this->player->character->skillpoints += spl->level;
                        this->player->character->DelSpell(spellid);

                        reply.SetID(PACKET_STATSKILL, PACKET_REMOVE);
                        reply.AddShort(spellid);

                        CLIENT_SEND(reply);

                        break;
                    }
                }
            }
		}
		break;