Advertisement
henesua

DlgGetInformationOverview(object oPC)

Apr 20th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.02 KB | None | 0 0
  1. string DlgGetInformationOverview(object oPC)
  2. {
  3.     string sOverview;
  4.  
  5.     int x   = 1;
  6.     object oArea    = GetArea(OBJECT_SELF);
  7.  
  8.     // housing information -----------------------------------------------------
  9.     string sNPCHouse    = GetLocalString(OBJECT_SELF,"HOUSE");
  10.     string sHouseTag    = GetLocalString(GetArea(OBJECT_SELF),"HOUSE");
  11.     // Does the NPC take care of a house?
  12.     if(sNPCHouse!="")
  13.     {
  14.         object oHouse   = GetWaypointByTag(sNPCHouse);
  15.         // not in housing
  16.         if(sHouseTag=="")
  17.         {
  18.  
  19.         }
  20.         // we are in the NPC's establishment
  21.         else if(sNPCHouse==sHouseTag)
  22.         {
  23.           if( !GetRoomOccupiedByPC(sNPCHouse, oPC) )
  24.           {
  25.             string sKeeperTitle = GetLocalString(oHouse, "KEEPER_TITLE");
  26.             if(sKeeperTitle=="")
  27.                 sKeeperTitle = "the head of the house";
  28.             else
  29.                 sKeeperTitle = "the "+sKeeperTitle;
  30.  
  31.             // this NPC can't rent rooms, so directs the PC to the keeper for info about the place
  32.             if(!GetLocalInt(OBJECT_SELF,"HOUSE_KEEPER"))
  33.             {
  34.  
  35.                 string sKeeper  = HousingGetKeeperName(oHouse);
  36.                 if(sKeeper=="")
  37.                     sKeeper = sKeeperTitle;
  38.                 else
  39.                     sKeeper += ", "+sKeeperTitle;
  40.  
  41.                 sOverview   += "You are in "+GetName(oHouse)+". For more information, talk to "+sKeeper+". ";
  42.             }
  43.             // the NPC is the keeper
  44.             else
  45.             {
  46.                 sOverview   += "You are in "+GetName(oHouse)+". I am "+sKeeperTitle+". ";
  47.             }
  48.           }
  49.         }
  50.     }
  51.     // is the PC in a place that has rooms?
  52.     else if(sHouseTag!="")
  53.     {
  54.         // if the PC is not staying here, point them to the house keeper
  55.         if( !GetRoomOccupiedByPC(sHouseTag, oPC) )
  56.         {
  57.             object oHouse   = GetWaypointByTag(sHouseTag);
  58.  
  59.             string sKeeperTitle = GetLocalString(oHouse, "KEEPER_TITLE");
  60.             if(sKeeperTitle=="")
  61.                 sKeeperTitle = "the head of the house";
  62.             else
  63.                 sKeeperTitle = "the "+sKeeperTitle;
  64.  
  65.             string sKeeper  = HousingGetKeeperName(oHouse);
  66.             if(sKeeper=="")
  67.                 sKeeper = sKeeperTitle;
  68.             else
  69.                 sKeeper += ", "+sKeeperTitle;
  70.  
  71.             sOverview   += "If you want lodging in "+GetName(oHouse)+", speak to "+sKeeper+". ";
  72.         }
  73.     }
  74.     else
  75.     {
  76.         // we are not in "housing", lets look for Public Housing in an adjacent area
  77.         object oHouse, oDest, oDestArea;
  78.  
  79.         object oTrans   = GetFirstObjectInArea(oArea);
  80.         while(GetIsObjectValid(oTrans))
  81.         {
  82.             oDest    = GetTransitionTarget(oTrans);
  83.             if(oDest!=OBJECT_INVALID)
  84.             {
  85.                 oDestArea   = GetArea(oDest);
  86.                 if(oDestArea!=oArea)
  87.                 {
  88.                     sHouseTag = GetLocalString(oDestArea,"HOUSE");
  89.                     if(sHouseTag!="")
  90.                     {
  91.                         oHouse = GetWaypointByTag(sHouseTag);
  92.                         if(GetLocalInt(oHouse,"HOUSE_PRIVATE"))
  93.                             oHouse  = OBJECT_INVALID;
  94.                         else
  95.                             break;
  96.                     }
  97.                 }
  98.             }
  99.             oTrans  = GetNextObjectInArea(oArea);
  100.         }
  101.         if( oHouse!=OBJECT_INVALID )
  102.         {
  103.             sOverview   += GetName(oHouse) +" "+ DlgGetLocationDescription(oDest) + "offers lodging.";
  104.         }
  105.     }
  106.  
  107.  
  108.     // merchant search ---------------------------------------------------------
  109.     string sNPC;
  110.     object oMerch;
  111.     object oTemp    = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, OBJECT_SELF, x);
  112.     while(      oTemp!=OBJECT_INVALID
  113.             &&  GetArea(oTemp)==oArea
  114.          )
  115.     {
  116.         if(GetLocalInt(oTemp,"MERCH"))
  117.         {
  118.             oMerch  = oTemp;
  119.             sNPC    = GetName(oMerch)+" ";
  120.             if(GetSharesGroupMembership(oMerch))
  121.                 break;
  122.         }
  123.         oTemp   = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, OBJECT_SELF, ++x);
  124.     }
  125.     if(sNPC!="")
  126.     {
  127.         if(sOverview!="")
  128.             sOverview += BR+BR;
  129.         sOverview +=    sNPC
  130.                      +  DlgGetLocationDescription(oMerch)
  131.                      ;
  132.         string sGoods   = GetLocalString(oMerch, "MERCH_STORE1_DESCRIPTION");
  133.         if(sGoods!="")
  134.             sOverview += "trades in "+sGoods+".";
  135.         else
  136.         {
  137.             sGoods  = GetLocalString(oMerch, "MERCH_STORE1_NAME");
  138.             if(sGoods!="")
  139.                 sOverview += "has a store named "+sGoods+".";
  140.             else
  141.                 sOverview += "conducts trade.";
  142.         }
  143.     }
  144.  
  145.     // lack of information response
  146.     if(sOverview=="")
  147.         sOverview   = GetLocalString(OBJECT_SELF,"DIALOG_INFO_NONE");
  148.     if(sOverview=="")
  149.         sOverview   = "*Provides no useful information.*";
  150.  
  151.     return sOverview;
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement