Advertisement
Guest User

Untitled

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