funcvoidOpenFocussedChestOrDoor(){varoCNpcher;her=Hlp_GetNpc(hero);// No focus vob at all?if(!her.focus_vob){Print("No focus!");return;};// Focus vob not a lockable vob?if(!Hlp_Is_oCMobLockable(her.focus_vob)){Print("No chest or door in focus!");return;};varoCMobLockableLockable;Lockable=MEM_PtrToInst(her.focus_vob);if(Lockable.bitfield&oCMobLockable_bitfield_locked){Lockable.bitfield=Lockable.bitfield&~oCMobLockable_bitfield_locked;Print(ConcatStrings("Opened the following vob: ",Lockable._zCObject_objectName));}else{Print(ConcatStrings(Lockable._zCObject_objectName,"wasn't even complete!"));};};
funcvoidPrintCameraPos(){// Initialize global instances (which only exist once):// Initializes MEM_World, MEM_Game, etc. including MEM_CameraMEM_InitGlobalInst();/* The camera object is not a vob (but something abstract), do not know where and how there are position data. I prefer to work on the camera vob : */varzCVobcamVob;camVob=MEM_PtrToInst(MEM_Camera.connectedVob);/* Here you have to know how the transformation matrix is structured: It consists of three vectors, the x, y and z directions of the local coordinate system of the camera vob in world coordinates (where z specifies the line of sight). These vectors are denoted by v1, v2, v3. In addition, in the 4th column there is the translation, that is, the position of the camera. v1_x v2_x v3_x x v1_y v2_y v3_y y v1_z v3_z v3_z z 0 0 0 0 The matrix is stored row by row in memory. Since we are interested in the last column are the indices in the trafoWorld Array 3, 7 and 11 that we need. */Print(ConcatStrings("x: ",IntToString(roundf(camVob.trafoObjToWorld[3]))));Print(ConcatStrings("y: ",IntToString(roundf(camVob.trafoObjToWorld[7]))));Print(ConcatStrings("z: ",IntToString(roundf(camVob.trafoObjToWorld[11]))));};
funcvoidStartRain(){// Initialize global instances// This also includes SkycontrollerMEM_InitGlobalInst();// start at the beginning of the day (12:00 noon)MEM_SkyController.rainFX_timeStartRain=0;// FLOATNULL constant// end at the end of the day (12:00 noon of the next day)MEM_SkyController.rainFX_timeStopRain=1065353216;// FLOATONE constant/* Note: The start and end times are floating point numbers. * 0 stands for the beginning of the day 1 for the end of the day. * a day in the game begins at 12:00 p.m. * For the structure of the floating point format, google for IEEE-745.*//* Result: rain all day! (unless you are in a zone * in which it snows, then snow all day) */};
// This example doesn't show why MEM_CallByString * is useful, but how to use the function.varzCVobsomeObject;funcintMyFunction(varintparam1,varstringstr1,varintparam2,varstringstr2){Print(ConcatStrings(str1,str2));//(*)return100*param1+param2;};funcvoidfoo(){varintresult;// The following code is in this case equivalent to:// result = MyFunction(42, "Hello", 23, "World!");// Lay the call arguments on the call stackMEM_PushIntParam(42);MEM_PushStringParam("Hello ");MEM_PushIntParam(23);MEM_PushStringParam("World!");MEM_CallByString("MYFUNCTION");// the function puts the result (of type int in this case) on the stack// we pop the int result and save it to a variableresult=MEM_PopIntResult();// print the resultPrint(IntToString(result));};/* Note: Since symbol indices are continuous and someObject's symbol index is simply given by someObject itself, could MEM_CallByString("MYFUNCTION"); also be replaced here by MEM_CallByID(someObject + 1);*/