scripts are special format DLL files.
they must have the following functions:

Register
script

Any other functions used by the DLL will be ignored.
Only these 2 functions are called by the game.

***************************************************

ProcedureCDLL.l register(*map,*Objects,*Trees,*Script,MaxCED.l)

*map is a pointer to the map memory area

*objects is the pointer to the global list of objects
including creatures and inventory

*Trees is a pointer to a list of tree positions

*Scripts is a pointer to a memory area used for scripts only

MaxCED is the total number of objects present in the game.


*****************************************************

ProcedureCDLL.l script()

see the script memory map for location of values

CID is the offset to a creature triggering the script.
Its an offset from *Objects
this value is located *Scripts

DID is offset to a device used by the creature.
this value is word *Objects+CID+14

TID is the intended target.
this is word *Scripts+2

id is the value supplied by the register function
to identify the exact script.
This is word *Objects+TID+224

The entire command context is stored in the *Script
structure ....

your script should then check any flags needed
and set the state flag. The state flag is used to control
animations. If an animation is still playing, the state
is assumed incomplete. This can be used to control "timed" doors.
A non-zero return value indicates a state change, and the new
animation to begin playing.

return value meanings:
0 - no change
1 - 11 state change, animations only
-1 - -11 state change, objective change state, show message 1-11
>11 show temp message
<-11 show full message, wait for answer



*******************************************************

functional use example:
Using a BOX object (movable by player) to block a door

as block approaches door, or moves away ...
A trigger is called. In the creature editor,
The "BOX"es ID is passed to the door script.
Box calls script with the block/unblock command

as creature moves to or from door, door script determine if blocked.
IF creature wants to open/close door, creature calls door script
with command "open/close/lock/unlock"

********************************************************
terms for memory specs:

B  - Byte
W  - Word, 2 bytes
DW - double word, 4 bytes
F  - float, 4 bytes
*  - designated memory location uses multiple data types
*********************************************************
Tree memory spec:

byte	type	data
0	F	tree X position
4	F	Tree Y position
8	F	Tree Z position
12	W	Valid Tree Flag (-1,0,1 = Invalid/not checked/validated)
14,15   not used

16 bytes per tree
see *Map word 31,33

*********************************************************
Map memory spec:

byte	type	data
0	B	Max world factor (1-10 only) 10 is the default
1	W	render map size.
3	B	fog on/off
4	W	fog range
6	DW	fog color
10	w	Camera Range
12	DW	Light Color
16	w	Texture size in pixcels
18	B	Tileset (on load)/ Update flag
19	w	number of tiles accrossed render map
21	W	tile size in real world units
23	w	TMax(1)	max tiles in entire world
25	W	DY(1) memory offset per change in Z
27	F	mmax#(1) maximum real world position
31	Dw	dTree(1) memory offset per z position
35	W	Active critter used by player
37	B	Critter change flag
38	B	Mission Objective Flag 1
39 .......
49	B	Mission Object Flag 11
...................
start of actual map data
50	F	tile virtex height
54	B	Tile Texture
55	F	Tile Virtex Normal X
59	F	Tile Vittex Normal Y
63	F	Tile Virtex Normal Z
64	B	not used
....................
18 bytes of data per grid X
DY(1) bytes offset per grid Z ... memory word 25

***********************************************************
creature memory map

