file_id.diz
::::::::
Enforce0.2/Scripting/Script.txt
::::::::
//=================================================================
// MESSAGE FILES
//=================================================================
msgfile("text/enforce.msg" ,lang)
//=================================================================
// PROGRAMS
//=================================================================
//-----------------------------------------------------------------
// PROTOTYPES FOR ENGINE API
//-----------------------------------------------------------------
proto void Print(void var)
proto void Println(void var)
proto void PlayMap(string name)
proto void PlayAnim(string name)
// proto void ShowPicture(string name)
// proto void PlayMusic(string name)
// proto void StopMusic()
// proto void PlayTrack(int num)
// proto void Say(string text)
proto int Rand()
// Light functions
proto void ChangeLight(int num,int intens)
//proto int AddDynamicLight(vector origin,int intens,int delay)
// Sound functions
proto void InitSounds(int ambients)
proto void SetAmbient(string name,int idx)
proto void AddSound(string name,int pri,int flags,thing source)
//cache object
proto void CacheObject(string name)
//things
proto vector GetOrigin(thing th)
proto void SetOrigin(thing th,vector orig)
proto vector GetVelocity(thing th)
proto void SetVelocity(thing th,vector vel)
proto void SetFlags(thing th,int flag)
proto void ClearFlags(thing th,int flag)
proto int GetFlags(thing th)
proto int CallTargetClients(thing th,thing actor)
proto int AddTriggerInsider(thing th,thing actor)
//tobject
proto void SetFrameGroup(thing th,int n)
//AI
proto void Walk(thing th)
proto void WalkTo(thing th,vector final)
//-----------------------------------------------------------------
// Internal things
//-----------------------------------------------------------------
class door
constant tkind KIND_FUNC
begin void Exception()
eventmask(%0000000010110000010)
door_i()
end
end
//-----------------------------------------------------------------
class secretdoor
constant tkind KIND_FUNC
begin void Exception()
eventmask(%0000000000110000010)
// secretdoor_i()
end
end
//-----------------------------------------------------------------
class lift
constant tkind KIND_FUNC
begin void Exception()
eventmask(%0000000010111000000)
lift_i()
end
end
//-----------------------------------------------------------------
class button
constant tkind KIND_FUNC
begin void Exception()
eventmask(%0000000010010000010)
button_i()
end
end
//-----------------------------------------------------------------
class portalsource
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
//call all things connected to this portal
CallTargetClients(this,other)
end
end
//-----------------------------------------------------------------
class portaldest
constant tkind KIND_NULL
begin void Exception()
eventmask(%0000000000100000000)
//someone was sent thru portal
GetOrigin(this)
SetOrigin(other,GetOrigin)
AddSound("sound/r_tele4.wav",20,SF_ONCE,this)
end
end
//-----------------------------------------------------------------
class waypoint
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
// waypoint_i()
end
end
//-----------------------------------------------------------------
class wall
constant tkind KIND_FUNC
begin void Exception()
eventmask(%0000000000110000010)
// wall_i()
end
end
//-----------------------------------------------------------------
class switch1
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
if event & EV_TOUCH
AddTriggerInsider(this,other)
if AddTriggerInsider = TRUE
AddSound("sound/switch02.wav",10,SF_ONCE,this);
endif
ClearFlags(this,TFL_ACTIVE)
endif
end
end
//-----------------------------------------------------------------
class switch2
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
if event & EV_TOUCH
AddTriggerInsider(this,other)
if AddTriggerInsider = TRUE
AddSound("sound/switch02.wav",10,SF_ONCE,this);
endif
endif
end
end
//-----------------------------------------------------------------
class secret
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
// secret_i()
end
end
//-----------------------------------------------------------------
class changemap
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
// changemap_i()
end
end
//-----------------------------------------------------------------
class wind
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
// wind_i()
end
end
//-----------------------------------------------------------------
class earthquake
constant tkind KIND_TRIGGER
begin void Exception()
eventmask(%0000000000001000010)
// earthquake_i()
end
end
//-----------------------------------------------------------------
class light
constant tkind KIND_NULL
begin void Exception()
eventmask(%0000000000100000000)
light_i()
end
end
//-----------------------------------------------------------------
class world
constant tkind KIND_WORLD
begin void Exception()
eventmask(%0000000000000000000)
end
end
//-----------------------------------------------------------------
class player
//accept all events
constant tkind KIND_ACTOR
object("obj/player.obj")
framegrp(1)
frame("Wait_1" ,80 ,0)
frame("Wait_2" ,80 ,0)
framegrp(2)
frame("Wait_2" ,100 ,0)
frame("Wait_2" ,30 ,0)
frame("Wait_3" ,30 ,0)
frame("Wait_4" ,30 ,0)
frame("Wait_5" ,100 ,0)
frame("Wait_5" ,30 ,0)
frame("Wait_4" ,30 ,0)
frame("Wait_3" ,30 ,0)
frame("Wait_1" ,30 ,0)
framegrp(3)
frame("Walk_1" ,50 ,0)
frame("Walk_2" ,50 ,0)
frame("Walk_3" ,50 ,0)
frame("Walk_4" ,50 ,0)
frame("Walk_5" ,50 ,0)
frame("Walk_6" ,50 ,0)
frame("Walk_7" ,50 ,0)
frame("Walk_8" ,50 ,0)
begin void Exception()
if event & EV_KEY
AddSound("sound/sgun1.wav",20,SF_ONCE,this);
return
endif
// if event & EV_
// player_i()
end
end
//-----------------------------------------------------------------
class monst_civil
constant tkind KIND_PERSON
object("obj/civil.obj")
framegrp(1)
frame("Wait_1" ,80 ,0)
frame("Wait_2" ,80 ,0)
framegrp(2)
frame("Wait_2" ,100 ,0)
frame("Wait_2" ,30 ,0)
frame("Wait_3" ,30 ,0)
frame("Wait_4" ,30 ,0)
frame("Wait_5" ,100 ,0)
frame("Wait_5" ,30 ,0)
frame("Wait_4" ,30 ,0)
frame("Wait_3" ,30 ,0)
frame("Wait_1" ,30 ,0)
framegrp(3)
frame("Walk_1" ,50 ,0)
frame("Walk_2" ,50 ,0)
frame("Walk_3" ,50 ,0)
frame("Walk_4" ,50 ,0)
frame("Walk_5" ,50 ,0)
frame("Walk_6" ,50 ,0)
frame("Walk_7" ,50 ,0)
frame("Walk_8" ,50 ,0)
begin void Exception()
// civil_i()
end
end
//-----------------------------------------------------------------
//global variables for light anims
declare int Time10
declare int Light10
declare int Inc02
declare int Light02
//-----------------------------------------------------------------
begin void newframe()
declare int light
declare int rnd
declare int inc
//anim lights
Rand()
let rnd = Rand & 255
//style 10
let Time10 = Time10 - time
if Time10 < 0
if rnd > 127
let Light10 = 255 - Light10
ChangeLight(10,Light10)
endif
let Time10 = 15
endif
//style 1
let light = rnd & 63
let light = light + 192
if light < 200
let light = 200
endif
ChangeLight(1,light)
//style 2 & 5
let inc = Inc02 * time
let Light02 = Light02 + inc
if Light02 < 0
let Light02 = 0
let Inc02 = 0 - Inc02
endif
if Light02 > 255
let Light02 = 255
let Inc02 = 0 - Inc02
endif
ChangeLight(2,Light02)
ChangeLight(5,Light02)
newframe_i()
end
//-----------------------------------------------------------------
begin void postframe()
postframe_i()
end
//-----------------------------------------------------------------
begin void initmap()
initmap_i()
end
//-----------------------------------------------------------------
begin int Pokus(int parm1 ,int parm2)
declare int ret
let ret = parm1 + parm2
return(ret)
end
//-----------------------------------------------------------------
begin string Test(string name)
PlayMap(name)
return(name)
end
//-----------------------------------------------------------------
class Trida
declare int member1
//constructor
begin void Trida()
let member1 = 666
end
//destructor
begin void ~Trida()
let member1 = 0
Println("Ooooh no, I'm dead :-(")
end
begin int pfunc()
Println(member1)
end
end
//-----------------------------------------------------------------
class Map
declare string path
begin void Map()
let path = ""
end
begin void ~Map()
end
begin void Play(string map)
declare string name
Println(path)
Println(map)
let name = path + map
Println(name)
PlayMap(name)
end
end
//-----------------------------------------------------------------
// Main function
//-----------------------------------------------------------------
begin void main()
declare string mpath
declare string map
declare string apath
declare string anim
declare string pokus
declare string star
declare int res
declare int p1
declare int p2
declare float p3
declare vector v
declare Trida obj
declare Map test
let v = "1 1 1"
// init light anims
let Time10 = 0
let Light10 = 0
let Inc02 = 4
let Light02 = 0
// init paths
let mpath = "maps/"
let apath = "anims/"
CacheObject("sound/pain1.wav")
InitSounds(2)
// First map
SetAmbient("sound/wind2.wav",1)
SetAmbient("sound/comp1.wav",0)
let map = mpath + "pokus.map"
PlayMap(map)
let map = mpath + "base.map"
PlayMap(map)
return
let test = new Map
let test.path = "maps/"
InitSounds(2)
// First map
SetAmbient("sound/wind2.wav",1)
SetAmbient("sound/comp1.wav",0)
test.Play("pokus.map")
delete test
let obj = new Trida
obj.pfunc()
Println(obj.member1)
let obj.member1 = 0
obj.pfunc()
delete obj
return
let p1 = 2
let p2 = 3
Pokus(p1 ,p2)
let p1 = Pokus
Println(p1)
let p1 = 1
let star = "*"
tag loop
if p1 = 10
goto out
endif
Println(star)
let star = star + "*"
let p1 = p1 + 1
goto loop
tag out
end
//-----------------------------------------------------------------