Harvestable by specific class

I have a question about the harvest function, i want to make a model that is just harvestable by a specific class. Like the farm fields. For something like this i have to work with LUA or is just .json enough??

Take a look at Archipelago. The fisherman is the only class that can harvest oysters AFAIK.

5 Likes

ohhh thx thats a good tip! :smiley:

ok i found the information but where i can set a new category? i have to make some items just harvestable for the Herbalist.

"stonehearth:renewable_resource_node": {
			"category": "fishing",
}

The category has to have a refference to a single class, animation, ecc.

i guess you have to look at the fisherman, his abilities. it probably points to an AI/something

1 Like

Task_groups. Have to try it out… maybe the thing that i want to do works xD

1 Like

let me know :slight_smile: im curious now (was thinking of making basicly a second type of fields and taking the flowers and saplings off the farmer and giving it to the herbalist, giving the herbalist the ability to “farm” them so he’s not such a drain on the farmer, while the cleric is the one stop-shop to healing all powered by the power of the gods… (and the best path to take is not herbalist 2>cleric forever)

1 Like

Yes, i want also to upgrade the Herbalist xD

So isn’t becoming useless once you have a Cleric

2 Likes

well i’d say go for it :smiley: let me know how its coming along! :slight_smile:

Mind you, task groups are JSON lists, not tables, so in order to add a new category to a class you have to overwrite the whole list (so there’s no way for more than one mod to add new task groups to the same class). A little shoutout to the devs: I’d rather see it as a logic table:

{
   "task_group": true,
   "task_group": true,
   "task_group": true
}
1 Like

I’ve seen Bruno was using the task group to define witch one can Harvest a specific ressource. There are some Lua & new Json files to add. Also mixintos for the Herbalist Description

The actual file:

"promotion_activity_name": "promote_herbalist",
   "task_groups": [
      "stonehearth:task_groups:common_tasks",
      "stonehearth:task_groups:restock",
      "stonehearth:task_groups:placement",
      "stonehearth:task_groups:healing",
      "stonehearth:task_groups:harvest",
      "stonehearth:task_groups:rescue",
      "stonehearth:task_groups:crafting",
      "stonehearth:task_groups:town_alert"
   ],

Adding here a new task group maybe could work. But i have to try it…

"promotion_activity_name": "promote_herbalist",
   "task_groups": [
      "stonehearth:task_groups:common_tasks",
      "stonehearth:task_groups:restock",
      "stonehearth:task_groups:placement",
      "stonehearth:task_groups:healing",
      "stonehearth:task_groups:harvest",

      "stonehearth:task_groups:herbalist-new-task",

      "stonehearth:task_groups:rescue",
      "stonehearth:task_groups:crafting",
      "stonehearth:task_groups:town_alert"
   ],
1 Like

I did it for Herbalist in one of my now obsolete mods. You have to overwrite the task group list to make some harvests class-specific and Lua is necessary if you want your class to gain XP from the new tasks.

Ohh that sounds a little bit too complicate :frowning:
I’m not a Pro in coding…

I think a mixinto would add your item to the array, it shouldn’t be needed to overwrite the whole array.
For removing task groups from it then yes, you would need to use mixintypes / overwrite the whole list.

So I’d say try the mixinto just in case, @pingu.

1 Like

First change the category of your item (renewable_)resource_node:

"stonehearth:renewable_resource_node": {
	"category": "fishing",

Then add to the job description the task_group that contains that new behavior:

"task_groups": [
	"archipelago_biome:task_groups:fishing",
]

(As Relyss mentioned, you don’t need to override. It is a simple addition to the existing list)

Then your task should be a lua file like this:

local YourCustomHarvestTaskGroup = class()
YourCustomHarvestTaskGroup.name = 'harvest'
YourCustomHarvestTaskGroup.does = 'stonehearth:simple_labor'
YourCustomHarvestTaskGroup.priority = {0.6, 0.8}

return stonehearth.ai:create_task_group(YourCustomHarvestTaskGroup)
         :work_order_tag("haul")
         :declare_permanent_task('stonehearth:harvest_resource', { category = "your_custom_harvest_category" }, {0.5, 1.0})
         :declare_permanent_task('stonehearth:harvest_renewable_resource', { category = "your_custom_harvest_category" }, {0.5, 1.0})

You can change the work_order_tag to one of those 4 categories that we can activate or deactivate in the character list (job, haul, build, mine)
You don’t need both resource and renewable_resource. It is there in the list just as an example.
“your_custom_harvest_category” is what you used in your item json.

5 Likes

Ahh ok also my idea was right! ^^
Wanted to do exactly this kind of modification, thx @BrunoSupremo :smiley:

So i have also the confirmation that the code i wanted to try really works xD

1 Like

Really? Something must have changed then because I wasn’t able to mix into an existing list while scripting Plant Lore for A22. Good!

I have a problem with the integration… Get this error messages while promoting a Worker to Herbalist. Something about “task not created”…

release-838 (x64)[M]
stonehearth/services/server/town/town.lua:359: assertion failed: task group "homesweethome:task_groups:gathering" not yet created
stack traceback:
	[C]: ?
	[C]: in function 'error'
	radiant/modules/commons.lua:247: in function 'assert'
	stonehearth/services/server/town/town.lua:359: in function 'join_task_group'
	stonehearth/components/job/job_component.lua:745: in function '_add_to_task_groups'
	stonehearth/components/job/job_component.lua:342: in function 'promote_to'
	debugtools/call_handlers/debugtools_commands.lua:261: in function <debugtools/call_handlers/debugtools_commands.lua:246>

and also this one

release-838 (x64)[M]
c++ exception: lua runtime error
stack traceback:

Is the first time that i try to make something in LUA. Maybe i made it wrong.

This is the Mod Link on Github >> Last Commit >> MOD homesweethome

Did you added it to your manifest?

@BrunoSupremo yes, in the aliases… But nothing. Doesn’t work :frowning: