/** Can a player see something? * \param player the looker. * \param thing object to be seen. * \param can_see_loc 1 if player can see the location, 0 if location is dark. * \retval 1 player can see thing. * \retval 0 player can not see thing. */ int can_see(dbref player, dbref thing, int can_see_loc) { if (!can_interact(thing, player, INTERACT_SEE, NULL)) return 0; /* * 1) your own body isn't listed in a 'look' 2) exits aren't listed in a * 'look' 3) unconnected (sleeping) players aren't listed in a 'look' */ if (player == thing || IsExit(thing) || (IsPlayer(thing) && !Connected(thing))) return 0; /* if thing is in a room set LIGHT, it can be seen */ else if (IS(Location(thing), TYPE_ROOM, "LIGHT")) return 1; /* if the room is non-dark, you can see objects which are light or non-dark */ else if (can_see_loc) return (Light(thing) || !DarkLegal(thing)); /* otherwise room is dark and you can only see lit things */ else return (Light(thing)); }
/** Return the first object near another object that is visible to a player. * * BEWARE: * * first_visible() does not behave as intended. It _should_ return the first * object in `thing' that is !DARK. However, because of the controls() check * the function will return a DARK object if the player owns it. * * The behavior is left as is because so many functions in fundb.c rely on * the incorrect behavior to return expected values. The lv*() functions * also make rewriting this fairly pointless. * * \param player the looker. * \param thing an object in the location to be inspected. * \return dbref of first visible object or NOTHING. */ dbref first_visible(dbref player, dbref thing) { int lck = 0; int ldark; dbref loc; if (!GoodObject(thing) || IsRoom(thing)) return NOTHING; loc = IsExit(thing) ? Source(thing) : Location(thing); if (!GoodObject(loc)) return NOTHING; ldark = IsPlayer(loc) ? Opaque(loc) : Dark(loc); while (GoodObject(thing)) { if (can_interact(thing, player, INTERACT_SEE, NULL)) { if (DarkLegal(thing) || (ldark && !Light(thing))) { if (!lck) { if (See_All(player) || (loc == player) || controls(player, loc)) return thing; lck = 1; } if (controls(player, thing)) /* this is what causes DARK objects to show */ return thing; } else { return thing; } } thing = Next(thing); } return thing; }
/** Take an action on an object and trigger attributes. * \verbatim * executes the @attr, @oattr, @aattr for a command - gives a message * to the enactor and others in the room with the enactor, and executes * an action. We optionally load pe_regs into the queue. * \endverbatim * * \param player the enactor. * \param thing object being triggered. * \param what message attribute for enactor. * \param def default message to enactor. * \param owhat message attribute for others. * \param odef default message to others. * \param awhat action attribute to trigger. * \param loc location in which action is taking place. * \param pe_regs the pe_regs arguments for the evaluation/queueing * \param flags flags controlling type of interaction involved. * \retval 0 no attributes were present, only defaults were used if given. * \retval 1 some attributes were evaluated and used. */ int real_did_it(dbref player, dbref thing, const char *what, const char *def, const char *owhat, const char *odef, const char *awhat, dbref loc, PE_REGS *pe_regs, int flags, int an_flags) { char buff[BUFFER_LEN], *bp; int attribs_used = 0; NEW_PE_INFO *pe_info = NULL; ufun_attrib ufun; if (!pe_info) { pe_info = make_pe_info("pe_info-real_did_it2"); } loc = (loc == NOTHING) ? Location(player) : loc; /* only give messages if the location is good */ if (GoodObject(loc)) { /* message to player */ if (what && *what) { if (fetch_ufun_attrib (what, thing, &ufun, UFUN_LOCALIZE | UFUN_REQUIRE_ATTR | UFUN_IGNORE_PERMS)) { attribs_used = 1; if (!call_ufun(&ufun, buff, thing, player, pe_info, pe_regs) && buff[0]) notify_by(thing, player, buff); } else if (def && *def) notify_by(thing, player, def); } /* message to neighbors */ if (!DarkLegal(player)) { if (owhat && *owhat && fetch_ufun_attrib(owhat, thing, &ufun, UFUN_LOCALIZE | UFUN_REQUIRE_ATTR | UFUN_IGNORE_PERMS | UFUN_NAME)) { attribs_used = 1; if (!call_ufun_int (&ufun, buff, thing, player, pe_info, pe_regs, (void *) AName(player, an_flags, NULL)) && buff[0]) notify_except2(player, loc, player, thing, buff, flags); } else if (odef && *odef) { bp = buff; safe_format(buff, &bp, "%s %s", AName(player, an_flags, NULL), odef); *bp = '\0'; notify_except2(player, loc, player, thing, buff, flags); } } } if (pe_info) { free_pe_info(pe_info); } if (awhat && *awhat) attribs_used = queue_attribute_base(thing, awhat, player, 0, pe_regs, 0) || attribs_used; return attribs_used; }
const char * spname_int(dbref thing, bool ansi) { /* if FULL_INVIS is defined, dark wizards and dark objects will be * Someone and Something, respectively. */ if (FULL_INVIS && DarkLegal(thing)) { if (IsPlayer(thing)) return "Someone"; else return "Something"; } else if (ansi) { /* This uses accents */ return AaName(thing, AN_SAY, NULL); } else { /* This does not */ return Name(thing); } }