object.c

merentha_fluffos_v2/lib/std/inheritables/object.c · 2.2 KB

From the archive merentha_fluffos_v2.zip

Download the archive   « Back to the archive contents

// Petrarch
// Merentha Lib 1.0
// object.c

#include <std.h>
#include "object.h"

inherit CLEANUP;

int __Mass, __Value;
string *__Id=({});
string __Name, __CapName, __Short, __Long;
string __PreventGet;
static mapping __Properties=([]);

void create() {
    ::create();
    __Mass=0;
    __Value=0;
    reset();
}

void init() {
    ::init();
}

void reset() {
    ::reset();
}

void post_move() { }

void set_mass(int i) { __Mass=i; }
int query_mass() { return __Mass; }
int query_total_mass() { return __Mass+this_object()->query_holding_mass(); }

void set_value(int i) { __Value=i; }
int query_value() { return __Value; }

void set_prevent_get(string str) { __PreventGet=str; }
string moveable() { return __PreventGet;}

int move(mixed dest) {
    int move_ok=0;
    object env;
    string tmp;
    if(env=environment()) {
        if(tmp=environment()->release_object(this_object()) || tmp=moveable()) {
            if(this_player())
                message("move", tmp, this_player());
            return 1;
        }
    } 
    if(tmp=dest->receive_object(this_object())) { 
        if(this_player())
            message("move", tmp, this_player());
        return 1;
    }
    dest->add_mass(__Mass);
    move_object(dest);
    post_move();
    return 0;
}

void set_name(string str) {  __Name=str; }
string query_name() { return __Name; }

void set_cap_name(string str) { __CapName=str; }

varargs string query_cap_name(mixed arg){
return (__CapName?__CapName:capitalize(__Name));
}

void set_short(string str) { __Short=str; }
string query_short() { return __Short; }

void set_long(string str) { __Long=str; }
string query_long() { return __Long; }

void set_id(string *arg) { __Id=arg; }
string *query_id() { return __Id; }
int id(string arg) {
    if (!arg || !__Id) return 0;
    return (member_array(arg, __Id) != -1);
}

void set_properties(mapping props) {  __Properties=props; }
void set_property(string prop, mixed val) { __Properties[prop]=val; }
void add_property(string prop, mixed val) { set_property(prop, val); }
void remove_property(string prop) { map_delete(__Properties, prop); }
mapping query_properties() { return __Properties; }
mixed query_property(string prop) { return __Properties[prop]; }

Site Stats

Snippets: 1791
Codebases: 571