-- -------------------------------------------------------------------------------- -- FILE: ice_trail_spawner_work_of_ice_art.lua -- DESCRIPTION: used to spawn ice trail references and also spawn ice prison of -- work of ice art -- AUTHOR: Benny Yang (), -- CREATED: 2011/3/10 -------------------------------------------------------------------------------- -- -- require "lua/entity.lua" require "lua/utilities.lua" curTime = 0 time_to_spawn_icetrail = 0 -- Spwan Frequency IceTrail_SpawnFreq = 0.02 -- Spwan number IceTrail_SpawnNumber = 1 -- Ice trail initialize scale IceTrail_InitScaleX = 0.25 * 3 IceTrail_InitScaleY = 0.2 * 3 IceTrail_InitScaleZ = 0.25 * 3 IceTrail_SpawnRandomOffset = 0.2 ------------------------------------------------------------------------ -- FUNCTIONS ------------------------------------------------------------------------ function SummonIcePrison ( ) -- get position x, y, z = position() -- get landing position, give z some offset to find landing position more precisely lx, ly, lz = landingPos(x, y, z+10) ice_prison = spawnInstFromGlobalMF("Yeti_Ice_Prison_Work_Of_Ice_Art_Instance", lx, ly, lz, 0.1, 0.1, 0.1) -- random facing local ranAng = math.random(0,359) ice_prison.rotation(nil,nil, ranAng) return end ---------- end of function SummonIcePrison ---------- function updateIceTrail ( dt ) -- check if time up to spawn new ice trail reference yet if time_to_spawn_icetrail > 0 then time_to_spawn_icetrail = time_to_spawn_icetrail - dt return end -- get position x, y, z = position() -- get landing position, give z some offset to find landing position more precisely lx, ly, lz = landingPos(x, y, z+10) local randomXOffset = ( math.random() - 0.5 )* IceTrail_SpawnRandomOffset local randomYOffset = ( math.random() - 0.5 )* IceTrail_SpawnRandomOffset -- spawn ice trails for count = 1, IceTrail_SpawnNumber do local ice_trail_ref = spawnInstFromGlobalMF("Yeti_Ice_Trail_Instance", lx+randomXOffset, ly + randomYOffset, lz, IceTrail_InitScaleX, IceTrail_InitScaleY, IceTrail_InitScaleZ) -- random facing local ranAng = math.random(0,359) ice_trail_ref.rotation(nil,nil, ranAng) ice_trail_ref.setAlpha(0) end -- reset time to spawn time_to_spawn_icetrail = IceTrail_SpawnFreq return end ---------- end of function updateIceTrail ---------- function shutdown ( ) -- delete self if delete then delete() end return end ---------- end of function shutdown ---------- function checkEvents ( ) if trigger.received() then if trigger.received(1,"EXIT_PROJECTILE_CONTROL_STATE") then trigger.send(1, "ProjectileSoundOff") SummonIcePrison() return false end end return true end ---------- end of function checkEvents ---------- ------------------------------------------------------------------------ -- MAIN LOOP ------------------------------------------------------------------------ while tick() do curTime = curTime + dt -- check events if checkEvents() == false then break; end -- update ice trail updateIceTrail(dt) end ------------------------------------------------------------------------ -- SHUT DOWN SECTION ------------------------------------------------------------------------ shutdown()