Conitec 3d gamestudio-source development 사용자 설명서

다운로드
페이지 21
3D Gamestudio Programmer's Manual
                        
© Conitec July 2002
                       10
  // get the address of some script variables and functions
    fixed *tracemode = (fixed *)a5dll_getwdlobj("trace_mode");
    wdlfunc2 vecrotate = (wdlfunc2)a5dll_getwdlfunc("vec_rotate");
    wdlfunc2 trace = (wdlfunc2)a5dll_getwdlfunc("trace");
    if (!tracemode || !trace || !vecrotate) return 0;
    fixed target[3] = { FLOAT2FIX(1000.0),0,0 }; // trace target vector
  // rotate vector by entity engles, just as in C-Script
    (*vecrotate)((long)target,(long)&(ent->pan));
  // add entity position to target
    target[0] += ent->x;
    target[1] += ent->y;
    target[2] += ent->z;
  // set trace_mode, then trace a line between entity and target,
  // and return the result
    *tracemode = INT2FIX(TRM_IGNORE_ME + TRM_IGNORE_PASSABLE + TRM_USE_BOX);
    return (*trace)((long)&(ent->x),(long)target);
  }
Some special C-Script functions, like keyboard entry, can not be called directly from a DLL.
However they can be executed indirectly by calling a script that executes that function. Scripts
can be called from a DLL through the following functions:
long a5dll_getscript(char *name);
This function returns a handle of the user-defined script function with the given name. It can be
used to call user defined C-Script actions or functions from inside a DLL plugin. If the function
is not found,
NULL
is returned and an error message will pop up. Example for a DLL function
that calls a function that must be defined in the C-Script code:
function beeptwice() { beep; beep; } // in the script
DLLFUNC fixed WDLBeep(fixed value)
{
// get the function
long beeptwice = a5dll_getscript("beeptwice");
if (!beeptwice) return 0; // "beeptwice" doesn't exist
// call it
(*a5->wdl->Call)(beeptwice);
 return 
INT2FIX(1);
}
fixed a5dll_callscript(long script,long p1=0,long p2=0,long p3=0,long p4=0);
fixed a5dll_callname(char *name,long p1=0,long p2=0,long p3=0,long p4=0);
These functions call a user-defined script function with given address or given name. The 4
parameters can be a fixed point number, an array, or a pointer to a C-Script object.
A4_TEX *a5dll_tex4ent(A4_ENTITY *entity,int frame,int texnum=0);
This function returns the texture of a sprite, model or terrain entity. It can be used to directly
access D3D textures (see example below).
Frame
is the frame or skin number,
texnum
the
subtexture number if it is split into several subtextures.