Quests, Event trigger Tutorial needed

Hello out there, i want to go forward and write down a quest or some event to get some very rare or historical recipes. I read the jsons from town tier quest and so on but cant put the finger on some things.

  1. Where is the action / function / system to trigger an event ?
  2. What files are necessary to begin a quest ?
  3. Is there a Tutorial for creating events or is there a mod which uses that ?

I would like to have a starting kick to get on with that, so pls give me some detailed starting information. I think i could reproduce a lot from the vanilla jsons but without understanding i will encounter errors which i cant solve myselve.

i know @BrunoSupremo have done something with triggers in his arpialego biome mod. I dont know if that fits the question?

Uhm, campaigns are not hard, but they are sure very time consuming and require a lot of work…

They are all at the /data/gm folder. Check there. Below a little resume of what is going on.

First you will need to add a campaign at the campaign index (stonehearth:data:gm_index)

Then a campaign file where you list the arcs of the campaign, that start at “trigger”, and having “challenge” and “climax” as optional following arcs.

The arc file (called encounter list) will list all files used in that arc.

The first file to run (where the campaign actually starts) is the one which have “in_edge” : “start”, as name.
in_edge is the name of the current encounter. out_edge is the name of the following encounter (the one to run after this one is done)

2 Likes

The term here would be “encounters”. Events are a different thing (and there’s documentation about them in the stonehearth/docs folder, unlike the encounters).

I believe that at some point there was a livestream where the different types of triggers and the general campaign system was explained, but I can’t find it. It might have been deleted by Twitch, since it was from very long ago. :glum: Or maybe it’s somewhere in one of the other modding-related streams :thinking:

Agreed. We should review this at some point.

So, as another tip, the different types of encounters are listed in stonehearth/services/server/game_master/controllers/encounters.

Use the Campaign Browser in debugtools to see how the different nodes connect to each other, and compare it with the json in the data/gm folder.

2 Likes

it is possible to catch the vent when a anima pasture is full ?
I want to automatly set a command for kill the animal…
need a tool for dont have to click one by one for ordered the kill…
:slight_smile:

Hmm… You might listen to the stonehearth:on_pasture_animals_changed event, and compare get_max_animals() with get_num_animals() (from the shepherd pasture component) in that specific pasture.

1 Like

thanks.
have you a good example for me how to mod this ?
i am new on mod. i have only added furniture.
i need to collect material before go in this feature :stuck_out_tongue:

Well, you don’t need to click them one by one. You can simple drag the harvest tool and everything inside will be marked.

Just a note for anyone modding for auto-harvesting the pastured animals - PLEASE add some way to prevent the harvesting of specific animals, such as Bluebell the sheep! :merry: I’ve accidentally harvested her several times already.

here my first try. it is not complete do not use it.
CE_mod2.smod (2.2 KB)

in wait_for_pasture_vacancy2.lua
in function WaitForPastureVacancy2:pasture_check()
i dont know how to test the colar of the animal before kill it.
i dont know how to send the slaughter command.

it is a good first try ? or not ?

++ go to bed…

Oh thanks, now i can upload directly the .smod :slight_smile:

Wait a minute!! Since when we can upload *.smod? This is much better!

1 Like

Since very recently. But we still have the limitation of 10MB for attachments, and I think Discourse charges for file storage.
So it’s not really a good solution for uploading mods, we still need to figure out how to go about it.

1 Like

here the mod : CE_mod2.smod (2.2 KB)

i have this error :
release-707 (x64)[M]
stonehearth/components/ai/ai_component.lua:412: could not load action script at CE_mod2:actions:shepherd:wait_for_pasture_vacancyCE
stack traceback:
radiant/modules/common.lua:245: in function ‘report_traceback’
radiant/modules/common.lua:256: in function <radiant/modules/common.lua:250>
[C]: in function ‘assert’
stonehearth/components/ai/ai_component.lua:412: in function ‘_get_key_and_constructor_for_action’
stonehearth/components/ai/ai_component.lua:292: in function ‘_add_action_internal’
stonehearth/components/ai/ai_component.lua:237: in function ‘add_action’
stonehearth/services/server/ai/ai_injector.lua:69: in function ‘_inject_actions’
stonehearth/services/server/ai/ai_injector.lua:50: in function ‘_inject_ai’
stonehearth/services/server/ai/ai_injector.lua:15: in function ‘__user_init’
radiant/lib/unclasslib.lua:270: in function ‘__init’
radiant/lib/unclasslib.lua:201: in function ‘AiInjector’
…
…s/server/town/orchestrators/promote_orchestrator.lua:71: in function ‘_change_job’
…s/server/town/orchestrators/promote_orchestrator.lua:22: in function ‘_trigger_cb’
radiant/modules/effects/trigger_effect.lua:14: in function ‘fn’
radiant/controllers/nonpersistent_timer.lua:56: in function ‘fire’
radiant/controllers/time_tracker_controller.lua:84: in function <radiant/controllers/time_tracker_controller.lua:84>
[C]: in function ‘xpcall’
radiant/modules/common.lua:265: in function ‘xpcall’
radiant/controllers/time_tracker_controller.lua:84: in function ‘set_now’
radiant/modules/gamestate.lua:9: in function ‘set_now’
radiant/server.lua:60: in function <radiant/server.lua:58>

could you explain me why ?
i dont know you to set the action json and the lua file is a simple copy of existing one i only rename the event.

where is the error ?

Is it possible, that campaigns must be loaded at world creation ?
i tried to have it start in a savegame but the “wait_for_net_worth” is not triggering the out_edge.
In a new game it does.

Someone out there pls have information for me

Is:
Encounter
Type: wait_for_population
Possible ?

And
Can check more than one item threshold in one encounter ?

And
Can i read classes with lvl to trigger something
Maybe like
Wait for class blacksmith lvl 6

I have been busy the hole day long with just the first steps of my questline to get it to work. And my outline of the other quest needs more possible encounter types.

1 Like

Yes, you can wait for having a class at a specific level.
Take a look at stonehearth/data/gm/campaigns/trader/arcs/encounters/returning_crop_trader_encounter.json
It has this (the trader that offers foreign crops only appears after you have a farmer lvl 6):

"can_start": {
      "test_1": {
         "script_check": {
            "item": "highest_job_level",
            "type": "deny_if_less_than",
            "value": 6,
            "job_alias": "stonehearth:jobs:farmer",
            "script": "stonehearth:game_master:script:returning_crop_trader_can_start"
         }
      }
   },

Yes, you can have more than one requirement for your encounter. For example, in stonehearth/data/gm/campaigns/orc_war/arcs/trigger/old_khan/encounters/wait_to_start.json you have two requirements:

"requirements": {
         "campaign_requirement": {
            "item": "campaign_completed",
            "campaign_name": "combat",
            "type": "deny_if_not",
            "value": true
         },
         "net_worth_requirement": {
            "item": "net_worth",
            "type": "deny_if_less_than",
            "value": 10000
         }
      }

You mean waiting until you have a certain number of hearthlings?
That would be with "item" : "num_citizens"

3 Likes

i finaly get the idea for my event for butcher.
now i want to send the command

but i dont know how.
here the text i found in shepherd_pasture_component.lua ;
commands_component:set_command_enabled(‘stonehearth:commands:slaughter’, false)

i see too the command:slaughter but dont know how to send…

have you a example ?

what do this in json :
“injected_commands”: [
“stonehearth:commands:release_pet”
]

Thank you @Relyss
that got me going. Now i did the first steps with my campaign…and it is an awful lot of work…
but it is also a lot of fun.
8 encounters are made and it does what i want…but testing the campaign is awful

sry, that i read not enough in the existing campaigns before i posted my questions :slight_smile:

1 Like

New question:
If i trigger the encounter by event - building finished
Can i have two possible triggers leading to one next encounter ?
Or must i create a copy for each race splitting at that point ?
Because the building should be different for rayyas and ascendancy because of style and needed resources.
Ok while writing this i possibly got an answer.
If i unlock recipes i must first check race and then unlock the specific recipes right ?
If i want to trigger by a race specific building event i have to check race before leading to the trigger ?

Omg now its getting complicated because the campaign must have two temporarily seperate roads. Or is there a simpler way to do it ?

Yes, you can “split” and “join” the encounters path at will.

Everything else: I didn’t understand :frowning:
You want to activate an encounter when the player has build something?