All pastes #470924 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-04 16:32 UTC
rendered paste body
local logf_console = nil

function logf( fmt, ... )
	logf_console = get_console()
	logf = logf_main
	logf_main( fmt, ... )
end

function logf_main( fmt, ... )
    local c = select( "#", ... )
    if c <= 0 then -- nothing to format
        logf_console:execute( ":" .. string.gsub( fmt, " ", "\160" ) )
    else
        logf_console:execute( ":" .. string.gsub( string.format( fmt, ... ), " ", "\160" ) )
    end
end

local basic_time_factor

function time_shift_start (hour)
    logf("time_shift_start() called")
	basic_time_factor = level.get_time_factor ()

    logf ("Need time : %d:00:00", hour )

    local c_time = level.get_time_hours()
    local n_time = hour
	
    if c_time > n_time then n_time = n_time + 24 end
		
	logf("c_time: %d, n_time: %d", c_time, n_time )	
	
	local time_diff = ( ( n_time - c_time ) )
	local factor = time_diff * (2650*0.25)
	
	logf( "time_diff: %d, factor: %d", time_diff, factor )
	
	game.start_tutorial("time_scaling")
    level.set_time_factor (factor)
    
	logf("time_shift_start() completed")
end

function time_shift_stop()

	level.set_time_factor (basic_time_factor)
	logf("new time: %d", level.get_time_hours() )
	
	spawn_tushkano()
	
end


local bloodsucker_types = {"tushkano_weak", "tushkano_normal", "tushkano_strong"}

function spawn_tushkano( position, total )

	--' Spawn a bunch of tushkano
	local tushkano_index
	local new_pos, x_offset, z_offset	
	logf("start adding tushkano")
	for tushkano_index=1, total do

		x_offset = math.random(40)-20
		z_offset = math.random(40)-20
		if( x_offset < 2 and x_offset > -2 ) then
			x_offset = -2
		end
		if( z_offset < 2 and z_offset > -2 ) then
			z_offset = -2
		end

		--' Relative to the player position
		new_pos = position
		new_pos.x = new_pos.x + x_offset
		new_pos.z = new_pos.z + z_offset
		new_pos.y = new_pos.y + 10

		alife():create(tushkano_types[math.random(3)], 
						new_pos,
						db.actor:level_vertex_id() ,	
						db.actor:game_vertex_id() )
		logf("tushkano created")
	end

end

function tell_story( actor, npc )

	logf("tell_story() called")
		
	--'level.add_pp_effector ("vibros.ppe", 234, false)					
	--'time_shift_start( 24 )
	
	--' Spawn 20 tushkano at a specific location
	--' local spawn_point = db.actor:position()	
	local spawn_point = vector():set( -169, -18, -130 )
	spawn_tushkano( spawn_point, 20 )
	
	logf("tell_story() completed")
	
end