domain_comunicator.c

final_realms_fluffos_v1/lib/obj/misc/domain_comunicator.c · 16.0 KB

From the archive final_realms_fluffos_v1.zip

Download the archive   « Back to the archive contents

/*****************************************************************************
*                                         *
*            Domain comunicator. Common for all the domains.             *
*                      Khelben, 1997                     *
*                 Lover of cut and paste :=)                 *
*                                         *
******************************************************************************/

inherit "/obj/armour.c";



void setup()
{
   set_name("Domain Communication Badge");
   add_alias("commbadge");
   add_alias("badge");
   reset_drop();
   set_wearable(1);
   set_short("%^BOLD%^%^YELLOW%^Domain Communication Badge%^RESET%^");
   set_long("%^BOLD%^%^YELLOW%^   Domain Communication Badge:%^RESET%^\n\n"
   "     This is the common communication badge. This will let you  "
   "chat with other members of your domain. It also have some interesting "
   "things. For more info, type 'help badge'.\n\n");
   set_value(0);
   add_alias("commbadge");
   add_alias("badge");
   reset_drop();
   call_out("badge_hi",2);
}

void badge_hi()
{
   if( ETO && interactive(ETO) && 
       "/d/ss/master.c"->query_member(ETO->query_name()) ) 
   {
      write("%^CYAN%^\n\nThe waves of Sword Sea welcome you my Lord.%^RESET%^\n\n");
      ETO->add_timed_property("free_action",1,3000000);
   }
}


void init()
{
   add_action("do_help","help");
   add_action("do_who","who");
   add_action("exit","exits");
   add_action("show_in", "in");
   add_action("qatt_me", "qatt");
   add_action("do_peace","peace");
   add_action("do_rain","rain");
   add_action("do_times","times");
   add_action("light","light");
   add_action("mudfind","mudfind");

    //Channels
   add_action("sschan","ss");
   add_action("bfchan","bf");
   add_action("sfchan","sf");
   add_action("mmchan","mm");
   add_action("dlchan","dl");
   add_action("fpchan","fp");
   add_action("umchan","um");
   add_action("ofchan","of");
   add_action("hoerkchan","hoerk");   
   add_action("apriorchan","aprior");
   add_action("omiqchan","omiq");
   add_action("mudlibchan","mudlib");
   add_action("heavenchan","heaven");   
   add_action("radishchan", "radish");
   ::init();
}
            
int domain_member(string name, string verb)
{
   string str;
   
   str = "/d/";
   str += verb;
   str += "/master.c";

   if( str->query_member(name) )
      return 1;
   if(find_player(name)->query_lord())
      return 1;

   return 0;   
}

int do_help(string arg)
{
    if(!(arg))
    return 0;
    if(arg=="badge")
    {
    write("\n%^BOLD%^%^RED%^As a member of your domain you can do the "
      "following:%^RESET%^\n\n"
      "  <domain>       :  Send message to the other members of <domain>\n"+
      "  who <domain>   :  Shows list of <domain> coders that are logged on\n"+
      "  in <domain>    :  Shows who is in <domain>\n"+
      "  mudfind <path> :  Search for the objects <path> cloned in the mud.\n"+
          "  exit           :  Checks the exits of the room you're in.\n"+                
      "  qatt           :  Show who is in battle on the mud\n"+
      "  peace          :  Stops fighting in a room.\n"+
      "  rain           :  Make money the easy way, rain <amt><type>\n"+
      "  light <amt>    :  Adjust the light in a room.\n"+ 
      "  times          :  Give selected times from states and Norway.\n\n");
    return 1;
    }
    else return 0;
}

int have_power(object ob)
{
   if ( ob->query_thane() || ob->query_lord() )
      return 1;
   else
      return 0;
}

int light(string str)
{  
   int num;

   num = to_int(str);
   set_light(num);
   return 1;
}

int mudfind(string str)
{
   object *ob;
   int i;

   if(!str)
      return 0;
   if( file_size(str) < 0 )
   {
      write("That file does not exist.\n");   
      return 1;
   }
   else
   {
      write("Searching for "+str+".\n\n");
      ob = children(str);
      for(i=0;i<sizeof(ob);i++)
      {        
         write(ob[i]->query_name()+" at "+file_name(environment(ob[i]))+
                ".\n");
      }
   }
   return 1;
}      

int show_in(string input)
{
    string *doms;
    object *ob;
    int i;
    string str;
    int yep = 0;
    object env;
    string *bass;

    if( !have_power(TP) )
    {
       write("Only thanes and upper can use this command.\n");
       return 1;
    }

    ob = users();
    for (i=0; i<sizeof(ob); i++) 
    {
    if ((string)ob[i]->query_gender_string() != "blue") 
    {
        str = file_name(environment(ob[i]));
        bass = explode (str, "/");
        doms = get_dir("/d/");
        if (member_array(input, doms) == -1) { return 0; }
        if (bass[1] == input) 
        {
        yep = 1;
        write (ob[i]->query_cap_name()+ " in "+
            environment(ob[i])->query_short()+ "   ("+
        file_name(environment(ob[i]))+ ")\n");
        }
    }
    }
    if (yep == 0) 
    {
    write (sprintf("Noone in %s domain at the moment. *weep*\n", 
           capitalize(input)));
    return 1;
    }
    return 1;
}

int do_peace() 
{
    object *ob;
    object *att;
    object *call;
    int i, s;

    ob=all_inventory(environment(this_player()));
    i=0;
    for(i=0; i<sizeof(ob); i++) 
    {
    if(living(ob[i])) 
    {
        att=ob[i]->query_attacker_list();
        call=ob[i]->query_call_outed();
        for(s=0; s<sizeof(att); s++) 
        {
        ob[i]->stop_fight(att[s]);
        att[s]->stop_fight(ob[i]);
        }
        for(s=0; s<sizeof(call); s++) 
        {
        ob[i]->stop_fight(call[s]);
        call[s]->stop_fight(ob[i]);
        }
    }
    }
    write("You raise your hand and say: "+
          "%^YELLOW%^STOP FIGHTING MORTALS! %^RESET%^\n");
    tell_room(environment(this_player()), this_player()->query_cap_name()+
              " raises his hand and says: %^YELLOW%^STOP FIGTING MORTALS! 
              %^RESET%^\n", ({this_player()}));
    return 1;
} 

int do_times() 
{
    if(!this_player()->query_creator()) 
    return 0;
    write("It is now "+ctime(time())+" Norway Time.\n");
    write("It is now "+ctime(time() - 21600)+" Eastern Time.\n");
    write("It is now "+ctime(time() - 25200)+" Central Time.\n");
    write("It is now "+ctime(time() - 28800)+" Mountain Time.\n");
    write("It is now "+ctime(time() - 32400)+" Pacific Time.\n");
    return 1;
} 

string get_type(string str) 
{          
    if(str=="c" || str=="copper")   
    return "copper";            
    if(str=="b" || str=="brass")  
    return "brass";           
    if(str=="s" || str=="silver")        
    return "silver";                 
    if(str=="g" || str=="gold")        
    return "gold";                 
    if(str=="p" || str=="platinum")  
    return "platinum";           
    return"none";                  
} 

int do_rain(string str) 
{      

    string type, cktype;      
    int amt;                 

    if(!str) 
    {
    write("Usuage: rain <amount> <type of money>\n");      
    return 1;                                             
    }     
    if(sscanf(str,"%d %s",amt,type)!=2) 
    {       
    write("Usuage: rain <amount> <type of money>\n");      
    return 1;                                             
    }     
    cktype=get_type(type);        
    if(cktype=="none") 
    {         
    write("Please use an existing moneytype.\n"); 
    return 1;                                    
    }    
    if(TP->adjust_money(amt, cktype)) 
    {         
        write("You have been given "+amt+" "+cktype+" coins\n");
    tell_room(environment(this_player()), this_player()->query_cap_name()+
                  " motions crest at "+this_player()->query_possessive()+
                  " purse, presses a button, and the purse gets"+
                  " visibly larger.\n", this_player());  
    return 1;
    } 
    else 
    {
    write("Nothing happened! What's wrong?\n");                           
    return 1;                                                            
    }                                                                      

}                                                        

int qatt_me()
{
    object *ob;
    int i;
    int yep = 0;
    object *fig;
    int f;
    
    if( !have_power(TP) )
    {
       write("Only thanes and upper can use this command.\n");
       return 1;
    }
    
    ob = users();
    for (i=0;i<sizeof(ob);i++)
    {
    if (sizeof(ob[i]->query_attacker_list())) 
    {
        write ("\n"+ ob[i]->query_cap_name()+ " is fighting:\n");
        fig = ob[i]->query_attacker_list();
        for (f=0;f<sizeof(fig);f++) 
        {
        write ("\t"+ fig[f]->query_short()+ "\t("+ file_name(fig[f])+ ")\n");
        yep = 1;
        }
        }
    }
    if (yep == 0) 
    {
    write ("Wow, noone is fighting at the moment.\n");
    return 1;
    }
    return 1;
}

string adjust_string_size(string str,int size) 
{
  int q;
  q=sizeof(explode(str,""));
  if(q<=size) return str;
  return("..."+str[q-(size-3)..q]);
}

int exit() 
{
  int i,j;
  mixed* dirs,dirs2;
  mapping opposite = (["north":"south","south":"north","west":"east",
               "east":"west","northwest":"southeast",
               "southeast":"northwest","northeast":"southwest",
               "southwest":"northeast","up":"down","down":"up",
               "out":"in","in":"out"]);
  if(!environment(this_player())) 
  {
    write("You have no environment.\n");
    return 1;
  }
  dirs = environment(this_player())->query_dest_dir();
  if(!sizeof(dirs)) 
  {
    write("There are no exits in this room.\n");
    return 1;
  }
  for(i=0;i<sizeof(dirs);i=i+2) 
  {
    string match;
    printf("%-10s: ",dirs[i][0..8]);
    sscanf(dirs[i+1],"%s.c",dirs[i+1]);
    dirs[i+1] = dirs[i+1]+".c";
    write(adjust_string_size(dirs[i+1],67)+"\n            ");
    if(file_size(dirs[i+1]) == -1)
      write("The file "+adjust_string_size(dirs[i+1],42)+" does not exist.\n");
    else 
    {
      string ppp;
      if(ppp=catch(dirs2 = dirs[i+1]->query_dest_dir())) 
      {
        write(adjust_string_size(dirs[i+1],66)+" won't load.\n");
    write(ppp);
      }
      else 
      {
        match = 0;
        if(sizeof(dirs2))
        for(j=0;j<sizeof(dirs2);j=j+2) 
        {
      sscanf(dirs2[j+1],"%s.c",dirs2[j+1]); 
      if(file_name(environment(this_player()))==dirs2[j+1])
        match = dirs2[j];
        }
        if(!match)
        write("There are no exit from "+adjust_string_size(dirs[i+1],30)+
            " to this room.\n");
        else 
        {
      if(opposite[dirs[i]] == match)
        write("Ok.\n");
          else
        write("The exit from "+adjust_string_size(dirs[i+1],24)+
              " to this room is: "+match[0..8]+".\n");
        }
      }
    }
  }
  return 1;
}

string query_rank_string(object ob) 
{

   string type;
   string rank = ob->query_object_type();

   if(rank == "B") 
      type = "Builder";
   if(rank == "P") 
   {
      if((int)this_player()->query_gender() == 2)
         type = "Patroness";
      else
         type = "Patron";
   }
   if(rank == "T") 
      type = "Thane";
   if(rank == "D" || rank == "H") 
   {
      //if("/secure/lords"->query_boo(this_player()->query_name()))
         type = "Demi-God";
      //else
      //   type = "Alchemist";        
   }
   if(rank == "G") 
     type = "God";

  return type;
}

int valid_domain(string str)
{
   string *domains;

   domains = get_dir("/d/");
   if( !sizeof(domains) || (member_array(str, domains) == -1) ) 
      return 0;
   return 1;
}      

int do_who(string str) 
{
   
   object *ob;
   string nam, gende, rank, htype,dom;
   int i;
   string ip;
   
   if( !valid_domain(str) )
      return 0;
   
   ob = users();
   write("\n"
         "========================================================================\n"
         "                        "+capitalize(str)+" STAFF LOGGED IN                  \n"
         "========================================================================"
          "\n\n");
   for (i=0; i<sizeof(ob); i++) 
   {
      gende=(ob[i]->query_gender_string());
      nam=(ob[i]->query_name());
      ip=query_ip_number(ob[i]);
      nam = capitalize(nam);
      gende = capitalize(gende);
      htype = query_rank_string(ob[i]); 
      if( domain_member((string)ob[i]->query_name() , str) )
          printf("%-15s  %-8s  %-11s %-15s\n", ip, gende, htype, nam);
   }
   write("\n========================================================================\n\n");
   return 1;
}


/*****************************************************************************
   Chat stuff. Since "/global/do_chat" uses query_verb  I didn't found a 
way of doing this. Also is easier type 'ss message' than 'channel ss message'.
That is way I used all those add_action.
*****************************************************************************/

int sschan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int bfchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}
int fpchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int sfchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int radishchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat.c"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
   return 1;
}

int mmchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int dlchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int umchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int ofchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int hoerkchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int apriorchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int omiqchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int mudlibchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

int heavenchan(string str)
{
   if( domain_member((string)TP->query_name(), query_verb()) )
   {
      "/global/do_chat"->do_chat(str);
      return 1;
   }
   else
      write("You are not a member of the "+query_verb()+" domain.\n");
     
   return 1;
}

Site Stats

Snippets: 1791
Codebases: 571