-- -- LUA Globals Common Header -- -- Constants AI_MANUAL = 0 AI_AUTOMATIC = 1 AI_CLOSEST_TO_PLAYER = 50 -- Globals (built-in) g_Entity = {} -- AI Globals ai_soldier_state = {} ai_soldier_pathindex = {} ai_combat_mode = {} ai_combat_state_delay = {} ai_combat_old_time = {} ai_combat_turn_delay = 1 ai_combat_cover_delay = 4 ai_combat_delay_after_finding = 2 ai_next_aggro_delay = 0 ai_start_x = {} ai_start_z = {} ai_dest_x = {} ai_dest_z = {} ai_old_health = {} ai_ran_to_cover = {} ai_alerted_mode = {} ai_alerted_state_delay = {} ai_alerted_old_time = {} ai_alerted_spoken = {} ai_returning_home = {} ai_alert_x = -10000 ai_alert_z = -10000 ai_alert_counter = 0 ai_alert_entity = 0 ai_path_point_index = {} ai_path_point_direction = {} ai_path_point_max = {} ai_starting_heath = {} ai_patrol_x = {} ai_patrol_z = {} ai_aggro_x = nil ai_aggro_z = nil ai_aggro_entity = nil ai_aggro_range = 400 PlayerDist = 0 -- Weapon name global weapon_name = {} -- Globals (passed-in) g_PlayerPosX = 0 g_PlayerPosY = 0 g_PlayerPosZ = 0 g_PlayerAngX = 0 g_PlayerAngY = 0 g_PlayerAngZ = 0 g_PlayerObjNo = 0 g_PlayerHealth = 0 g_Time = 0 g_KeyPressE = 0 -- Common Updater Functions (called by Engine) function UpdateEntitySMALL(e,object,x,y,z) g_Entity[e] = {x=x; y=y; z=z; obj=object;} end function UpdateEntity(e,object,x,y,z,act,col,key,zon,plrvis,ani,hea,frm,tmr,pdst,avd) g_Entity[e] = {x=x; y=y; z=z; activated=act; animating=ani; collected=col; haskey=key; plrinzone=zon; plrvisible=plrvis; obj=object; health=hea; frame=frm; timer=tmr; plrdist=pdst; avoid=avd; } end function UpdateEntityRT(e,object,x,y,z,col,key,zon,plrvis,hea,frm,tmr,pdst,avd) g_Entity[e]['x'] = x; g_Entity[e]['y'] = y; g_Entity[e]['z'] = z; g_Entity[e]['obj'] = object; g_Entity[e]['collected'] = col; g_Entity[e]['haskey'] = key; g_Entity[e]['plrinzone'] = zon; g_Entity[e]['plrvisible'] = plrvis; g_Entity[e]['health'] = hea; g_Entity[e]['frame'] = frm; g_Entity[e]['timer'] = tmr; g_Entity[e]['plrdist'] = pdst; g_Entity[e]['avoid'] = avd; end function UpdateEntityAnimatingFlag(e,ani) g_Entity[e]['animating'] = ani; end -- Macro Functions function GetPlayerDistance(e) tPlayerDX = (g_Entity[e]['x'] - g_PlayerPosX) tPlayerDY = (g_Entity[e]['y'] - g_PlayerPosY) tPlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ) if math.abs(tPlayerDY) > 100 then tPlayerDY = tPlayerDY * 4 end return math.sqrt(math.abs(tPlayerDX*tPlayerDX)+math.abs(tPlayerDY*tPlayerDY)+math.abs(tPlayerDZ*tPlayerDZ)); end -- Common Action Functions (called by LUA) function Prompt(str) SendMessageS("prompt",str); end function PromptDuration(str,v) SendMessageS("promptduration",v,str); end function SetFogNearest(v) SendMessageF("setfognearest",v) end function SetFogDistance(v) SendMessageF("setfogdistance",v) end function SetFogRed(v) SendMessageF("setfogred",v) end function SetFogGreen(v) SendMessageF("setfoggreen",v) end function SetFogBlue(v) SendMessageF("setfogblue",v) end function SetAmbienceIntensity(v) SendMessageF("setambienceintensity",v) end function SetAmbienceRed(v) SendMessageF("setambiencered",v) end function SetAmbienceGreen(v) SendMessageF("setambiencegreen",v) end function SetAmbienceBlue(v) SendMessageF("setambienceblue",v) end function SetSurfaceRed(v) SendMessageF("setsurfacered",v) end function SetSurfaceGreen(v) SendMessageF("setsurfacegreen",v) end function SetSurfaceBlue(v) SendMessageF("setsurfaceblue",v) end function HideTerrain() SendMessageF("hideterrain",0) end function ShowTerrain() SendMessageF("showterrain",0) end function HideWater() SendMessageF("hidewater",0) end function ShowWater() SendMessageF("showwater",0) end function SetPlayerHealth(v) SendMessageF("setplayerhealth",v) end function SetEntityHealth(e,v) SendMessageI("setentityhealth",e,v); end function StartParticleEmitter(e) SendMessageF("startparticleemitter",e,0); end function StopParticleEmitter(e) SendMessageF("stopparticleemitter",e,0); end function StartTimer(e) SendMessageI("starttimer",e); end function GetTimer(e) return g_Time - g_Entity[e]['timer']; end function Destroy(e) SendMessageI("destroy",e); end function CollisionOn(e) SendMessageI("collisionon",e); end function CollisionOff(e) SendMessageI("collisionoff",e); end function Hide(e) SendMessageI("hide",e); end function Show(e) SendMessageI("show",e); end function Spawn(e) SendMessageI("spawn",e); end function ActivateIfUsed(e) SendMessageI("activateifused",e); end function TransportToIfUsed(e) SendMessageI("transporttoifused",e); end function Collected(e) SendMessageI("collected",e); end function MoveUp(e,v) SendMessageF("moveup",e,v); end function MoveForward(e,v) SendMessageF("moveforward",e,v); end function MoveBackward(e,v) SendMessageF("movebackward",e,v); end function SetPosition(e,x,y,z) SendMessageF("setpositionx",e,x); SendMessageF("setpositiony",e,y); SendMessageF("setpositionz",e,z); end function ResetPosition(e,x,y,z) SendMessageF("resetpositionx",e,x); SendMessageF("resetpositiony",e,y); SendMessageF("resetpositionz",e,z); end function SetRotation(e,x,y,z) SendMessageF("setrotationx",e,x); SendMessageF("setrotationy",e,y); SendMessageF("setrotationz",e,z); end function ModulateSpeed(e,v) SendMessageF("modulatespeed",e,v); end function RotateX(e,v) SendMessageF("rotatex",e,v); end function RotateY(e,v) SendMessageF("rotatey",e,v); end function RotateZ(e,v) SendMessageF("rotatez",e,v); end function Scale(e,v) SendMessageF("scale",e,v); end function SetAnimation(e) SendMessageI("setanimation",e); end function SetAnimationFrames(e,v) SendMessageI("setanimationframes",e,v); end function PlayAnimation(e) SendMessageI("playanimation",e); end function LoopAnimation(e) SendMessageI("loopanimation",e); end function StopAnimation(e) SendMessageI("stopanimation",e); end function SetAnimationSpeed(e,v) SendMessageI("setanimationspeed",e,v); end function SetAnimationFrame(e,v) SendMessageF("setanimationframe",e,v); end function GetAnimationFrame(e) return g_Entity[e]['frame']; end function CharacterControlUnarmed(e) SendMessageI("charactercontrolunarmed",e); end function CharacterControlLimbo(e) SendMessageI("charactercontrollimbo",e); end function CharacterControlArmed(e) SendMessageI("charactercontrolarmed",e); end function CharacterControlFidget(e) SendMessageI("charactercontrolfidget",e); end function CharacterControlDucked(e) SendMessageI("charactercontrolducked",e); end function CharacterControlStand(e) SendMessageI("charactercontrolstand",e); end function SetCharacterToWalk(e) SendMessageI("setcharactertowalkrun",e,0); end function SetCharacterToRun(e) SendMessageI("setcharactertowalkrun",e,1); end function SetCharacterToStrafeLeft(e) SendMessageI("setcharactertostrafe",e,0); end function SetCharacterToStrafeRight(e) SendMessageI("setcharactertostrafe",e,1); end function SetCharacterVisionDelay(e,v) SendMessageI("setcharactervisiondelay",e,v); end function LockCharacterPosition(e,v) SendMessageI("setlockcharacter",e,1); end function UnlockCharacterPosition(e,v) SendMessageI("setlockcharacter",e,0); end function GravityOff(e) SendMessageI("setnogravity",e,1); end function GravityOn(e) SendMessageI("setnogravity",e,0); end function LookAtPlayer(e) SendMessageI("lookatplayer",e); end function RotateToPlayer(e) SendMessageI("rotatetoplayer",e,100); end function RotateToPlayerSlowly(e,v) SendMessageI("rotatetoplayer",e,v); end function AddPlayerWeapon(e) SendMessageI("addplayerweapon",e); end function AddPlayerAmmo(e) SendMessageI("addplayerammo",e); end function AddPlayerHealth(e) SendMessageI("addplayerhealth",e); end function AddPlayerJetPack(e,fuel) SendMessageI("addplayerjetpack",e,fuel); end function Checkpoint(e) SendMessageI("checkpoint",e); end function GetPlayerInZone(e) return g_Entity[e]['plrinzone']; end function PlaySound(e,v) SendMessageI("playsound",e,v); end function PlaySoundIfSilent(e,v) SendMessageI("playsoundifsilent",e,v); end function PlayNon3DSound(e,v) SendMessageI("playnon3dsound",e,v); end function LoopSound(e,v) SendMessageI("loopsound",e,v); end function StopSound(e,v) SendMessageI("stopsound",e,v); end function SetSoundSpeed(freq) SendMessageI("setsoundspeed",freq); end function SetSoundVolume(vol) SendMessageI("setsoundvolume",vol); end function FireWeapon(e) SendMessageI("fireweapon",e); end function HurtPlayer(e,v) SendMessageI("hurtplayer",e,v); end function SwitchScript(e,str) SendMessageS("switchscript",e,str); end function SetCharacterSound(e,str) SendMessageS("setcharactersound",e,str); end function PlayCharacterSound(e,str) SendMessageS("playcharactersound",e,str); end function FinishLevel() SendMessageI("finishlevel",0); end function PlayCombatMusic(playTime,fadeTime) music_play_timecue(2,playTime,fadeTime); end function PlayFinalAssaultMusic(fadeTime) music_play_cue(3,fadeTime); end