From cf77ab529914f60e99324f4981fdab66d8af1f4e Mon Sep 17 00:00:00 2001 From: Hector Franqui Date: Mon, 18 Sep 2017 01:13:20 -0400 Subject: [PATCH] Farmer: Add other schedule entries for commonplace tasks. Priest: Fixed missing dialogue issue. Miner: Fixed indentation. --- data/occupations/default_farmer.lua | 244 ++++++++++++++++++++++------ data/occupations/default_miner.lua | 109 ++++++------- data/occupations/default_priest.lua | 10 +- 3 files changed, 245 insertions(+), 118 deletions(-) diff --git a/data/occupations/default_farmer.lua b/data/occupations/default_farmer.lua index a61e44f..92ce989 100644 --- a/data/occupations/default_farmer.lua +++ b/data/occupations/default_farmer.lua @@ -8,16 +8,22 @@ -- afternoon. 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" - } + "farming:cotton_1", + "farming:cotton_2", + "farming:cotton_3", + "farming:cotton_4", + "farming:cotton_5", + "farming:cotton_6", + "farming:cotton_7", + "farming:cotton_8", + "farming:wheat_1", + "farming:wheat_2", + "farming:wheat_3", + "farming:wheat_4", + "farming:wheat_5", + "farming:wheat_6", + "farming:wheat_7", + "farming:wheat_8" } local farmer_def = { @@ -29,9 +35,28 @@ local farmer_def = { surrounding_building_types = { {type="field", origin_building_types={"hut", "house", "lumberjack"}} }, - walkable_nodes = farming_plants.cotton, + walkable_nodes = farming_plants, initial_inventory = {}, schedules_entries = { + [6] = { + -- Get out of bed + [1] = { + task = npc.actions.cmd.USE_BED, args = { + pos = npc.places.PLACE_TYPE.BED.PRIMARY, + action = npc.actions.const.beds.GET_UP + } + }, + -- Walk to home inside + [2] = { + task = npc.actions.cmd.WALK_TO_POS, args = { + end_pos = npc.places.PLACE_TYPE.OTHER.HOME_INSIDE, + walkable = {} + }, + chance = 75 + }, + -- Allow mobs_redo wandering + [3] = {action = npc.actions.cmd.FREEZE, args = {freeze = false}} + }, [7] = { [1] = { @@ -48,9 +73,9 @@ local farmer_def = { random_execution_times = true, min_count = 20, max_count = 25, - nodes = farming_plants.cotton, + nodes = farming_plants, prefer_last_acted_upon_node = true, - walkable_nodes = farming_plants.cotton, + walkable_nodes = farming_plants, actions = { -- Actions for cotton - harvest and replant @@ -61,7 +86,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -98,7 +123,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -135,7 +160,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -172,7 +197,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -209,7 +234,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -246,7 +271,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -283,7 +308,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -320,7 +345,7 @@ local farmer_def = { task = npc.actions.cmd.WALK_TO_POS, args = { end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, - walkable = farming_plants.cotton + walkable = farming_plants } }, [2] = @@ -349,38 +374,45 @@ local farmer_def = { action = npc.actions.cmd.STAND, args = {} } + }, + ["farming:wheat_8"] = + { + [1] = + { + task = npc.actions.cmd.WALK_TO_POS, + args = { + end_pos = npc.places.PLACE_TYPE.SCHEDULE.TARGET, + walkable = farming_plants + } + }, + [2] = + { + action = npc.actions.cmd.DIG, + args = { + bypass_protection = true + } + }, + [3] = + { + action = npc.actions.cmd.STAND, + args = {} + }, + [4] = + { + action = npc.actions.cmd.PLACE, + args = + { + node = "farming:wheat_1", + bypass_protection = true + } + }, + [5] = + { + action = npc.actions.cmd.STAND, + args = {} + } } }, - [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" - } - } - } - }, none_actions = { -- Walk a single step in a random direction @@ -397,9 +429,117 @@ local farmer_def = { } } } + }, + [13] = { + -- Walk to a sittable node + [1] = { + task = npc.actions.cmd.WALK_TO_POS, args = { + end_pos = {place_type=npc.places.PLACE_TYPE.SITTABLE.PRIMARY, use_access_node=true}, + walkable = {"cottages:bench"} + }, + chance = 75 + }, + -- Sit on the node + [2] = { + task = npc.actions.cmd.USE_SITTABLE, args = { + pos = npc.places.PLACE_TYPE.SITTABLE.PRIMARY, + action = npc.actions.const.sittable.SIT + }, + depends = {1} + }, + -- Stay put into place + [3] = { + action = npc.actions.cmd.SET_INTERVAL, args = { + freeze = true, + interval = 35 + }, + depends = {2} + }, + [4] = { + action = npc.actions.cmd.SET_INTERVAL, args = { + freeze = true, + interval = npc.actions.default_interval + }, + depends = {3} + }, + -- Get up from sit + [5] = { + action = npc.actions.cmd.USE_SITTABLE, args = { + pos = npc.places.PLACE_TYPE.SITTABLE.PRIMARY, + action = npc.actions.const.sittable.GET_UP + }, + depends = {4} + } + }, + [14] = { + -- Give NPC money to buy from player + [1] = { + property = npc.schedule_properties.put_multiple_items, args = { + itemlist = { + {name="default:iron_lump", random=true, min=2, max=4} + } + }, + chance = 50 + }, + -- Change trader status to "trader" + [2] = { + property = npc.schedule_properties.trader_status, args = { + status = npc.trade.TRADER + }, + chance = 90 + }, + [3] = { + property = npc.schedule_properties.can_receive_gifts, args = { + can_receive_gifts = false + }, + depends = {1} + }, + -- Allow mobs_redo wandering + [4] = {action = npc.actions.cmd.FREEZE, args = {freeze = false}} + }, + -- Schedule entry for 6 in the evening + [18] = { + -- Change trader status to "none" + [1] = { + property = npc.schedule_properties.trader_status, args = { + status = npc.trade.NONE + } + }, + -- Enable gift receiving again + [2] = { + property = npc.schedule_properties.can_receive_gifts, args = { + can_receive_gifts = true + } + }, + -- Get inside home + [3] = { + task = npc.actions.cmd.WALK_TO_POS, args = { + end_pos = npc.places.PLACE_TYPE.BED.PRIMARY, + walkable = {} + } + }, + -- Allow mobs_redo wandering + [4] = {action = npc.actions.cmd.FREEZE, args = {freeze = false}} + }, + [22] = { + [1] = { + task = npc.actions.cmd.WALK_TO_POS, args = { + end_pos = {place_type=npc.places.PLACE_TYPE.BED.PRIMARY, use_access_node=true}, + walkable = {} + } + }, + -- Use bed + [2] = { + task = npc.actions.cmd.USE_BED, args = { + pos = npc.places.PLACE_TYPE.BED.PRIMARY, + action = npc.actions.const.beds.LAY + } + }, + -- Stay put on bed + [3] = {action = npc.actions.cmd.FREEZE, args = {freeze = true} } } } } -- Register occupation -npc.occupations.register_occupation("farmer", farmer_def) +npc.occupations.register_occupation("default_farmer", farmer_def) diff --git a/data/occupations/default_miner.lua b/data/occupations/default_miner.lua index 9a28158..0d37c26 100644 --- a/data/occupations/default_miner.lua +++ b/data/occupations/default_miner.lua @@ -1,68 +1,51 @@ -- WIP miner by NewbProgrammer101 or roboto + local miner_def = { - dialogues = {}, - textures = {"miner.png"}, - initial_inventory = { - {name="default:pick_steel", chance=1}, - {name="default:shovel_bronze", chance=1} - }, - schedule_entries = { - [7] = { - [1] = { - task = npc.actions.cmd.WALK_TO_POS, - args = { - end_pos = npc.places.PLACE_TYPE.OTHER.HOME_OUTSIDE, - walkable = {} - } - }, - [2] = { - check = true, - range = 3, - random_execution_times = true, - min_count = 20, - max_count = 99, - nodes = {"default:dirt", "default:dirt_with_grass", "default:sand", "default:desert_sand", "default:silver_sand", "default:gravel", "default:clay", "default:snow", "default:snowblock", "default:}, - actions = { - ["default:dirt"] = { - [1] = { - action = npc.actions.cmd.WALK_STEP - }, - [2] = { - action = npc.actions.cmd.DIG - } - } - } - }, - [3] = { - check = true, - range = 3, - random_execution_times = true, - min_count = 20, - max_count = 99, - nodes = {"default:stone", "default:stonebrick", "default:stone_block", "default:mossycobble", "default:desert_stone", "default:desert_cobble", "default:desert_stonebrick", "default:desert_stone_block"}, - actions = { - ["default:stone"] = { - [1] = { - action = npc.actions.cmd.WALK_STEP - }, - [2] = { - action = npc.actions.cmd.DIG - } - } - } - }, - none_actions = { - [1] = { - action = npc.actions.cmd.WALK_STEP, - args = { - dir = "random" - } - } - } - } - } - } + dialogues = {}, + textures = {"miner.png"}, + initial_inventory = { + {name="default:pick_steel", chance=1}, + {name="default:shovel_bronze", chance=1} + }, + schedule_entries = { + [7] = { + [1] = { + task = npc.actions.cmd.WALK_TO_POS, + args = { + end_pos = npc.places.PLACE_TYPE.OTHER.HOME_OUTSIDE, + walkable = {} + } + }, + [2] = { + check = true, + range = 3, + random_execution_times = true, + min_count = 20, + max_count = 99, + nodes = {"default:dirt", "default:dirt_with_grass", "default:sand", "default:desert_sand", "default:silver_sand", "default:gravel", "default:clay", "default:snow", "default:snowblock"}, + actions = { + ["default:dirt"] = { + [1] = { + action = npc.actions.cmd.WALK_STEP + }, + [2] = { + action = npc.actions.cmd.DIG + } + } + } + }, + + none_actions = { + [1] = { + action = npc.actions.cmd.WALK_STEP, + args = { + dir = "random" + } + } + } + } + } } -- Occupation registration -npc.occupations.register_occupation("miner", miner_def) +npc.occupations.register_occupation("default_miner", miner_def) diff --git a/data/occupations/default_priest.lua b/data/occupations/default_priest.lua index ba282aa..2458532 100644 --- a/data/occupations/default_priest.lua +++ b/data/occupations/default_priest.lua @@ -13,6 +13,7 @@ local priest_def = { dialogues = { type = "given", + max_count = 5, data = { { text = "Blessings be upon you, my child!", @@ -20,6 +21,7 @@ local priest_def = { }, { text = "The temple will always open the doors to everyone.", + flag = {name="on_church", value=true}, tags = {"unisex"} }, { @@ -28,6 +30,7 @@ local priest_def = { }, { text = "Thanks for coming to greet me, I hope you have a blessed day! ", + flag = {name="on_church", value=false}, tags = {"unisex"} }, { @@ -57,7 +60,7 @@ local priest_def = { else npc.chat(self.npc_name, player:get_player_name(), "Receive the blessings of the Creator!") - effect(self.object:getpos(), 20, "default_coral_skeleton.png", 0.1, 0.3, 3, 10) + npc.effect(self.object:getpos(), 20, "default_coral_skeleton.png", 0.1, 0.3, 3, 10) -- Heal one heart player:set_hp(player:get_hp() + 2) end @@ -117,7 +120,8 @@ local priest_def = { }, properties = { initial_trader_status = npc.trade.NONE, - enable_gift_items_hints = false + enable_gift_items_hints = false, + can_receive_gifts = false }, building_types = {}, surrounding_building_types = { @@ -208,4 +212,4 @@ local priest_def = { } -- Register occupation -npc.occupations.register_occupation("priest", priest_def) +npc.occupations.register_occupation("default_priest", priest_def)