2013年10月3日 星期四

Spawner Trigger Edit And 3D Sound Testing

As title, all trigger Integrate LUA Script and LUABind.
It shows the behavior Stroll and Shy.
This demo also tested 3d sound.
There is demo video:





My LUA Script is Here:

=============================================================================
General AI:


math.randomseed(os.time())

function Stroll_Enter(Brain, FromStateName)
Brain:ResetReponseIntervalTime(2.0)
end

function Stroll_Update(Brain, fDeltaTime)
if Brain:IsReponse() and (Brain:IsProcessPath() == false) then
local iRandomValue = math.random(7)
if iRandomValue <= 2 then
local pSelfTransform = Brain:GetSelfTransform()
local DestPosition = pSelfTransform:GetPosition()
local Movement = CVector3()
Movement:ReadFormAngle(math.random()*360.0, 0.0)
Movement = Movement*20.0
DestPosition = DestPosition+Movement
Brain:MoveToTargetPosition(DestPosition, true)
end
end
end

function Stroll_Exit(Brain)
end
=============================================================================
Shy AI:

math.randomseed(os.time())

function Stroll_Enter(Brain, FromStateName)
Brain:ResetReponseIntervalTime(2.0)
end

function Stroll_Update(Brain, fDeltaTime)
if Brain:IsReponse() and (Brain:IsProcessPath() == false) then
local iRandomValue = 2
local EnemyInfo = CEnemyInformation()
local Movement = CVector3()
local fMoveDistance = 20.0
local SelfPosition = Brain:GetSelfTransform():GetPosition()
if Brain:FindEnemy(50.0, CBrainProcessorManager.ENEMY_GROUP_TYPE_PLAYER, EnemyInfo) then
Movement = SelfPosition-Brain:GetTransformByID(EnemyInfo.m_iObjectID):GetPosition()
Movement:Normalize()
Brain:ResetReponseIntervalTime(0.5)
fMoveDistance = 30.0
else
iRandomValue = math.random(7)
if iRandomValue <= 2 then
Movement:ReadFormAngle(math.random()*360.0, 0.0)
Brain:ResetReponseIntervalTime(2.0)
end
end
if iRandomValue <= 2 then
Movement = Movement*fMoveDistance
Brain:MoveToTargetPosition(SelfPosition+Movement, true)
end
end
end

function Stroll_Exit(Brain)
end
=============================================================================
Dream continues in...

沒有留言:

張貼留言