Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -545,11 +545,13 @@ leaving those locations rather than arriving there. Destroyed : bool [ro] It is set if this object has been successfully destroyed (but not yet deleted from memory). You must use the Destroy or Assassinate command - in order to set this flag; you cannot set it by yourself. + in order to set this flag; you cannot set it by yourself. Unlike all + other variables, you can access this variable even for an object that + does not exist; it returns 1 in that case. Dir : int3 The current direction. When it moves (without teleportation), it will automatically be set to the direction it moved. You can also set this by yourself. Relative directions are relative to this direction. If you Index: exec.c ================================================================== --- exec.c +++ exec.c @@ -516,10 +516,22 @@ //TODO: subclassing (using CF_GROUP) } else { Throw("Type mismatch"); } } + +static Uint32 v_destroyed(Value v) { + if(v.t==TY_NUMBER) { + if(v.u) Throw("Cannot convert non-zero number to object"); + return 0; + } else if(v.t>TY_MAXTYPE) { + if(v.u>=nobjects || !objects[v.u] || objects[v.u]->generation!=v.t) return 1; + return objects[v.u]->oflags&OF_DESTROYED?1:0; + } else { + Throw("Cannot convert non-object to object"); + } +} static Uint8 collisions_at(Uint32 x,Uint32 y) { Uint8 c=0; Uint32 n; if(x<1 || y<1 || x>pfwidth || y>pfheight) return 0; @@ -1264,11 +1276,11 @@ case OP_DESTROY: NoIgnore(); StackReq(0,1); Push(destroy(obj,obj,0)); break; case OP_DESTROY_C: NoIgnore(); StackReq(1,1); i=v_object(Pop()); Push(destroy(obj,i,0)); break; case OP_DESTROY_D: NoIgnore(); destroy(obj,obj,0); break; case OP_DESTROY_CD: NoIgnore(); StackReq(1,0); i=v_object(Pop()); destroy(obj,i,0); break; case OP_DESTROYED: StackReq(0,1); if(o->oflags&OF_DESTROYED) Push(NVALUE(1)); else Push(NVALUE(0)); break; - case OP_DESTROYED_C: StackReq(1,1); GetFlagOf(OF_DESTROYED); break; + case OP_DESTROYED_C: StackReq(1,1); t1=Pop(); Push(NVALUE(v_destroyed(t1))); break; case OP_DIR: StackReq(0,1); Push(NVALUE(o->dir)); break; case OP_DIR_C: StackReq(1,1); Push(GetVariableOf(dir,NVALUE)); break; case OP_DIR_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->dir=resolve_dir(obj,t1.u); break; case OP_DIR_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->dir=resolve_dir(i,t1.u); break; case OP_DISTANCE: StackReq(0,1); Push(NVALUE(o->distance)); break;