byte	type	data
0	f	actual X position
4	f	Y
8	f	z
*12	f	offset x, on load object offset before rendering
*12	w	ID of creature image for display (after loading)
*14	w	Active Tool used by creature (after loading)
*16	f	offset Y, on load
*16	B	Tool Change Flag
*17	B	Creature is carried by another when set
*18	W	creature carriing this creature
*20	f	offset z on load
*20	W	bonus object #1
*22	W	Bonus Object #2
24	f	rotx ... on load, default orientation, after load, heading
28	f	y
32	f	z
36	w	player ID of controlling player
38	w	camera offset y ... for third person viewing
40	w	camera offset range ... for third person viewing
42	w	object ID. Used to identify rendered object to direct x
44	w	animation mode (object state)
46,48	w	idle animation start/stop
50,52	w	walk
54,56	w	attack
58,60	w	hit
62,64	w	die
66,68	w	swim
70,72	w	dig
74,76	w	fly
...............................................
78	F	Health expressed as a pecentage
82	F	Stamina as a percentage
86	F	HRegen ... actual value added to health each turn
90	f	swim speed in real world units per turn
94	F	ground speed
98	f	fly speed
102	f	dig
106	f	accerate maximum rate of speed change
110	f	loss to health to use range attack
114	f	loss to health to use melee attack
118	f	loss to health to carry this item
122	f	loss to health when moving
................................................
126	f	damage inflicted during standard melee attack
130	f	damage inflicted during range attack
134	f	speed of projectile used in range attack (0=instint)
138	f	max range to hit with melee weapon
142	f	max range to hit with ranged weapon
146	f	area effect (explosion) of ranged weapon
150	f	delay between attacks with melee weapon
154	f	delay between attacks with ranged weapon
158	f	proximity of ranged weapon to target to hit
162	B	creature collision type(0,1,2,3=none,box,cylinder,sphere)
163	f	collision width or radious (for cylinder or sphere)
167	f	collision height ... not used for spheres
171	f	collision depth ... not used for cylinder or sphere
...................................................
175	w	idle sound effect ID
177	w	walk
179	w	attack
181	w	hit
183	w	die
185	w	swim
187	w	dig
189	w	fly
191	B	Play/Loop animation and sounds flag
192	w	idle sound syncronize with animation frame, first value
194	w	walk
196	w	attack
198	w	hit
200	w	die
202	w	swim
204	w	dig
206	w	fly
208	w	idle sound syncronize with animation frame, second value
210	w	walk
212	w	attack
214	w	hit
216	w	die
218	w	swim
220	w	dig
222	w	fly
.........................................................
224	W	data to identify this object to script
226	W	ID of script to be called
.........................................................
228	W	first item in inventory
230 .....
242	W	last item in inventory
..........................................................
244	B	Turn direction flag, used for internal AI
		(0,1,2,3) for (no collision,left,right,resume)
245	F	move destination X position
249	F	Y
253	F	Z
257	W	final facing ... angle Y
259	F	Alternate destination 1 X position
263	F	Y
267	F	Z
271	F	Alternate destination 2 X position
275	F	Y
279	F	Z
283	W	steps taken for destination 1
285	W	steps taken for destination 2
287	F	alternate destination 3 X position
291	F	Y
295	F	Z

300 bytes per creature in object list
 .......................................................
script memory map
0	W	offset to creature calling script (obj#1)
2	W	offset to object hit (obj#2)
4	W	mousebutton state
6	W	keyboard command state
8	W	multiple contact test loop status
10	F	prev X location
14	F	Y
18	F	Z
22	F	scripted new X location
26	F	Y
30	F	Z
34	F	scripted new headying
38	B	moved blocked by object #2
39	B	animation changed for object #2
40	B	new animation state for object #2
41	B	object #1 moved using script
42	B	Activate Script debugging (outputs script data to screen)
43	W	first output byte
45	W	last output byte
47	B	animation changed for object #1
48	B	new animation state for object #1
49	B	ghost object #1 (0,1,2,3=NC,off,yes,dark)
50	B	ghost object #2
51	B	Special effect flag (enables all effects)
52	B	Invisible flag #1
53	B	invisible flag.#2 set to 1 to hide,2 to show
54	B	point#2 at camera flag (0,1,2,3) 1 face cam,2 face away,3 Y angle only
55	B	Script Owner Flag 0= Obj1, 1=Obj2
56	B	Scroll texture flag (1 for obj 1, 2 for obj 2)
57	F	texture scroll x
61	F	texture scroll y
65	B	point #1 at camera

.........................
100	start user defined data 
999	last available byte