Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void world_execute_weddings(void *world_void)
- {
- World *world = static_cast<World *>(world_void);
- double now = Timer::GetTime();
- UTIL_FOREACH(world->maps, map)
- {
- UTIL_FOREACH(map->npcs, npc)
- {
- if (npc->marriage && npc->marriage->request_accepted)
- {
- if (!npc->marriage->partner[0] || !npc->marriage->partner[1])
- {
- npc->ShowDialog("Something went wrong. Stopping wedding");
- npc->marriage = 0;
- continue;
- }
- else if (!npc->marriage->partner[0]->online || !npc->marriage->partner[1]->online)
- {
- npc->ShowDialog("One of the wedding partners has exited the game. Stopping wedding");
- npc->marriage = 0;
- continue;
- }
- else if (npc->marriage->partner[0]->map != npc->map || npc->marriage->partner[1]->map != npc->map)
- {
- npc->ShowDialog("One of the wedding partners has left the map. Stopping wedding");
- npc->marriage = 0;
- continue;
- }
- else if ((npc->marriage->state == 5 && npc->marriage->partner_accepted[0]) || (npc->marriage->state == 8 && npc->marriage->partner_accepted[1]))
- {
- ++npc->marriage->state;
- }
- else if (npc->marriage->last_execution + (util::to_int(world->config["PriestDialogInterval"])) <= now)
- {
- switch (npc->marriage->state)
- {
- case 1:
- {
- npc->ShowDialog("We are here at the invitation of " + util::ucfirst(npc->marriage->partner[0]->name) + " and " + util::ucfirst(npc->marriage->partner[1]->name) + ", who have come before us to join together in marriage.");
- ++npc->marriage->state;
- }
- break;
- case 2:
- {
- npc->ShowDialog("Their relationship is based on love, respect, and a determination to face the future together in health or sickness, in joy and sorrow.");
- ++npc->marriage->state;
- }
- break;
- case 3:
- {
- npc->ShowDialog(util::ucfirst(npc->marriage->partner[0]->name) + ", do you take " + util::ucfirst(npc->marriage->partner[1]->name) + " to be your partner, and promise to love, comfort and stay together as long as you both shall live?");
- ++npc->marriage->state;
- }
- break;
- case 4:
- {
- PacketBuilder builder(PACKET_PRIEST, PACKET_REPLY);
- builder.AddChar(PRIEST_REQUEST);
- npc->marriage->partner[0]->player->client->Send(builder);
- ++npc->marriage->state;
- }
- break;
- case 5:
- {
- ++npc->marriage->state;
- }
- break;
- case 6:
- {
- npc->ShowDialog(util::ucfirst(npc->marriage->partner[1]->name) + ", do you take " + util::ucfirst(npc->marriage->partner[0]->name) + " to be your partner, and promise to love, comfort and stay together as long as you both shall live?");
- ++npc->marriage->state;
- }
- break;
- case 7:
- {
- PacketBuilder builder(PACKET_PRIEST, PACKET_REPLY);
- builder.AddChar(PRIEST_REQUEST);
- npc->marriage->partner[1]->player->client->Send(builder);
- ++npc->marriage->state;
- }
- break;
- case 8:
- {
- ++npc->marriage->state;
- }
- break;
- case 9:
- {
- npc->ShowDialog("Let these rings be given and received as a token of your affection, sincerity and trust in one another.");
- ++npc->marriage->state;
- }
- break;
- case 10:
- {
- PacketBuilder builder(PACKET_ITEM, static_cast<PacketAction>(26));
- builder.AddShort(util::to_int(world->config["WeddingRing"]));
- builder.AddThree(1);
- for (int i = 0; i < 2; ++i)
- {
- npc->marriage->partner[i]->AddItem(util::to_int(world->config["WeddingRing"]), 1);
- npc->marriage->partner[i]->player->client->Send(builder);
- }
- ++npc->marriage->state;
- }
- case 11:
- {
- npc->ShowDialog("Please place these rings on each others finger.");
- ++npc->marriage->state;
- }
- break;
- case 12:
- {
- int effect = util::to_int(util::explode(',', world->config["WeddingEffects"])[0]);
- for (int i = 0; i < 2; ++i)
- npc->marriage->partner[i]->Effect(effect);
- npc->ShowDialog(util::ucfirst(npc->marriage->partner[0]->name) + " and " + util::ucfirst(npc->marriage->partner[1]->name) + " have consented together in marriage. And are now partners for as long you both shall live.");
- ++npc->marriage->state;
- }
- break;
- case 13:
- {
- int effect = util::to_int(util::explode(',', world->config["WeddingEffects"])[1]);
- for (int i = 0; i < 2; ++i)
- npc->marriage->partner[i]->Effect(effect);
- ++npc->marriage->state;
- }
- break;
- case 14:
- {
- npc->ShowDialog("Congratulations to the couple!");
- PacketBuilder reply;
- reply.SetID(PACKET_JUKEBOX, PACKET_USE);
- reply.AddShort(util::rand(7, 20));
- UTIL_FOREACH(npc->marriage->partner[0]->map->characters, character)
- {
- character->player->client->Send(reply);
- }
- int effect = util::to_int(util::explode(',', world->config["WeddingEffects"])[2]);
- for (int i = 0; i < 2; ++i)
- npc->marriage->partner[i]->Effect(effect);
- npc->marriage->partner[0]->partner = npc->marriage->partner[1]->name;
- npc->marriage->partner[0]->fiance = "";
- npc->marriage->partner[1]->partner = npc->marriage->partner[0]->name;
- npc->marriage->partner[1]->fiance = "";
- npc->marriage = 0;
- }
- break;
- default:
- Console::Err("Invalid state for marriage ceremony.");
- npc->marriage = 0;
- }
- if (npc->marriage)
- npc->marriage->last_execution = Timer::GetTime();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement