placing of traders into villages has been moved to mobf_trader
parent
f65a1281ea
commit
d199cb8ffd
3
init.lua
3
init.lua
|
@ -51,9 +51,6 @@ dofile(handle_schematics.modpath.."/build_chest_add_schems_from_file.lua");
|
|||
-- locate schematics through directories
|
||||
dofile(handle_schematics.modpath.."/build_chest_add_schems_by_directory.lua");
|
||||
|
||||
-- chooses traders and spawn positions for buildings
|
||||
dofile(handle_schematics.modpath.."/village_traders.lua")
|
||||
|
||||
-- the main functionality of the mod;
|
||||
-- provides the function handle_schematics.place_building_from_file
|
||||
-- (and also place_buildings for mg_villages)
|
||||
|
|
|
@ -319,21 +319,6 @@ local function generate_building(pos, minp, maxp, data, param2_data, a, extranod
|
|||
mg_villages.get_fruit_replacements( replacements, pos.fruit);
|
||||
end
|
||||
|
||||
local traders = {};
|
||||
if( handle_schematics.choose_traders ) then
|
||||
local village_type = "";
|
||||
if( village_id and mg_villages and mg_villages.all_villages and mg_villages.all_villages[ village_id ] ) then
|
||||
village_type = mg_villages.all_villages[ village_id ].village_type;
|
||||
end
|
||||
local building_type = "";
|
||||
if( binfo.typ ) then
|
||||
building_type = binfo.typ;
|
||||
end
|
||||
if( not( pos.traders )) then
|
||||
traders = handle_schematics.choose_traders( village_type, building_type, replacements )
|
||||
end
|
||||
end
|
||||
|
||||
local c_ignore = minetest.get_content_id("ignore")
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_snow = minetest.get_content_id( "default:snow");
|
||||
|
@ -553,13 +538,6 @@ local function generate_building(pos, minp, maxp, data, param2_data, a, extranod
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- determine suitable positions for the traders
|
||||
if( handle_schematics.choose_trader_pos and #traders>0) then
|
||||
extra_calls.traders = handle_schematics.choose_trader_pos(pos, minp, maxp, data, param2_data, a, extranodes, replacements, cid, extra_calls, building_nr_in_bpos, village_id, binfo_extra, road_node, traders);
|
||||
print('TRADERS CHOOSEN FOR '..tostring( binfo.scm )..': '..minetest.serialize( extra_calls.traders ));
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,146 +0,0 @@
|
|||
|
||||
|
||||
handle_schematics.choose_traders = function( village_type, building_type, replacements )
|
||||
|
||||
if( not( building_type ) or not( village_type )) then
|
||||
return;
|
||||
end
|
||||
|
||||
-- some jobs are obvious
|
||||
if( building_type == 'mill' ) then
|
||||
return { 'miller' };
|
||||
elseif( building_type == 'bakery' ) then
|
||||
return { 'baker' };
|
||||
elseif( building_type == 'school' ) then
|
||||
return { 'teacher' };
|
||||
elseif( building_type == 'forge' ) then
|
||||
local traders = {'blacksmith', 'bronzesmith' };
|
||||
return { traders[ math.random(#traders)] };
|
||||
elseif( building_type == 'shop' ) then
|
||||
local traders = {'seeds','flowers','misc','default','ore', 'fruit trader', 'wood'};
|
||||
return { traders[ math.random(#traders)] };
|
||||
-- there are no traders for these jobs - they'd require specialized mobs
|
||||
elseif( building_type == 'tower'
|
||||
or building_type == 'church'
|
||||
or building_type == 'secular'
|
||||
or building_type == 'tavern' ) then
|
||||
return {};
|
||||
end
|
||||
|
||||
if( village_type == 'charachoal' ) then
|
||||
return { 'charachoal' };
|
||||
elseif( village_type == 'claytrader' ) then
|
||||
return { 'clay' };
|
||||
end
|
||||
|
||||
local res = {};
|
||||
if( building_type == 'shed'
|
||||
or building_type == 'farm_tiny'
|
||||
or building_type == 'house'
|
||||
or building_type == 'house_large'
|
||||
or building_type=='hut') then
|
||||
local traders = { 'stonemason', 'stoneminer', 'carpenter', 'toolmaker',
|
||||
'doormaker', 'furnituremaker', 'stairmaker', 'cooper', 'wheelwright',
|
||||
'saddler', 'roofer', 'iceman', 'potterer', 'bricklayer', 'dyemaker',
|
||||
'dyemakerl', 'glassmaker' }
|
||||
-- sheds and farms both contain craftmen
|
||||
res = { traders[ math.random( #traders )] };
|
||||
if( building_type == 'shed'
|
||||
or building_type == 'house'
|
||||
or building_type == 'house_large'
|
||||
or building_type == 'hut' ) then
|
||||
return res;
|
||||
end
|
||||
end
|
||||
|
||||
if( building_type == 'field'
|
||||
or building_type == 'farm_full'
|
||||
or building_type == 'farm_tiny' ) then
|
||||
|
||||
local fruit = 'farming:cotton';
|
||||
if( 'farm_full' ) then
|
||||
-- RealTest
|
||||
fruit = 'farming:wheat';
|
||||
if( replacements_group['farming'].traders[ 'farming:soy']) then
|
||||
fruit_item = 'farming:soy';
|
||||
end
|
||||
if( minetest.get_modpath("mobf") ) then
|
||||
local animal_trader = {'animal_cow', 'animal_sheep', 'animal_chicken', 'animal_exotic'};
|
||||
res[1] = animal_trader[ math.random( #animal_trader )];
|
||||
end
|
||||
return { res[1], replacements_group['farming'].traders[ fruit_item ]};
|
||||
elseif( #replacements_group['farming'].found > 0 ) then
|
||||
-- get a random fruit to grow
|
||||
fruit = replacements_group['farming'].found[ math.random( #replacements_group['farming'].found) ];
|
||||
return { res[1], replacements_group['farming'].traders[ fruit_item ]};
|
||||
else
|
||||
return res;
|
||||
end
|
||||
end
|
||||
|
||||
if( building_type == 'pasture' and minetest.get_modpath("mobf")) then
|
||||
local animal_trader = {'animal_cow', 'animal_sheep', 'animal_chicken', 'animal_exotic'};
|
||||
return { animal_trader[ math.random( #animal_trader )] };
|
||||
end
|
||||
|
||||
|
||||
-- TODO: banana,cocoa,rubber from farming_plus?
|
||||
-- TODO: sawmill
|
||||
if( building_type == 'lumberjack' or village_type == 'lumberjack' ) then
|
||||
-- TODO: limit this to single houses
|
||||
if( replacements.table and replacements.table[ 'default:wood' ] ) then
|
||||
return { replacements_group['wood'].traders[ replacements.table[ 'default:wood' ]] };
|
||||
elseif( #replacements_group['wood'].traders > 0 ) then
|
||||
return { replacements_group['wood'].traders[ math.random( #replacements_group['wood'].traders) ]};
|
||||
else
|
||||
return { 'common_wood'};
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- tent, chateau: places for living at; no special jobs associated
|
||||
-- nore,taoki,medieval,lumberjack,logcabin,canadian,grasshut,tent: further village types
|
||||
|
||||
return res;
|
||||
end
|
||||
|
||||
|
||||
handle_schematics.choose_trader_pos = function(pos, minp, maxp, data, param2_data, a, extranodes, replacements, cid, extra_calls, building_nr_in_bpos, village_id, binfo_extra, road_node, traders)
|
||||
|
||||
local trader_pos = {};
|
||||
-- determine spawn positions for the mobs
|
||||
for i,tr in ipairs( traders ) do
|
||||
local tries = 0;
|
||||
local found = false;
|
||||
local pt = {x=pos.x, y=pos.y, z=pos.z};
|
||||
while( tries < 10 and not(found)) do
|
||||
-- get a random position for the trader
|
||||
pt.x = pos.x+math.random(pos.bsizex);
|
||||
pt.z = pos.z+math.random(pos.bsizez);
|
||||
-- check if it is inside the area contained in data
|
||||
if (pt.x >= minp.x and pt.x <= maxp.x) and (pt.y >= minp.y and pt.y <= maxp.y) and (pt.z >= minp.z and pt.z <= maxp.z) then
|
||||
|
||||
while( pt.y < maxp.y
|
||||
and (data[ a:index( pt.x, pt.y, pt.z)]~=cid.c_air
|
||||
or data[ a:index( pt.x, pt.y+1, pt.z)]~=cid.c_air )) do
|
||||
pt.y = pt.y + 1;
|
||||
end
|
||||
|
||||
-- TODO: check if this position is really suitable? traders standing on the roof are a bit odd
|
||||
found = true;
|
||||
end
|
||||
tries = tries+1;
|
||||
|
||||
-- check if this position has already been assigned to another trader
|
||||
for j,t in ipairs( trader_pos ) do
|
||||
if( t.x==pt.x and t.y==pt.y and t.z==pt.z ) then
|
||||
found = false;
|
||||
end
|
||||
end
|
||||
end
|
||||
if( found ) then
|
||||
table.insert( trader_pos, {x=pt.x, y=pt.y, z=pt.z, typ=tr, bpos_i = building_nr_in_bpos} );
|
||||
end
|
||||
end
|
||||
return trader_pos;
|
||||
end
|
Loading…
Reference in New Issue