Advertisement
Guest User

Untitled

a guest
Sep 4th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.30 KB | None | 0 0
  1. void world_execute_weddings(void *world_void)
  2. {
  3.     World *world = static_cast<World *>(world_void);
  4.  
  5.     double now = Timer::GetTime();
  6.  
  7.     UTIL_FOREACH(world->maps, map)
  8.     {
  9.         UTIL_FOREACH(map->npcs, npc)
  10.         {
  11.             if (npc->marriage && npc->marriage->request_accepted)
  12.             {
  13.                 if (!npc->marriage->partner[0] || !npc->marriage->partner[1])
  14.                 {
  15.                     npc->ShowDialog("Something went wrong. Stopping wedding");
  16.                     npc->marriage = 0;
  17.                     continue;
  18.                 }
  19.                 else if (!npc->marriage->partner[0]->online || !npc->marriage->partner[1]->online)
  20.                 {
  21.                     npc->ShowDialog("One of the wedding partners has exited the game. Stopping wedding");
  22.                     npc->marriage = 0;
  23.                     continue;
  24.                 }
  25.                 else if (npc->marriage->partner[0]->map != npc->map || npc->marriage->partner[1]->map != npc->map)
  26.                 {
  27.                     npc->ShowDialog("One of the wedding partners has left the map. Stopping wedding");
  28.                     npc->marriage = 0;
  29.                     continue;
  30.                 }
  31.                 else if ((npc->marriage->state == 5 && npc->marriage->partner_accepted[0]) || (npc->marriage->state == 8 && npc->marriage->partner_accepted[1]))
  32.                 {
  33.                     ++npc->marriage->state;
  34.                 }
  35.                 else if (npc->marriage->last_execution + (util::to_int(world->config["PriestDialogInterval"])) <= now)
  36.                 {
  37.                     switch (npc->marriage->state)
  38.                     {
  39.                         case 1:
  40.                         {
  41.                             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.");
  42.                             ++npc->marriage->state;
  43.                         }
  44.                         break;
  45.  
  46.                         case 2:
  47.                         {
  48.                             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.");
  49.                             ++npc->marriage->state;
  50.                         }
  51.                         break;
  52.  
  53.                         case 3:
  54.                         {
  55.                             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?");
  56.                             ++npc->marriage->state;
  57.                         }
  58.                         break;
  59.  
  60.                         case 4:
  61.                         {
  62.                             PacketBuilder builder(PACKET_PRIEST, PACKET_REPLY);
  63.                             builder.AddChar(PRIEST_REQUEST);
  64.                             npc->marriage->partner[0]->player->client->Send(builder);
  65.                             ++npc->marriage->state;
  66.                         }
  67.                         break;
  68.  
  69.                         case 5:
  70.                         {
  71.                             ++npc->marriage->state;
  72.                         }
  73.                         break;
  74.  
  75.                         case 6:
  76.                         {
  77.                             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?");
  78.                             ++npc->marriage->state;
  79.                         }
  80.                         break;
  81.  
  82.                         case 7:
  83.                         {
  84.                             PacketBuilder builder(PACKET_PRIEST, PACKET_REPLY);
  85.                             builder.AddChar(PRIEST_REQUEST);
  86.                             npc->marriage->partner[1]->player->client->Send(builder);
  87.                             ++npc->marriage->state;
  88.                         }
  89.                         break;
  90.  
  91.                         case 8:
  92.                         {
  93.                             ++npc->marriage->state;
  94.                         }
  95.                         break;
  96.  
  97.                         case 9:
  98.                         {
  99.                             npc->ShowDialog("Let these rings be given and received as a token of your affection, sincerity and trust in one another.");
  100.                             ++npc->marriage->state;
  101.                         }
  102.                         break;
  103.  
  104.                         case 10:
  105.                         {
  106.                             PacketBuilder builder(PACKET_ITEM, static_cast<PacketAction>(26));
  107.                             builder.AddShort(util::to_int(world->config["WeddingRing"]));
  108.                             builder.AddThree(1);
  109.                             for (int i = 0; i < 2; ++i)
  110.                             {
  111.                                 npc->marriage->partner[i]->AddItem(util::to_int(world->config["WeddingRing"]), 1);
  112.                                 npc->marriage->partner[i]->player->client->Send(builder);
  113.                             }
  114.                             ++npc->marriage->state;
  115.                         }
  116.  
  117.                         case 11:
  118.                         {
  119.                             npc->ShowDialog("Please place these rings on each others finger.");
  120.                             ++npc->marriage->state;
  121.                         }
  122.                         break;
  123.  
  124.                         case 12:
  125.                         {
  126.                             int effect = util::to_int(util::explode(',', world->config["WeddingEffects"])[0]);
  127.  
  128.                             for (int i = 0; i < 2; ++i)
  129.                             npc->marriage->partner[i]->Effect(effect);
  130.  
  131.                             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.");
  132.                             ++npc->marriage->state;
  133.                         }
  134.                         break;
  135.  
  136.                         case 13:
  137.                         {
  138.                             int effect = util::to_int(util::explode(',', world->config["WeddingEffects"])[1]);
  139.  
  140.                             for (int i = 0; i < 2; ++i)
  141.                             npc->marriage->partner[i]->Effect(effect);
  142.                             ++npc->marriage->state;
  143.                         }
  144.                         break;
  145.  
  146.                         case 14:
  147.                         {
  148.                             npc->ShowDialog("Congratulations to the couple!");
  149.  
  150.                             PacketBuilder reply;
  151.                             reply.SetID(PACKET_JUKEBOX, PACKET_USE);
  152.                             reply.AddShort(util::rand(7, 20));
  153.  
  154.                             UTIL_FOREACH(npc->marriage->partner[0]->map->characters, character)
  155.                             {
  156.                                 character->player->client->Send(reply);
  157.                             }
  158.  
  159.                             int effect = util::to_int(util::explode(',', world->config["WeddingEffects"])[2]);
  160.                             for (int i = 0; i < 2; ++i)
  161.                                 npc->marriage->partner[i]->Effect(effect);
  162.  
  163.                             npc->marriage->partner[0]->partner = npc->marriage->partner[1]->name;
  164.                             npc->marriage->partner[0]->fiance = "";
  165.  
  166.                             npc->marriage->partner[1]->partner = npc->marriage->partner[0]->name;
  167.                             npc->marriage->partner[1]->fiance = "";
  168.                             npc->marriage = 0;
  169.                         }
  170.                         break;
  171.  
  172.                         default:
  173.                         Console::Err("Invalid state for marriage ceremony.");
  174.                         npc->marriage = 0;
  175.                     }
  176.  
  177.                     if (npc->marriage)
  178.                     npc->marriage->last_execution = Timer::GetTime();
  179.                 }
  180.             }
  181.         }
  182.     }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement