Author Topic: Obvious Exits with verbose and colorized support  (Read 4559 times)

Offline shadyman

  • Friend
  • **
  • Posts: 50
    • View Profile
Obvious Exits with verbose and colorized support
« on: September 01, 2008, 08:26:27 pm »
This is an Uber-release, it should work normally on any setup, totally backwards compatible. Below is a list of additions (and where to put them), as well as modifications to a couple files.

I'll be submitting this to Cratylus for lib integration, so please try it out and let me know of any bugs, errors, gripes, whines, etc.
Cheers!

/lib/door.c: Add...

To void SetSide (underneath new_side["Long"]... ):
Code: [Select]
    new_side["Desc"] = mp["desc"];
To mapping GetSide (underneath RetMap["short"]...):
Code: [Select]
    RetMap["desc"] = Sides[side]["Desc"];
To the end of the file:
Code: [Select]
//Get the shortened description ("desc" in the door mapping) for use in verbose room exits. If not, use "door"
string GetDesc(string side) {
    if( !side) { /* let's hack a side */
        object room;

        if( !this_player() ) room = previous_object();
        else room = environment(this_player());
        foreach(string s, class door_side val in Sides) {
            side = s;
            if( member_array(room, val->Rooms) != -1 ) break;
        }
    }
    if( stringp(((class door_side)Sides[side])->Desc) )
        return ((class door_side)Sides[side])->Desc;
    else return "door";
}


/lib/include/door.h: Add: (Under "mixed Long;"):
Code: [Select]
    mixed Desc;

/secure/include/config.h: Add under #define NM_STYLE_EXITS...
Code: [Select]
#define COLORIZED_EXITS          1
#define VERBOSE_EXITS            1


/lib/exits.c: Add (to the end of file):
Code: [Select]
//Use this to get whether or not an exit is obvious.
int GetExitObv( string str ) {
    if( !Exits[str] ) return 0;
    else return Exits[str]["obv"];
}

//Use this or GetFullExitData to get a mapping of obvious or not, to use for visible/invisible doors in lib/std/room.c
mapping GetObvMap() {
    mapping ret = ([]);
    foreach(string key in keys(Exits)){
ret[key] = Exits[key]["obv"];
    }

    return ret;
}

//Use this to hide an exit
int HideExit( string dir ) {
  if ( !Exits[dir] ) return 0;
  else return Exits[dir]["obv"] = 0;
}

//Use this to show a hidden exit
int ShowExit( string dir ) {
  if ( !Exits[dir] ) return 0;
  else return Exits[dir]["obv"] = 1;
}

Updated /lib/std/room.c:
Code: [Select]
/*    /lib/obj/room.c
 *    From the Dead Souls LPC Library
 *    The room object used to represent any room in the game
 *    Created by Descartes of Borg 940711
 *    Version: @(#) room.c 1.20@(#)
 *    Last Modified: 050912
 *
 * Updated by Shadyman to support VERBOSE_EXITS
 *    And COLORIZED_EXITS on 1-Sep-2008
 */

#ifndef NM_STYLE_EXITS
#define NM_STYLE_EXITS 1
#endif

#ifndef COLORIZED_EXITS
#define COLORIZED_EXITS 1
#endif

#ifndef VERBOSE_EXITS
#define VERBOSE_EXITS 1
#endif

#include <lib.h>
#include <rooms.h>
#include <config.h>
#include <daemons.h>
#include <function.h>
#include <medium.h>
#include <message_class.h>
#include <talk_type.h>
#include <terrain_types.h>
#include <privs.h>

inherit LIB_SHADOW_HOOK;
inherit LIB_CLEAN;
inherit LIB_CONTAINER;
inherit LIB_EXITS;
inherit LIB_DESCRIPTION;
inherit LIB_INVENTORY;
inherit LIB_LOOK;
inherit LIB_PROPERTIES;
inherit LIB_AMBIANCE;
inherit LIB_READ;
inherit LIB_SAVE;
inherit LIB_MONEY;

private function        Bury          = 0;
private string          Climate       = "temperate";
private int             DayLight      = -1970;
private int             counter       = 0;
private static string   DayLong       = 0;
private object array    DummyItems    = ({});
private static int      GasCheck      = time();
private float           Gravity       = 1.0;
private static mixed    Listen        = 0;
private int             NightLight    = -1970;
private static string   NightLong     = 0;
private static int      NoReplace     = 0;
private static int      PlayerKill    = 0;
private static int      PoisonGas     = 0;
private static int      ResetNumber   = 0;
private static mixed    Search        = 0;
private static int      Shade         = 0;
private static mixed    Smell         = 0;
private static mixed    Touch         = 0;
private string          Town          = "wilderness";
private int DefaultExits  = 1;
private int Flying        = 1;
private int Sitting       = 0;
private int Kneeling      = 0;
private int Standing      = 0;
private int Swimming      = 0;
private int ObviousVisible       = 1;
private int ActionChance  = 10;
mapping ItemsMap      = ([]);
private static mixed    global_item;
private static mixed Action;
private int tick_resolution = 5;
private int TerrainType = T_OUTDOORS;
private int Medium  = MEDIUM_LAND;
private mapping         ActionsMap      = ([]);
private string          SinkRoom        = "";
private string          FlyRoom         = "";


string GetClimate();
int GetNightLight();
int GetDayLight();
int GetShade();

mixed direct_delete_exit_str(){
    return 1;
}

mixed indirect_delete_exit_str(){
    return 1;
}

varargs int eventPrint(string msg, mixed arg2, mixed arg3);

/***********      /lib/room.c data manipulation functions      **********/

void CheckActions(){

    if(sizeof(ActionsMap)){
        foreach(mixed key, mixed val in ActionsMap){
            if( ActionChance > random(100) ){
                if(functionp(key)) evaluate(key);
                else eventPrint(key);
            }
        }
    }

    if( ActionChance > random(100) ){
        int x;

        if( functionp(Action) ) evaluate(Action);
        else if( pointerp(Action) && (x = sizeof(Action)) ){
            mixed act;

            act = Action[random(x)];
            if(functionp(act)){
                evaluate(act);
                return;
            }
            else eventPrint(act);
        }
    }
}

void heart_beat(){
    counter++;
    inventory::heart_beat();
    if(counter > 9999) counter = 0;
    CheckActions();
}

void SetAction(int chance, mixed val){
    ActionChance = chance;
    if( stringp(val) ) val = ({ val });
    else if( !functionp(val) && !pointerp(val) )
        error("Bad argument 2 to SetAction()\n");
    Action = val;
}

mixed GetAction(){ return Action; }

mapping SetActionsMap(mapping ActMap){
    if(ActMap && sizeof(ActMap)) ActionsMap = ActMap;
    return copy(ActionsMap);
}

mapping GetActionsMap(){
    return copy(ActionsMap);
}


int SetFrequency(int tick){
    if(tick) tick_resolution = tick;
    else tick_resolution = 5;
    set_heart_beat(0);
    return tick_resolution;
}

int GetFrequency(){
    return tick_resolution;
}

int GetTerrainType(){
    return TerrainType;
}

int SetTerrainType(int i){
    if(i) TerrainType = i;
    else return TerrainType;
}

int AddTerrainType(int i){
    if(!bitshiftedp(i)) return 0;
    else TerrainType = TerrainType | i;
    return TerrainType;
}

int RemoveTerrainType(int i){
    if(!bitshiftedp(i)) return 0;
    else TerrainType = TerrainType ^ i;
    return TerrainType;
}

int GetAmbientLight(){
    int a, dayset, nightset;

    dayset = this_object()->GetDayLight();
    nightset = this_object()->GetNightLight();

    if(dayset == -1970 && nightset == -1970 ){
        a = ambiance::GetAmbientLight();
    }

    else if( query_night() && nightset != -1970 ){
        a = nightset;
    }
    else if(!query_night() && dayset != -1970){
        a = dayset;
    }
    else {
        a = ambiance::GetAmbientLight();
    }
    if( GetClimate() != "indoors" ){
        //a += SEASONS_D->GetRadiantLight() - GetShade();
    }

    foreach(object ob in all_inventory()){
        a += ob->GetRadiantLight();
    }

    return a;
}

function GetBury(){
    return Bury;
}

function SetBury(function what){
    Bury = what;
}

static string GetExtraLong(){
    int i;
    string *l,*tmp;
    string ret;
    object array stuff;
    ret = "  ";
    tmp = ({});
    stuff=all_inventory(this_object());
    for(i=0; i<sizeof(stuff);i++){
        if(tmp = ({ stuff[i]->GetAffectLong() }) && !sizeof(l)) l = tmp;
        if( !sizeof(l) ) return 0;
        if(tmp = ({ stuff[i]->GetAffectLong() }) ) l += tmp;
    }
    if( !sizeof(l) ) return 0;
    ret += implode(l, " ");
    return ret;
}

string GetInternalDesc(){
    string ret, tmp;

    if( DayLong && !query_night() ){
        ret = DayLong;
    }
    else if( NightLong && query_night() ){
        ret = NightLong;
    }
    else {
        ret = container::GetInternalDesc();
    }
    if( !ret ){
        ret = "";
    }
    if( tmp = GetExtraLong() ){
        ret += GetExtraLong();
    }
    return ret;
}

int GetResetNumber(){
    return ResetNumber;
}

string array GetId(){ return ({}); }

string SetDayLong(string str){ return (DayLong = str); }

string GetDayLong(){ return DayLong; }

string SetNightLong(string str){ return (NightLong = str); }

string GetNightLong(){ return NightLong; }

string SetClimate(string str){
    if(str == "indoors" && TerrainType == T_OUTDOORS) TerrainType = T_INDOORS;
    return (Climate = str);
}

string GetClimate(){ return Climate; }

float SetGravity(float h){ return (Gravity = h); }

float GetGravity(){ return Gravity; }

int GetDayLight(){
    return DayLight;
}

static int SetDayLight(int x){
    return (DayLight = x);
}

object array GetDummyItems(){
    DummyItems = ({});
    foreach(object item in all_inventory(this_object())){
        if(base_name(item) == LIB_DUMMY){
            DummyItems += ({ item });
        }
    }
    return DummyItems;
}

varargs void AddItem(mixed item, mixed val, mixed adjectives){
    object ob, same_dummy;
    object *dummies = filter(all_inventory(this_object()), (: base_name(LIB_DUMMY) :) );
    global_item = item;

    if( objectp(item) ){
        same_dummy = filter(all_inventory(),(: base_name($1) == base_name(global_item) :));
        if(sizeof(same_dummy)) return;
        ob = item;
    }
    else {
        if( stringp(item) ){
            item = ({ item });
        }
        if( stringp(adjectives) ){
            adjectives = ({ adjectives });
        }
        same_dummy = filter(dummies,(: member_array(global_item[0],$1->GetId()) != -1 :));
        if(sizeof(same_dummy)) return;
        ob = new(LIB_DUMMY, item, val, adjectives);
    }
    ob->eventMove(this_object());
    DummyItems = ({ DummyItems..., ob });
}

mapping RemoveItem(mixed item){
    if( objectp(item) ){
        DummyItems -= ({ item });
        item->eventDestruct();
        return copy(Items);
    }
    else if( !arrayp(item) ){
        item = ({ item });
    }
    foreach(object ob in GetDummyItems()){
        if( sizeof(ob->GetId() & item) ){
            ob->eventDestruct();
            DummyItems -= ({ ob });
            return copy(Items);
        }
    }
}

mapping SetItems(mixed items){
    if(sizeof(DummyItems)) DummyItems->eventDestruct();
    DummyItems = ({});
    if( arrayp(items) ){
        items->eventMove(this_object());
        DummyItems = items;
    }
    else if( mapp(items) ){
        ItemsMap = items;
        foreach(mixed key, mixed val in items){
            string array adjs = ({});
            object ob;

            if( objectp(key) ){
                object *same_dummy = ({});
                global_item = key;
                same_dummy = filter(all_inventory() ,(: base_name($1) == base_name(global_item) :));
                if(sizeof(same_dummy)) continue;
                ob = key;
            }

            if( stringp(key) ){
                key = ({ key });
            }
            else {
                if( sizeof(key) == 2 && arrayp(key[0]) ){
                    adjs = key[1];
                    key = key[0];
                }
            }
            ob = new(LIB_DUMMY, key, val, adjs);
            ob->eventMove(this_object());
            DummyItems = ({ DummyItems..., ob });
        }
    }
    else {
        error("Bad argument 1 to SetItems(), expected object array or "
          "mapping.\n");
    }
    return copy(ItemsMap);
}

mapping GetItemsMap(){
    return copy(ItemsMap);
}

mapping GetSmellMap(){
    mapping Smells = ([]);
    foreach(object ob in GetDummyItems()){
        if( ob->GetSmell() ){
            Smells[ob->GetId()] = ob->GetSmell();
        }
    }
    if(this_object()->GetSmell()) Smells["default"] = this_object()->GetSmell();
    return copy(Smells);

}

mapping GetListenMap(){
    mapping Listens = ([]);
    foreach(object ob in GetDummyItems()){
        if( ob->GetListen() ){
            Listens[ob->GetId()] = ob->GetListen();
        }
    }
    if(this_object()->GetListen()) Listens["default"] = this_object()->GetListen();
    return copy(Listens);
}

mapping QueryMap(string str){
    switch(str){
    case "SetItems" : return GetItemsMap();break;
    case "SetSmell" : return GetSmellMap();break;
    case "SetListen" : return GetListenMap();break;
    case "SetInventory" : return this_object()->GetInventory();break;
    default : return ([]);
    }

}

varargs void AddListen(mixed item, mixed val){
    if( !val ){
        Listen = item;
        return;
    }
    if( !item || item == "default" ){
        Listen = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetListen(val);
                break;
            }
        }
    }
}

mixed GetListen(){
    return Listen;
}

varargs void RemoveListen(mixed item){
    if( !item || item == "default" ){
        Listen = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetListen(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetListen(0);
            }
        }
    }
}

varargs void SetListen(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddListen("default", items);
        }
        else {
            AddListen(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddListen(key, val);
    }
}

int SetMedium(int medium){
    Medium = medium;
    return Medium;
}

int GetMedium(){
    return Medium;;
}

int GetNightLight(){
    return NightLight;
}

int GetClimateExposed(){
    string *nonexposed_media = ({ MEDIUM_SPACE, MEDIUM_WATER });
    int nonexposed_terrain = (T_SEAFLOOR|T_INDOORS|T_UNDERWATER|T_UNDERGROUND|T_SPACE|T_PLANAR|T_BIOLOGICAL);
    if(GetClimate()=="indoors") return 0;
    if(GetTerrainType() & (nonexposed_terrain)) return 0;
    if(member_array(GetMedium(), nonexposed_media) != -1) return 0;
    return 1;
}

static int SetNightLight(int x){
    return (NightLight = x);
}

int SetNoReplace(int x){ return (NoReplace = x); }

int GetNoReplace(){ return NoReplace; }

int GetPlayerKill(){
    return PlayerKill;
}

int SetPlayerKill(int x){
    return (PlayerKill = x);
}

int AddPoisonGas(int x){
    PoisonGas += x;
    return PoisonGas;
}

int GetPoisonGas(){
    int x;

    if( PoisonGas < 1 ){
        return 0;
    }
    x = time() - GasCheck;
    GasCheck = time();
    if( x > 0 && x < 4 ){
        x = 1;
    }
    else {
        x = x/4;
    }
    PoisonGas -= x;
    if( PoisonGas < 0 ){
        PoisonGas = 0;
    }
    return PoisonGas;
}

int SetPoisonGas(int x){
    return (PoisonGas = x);
}

void AddRead(mixed item, mixed val){
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetRead(val);
                break;
            }
        }
    }
}

void RemoveRead(mixed item){
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetRead(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetRead(0);
            }
        }
    }
}

varargs void SetRead(mixed items, mixed arg){
    if( !mapp(items) ){
        AddRead(items, arg);
        return;
    }
    foreach(mixed key, mixed val in items){
        AddRead(key, val);
    }
}

int GetShade(){
    return Shade;
}

static int SetShade(int x){
    return (Shade = x);
}

varargs void AddSearch(mixed item, mixed val){
    if( !val ){
        Search = item;
        return;
    }
    if( !item || item == "default" ){
        Search = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetSearch(val);
                break;
            }
        }
    }
}

varargs mixed GetSearch(){
    return Search;
}

varargs void RemoveSearch(mixed item){
    if( !item || item == "default" ){
        Search = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetSearch(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetSearch(0);
            }
        }
    }
}

varargs void SetSearch(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddSearch("default", items);
        }
        else {
            AddSearch(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddSearch(key, val);
    }
}

varargs void AddSmell(mixed item, mixed val){
    if( !val ){
        Smell = item;
        return;
    }
    if( !item || item == "default" ){
        Smell = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetSmell(val);
                break;
            }
        }
    }
}

varargs mixed GetSmell(){
    return Smell;
}

varargs void RemoveSmell(mixed item){
    if( !item || item == "default" ){
        Smell = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetSmell(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetSmell(0);
            }
        }
    }
}

varargs void SetSmell(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddSmell("default", items);
        }
        else {
            AddSmell(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddSmell(key, val);
    }
}

varargs void AddTouch(mixed item, mixed val){
    if( !val ){
        Touch = item;
        return;
    }
    if( !item || item == "default" ){
        Touch = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetTouch(val);
                break;
            }
        }
    }
}

varargs void RemoveTouch(mixed item){
    if( !item || item == "default" ){
        Touch = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetTouch(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetTouch(0);
            }
        }
    }
}

varargs void SetTouch(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddTouch("default", items);
        }
        else {
            AddTouch(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddTouch(key, val);
    }
}

string GetTown(){ return Town; }

string SetTown(string town){ return (Town = town); }

/** this stuff is for backwards compat **/

mixed SetProperty(string prop, mixed val){
    if( prop == "light" ){
        if( !val ) return val;
        if( val < 0 ) return val;
        else return ambiance::SetAmbientLight(val*25);
    }
    else if( prop == "night light" ){
        if( !val ) return val;
        if( val < 0 ) return val;
        else return SetNightLight(15*val);
    }

    else return properties::SetProperty(prop, val);
}

mixed SetProperties(mapping mp){
    if( mp["light"] ){
        SetProperty("light", mp["light"]);
    }
    else if( mp["night light"] ){
        SetProperty("night light", mp["night light"]);
    }
    return properties::SetProperties(mp);
}


string GetLong(){
    return GetInternalDesc();
}

string SetLong(string str){
    return SetInternalDesc(str);
}

int CanAttack( object attacker, object who ){
    if( PlayerKill ){
        return 1;
    }
    attacker->RemoveHostile( who );
    return 0;
}

varargs int eventShow(object who, string args){
    string str;

    if( !(str = (string)SEASONS_D->GetLong(args)) ){
        who->eventPrint("You do not see that there.");
        return 1;
    }
    who->eventPrint(str);
    eventPrint(who->GetName() + " looks at the " + args + ".", who);
}

/***********          /lib/room.c events          ***********/
mixed eventBuryItem(object who, object tool, object what){
    if( !functionp(Bury) ){
        return "You cannot bury things here!";
    }
    if( functionp(Bury) & FP_OWNER_DESTED ){
        return "You cannot bury things here.";
    }
    return evaluate(Bury, who, tool, what);
}

varargs mixed eventHearTalk(object who, object target, int cls, string verb,
  string msg, string lang){
    object *obs;
    string exit, door;

    switch(cls){
    case TALK_PRIVATE:
        return 1;

    case TALK_SEMI_PRIVATE:
        target->eventHearTalk(who, target, cls, verb, msg, lang);
        eventPrint("%^BOLD%^CYAN%^" + (string)who->GetName() +
          " whispers something to " + (string)target->GetName() + ".",
          MSG_CONV, ({ who, target }));
        return 1;

    case TALK_LOCAL:
        obs = get_livings(this_object(),1);
        if(sizeof(obs)) obs -= ({ who });
        if(sizeof(obs))
            obs->eventHearTalk(who, target, cls, verb, msg, lang);
        obs = get_livings(this_object(),2);
        if(sizeof(obs)) obs -= ({ who });
        if(sizeof(obs))
            obs->eventHearTalk(who, target, cls, verb, msg, lang);
        return 1;

    case TALK_AREA:
        foreach(exit in GetExits()){
            string tmp;

            tmp = GetExit(exit);
            if( !find_object(tmp) ) continue;
            //if( (door = GetDoor(exit)) && (int)door->GetClosed() ) continue;
            tmp->eventHearTalk(who, target, TALK_LOCAL, verb, msg, lang);
        }
        foreach(exit in GetEnters(1)){
            string tmp;

            tmp = GetEnter(exit);
            if( !find_object(tmp) ) continue;
            if( (door = GetDoor(exit)) && (int)door->GetClosed() ) continue;
            tmp->eventHearTalk(who, target, TALK_LOCAL, verb, msg, lang);
        }
        obs = filter(all_inventory(),
          (: (int)$1->is_living() && $1 != $(who) :));
        obs->eventHearTalk(who, target, cls, verb, msg, lang);
        return 1;

    }
}

int eventMove(){ return 0; }

varargs int eventPrint(string msg, mixed arg2, mixed arg3){
    object *targs;
    int msg_class;
    targs = filter(all_inventory(), (: (int)$1->is_living() :));

    if( !arg2 && !arg3 ){
        msg_class = MSG_ENV;
    }
    else if( objectp(arg2) || arrayp(arg2) ){
        if( objectp(arg2) ) arg2 = ({ arg2 });
        foreach(mixed mount in arg2){
            object *riders;
            if(!mount) continue;
            riders = mount->GetRiders();
            if(riders) targs += riders;
        }
        targs -=  arg2;
        if( !arg3 ) msg_class = MSG_ENV;
        else if(intp(arg3)) msg_class = arg3;
    }
    else if(!arg3){
        if(intp(arg2)) msg_class = arg2;
        else msg_class = MSG_ENV;
    }
    else if( objectp(arg3) || arrayp(arg3) ){
        if( objectp(arg3) ) arg3 = ({ arg3 });
        foreach(mixed mount in arg3){
            object *riders;
            if(!mount) continue;
            riders = mount->GetRiders();
            if(riders) targs += riders;
        }
        targs -= arg3;
        msg_class = arg2;
    }
    targs->eventPrint(msg, msg_class);
    return 1;
}

static void create(){
    exits::create();
    reset(query_reset_number());
    set_heart_beat(0);
    if( replaceable(this_object()) && !GetNoReplace() ){
        string array tmp= inherit_list(this_object());

        if( sizeof(tmp) == 1 ){
            replace_program(tmp[0]);
        }
    }
}

int CanReceive(object ob){
    if(!GetProperty("no teleport") || !living(ob)) return container::CanReceive(ob);
    else {
        string verb = query_verb();
        string *allowed = ({ "go", "climb", "jump", "enter", "fly", "crawl" });
        if(member_array(verb, allowed) == -1 && !archp(this_player())){
            write("Your teleportation is prevented.");
            return 0;
        }
    }
    return container::CanReceive(ob);
}

varargs void reset(int count){
    if(sizeof(all_inventory())){
        foreach(object element in deep_inventory()){
            if(element->GetNoClean()) return;
        }
    }
    inventory::reset(count);
    all_inventory()->reset(count);
    ResetNumber++;
}

int id(){
    return 0;
}

int inventory_accessible(){
    return 1;
}

int inventory_visible(){
    return 1;
}

int SetNoDefaultExits(int i){
    if(!i) i = 0;
    DefaultExits = bool_reverse(i);
    ObviousVisible = DefaultExits;
    return DefaultExits;
}

int SetDefaultExits(int i){
    if(!i) i = 0;
    DefaultExits = i;
    ObviousVisible = DefaultExits;
    return DefaultExits;
}

int SetCanFly(int i){
    if(i && i > 0) Flying = 1;
    else Flying = 0;
}

mixed CanFly(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(MEDIUM_WATER == Medium || MEDIUM_SPACE == Medium) return 0;
    if(sizeof(FlyRoom)) return 1;
    return Flying;
}

int SetCanSwim(int i){
    if(i && i > 0) Swimming = 1;
    else Swimming = 0;
}

mixed CanSwim(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if((MEDIUM_WATER == Medium) || (MEDIUM_SURFACE == Medium) ) return 1;
    if(GetTerrainType() & (T_ALL_SEA)) return 1;
    return Swimming;
}

int SetCanStand(int i){
    if(i && i > 0) Standing = 1;
    else Standing = 0;
}

mixed CanStand(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(GetTerrainType() & (T_SPACE | T_UNDERWATER | T_SURFACE)) return 0;
    if(GetTerrainType() & (T_SEAFLOOR)) return 1;
    if((MEDIUM_AIR == Medium)) return 0;
    if((MEDIUM_LAND == Medium)) return 1;
    return Standing;
}

int SetCanSit(int i){
    if(i && i > 0) Sitting = 1;
    else Sitting = 0;
}

mixed CanSit(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(GetTerrainType() & (T_SPACE | T_UNDERWATER | T_SURFACE)) return 0;
    if(GetTerrainType() & (T_SEAFLOOR)) return 1;
    if((MEDIUM_AIR == Medium)) return 0;
    if((MEDIUM_LAND == Medium)) return 1;
    return Sitting;
}

int SetCanKneel(int i){
    if(i && i > 0) Kneeling = 1;
    else Kneeling = 0;
}

mixed CanKneel(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(GetTerrainType() & (T_SPACE | T_UNDERWATER | T_SURFACE)) return 0;
    if(GetTerrainType() & (T_SEAFLOOR)) return 1;
    if((MEDIUM_AIR == Medium)) return 0;
    if((MEDIUM_LAND == Medium)) return 1;
    return Kneeling;
}

int SetNoObviousExits(int i){
    if(!i) i = 0;
    ObviousVisible = bool_reverse(i);
    DefaultExits = ObviousVisible;
    return ObviousVisible;
}

int GenerateObviousExits(){
    string *normals;
    string *exits;
    string dir_string, enters;
    mapping obv;

    //exits = GetExits();
    obv = GetObvMap();
    exits = filter(GetExits(), (: !($1 == "up" && !(this_object()->GetVirtualSky()) &&
          load_object(GetExit($1))->GetVirtualSky()) :) );
    enters = "";
    normals = ({ "north", "south", "east", "west", "up", "down" });
    normals += ({ "northeast", "southeast", "northwest", "southwest" });
    normals += ({ "out" });
    dir_string = "";

    if(sizeof(GetEnters(1)-({0}))){
        foreach(string enter in this_object()->GetEnters(1)){
            enters += "enter "+enter;
            if(member_array(enter,this_object()->GetEnters(1)) !=
              sizeof(this_object()->GetEnters(1)) -1){
                enters +=", ";
            }
        }
    }

    if(NM_STYLE_EXITS){
      if(member_array("north",exits) != -1 && obv["north"] == 1) dir_string += "n, ";
      if(member_array("south",exits) != -1 && obv["south"] == 1) dir_string += "s, ";
      if(member_array("east",exits) != -1 && obv["east"] == 1) dir_string += "e, ";
      if(member_array("west",exits) != -1 && obv["west"] == 1) dir_string += "w, ";
      if(member_array("northeast",exits) != -1 && obv["northeast"] == 1) dir_string += "ne, ";
      if(member_array("northwest",exits) != -1 && obv["northwest"] == 1) dir_string += "nw, ";
      if(member_array("southeast",exits) != -1 && obv["southeast"] == 1) dir_string += "se, ";
      if(member_array("southwest",exits) != -1 && obv["southwest"] == 1) dir_string += "sw, ";
      if(member_array("up",exits) != -1 && obv["up"] == 1) dir_string += "u, ";
      if(member_array("down",exits) != -1 && obv["down"] == 1) dir_string += "d, ";
      if(member_array("out",exits) != -1 && obv["out"] == 1) dir_string += "out, ";
    }
    else dir_string = implode(keys(obv),", ")+", ";
    if(sizeof(this_object()->GetEnters(1) - ({0}) )){
        if(sizeof(this_object()->GetExits())) dir_string += ", ";
        dir_string += enters;
    }
    if(last(dir_string,2) == ", ") dir_string = truncate(dir_string,2);
    dir_string = replace_string(dir_string,", , ",", ");
    if(ObviousVisible) SetObviousExits(dir_string);
    return 1;
}

int eventReceiveObject(object ob){
    return container::eventReceiveObject(ob);
}

string SetFlyRoom(string str){
    FlyRoom = str;
    return FlyRoom;
}

string GetFlyRoom(){
    return FlyRoom;
}

string SetSinkRoom(string str){
    SinkRoom = str;
    return SinkRoom;
}

string GetSinkRoom(){
    return SinkRoom;
}

string GenerateVerboseExits(){
    string *normals;
    int exitCount = 0;
    string *roomexits;
    string *entersArray;
    string dir_string, enters, door;
    string temp,temp2;
    mapping obv;

    roomexits = GetExits();
    obv = GetObvMap();

//Quick hack, may be a better way than this.
foreach (string ex in roomexits ) {
  if (obv[ex] == 0) roomexits -= ({ex});
}

    enters = "";
    normals = ({ "north", "south", "east", "west", "up", "down" });
    normals += ({ "northeast", "southeast", "northwest", "southwest" });
    normals += ({ "out" });
    dir_string = "";

    if( sizeof(GetEnters(1)-({0})))
    {
        entersArray = this_object()->GetEnters(1);
        foreach( string en in entersArray )
        {
        entersArray[exitCount++] = "enter "+entersArray[exitCount];
        }
        roomexits += entersArray;
    }

//Quick hack, may be a better way than this.
foreach (string ex in roomexits ) {
  if (obv[ex] == 0) roomexits -= ({ex});
}

    exitCount = 0;

    if (COLORIZED_EXITS) {
        if( sizeof( roomexits ) == 0 )
        dir_string += "%^BOLD%^WHITE%^There are no obvious exits%^RESET%^";
        else if( sizeof(roomexits) == 1 )
            dir_string += "%^BOLD%^WHITE%^There is "+ cardinal((int)sizeof(roomexits)) +" obvious exit%^RESET%^: ";
        else
        dir_string += "%^BOLD%^WHITE%^There are "+ cardinal((int)sizeof(roomexits)) +" obvious exits%^RESET%^: ";
    } else {
        if( sizeof( roomexits ) == 0 )
        dir_string += "There are no obvious exits";
        else if( sizeof(roomexits) == 1 )
            dir_string += "There is "+ cardinal((int)sizeof(roomexits)) +" obvious exit: ";
        else
        dir_string += "There are "+ cardinal((int)sizeof(roomexits)) +" obvious exits: ";
    }

    foreach( string ex in roomexits )
    {
        if (COLORIZED_EXITS) {
          //Generate Colorized Verbose list
        if ( door = GetDoor(ex) ) {
                temp = door->GetClosed();
    temp2 = door->GetDesc();
if (temp) dir_string += "a closed "+temp2+" %^RED%^"+roomexits[exitCount]+"%^RESET%^";
else dir_string += "an open "+temp2+" %^BOLD%^GREEN%^"+roomexits[exitCount]+"%^RESET%^";
        } else dir_string += "%^BOLD%^GREEN%^"+roomexits[exitCount]+"%^RESET%^";
        } else {
        //Generate non-colorized Verbose list
        if ( door = GetDoor(ex) ) {
                temp = door->GetClosed();
    temp2 = door->GetDesc();
if (temp) dir_string += "a closed "+temp2+" "+roomexits[exitCount];
else dir_string += "an open "+temp2+" "+roomexits[exitCount];
        } else dir_string += roomexits[exitCount];
        }

      if( ++exitCount == (sizeof( roomexits )-1) ) dir_string += ", and ";
      else dir_string += ", ";
    }

    if (last(dir_string,2) == ", ") dir_string = truncate(dir_string,2);
    dir_string = replace_string(dir_string,", , ",", ") + ".";
    return dir_string;
}
static void init(){
    if(this_object()->GetProperty("indoors")) SetClimate("indoors");
    if(!sizeof(GetObviousExits()) && DefaultExits > 0 && ObviousVisible) GenerateObviousExits();
    if((Action && sizeof(Action)) || sizeof(ActionsMap)) set_heart_beat(tick_resolution);
}

Change the block of code (marked in here as "CHANGED CODE") in /lib/events/describe.c, starting around line 31:
Code: [Select]
//UNTOUCHED CODE:
    switch( i ){
    case VISION_BLIND:
        this_object()->eventPrint("You are blind and can see nothing.");
        break;
    case VISION_TOO_DARK:
        this_object()->eventPrint("It is much too dark to see.");
        break;
    case VISION_DARK:
        this_object()->eventPrint("It is too dark to see.");
        break;
    case VISION_TOO_BRIGHT:
        this_object()->eventPrint("It is much too %^YELLOW%^bright%^RESET%^ to see.");
        break;
    case VISION_BRIGHT:
        this_object()->eventPrint("It is too %^YELLOW%^bright%^RESET%^ to see.");
        break;
    }
