Exemplo n.º 1
0
mixed
vquery(mixed key, mixed space_key)
{
  if(!mappingp(variables)
     || !member(variables, space_key)
     || !mappingp(variables[space_key]))
    return 0;
  return variables[space_key][key];
}
Exemplo n.º 2
0
void
vset(mixed key, mixed value, mixed space_key)
{
  if(!mappingp(variables))
    variables = ([ ]);
  
  if(!member(variables, space_key)
     || !mappingp(variables[space_key]))
    variables[space_key] = ([]);
  
  variables[space_key][key] = value;
}
Exemplo n.º 3
0
SetUser(name,what)
{
  if (!ok()) return;
  if (!mappingp(what)) return;
  data[name]=what;
  save_object(SAVEFILE);
}
Exemplo n.º 4
0
mixed *
vspaces()
{
  if(!mappingp(variables))
    return 0;
  return m_indices(variables);
}
Exemplo n.º 5
0
static string print_object(mixed ob)
{
  write(to_string(ob));

  if (intp(ob)) 
  {
    return "int";
  }
  else if (stringp(ob)) 
  {
    return "string";
  }
  else if (objectp(ob)) 
  {
    if (interactive(ob)) 
      return "user object";

    return "object";
  }
  else if (mappingp(ob))
  {
    return "mapping";
  }
  else if (arrayp(ob)) 
  {
    return "array";
  }
  else if (undefinedp(ob))
  {
    return "nil";
  }

  return "oh dear";
}
Exemplo n.º 6
0
protected int StdSkill_Nightvision(object me, string sname, mixed sinfo) {
  int abil,light,llt,dt,res;

  if (!sinfo || !environment()) return 0;
  if (intp(sinfo)) sinfo=([SI_SKILLABILITY:sinfo]);
  if (!mappingp(sinfo)) return 0;
  if ((light=QueryProp(P_PLAYER_LIGHT))>0) {
    ModifySkill(sname,([SI_LASTLIGHT:time()]));
    return light;
  }
Exemplo n.º 7
0
msg(source, mc, data, vars) {
    string c;

    PT(("]] %O:msg(%O, %O, %O, %O)\n", ME, source, mc, data, vars))

    if (mappingp(vars) && (c = vars["_context"]) && (c = find_context(c)))
	return c->castmsg(source, mc, data, vars);

    return 0;
}
Exemplo n.º 8
0
/*
 * Function name: restore_mail
 * Description  : Restore the mail-file of a player from disk.
 * Arguments    : string name - the name of the player.
 * Returns      : mapping     - the mail of the player.
 */
static mapping
restore_mail(string name)
{
    mapping mail;

    mail = restore_map(FILE_NAME_MAIL(name));

    if ((!mappingp(mail)) ||
	(m_sizeof(mail) != M_SIZEOF_MAIL))
    {
	return 0;
    }

    return mail;
}
Exemplo n.º 9
0
/*
 * Function name: restore_message
 * Description  : Restore an individual message from disk.
 * Arguments    : int number - the time of the message.
 * Returns      : mapping  - the message restored.
 */
static varargs mapping
restore_message(int number)
{
    mapping message;

    message = restore_map(FILE_NAME_MESSAGE(number, HASH_SIZE));

    if ((!mappingp(message)) ||
	(m_sizeof(message) != M_SIZEOF_MSG))
    {
	return 0;
    }

    return message;
}
Exemplo n.º 10
0
mapping scan_objects(mixed src) {
  // Ermittelt zu jedem Typ (Waffe, Ruestungstyp...) alle Objekte diesen Typs
  // Gesucht wird: - Im Inventory, falls Objekt angegeben
  //               - Im Array, falls Array angegeben
  object *obs;
  mapping res;
  mixed x;
  int i,cost,cost_limit;

  if (mappingp(src))
    return src;
  res=([]);
  if (objectp(src))
    src=all_inventory(src);
  if (!pointerp(src))
    src=({src});
Exemplo n.º 11
0
/*
 * Function name: send_rwho_q
 * Description:   Sends a tell message to someone at another mud.
 * Argument:	  mud: The mudname
 *		  askwiz: Name of the wizard asking for rwho info
 * Returns:	  True if mud known and message sent.
 */
public int
send_rwho_q(string mud, string askwiz)
{
    mapping minfo;

    minfo = TO->query_mud_info(mud);

    if (!mappingp(minfo))
	return 0;

    if (stringp(minfo["HOSTADDRESS"]) && (atoi(minfo["PORTUDP"]) > 0))
    {
	TO->send_udp(minfo["HOSTADDRESS"], atoi(minfo["PORTUDP"]),
		     "@@@" + UDP_RWHO_Q +
		     "||NAME:" + TO->query_my_name() +
		     "||PORTUDP:" + TO->query_my_udpport() +
		     "||ASKWIZ:" + askwiz +
		     "@@@\n");
	return 1;
    }
    return 0;
}
Exemplo n.º 12
0
add_property(arg1,arg2) {
  mapping map;
  int i,size;    
  if (mappingp(arg1)) {
    prop += arg1;
    map=arg1;
    arg1=m_indices(map);
    arg2=m_values(map);
    for(i=0,size = sizeof(arg1);i<size;i++) 
      map_array("/obj/daemon/propd"->give_me_links(arg1[i]),"add_property",this_object(),arg2[i]);    
    return;
  }
  if (!arg2)
    arg2 = 1;
  if (stringp(arg1)) {
    map_array("/obj/daemon/propd"->give_me_links(arg1),"add_property",this_object(),arg2);
    prop[arg1] = arg2;
    return;
  }
  if (pointerp(arg1))    
    if (pointerp(arg2))
      {
	map = mkmapping(arg1,arg2);
	prop+=map;
	arg1=m_indices(map);
	arg2=m_values(map);
	for(i=0,size = sizeof(arg1);i<size;i++) 
	  map_array("/obj/daemon/propd"->give_me_links(arg1[i]),"add_property",this_object(),arg2[i]);
      }
      else
	{
	  for(i=0,size = sizeof(arg1);i<size;i++) {
	    prop[arg1[i]] = arg2;
	    map_array("/obj/daemon/propd"->give_me_links(arg1[i]),"add_property",this_object(),arg2);
	  }
	}   
}
Exemplo n.º 13
0
Arquivo: hit.c Projeto: shentino/simud
void on_action( object victim ) {
   mixed result;
   mapping wc;
   int damage;
   object weapon, *weapons;
   string buf = "";
   string bp;
   this_player()->add_readiness(-500);

   if( !BATTLE_DAEMON->check_legal_melee(victim, "hit") )
      return;

   this_player()->add_endurance(-1);

   if (weapons = BATTLE_DAEMON->query_wielded_weapons(this_player(),
       (this_player()->query_form_object())->query_weapon_types()))
     weapon = weapons[random(sizeof(weapons))];
   else {
     msg("You are not wielding an appropriate weapon.");
     this_player()->adopt_best_form();
     return;
   }

   wc = copy(weapon->query_wc());

   if (!mappingp(wc)) {
     debug((string)weapon+" does not have a valid wc mapping.");
     return;
   }

   /* wc["blunt"] += this_player()->query_str_wc() +
                  this_player()->query_attitude("offense"); */

   wc["blunt"] += this_player()->query_str_wc();
   result = BATTLE_DAEMON->execute_melee(weapon, wc, victim, 2, 0);
   damage = result[RESULT_MOD];

   if(sizeof(result) > 3)
      bp = victim->query_bp_name(result[RESULT_BP]);

   switch (result[RESULT_TYPE]) {
     case "miss":
       buf = "~[130~Name ~verbmiss ~targ with a wild swing of ~poss "+weapon->query_name()+"!";
       break;

   default:
	   // sound
	   AUDIO_DAEMON->sfx_room(environment(victim),"smash.wav");
	
         if( damage >= 100 )
	     buf = "~[090~Npos ~verbhit ~targ viciously with ~poss "+weapon->query_name()+
	           ", killing ~objt.";
          else if (damage >= 40)
	    buf = "~[090~Name ~verbpunch deep into ~npot "+bp+" with ~poss "+weapon->query_name()+".";
          else if (damage >= 5) {
            if (result[RESULT_ARMOUR])
               buf = "~[090~Name ~verbhit ~targ hard in the "+bp+", but ~post "+result[RESULT_ARMOUR]->query_name()+" absorbs some of the blow.";
	     else
	        buf = "~[090~Name ~verbhit ~targ hard in the "+bp+" with ~poss "+weapon->query_name()+".";
	   } else {
	     if (result[RESULT_ARMOUR])
	        buf = "~[090~Name ~verbhit ~npot "+bp+", but ~post "+result[RESULT_ARMOUR]->query_name()+" absorbs most of the blow.";
	     else
	        buf = "~[090~Name ~verbhit ~npot "+bp+", but the blow seems to have little effect.";
	   }
       break;
   }

   if (result[RESULT_MSG])
     buf += "~[060 "+result[RESULT_MSG];

   this_player()->msg_local(buf+"~CDEF");
}
Exemplo n.º 14
0
void create() {
   ::create();
   if (!mappingp(desire)) {
      desire = ([ ]);
   }
Exemplo n.º 15
0
void remove_landmark( string name ) {
   if( !mappingp(landmarks) ) landmarks = ([ ]);
   m_delete( landmarks, name );
}
Exemplo n.º 16
0
int query_landmark( string name ) {
   if( !mappingp(landmarks) ) landmarks = ([ ]);
   return landmarks[name];
}
Exemplo n.º 17
0
string get_landmark_description( int pos ) {
   string *desc, ilandname, base_phrase;
   int ilandpos;

   if( !mappingp(landmarks) || sizeof(landmarks) == 0 ) return "No landmarks visible.";
   desc = ({ });
Exemplo n.º 18
0
/*
 * Function name: export_mail
 * Description  : With this function the mail-folder of a player can be
 *                exported to a file.
 * Arguments    : string name - the lower case name of the player whose
 *                              mailbox is to be exported.
 *                string path - the name of the output file.
 * Returns      : int 1/0 - success/failure.
 */
static int
export_mail(string name, string path)
{
    mapping mail;
    mixed   messages;
    int     index;
    int     size;
    string  text;

    /* Get the output path and test its valitity by writing the header. */
    path = FTPATH(this_player()->query_path(), path);
    if (file_size(path) != -1)
    {
	notify_fail("File " + path + " already exists.\n");
	return 0;
    }

    /* This may fail if there is no such directory, for instance. */
    if (!write_file(path, "Mailbox of: " + capitalize(name) +
	"\nPrinted at: " + ctime(time()) + "\n\n"))
    {
	notify_fail("Failed to write header of " + path + "\n");
	return 0;
    }

    /* Read the mail file. */
    mail = restore_mail(name);
    if (!mappingp(mail))
    {
	notify_fail("No correct mail folder for player " + name + ".\n");
	return 0;
    }

    /* Loop over all messages. */
    messages = mail[MAIL_MAIL];
    index = -1;
    size = sizeof(messages);
    while(++index < size)
    {
	mail = restore_message(messages[index][MAIL_DATE]);
	
	text = "Message: " + (index + 1) + "\nFrom   : " +
	      messages[index][MAIL_FROM] + "\n" +
	      (messages[index][MAIL_REPLY] ? "Reply  : " : "Subject: ") +
	      messages[index][MAIL_SUBJ] + "\n";
	
	if (mail[MSG_TO] != capitalize(name))
	{
	    text += HANGING_INDENT("To     : " +
		COMPOSITE_WORDS(explode(mail[MSG_TO], ",")), 9, 1);
	}
	
	if (mail[MSG_CC] != "")
	{
	    text += HANGING_INDENT("CC     : " +
		COMPOSITE_WORDS(explode(mail["cc"], ",")), 9, 1);
	}

	/* Write the message to file and print a sequence number to the
	 * wizard. Notice that the index of the loop is also increased in
	 * this write-statement.
	 */	
	write_file(path, text + "Date   : " +
            MAKE_DATE(messages[index][MAIL_DATE]) + " " +
            DATE_YEAR(messages[index][MAIL_DATE]) +
	    "\n\n" + wrap_text(mail[MSG_BODY]) + "\n\n");
    }

    write("Mail folder written for " + capitalize(name) + ".\nFilename: " +
	path + "\n");
    return 1;
}
Exemplo n.º 19
0
void
create()
{
  if( !mappingp( hashtable ) )
    hashtable = ([ ]);
}
Exemplo n.º 20
0
void on_action( object victim ) {
   mixed result;
   mapping wc;
   int damage;
   object weapon, *weapons;
   string bp, buf = "";

        this_player()->add_readiness(-1300);

   if( !BATTLE_DAEMON->check_legal_melee(victim, "smash") )
      return;

   this_player()->add_endurance(-1);

   if (weapons = BATTLE_DAEMON->query_wielded_weapons(this_player(),
       (this_player()->query_form_object())->query_weapon_types()))
     weapon = weapons[random(sizeof(weapons))];
   else {
     msg("You are not wielding an appropriate weapon.");
     this_player()->adopt_best_form();
     return;
   }

   wc = copy(weapon->query_wc());
   if (!mappingp(wc)) {
     debug((string)weapon+" does not have a valid wc mapping.");
     return;
   }

   // used to be a +4 bonus, which is -obscene- under the new system
   wc["blunt"] += this_player()->query_str_wc() + 2;
   // used to be a +1 bonus regardless of whether the weapon had pointy bits
   if (wc["piercing"])
      wc["piercing"]+= this_player()->query_str_wc() + 1;

   result = BATTLE_DAEMON->execute_melee(weapon, wc, victim, 2, 0);
   damage = result[RESULT_MOD];

        if(sizeof(result) > 3)
           bp = victim->query_bp_name(result[RESULT_BP]);

   switch (result[RESULT_TYPE]) {
     case "miss":
       buf = "~[130~Name ~verbmiss ~targ with a wild swing of ~poss "+weapon->query_name()+"!";
       break;

     default:
	   // sound
	   AUDIO_DAEMON->sfx_room(environment(victim),"smash.wav");
	
       if (damage >= 100)
         buf = "~[090~Name ~verbdeliver a frightening ~[150SMASH~[090 to ~npot "+bp+", instantly snuffing out ~post life!";
       else if (damage >= 40)
         buf = "~[090~Name ~verbsmash ~npot "+bp+" with ~poss "+weapon->query_name()+"!";
       else if (damage >= 5)
         buf = "~[090~Name ~verbslam ~poss "+weapon->query_name()+" into ~npot "+bp+".";
       else
         buf = "~[130~Name barely ~verbgraze ~npot "+bp+" with ~poss "+weapon->query_name()+".";
       break;
   }
   if (result[RESULT_MSG])
     buf += "~[060 "+result[RESULT_MSG];

   this_player()->msg_local(buf+"~CDEF");
}
Exemplo n.º 21
0
void on_action( object victim ) {
   mixed result;
   mapping wc;
   int damage;
   string buf = "";

   if( !BATTLE_DAEMON->check_legal_melee(victim, "throatbite") )
      return;

   if (this_player()->query_endurance() >= 2)
      this_player()->add_endurance(-2);
   else {
      msg("~CWRNYou are too tired to fight any more!~CDEF");
      this_player()->add_readiness(-1000);
      return;
   }

   wc = copy(this_player()->query_wc());
   if (!mappingp(wc))
     wc = (["piercing":7]);
   wc["piercing"] += wc["edged"] +
                     this_player()->query_str_wc() +
                     this_player()->query_attitude("attack");
   wc -= (["edged"]);

   result = BATTLE_DAEMON->execute_melee(this_player(), wc, victim, 2, 0);
   damage = result[RESULT_MOD];

   switch (result[RESULT_TYPE]) {
     case "miss":
       buf = "~[130~Name ~verbsnap ~poss teeth centimeters from ~npot neck!";
       break;
/*
     case "block":
     case "parry":
     case "dodge":
       if (damage)
         buf = "~[130~Targ almost ~vert"+result[RESULT_TYPE]+" ~npos punch, but not quite.";
       else
         buf = "~[130~Targ ~vert"+result[RESULT_TYPE]+" ~npos punch!";
       break;

     case "hit":
     case "counter":
*/
     default:
       if (damage > 10 && random(100) < 30-(victim->query_constitution())) {
         buf = "~[090~Name ~verbtear ~npot throat wide open with a ferocious bite!";
         victim->add_hp(-(victim->query_hp()));
         break;
       }
       if (damage >= 15)
         buf = "~[090~Name ~verbsink ~poss teeth into ~post neck!";
       else if (damage > 0)
         buf = "~[090~Name ~verbbite ~targ viciously on the shoulder!";
       else
         buf = "~[090~Name barely ~verbmanage to bite ~targ.";
       break;
   }
   if (result[RESULT_MSG])
     buf += "~[060 "+result[RESULT_MSG];

   this_player()->add_readiness(-1700);
   this_player()->msg_local(buf+"~CDEF");
}
Exemplo n.º 22
0
void on_action( object victim ) {
   mixed result;
   mapping wc;
   int damage;
   string buf, bp;
   object boots;

   this_player()->add_readiness(-500);
   if( !BATTLE_DAEMON->check_legal_melee(victim, "kick") )
      return;

   this_player()->add_endurance(-1);

   wc = copy(this_player()->query_wc());
   if( !mappingp(wc) || !member(wc,"blunt") )
     wc = (["blunt":3]);
   wc["blunt"] += this_player()->query_str_wc();

   // use boots if they got 'em, and anything else they may be wearing on
   // their feet. Effects stack. So if I am wearing iron boots over socks of
   // death... they will both affect the damage ;)
   foreach (boots : all_inventory(this_player())) {
      if (!boots->query_worn() ||
          !(boots->query_body_parts() & BP_FEET))
        continue;
      if (mappingp(boots->query_wc()))
        wc += boots->query_wc();
        // This causes severe balance problems. Boots should
        // specify a WC.
//      else
//        wc["blunt"] += boots->query_base_ac() / 2;
      // kicking in boots is more tiring than kicking w/o
      this_player()->add_readiness(boots->query_weight()/-10);
   }

   result = BATTLE_DAEMON->execute_melee(this_player(), wc, victim, 2, 0);
   damage = result[RESULT_MOD];
   if (sizeof(result) > 3)
     bp = victim->query_bp_name(result[RESULT_BP]);

   switch (result[RESULT_TYPE]) {
   case "miss":
      buf = "~[130~Name almost ~verbstrain ~poss leg as ~poss kick misses ~targ!";
      break;

   case "hit":
   case "counter":
   default:
	   // sound
	   AUDIO_DAEMON->sfx_room(environment(victim),"smash.wav");
	
      if( damage >= 100 )
         buf = "~[090~Name ~verbland a solid kick squarely on ~npot "+bp+". ~Subt ~vertgrunt briefly in pain before falling to the ground, unconscious.";
      else if (damage >= 40)
         buf = "~[090~Name ~verbkick ~targ solidly in the "+bp+"!";
      else if (damage >= 5) {
         if (result[RESULT_ARMOUR])
            buf = "~[090~Name ~verbkick ~targ in the "+bp+" but ~post "+result[RESULT_ARMOUR]->query_name()+" cushions the blow.";
         else
            buf = "~[090~Name ~verbkick ~targ in ~post "+bp+".";
      }
      else {
         if (result[RESULT_ARMOUR])
            buf = "~[090~Name ~verbkick ~targ, but ~post "+result[RESULT_ARMOUR]->query_name()+" absorbs the blow.";
         else
            buf = "~[090~Name ~verbtry to kick ~targ, but ~verbmanage only a glancing hit.";
      }
      break;
   }

   if (result[RESULT_TYPE] != "hit")
     buf += "~[060 "+result[RESULT_MSG];

   this_player()->msg_local(buf+"~CDEF");
}
Exemplo n.º 23
0
void set_landmark( string name, int pos ) {
   if( !mappingp(landmarks) ) landmarks = ([ ]);
   landmarks[name] = pos;
}