All pastes #495636 Raw Edit

Chao7

public text v1 · immutable
·published 2007-05-18 21:26 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, ... )
    if fmt == nil then return end

    local c = select( "#", ... )

    if c <= 0 then
        printf_console:execute( ":" .. string.gsub( fmt, " ", "\160" ) )
    else
        printf_console:execute( ":" .. string.gsub( string.format( fmt, ... ), " ", "\160" ) )
    end
end


function spawn_bar_dolg_respawn_3( position, total, level_vertex, game_vertex )
    local index
    local new_pos, x_offset, z_offset

    local area_longitude, area_latitude = total*10, total*10
    local height = 10

    local bob = nil -- reserve bob the recurring newly spawned holder's place outside the loop

    logf("start adding dutyers")
    for index = 1, total do -- spawns dutyers numbering from index to total (1...total)
        x_offset = math.random(-(area_longitude/2),(area_longitude/2))
        z_offset = math.random(-(area_latitude/2),(area_latitude/2))

        new_pos = vector():set(
            position.x + x_offset,
            position.y + height,
            position.z + z_offset
        )
        bob = alife():create("bar_dolg_respawn_3", 
            new_pos,
            level_vertex,
            game_vertex
        )
        logf( "dutyer #%i ( %s, %s, %s ) created", index, bob.name, bob.character_name, bob.profile_name )
    end
end

function spawn_dolg( actor, npc )
    logf("spawn_dolg() called")
    local spawn_point = 
    -- the player (db.actor) may not be on the same level_vertex & game_vertex, that could cause a problem
    spawn_bar_dolg_respawn_3( 
        vector():set( 2, 8, 129 ), -- 3d location on some level
        2, -- number to spawn
        db.actor:level_vertex_id(), -- if you're trying to spawn something on a different level than the player
        db.actor:game_vertex_id() -- you may have to find out what these actually need to be in numeric form
    )
    logf("spawn_dolg() completed")
end