//CHANGED CODE:
    if( !brief ){
        if( i == VISION_CLEAR ){
            desc = (string)env->GetObviousExits() || "";
            if(desc && desc != "")
                desc = capitalize((string)env->GetShort() || "")
                + " [" + desc + "]\n";
            else desc = capitalize((string)env->GetShort()+"\n" || "\n");
            if(!NM_STYLE_EXITS){
                desc = capitalize((string)env->GetShort()+"\n" || "\n");
                if (VERBOSE_EXITS) {
                    altern_obvious = env->GenerateVerboseExits();
                } else {
                    altern_obvious = "Obvious exit$Q: "+(string)env->GetObviousExits() || "none";
                }
            }
        }
        else desc = "\n";
//UNTOUCHED CODE:
        if( i == VISION_CLEAR || i == VISION_LIGHT || i == VISION_DIM ){
            if(this_object()->GetProperty("automapping")) desc += simple_map(env)+"\n";
            desc += (string)env->GetLong();
        }
        if(functionp(tmp = (mixed)env->GetSmell("default")))
            tmp = (string)(*tmp)("default");
        smell = tmp;
        if(functionp(tmp = (mixed)env->GetListen("default")))
            tmp = (string)(*tmp)("default");
        sound = tmp;
        if( functionp(tmp = (mixed)env->GetTouch("default")) )
            tmp = evaluate(tmp, "default");
        touch = tmp;
    }
    else {
        if(i == VISION_CLEAR || i == VISION_LIGHT || i == VISION_DIM){
            desc = (string)env->GetShort();
            if(this_object()->GetProperty("automapping")) desc += simple_map(env)+"\n";
            if(NM_STYLE_EXITS){
                if( (tmp = (string)env->GetObviousExits()) && tmp != "" )
                    desc += " [" + tmp + "]";
                else desc += "\n";
            }
            else altern_obvious = "Obvious exits: "+(string)env->GetObviousExits() || "none";
        }
        else desc = "\n";
    }
    if( desc ) this_object()->eventPrint(desc, MSG_ROOMDESC);
    if(sizeof(altern_obvious)){
        int quant = sizeof(env->GetExits()) + sizeof(env->GetEnters());
        if(quant > 1) altern_obvious = replace_string(altern_obvious,"$Q","s");
        else altern_obvious = replace_string(altern_obvious,"$Q","");
        this_object()->eventPrint(altern_obvious,MSG_ROOMDESC);
    }
    if( smell ) this_object()->eventPrint("%^GREEN%^" + smell, MSG_ROOMDESC);
    if( sound ) this_object()->eventPrint("%^CYAN%^" + sound, MSG_ROOMDESC);
    if( touch ) this_object()->eventPrint("%^YELLOW%^" + touch, MSG_ROOMDESC);
« Last Edit: September 01, 2008, 08:37:46 pm by shadyman »

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Obvious Exits with verbose and colorized support
« Reply #1 on: September 01, 2008, 09:01:34 pm »
Quote
I'll be submitting this to Cratylus for lib integration

Yay!

Licensing on this?

-Crat

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: Obvious Exits with verbose and colorized support
« Reply #2 on: September 01, 2008, 09:47:07 pm »
Oh, hey, uh, speaking of licensing, Crat, I hereby declare everything I've posted on Code Vault to be public domain if you want to port it to DS.

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Obvious Exits with verbose and colorized support
« Reply #3 on: September 01, 2008, 10:19:05 pm »
Quote
I hereby declare everything I've posted on Code Vault to be public domain if you want to port it to DS.

Thank you

:)

-Crat

Offline shadyman

  • Friend
  • **
  • Posts: 50
    • View Profile
Re: Obvious Exits with verbose and colorized support
« Reply #4 on: November 11, 2008, 05:53:55 pm »
Quote
I'll be submitting this to Cratylus for lib integration

Yay!

Licensing on this?

-Crat
Public Domain.

Offline Io

  • Acquaintance
  • *
  • Posts: 44
    • View Profile
Re: Obvious Exits with verbose and colorized support
« Reply #5 on: May 08, 2011, 02:52:21 pm »
any chance on updating this for ds 3.2? I have been trying to tweak it but it keeps returning "No obvious exits" and some errors with doors

Offline Io

  • Acquaintance
  • *
  • Posts: 44
    • View Profile
Re: Obvious Exits with verbose and colorized support
« Reply #6 on: May 08, 2011, 04:27:42 pm »
nevermind, I accomplished what I needed by writing my own little script

To transform
Code: [Select]
Obvious exits: east, west
To
Code: [Select]
Obvious exits:
East [Tavern]
West [Street]

I did the following,

Replace this line (around line 59) in /lib/events/describe.c
Code: [Select]
altern_obvious = "Obvious exit$Q: "+env->GetObviousExits() || "none";
With
Code: [Select]
               altern_obvious = "%^BOLD%^WHITE%^Obvious exit$Q:%^RESET%^";
                foreach( string vExit in env->GetExits() ) {
                    altern_obvious += "\n%^BOLD%^RED%^" + capitalize(vExit) + "%^RESET%^ [";
                    if(env->GetDoor(vExit) && env->GetDoor(vExit)->CanClose() && env->GetDoor(vExit)->GetClosed()) {
                        altern_obvious += capitalize(env->GetDoor(vExit)->GetShort());
                    } else {
                        exit_short = load_object(env->GetExit(vExit));
                        altern_obvious += exit_short->GetShort();
                    }
                    altern_obvious += "]";
                }

Declare the exit_short string at the top of void eventDescribeEnvironment
Code: [Select]
string exit_short;
The script also checks for doors.  If the door is closed it won't display the Short of the connected room, if you open the door it will

I'm just starting out with the DS codebase, so please let me know if this modification can be improved or if it may cause memory leaks or other problems
« Last Edit: May 08, 2011, 04:42:44 pm by Io »