Example script: a Tunarian scout - when you approach, this scout "crouches" til you go out of range.
Code: Select all
--[[
Script Name : SpawnScripts/OutpostOverlord/aTunarianscout1.lua
Script Purpose : When player enters 20m proximity, scout Crouches
Script Author : John Adams
Script Date : 2009.01.08
Script Notes : JA: may need to adjust range
--]]
function spawn(NPC)
SetPlayerProximityFunction(NPC, 30, "InRange", "LeaveRange")
end
function respawn(NPC)
spawn(NPC)
end
function InRange(NPC, Player)
FaceTarget(NPC, Player)
DuckSpawn = GetSpawn(NPC, 2780067) -- Get Tunarian Scout
SpawnSet(DuckSpawn, "visual_state", "221") -- Start crouch_idle
end
function LeaveRange(NPC, Player)
DuckSpawn = GetSpawn(NPC, 2780067) -- Get Tunarian Scout
SpawnSet(DuckSpawn, "visual_state", "0") -- Stop crouch_idle
endBtw, we know that GetSpawn() should be done differently - these are old scripts that need to be re-addressed before release. Change the spawn ID to your spawn ID for testing, or fix the script.


