Пример #1
0
// Sends a message to the contents of an object, which is usually
// a room.
void CHSInterface::NotifyContents(int objnum, const HS_INT8 * strMsg)
{
#ifdef PENNMUSH
    notify_except(db[objnum].contents, NOTHING, strMsg, 0);
#endif

#if defined(TM3) || defined(MUX)
    notify_except(objnum, GOD, NOTHING, strMsg, 0);
#endif
}
Пример #2
0
void CHSInterface::NotifyExcept(HS_DBREF dbFirst,
                                HS_DBREF dbExcept, const HS_INT8 * pcMessage)
{
#ifdef PENNMUSH
    notify_except(dbFirst, dbExcept, pcMessage, 0);
#endif

#if defined(TM3) || defined(MUX)
    notify_except(Location(dbFirst), GOD, dbExcept, pcMessage, 0);
#endif
}
Пример #3
0
/* board a ship through the ship object */
void board_ship(dbref player, char *which, char *code)
{
  ATTR *a;
  char *bcode;
  dbref obj, nav, bay;
  int security;
  
  /* find the shipobj */
  obj = match_result(player, which, TYPE_THING, MAT_NEAR_THINGS);
  if (!IsShipObj(obj))
  {
    notify(player, "Can't find that ship.");
    return;
  }
  
  /* see if it's got an HSNAV */
  nav = atr_parse_dbref(obj, "HSNAV");
  if (!IsShip(nav))
  {
    notify(player, "That is not a valid ship object.");
    return;
  }
  
  /* check the boarding code, if necessary */
  security = atr_parse_integer(nav, "SECURITY", 0);
  if (security)
  {
    a = atr_get(nav, "BOARDING_CODE");
    if (a)
    {
      bcode = atr_value(a);
      if (strcmp(bcode, code))
      {
        notify(player, "Invalid boarding code.");
        return;
      }
    }
  }
  
  /* check for a BAY on the nav, otherwise go to the nav's location */
  bay = atr_parse_dbref(nav, "BAY");
  if (!RealGoodObject(bay))
  {
    bay = Location(nav);
  }
  
  atr_add(player, "HSPACE", unparse_dbref(nav), hs_options.space_wiz, 0);
  notify_except(obj, Location(player), player, tprintf("%s boards the %s.", Name(player), Name(obj)), 0);
  notify_except(obj, bay, player, tprintf("%s boards through the main hatch.", Name(player)), 0);
  moveto(player, bay, hs_options.space_wiz, NULL);
}
Пример #4
0
HS_DBREF CHSInterface::ConsoleUser(int objnum)
{
    HS_DBREF dbUser;

    dbUser = GetLock(objnum, LOCK_USE);

    if (dbUser == HSNOTHING || objnum == HSNOTHING)
        return HSNOTHING;

#ifndef TM3
    if (IsPlayer(dbUser))
#else
    if (isPlayer(dbUser))
#endif
    {
        // If the user is not in the same location as the object,
        // set the lock to the object and return NOTHING.
#ifdef PENNMUSH
        if (Location(dbUser) != Location(objnum)
            || !HasFlag(dbUser, TYPE_PLAYER, PLAYER_CONNECT)
            && IsPlayer(dbUser))
#else
        if (Location(dbUser) != Location(objnum) || !Connected(dbUser)
            && isPlayer(dbUser))
#endif
        {
            SetLock(objnum, objnum, LOCK_USE);


            // Delete attribute from player.
            hsInterface.AtrDel(dbUser, "MCONSOLE", GOD);
#ifdef PENNMUSH
            notify_except(db[Location(objnum)].contents, dbUser,
                          tprintf("%s unmans the %s.", Name(dbUser),
                                  Name(objnum)), 0);
#else
            notify_except(Location(objnum), dbUser, NOTHING,
                          tprintf("%s unmans the %s.", Name(dbUser),
                                  Name(objnum)), 0);
#endif

            return NOTHING;
        }
    }

    return dbUser;
}
Пример #5
0
void
do_pose(dbref player, const char *message)
{
	dbref loc;
	char buf[BUFFER_LEN];

	if ((loc = getloc(player)) == NOTHING)
		return;

	/* notify everybody */
	snprintf(buf, sizeof(buf), "%s %s", NAME(player), message);
	notify_except(DBFETCH(loc)->contents, NOTHING, buf, player);
}
Пример #6
0
/* unman console command */
void unman_console(dbref player)
{
  dbref curman, console;
  hship *ship;
  hconsole *con;

  console = atr_parse_dbref(player, "MANNING");
  if (!IsConsole(console) && !IsShip(console))
  {
    notify(player, "You are not manning a console.");
    return;
  }
  
  curman = get_user(console);
  
  if (curman != player)
  {
    notify(player, "You aren't manning that.");
    return;
  }
  
  ship = find_ship_by_nav(console);
  if (!ship)
  {
    con = find_console(console);
    if (!con)
    {
      notify(player, "That console has not been activated.");
      return;
    }
    
    load_weapon(console, &(con->primary), HS_PRIMARY);
    load_weapon(console, &(con->secondary), HS_SECONDARY);
  } else {
    load_weapon(console, &(ship->primary), HS_PRIMARY);
    load_weapon(console, &(ship->secondary), HS_SECONDARY);
  }

  set_user(console, NOTHING);
  notify(player, tprintf("You unman the %s.", Name(console)));
  notify_except(console, Location(console), player,
             tprintf("%s unmans the %s.", Name(player), Name(console)), 0);

  execute_trigger(console, "AUNMAN", ship);
}
Пример #7
0
/** The say command.
 * \param player the enactor.
 * \param message the message to say.
 * \param pe_info pe_info to eval speechmod with
 */
void
do_say(dbref player, const char *message, NEW_PE_INFO *pe_info)
{
  dbref loc;
  PE_REGS *pe_regs;
  char modmsg[BUFFER_LEN];
  char says[BUFFER_LEN];
  char *sp;
  int mod = 0;
  loc = speech_loc(player);
  if (!GoodObject(loc))
    return;

  if (!Loud(player) && !eval_lock_with(player, loc, Speech_Lock, pe_info)) {
    fail_lock(player, loc, Speech_Lock, T("You may not speak here!"), NOTHING);
    return;
  }

  if (*message == SAY_TOKEN && CHAT_STRIP_QUOTE)
    message++;

  pe_regs = pe_regs_create(PE_REGS_ARG, "do_say");
  pe_regs_setenv_nocopy(pe_regs, 0, message);
  pe_regs_setenv_nocopy(pe_regs, 1, "\"");
  modmsg[0] = '\0';

  if (call_attrib(player, "SPEECHMOD", modmsg, player, pe_info, pe_regs)
      && *modmsg != '\0')
    mod = 1;
  pe_regs_free(pe_regs);

  /* notify everybody */
  notify_format(player, T("You say, \"%s\""), (mod ? modmsg : message));
  sp = says;
  safe_format(says, &sp, T("%s says, \"%s\""), spname(player),
              (mod ? modmsg : message));
  *sp = '\0';
  notify_except(player, loc, player, says, NA_INTER_HEAR);
}
Пример #8
0
/* leave a flying ship through the escape pod */
void emergency_eject(dbref player)
{
  dbref nav, pad;
  hship *ship;
  hcelestial *cel, *min_cel;
  ATTR *a;
  char *r, *s;
  char buff[512];
  double dist, min_dist;
  dbref min_pad;
  hship *sptr, *min_ship;
  
  /* check for a BAY */
  a = atr_get(Location(player), "BAY");
  if (!a)
  {
    /* no BAY, see if we're next to the nav console */
    ship = find_ship(player);
    if (ship)
    {
      if (Location(ship->objnum) != Location(player))
      {
        notify(player, "You can't eject from here.");
        return;
      }
    }
  }
  else
  {
    /* there's a BAY, see if the ship is valid */
    nav = parse_dbref(atr_value(a));
    if (!IsShip(nav))
    {
      notify(player, "You can't eject from here.");
      return;
    }

    ship = find_ship_by_nav(nav);
  }
  
  if (!ship)
  {
    notify(player, "You can't eject from here.");
    return;
  }

  /* only eject when flying, not when landing or docking */
  if (!ship->uid || ship->landed || ship->docked)
  {
    notify(player, "You may only eject while flying.");
    return;
  }
  
  /* find a planet with a drop pad */
  min_pad = NOTHING;
  min_dist = 1000000.0;
  min_cel = NULL;
  for (cel = ship->uid->head_celestial; cel; cel = cel->next)
  {
    if (!HasFlag(cel->type, HS_PLANET))
      continue;
    
    pad = atr_parse_dbref(cel->objnum, "DROPPADS");
    if (!RealGoodObject(pad))
      continue;

    dist = ship_celestial_distance(ship, cel);

    if (dist < min_dist)
    {
      min_dist = dist;
      min_pad = pad;
      min_cel = cel;
    }
  }
  
  min_ship = NULL;
  for (sptr = ship->uid->head_ship; sptr; sptr = sptr->next)
  {
    if (min_cel)
      break;
    
    if (!HasFlag(sptr->type, HS_STATION | HS_CAPITAL))
      continue;
    
    pad = atr_parse_dbref(sptr->objnum, "BAY");
    if (!RealGoodObject(pad))
      continue;
    
    dist = ship_distance(ship, sptr);

    if (dist < min_dist)
    {
      min_cel = NULL;
      min_ship = sptr;
      min_dist = dist;
      min_pad = pad;
    }
  }
  
  if (!RealGoodObject(min_pad))
  {
    notify(player, "There is nowhere to eject to!");
    return;
  }

  /* finish up by setting HSPACE and notifying everybody of the move */
  if (min_ship)
  {
    atr_add(player, "HSPACE", unparse_dbref(min_ship->objnum), hs_options.space_wiz, 0);
  }
  else if (min_cel)
  {
    atr_add(player, "HSPACE", unparse_dbref(min_cel->objnum), hs_options.space_wiz, 0);
  }
  else
  {
    SPACEWALL("Weird problem in eject.");
    notify(player, "Bad space object. Contact an administrator.");
    return;
  }

  notify_except(Location(player), Location(player), player, tprintf("%s ejects in an emergency escape pod!", Name(player)), 0);
  notify_except(min_pad, min_pad, player, tprintf("%s crash lands in an emergency escape pod!", Name(player)), 0);
  if (min_ship)
  {
    notify_consoles(min_ship, tprintf("%s%s-%s Emergency ejection pod automatically tractored into the docking back.",
          ANSI_HILITE, ANSI_GREEN, ANSI_NORMAL));
  }
  moveto(player, min_pad, hs_options.space_wiz, NULL);
}
Пример #9
0
/* leave a landed/docked ship through the hatch */
void disembark(dbref player)
{
  dbref nav, obj, newobj;
  hship *ship;
  ATTR *a;
  int security;
  
  /* check if we can disembark from here */
  a = atr_get(Location(player), "BAY");
  if (!a)
  {
    /* no BAY, check if we're near the nav console */
    ship = find_ship(player);
    if (ship)
    {
      if (Location(ship->objnum) != Location(player))
      {
        notify(player, "You can't disembark from here.");
        return;
      }
    }
  }
  else
  {
    /* there's a BAY here, make sure it's a good one */
    nav = parse_dbref(atr_value(a));
    if (!IsShip(nav))
    {
      notify(player, "You can't disembark from here.");
      return;
    }
  
    ship = find_ship_by_nav(nav);
  }
  
  if (!ship)
  {
    notify(player, "You can't disembark from here.");
    return;
  }
  
  /* no ditching in space, or early after launching, or prematurely when landing */
  if ((ship->uid || ship->landing || ship->launching) && !ship->linked)
  {
    notify(player, "You can't disembark while in space.");
    return;
  }
  
  obj = atr_parse_dbref(ship->objnum, "SHIPOBJ");
  if (!RealGoodObject(obj))
  {
    notify(player, "This ship can not be disembarked.");
    return;
  }
  
  /* check whether we're docking or landing, save the new space object */
  if (ship->landed)
  {
    newobj = ship->landed->objnum;
  }
  else if (ship->docked)
  {
    newobj = ship->docked->objnum;
  }
  else if (ship->linked)
  {
    newobj = ship->linked->objnum;
  } else {
    notify(player, "You can't disembark while in space.");
    return;
  }
  
  if (ship->linked)
  {
    /* check the boarding code, if necessary */
    security = atr_parse_integer(ship->linked->objnum, "SECURITY", 0);
    if (security)
    {
      notify(player, "Unable to use boarding link while the other ship has security enabled.");
      return;
    }
    
    security = atr_parse_integer(ship->objnum, "SECURITY", 0);
    if (security)
    {
      notify(player, "Unable to use boarding link while security is enabled.");
      return;
    }
    
    obj = atr_parse_dbref(ship->linked->objnum, "BAY");
    if (!RealGoodObject(obj))
      obj = Location(ship->linked->objnum);
      
    moveto(player, obj, hs_options.space_wiz, NULL);
  } else {
    moveto(player, Location(obj), hs_options.space_wiz, NULL);
  }
  
  /* finish up by setting HSPACE attribute and notifying everybody about the move */
  atr_add(player, "HSPACE", unparse_dbref(newobj), hs_options.space_wiz, 0);
  notify_except(obj, Location(player), player, tprintf("%s disembarks through the main hatch.", Name(player)), 0);
  notify_except(obj, Location(obj), player, tprintf("%s disembarks from the %s.", Name(player), Name(obj)), 0);
  
  return;
}
Пример #10
0
/* man console command */
void man_console(dbref player, char *where)
{
  hship *ship;
  hconsole *con;
  dbref   console;
  dbref   manner, manning;
  hweapon *pri, *sec;
  char *prompt;
  int ptype, stype, type;

  if (Typeof(player) != TYPE_PLAYER && hs_options.forbid_puppets)
  {
    notify(player, "Only players may man this console.");
    return;
  }
  
  console = match_result(player, where, TYPE_THING, MAT_NEAR_THINGS);

  switch (console)
  {
  case NOTHING:
    notify(player, "I don't see that here.");
    return;

  case AMBIGUOUS:
    notify(player, "I don't know which you mean!");
    return;
  }

  /* don't need to do this now because we want to allow you
     to reman consoles easily for equipment changes */

  /*manner = get_user(console);
  if (manner == player)
  {
    notify(player, "You are already manning that console.");
    return;
  }*/

  if (!IsConsole(console) && !IsShip(console))
  {
    notify(player, "You cannot man that.");
    return;
  }
  
  if (IsConsole(console))
  {
    con = find_console(console);
    if (!con)
    {
      notify(player, "That console has not been activated.");
      return;
    }
    
    pri = &(con->primary);
    sec = &(con->secondary);
    prompt = &(con->prompt);
    
    ship = find_ship(console);
  }
  else if (IsShip(console))
  {
    con = NULL;
    ship = find_ship_by_nav(console);
    
    if (ship)
    {
      pri = &(ship->primary);
      sec = &(ship->secondary);
      prompt = &(ship->prompt);
    }
    
  } else{
    ship = NULL;
  }
  
  if (!ship)
  {
    notify(player, "Invalid ship object. Please contact your flight mechanic immediately!");
    return;
  }
    

  if (InCombat(ship))
  {
    notify(player, "Can't reload weapons in combat!");
    stype = sec->type;
    ptype = pri->type;
  } else {
    ptype = load_weapon(player, pri, HS_PRIMARY);
    stype = load_weapon(player, sec, HS_SECONDARY);
  }
  
  type = HasFlag(ptype | stype, HS_ANY_WEAPON);

  if (con)
  {
    /* this is an auxiliary console */
    /* no missiles on the aux consoles */
    if (HasFlag(type, HS_MISSILE))
    {
      clear_weapon(pri);
      clear_weapon(sec);
      
      notify(player, "You may not man an auxiliary console with missiles equipped.");
      return;
    }
    
    if (HasFlag(type, HS_WIRETAP))
      con->type = HS_OPS;
    else if (HasFlag(type, HS_CAPACITOR))
      con->type = HS_ENG;
    else if (HasFlag(type, HS_CANNON | HS_EMITTER | HS_WEAPON))
      con->type = HS_GUN;
    else
      con->type = HS_CIV;
    
  } else {
    /* this is a nav console */
    /* no cans, caps or taps */
    
    if (HasFlag(type, HS_CANNON))
    {
      clear_weapon(pri);
      clear_weapon(sec);
      
      notify(player, "You may not man a navigation console with a cannon equipped.");
      return;
    }
  }
  
  /* the equipment slots check out, and the console
     has been set to the appropriate type, if needed */

  if (prompt)
  {
    *prompt = HasFlag(atr_parse_integer(player, "HSPROMPT_FREQUENCY", 1), HS_PROMPT_FREQUENCY);
    FlagOn(*prompt, atr_parse_flags(player, hs_prompt_flags, "HSPROMPT_FLAGS"));
  }
  
  manning = get_console(player);
  if (manning != NOTHING)
  {
    manner = get_user(manning);
    if (manner == player)
    {
      con = find_console(manning);
      if (con)
      {
        load_weapon(manning, &(con->primary), HS_PRIMARY);
        load_weapon(manning, &(con->secondary), HS_SECONDARY);
      }
      
      set_user(manning, NOTHING);
      
      notify(player, tprintf("You unman the %s.", Name(manning)));
      notify_except(manning, Location(manning), player,
              tprintf("%s unmans the %s.", Name(player), Name(manning)), 0);
    }
  }
  
  /* set the HSPACE attribute in case something was fishy */
  if (!IsSim(ship->objnum))
  {
    atr_add(player, "HSPACE", unparse_dbref(ship->objnum), hs_options.space_wiz, 0);
  }

  set_user(console, player);

  execute_trigger(console, "AMAN", ship);

  if (con)
  {
    notify(player, tprintf("You man the %s (%s%s%s).", Name(console),
          ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL));
    notify_except(console, Location(console), player,
    	  tprintf("%s mans the %s (%s%s%s).", Name(player), Name(console),
    	  ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL), 0);
  } else {
    notify(player, tprintf("You man the %s.", Name(console)));
    notify_except(console, Location(console), player,
    	  tprintf("%s mans the %s.", Name(player), Name(console)), 0);
  }
}
Пример #11
0
void
do_kill(int descr, dbref player, const char *what, int cost)
{
	dbref victim;
	char buf[BUFFER_LEN];
	struct match_data md;

	init_match(descr, player, what, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_player(&md);
		match_absolute(&md);
	}
	victim = match_result(&md);

	switch (victim) {
	case NOTHING:
		notify(player, "I don't see that player here.");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if (Typeof(victim) != TYPE_PLAYER) {
			notify(player, "Sorry, you can only kill other players.");
		} else {
			/* go for it */
			/* set cost */
			if (cost < tp_kill_min_cost)
				cost = tp_kill_min_cost;

			if (FLAGS(DBFETCH(player)->location) & HAVEN) {
				notify(player, "You can't kill anyone here!");
				break;
			}

			if (tp_restrict_kill) {
				if (!(FLAGS(player) & KILL_OK)) {
					notify(player, "You have to be set Kill_OK to kill someone.");
					break;
				}
				if (!(FLAGS(victim) & KILL_OK)) {
					notify(player, "They don't want to be killed.");
					break;
				}
			}

			/* see if it works */
			if (!payfor(player, cost)) {
				notify_fmt(player, "You don't have enough %s.", tp_pennies);
			} else if ((RANDOM() % tp_kill_base_cost) < cost && !Wizard(OWNER(victim))) {
				/* you killed him */
				if (GETDROP(victim))
					/* give him the drop message */
					notify(player, GETDROP(victim));
				else {
					snprintf(buf, sizeof(buf), "You killed %s!", NAME(victim));
					notify(player, buf);
				}

				/* now notify everybody else */
				if (GETODROP(victim)) {
					snprintf(buf, sizeof(buf), "%s killed %s! ", NAME(player), NAME(victim));
					parse_oprop(descr, player, getloc(player), victim,
								   MESGPROP_ODROP, buf, "(@Odrop)");
				} else {
					snprintf(buf, sizeof(buf), "%s killed %s!", NAME(player), NAME(victim));
				}
				notify_except(DBFETCH(DBFETCH(player)->location)->contents, player, buf,
							  player);

				/* maybe pay off the bonus */
				if (GETVALUE(victim) < tp_max_pennies) {
					snprintf(buf, sizeof(buf), "Your insurance policy pays %d %s.",
							tp_kill_bonus, tp_pennies);
					notify(victim, buf);
					SETVALUE(victim, GETVALUE(victim) + tp_kill_bonus);
					DBDIRTY(victim);
				} else {
					notify(victim, "Your insurance policy has been revoked.");
				}
				/* send him home */
				send_home(descr, victim, 1);

			} else {
				/* notify player and victim only */
				notify(player, "Your murder attempt failed.");
				snprintf(buf, sizeof(buf), "%s tried to kill you!", NAME(player));
				notify(victim, buf);
			}
			break;
		}
	}
}