2017-09-06 04:47:03 +02:00
|
|
|
----------------------------------------------------
|
|
|
|
-- Test farmer occupation for Advanced NPC
|
|
|
|
-- By Zorman2000
|
|
|
|
----------------------------------------------------
|
|
|
|
-- This farmer implementation is still WIP. It is supposed to spawn
|
|
|
|
-- on buildings that have plots or there are fields nearby. Also, it
|
|
|
|
-- work on its crops during the morning, and sell some of them on the
|
|
|
|
-- afternoon.
|
|
|
|
|
2017-09-15 20:47:04 +02:00
|
|
|
local farming_plants = {
|
|
|
|
cotton = {
|
|
|
|
"farming:cotton_1",
|
|
|
|
"farming:cotton_2",
|
|
|
|
"farming:cotton_3",
|
|
|
|
"farming:cotton_4",
|
|
|
|
"farming:cotton_5",
|
|
|
|
"farming:cotton_6",
|
|
|
|
"farming:cotton_7",
|
|
|
|
"farming:cotton_8"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-06 04:47:03 +02:00
|
|
|
local farmer_def = {
|
|
|
|
dialogues = {},
|
|
|
|
textures = {},
|
2017-09-15 20:47:04 +02:00
|
|
|
building_types = {
|
|
|
|
"farm_tiny", "farm_full"
|
|
|
|
},
|
|
|
|
surrounding_building_types = {
|
|
|
|
{type="field", origin_building_types={"hut", "house", "lumberjack"}}
|
|
|
|
},
|
|
|
|
walkable_nodes = farming_plants.cotton,
|
2017-09-06 04:47:03 +02:00
|
|
|
initial_inventory = {},
|
2017-09-15 20:47:04 +02:00
|
|
|
schedules_entries = {
|
2017-09-06 04:47:03 +02:00
|
|
|
[7] = {
|
|
|
|
[1] =
|
|
|
|
{
|
|
|
|
task = npc.actions.cmd.WALK_TO_POS,
|
|
|
|
args = {
|
2017-09-15 20:47:04 +02:00
|
|
|
end_pos = npc.places.PLACE_TYPE.WORKPLACE.PRIMARY,
|
2017-09-06 04:47:03 +02:00
|
|
|
walkable = {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[2] =
|
|
|
|
{
|
|
|
|
check = true,
|
|
|
|
range = 2,
|
|
|
|
random_execution_times = true,
|
|
|
|
min_count = 10,
|
|
|
|
max_count = 12,
|
|
|
|
nodes = {"farming:cotton_3"},
|
2017-09-15 20:47:04 +02:00
|
|
|
walkable_nodes = farming_plants.cotton,
|
2017-09-06 04:47:03 +02:00
|
|
|
actions =
|
|
|
|
{
|
2017-09-15 20:47:04 +02:00
|
|
|
-- Actions for cotton - harvest and replant
|
2017-09-06 04:47:03 +02:00
|
|
|
["farming:cotton_3"] =
|
|
|
|
{
|
|
|
|
[1] =
|
|
|
|
{
|
2017-09-15 20:47:04 +02:00
|
|
|
task = npc.actions.cmd.WALK_TO_POS,
|
|
|
|
args = {
|
|
|
|
end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET,
|
|
|
|
walkable = farming_plants.cotton
|
|
|
|
}
|
2017-09-06 04:47:03 +02:00
|
|
|
},
|
|
|
|
[2] =
|
|
|
|
{
|
|
|
|
action = npc.actions.cmd.DIG,
|
2017-09-15 20:47:04 +02:00
|
|
|
args = {
|
|
|
|
bypass_protection = true
|
|
|
|
}
|
2017-09-06 04:47:03 +02:00
|
|
|
},
|
|
|
|
[3] =
|
2017-09-15 20:47:04 +02:00
|
|
|
{
|
|
|
|
action = npc.actions.cmd.STAND,
|
|
|
|
args = {}
|
|
|
|
},
|
|
|
|
[4] =
|
2017-09-06 04:47:03 +02:00
|
|
|
{
|
|
|
|
action = npc.actions.cmd.PLACE,
|
|
|
|
args =
|
|
|
|
{
|
2017-09-15 20:47:04 +02:00
|
|
|
node = "farming:cotton_1",
|
|
|
|
bypass_protection = true
|
2017-09-06 04:47:03 +02:00
|
|
|
}
|
2017-09-15 20:47:04 +02:00
|
|
|
},
|
|
|
|
[5] =
|
|
|
|
{
|
|
|
|
action = npc.actions.cmd.STAND,
|
|
|
|
args = {}
|
2017-09-06 04:47:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2017-09-09 16:32:24 +02:00
|
|
|
[3] =
|
|
|
|
{
|
|
|
|
check = true,
|
|
|
|
range = 3,
|
|
|
|
random_execution_times = true,
|
|
|
|
min_count = 8,
|
|
|
|
max_count = 8,
|
|
|
|
nodes = {"farming:wheat_8"},
|
|
|
|
actions =
|
|
|
|
{
|
|
|
|
["farming:wheat_8"] =
|
|
|
|
{
|
|
|
|
[1] =
|
|
|
|
{
|
|
|
|
action = npc.actions.cmd.WALK_STEP,
|
|
|
|
},
|
|
|
|
[2] =
|
|
|
|
{
|
|
|
|
action = npc.actions.cmd.DIG,
|
|
|
|
},
|
|
|
|
[3] =
|
|
|
|
{
|
|
|
|
action = npc.actions.cmd.PLACE,
|
|
|
|
args =
|
|
|
|
{
|
|
|
|
node = "farming:wheat_1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-09-06 04:47:03 +02:00
|
|
|
none_actions =
|
|
|
|
{
|
|
|
|
-- Walk a single step in a random direction
|
|
|
|
[1] = {
|
|
|
|
action = npc.actions.cmd.WALK_STEP,
|
|
|
|
args =
|
|
|
|
{
|
2017-09-15 20:47:04 +02:00
|
|
|
dir = "random_orthogonal"
|
2017-09-06 04:47:03 +02:00
|
|
|
}
|
|
|
|
},
|
2017-09-15 20:47:04 +02:00
|
|
|
[2] = {
|
|
|
|
action = npc.actions.cmd.STAND,
|
|
|
|
args = {}
|
|
|
|
}
|
2017-09-06 04:47:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Register occupation
|
2017-09-09 16:32:24 +02:00
|
|
|
npc.occupations.register_occupation("farmer", farmer_def)
|