[Tutorial] Creating New Dynamic Tasks for Call of Chernobyl

User avatar
Posts: 1368
Joined: 26 May 2012, 22:26

[Tutorial] Creating New Dynamic Tasks for Call of Chernobyl

Postby Alundaio » 17 May 2015, 23:01

Hello fellow modders! So you want to make some awesome tasks in Call of Chernobyl using many of the new added features? You've come to the right place!

Important File Locations:
  • configs\misc\tm_*.ltx
  • configs\gameplay\character_desc_*.xml
  • configs\gameplay\dialogs_*.xml
  • configs\text\eng\st_dialogs_*.xml
  • configs\text\eng\st_quests_*.xml
  • scripts\xr_conditions.script
  • scripts\xr_effects.script
  • scripts\task_status_functor.script
  • scripts\task_functor.script

The above is a general list of the files you usually need to alter to create a basic task. If these are not visible in your gamedata directory then you must use the unpacker! This guide will not go into adding new NPCs into the game world for the purposes of task giving.

Important Fields of a Task Object defined in tm_*.ltx:
  • icon - This is the texture name of the icon displayed for the task in the PDA. The texture for this is located at textures\ui\ui_actor_newsmanager_icons.dds. You can find the texture names in configs\ui\textures_descr\ui_actor_newsmanager_icons.xml.
  • title - This field takes a string ID defined in configs\text\eng\st_* as a parameter. This is the title of the task displayed in the PDA. It is also shown for the currently selected task when the player holds Tab in-game.
  • title_functor - This optional field is the name of a function that can be found in scripts\task_functor.script. This is so you can dynamically change the title of the task as it progresses.
  • descr - This field takes a string ID. This is the text for the description displayed in the PDA. It is also shown for the currently selected task when the player holds Tab in-game.
  • descr_functor - This optional field is the name of a function that can be found in scripts\task_functor.script. Generally, you want to only use a custom made function to alter the description of the task dynamically. In CoC it is used to add the name of the item for general fetch tasks.
  • prior - This field takes a number. The lower this number the less time between task updates. I'm not certain but it may also play a role in what order it is displayed in PDA. Generally not important, 10 should be good. On less important tasks put this number much higher. For every 1 increase is 100 milliseconds added between updates.
  • job_descr - This is a new field. This field takes a string ID. This is the description of the task as spoken by the task giver!
  • precondition - This field is for custom data logic a.k.a. condition lists. I won't go into detail about how to write logic here. Best bet is to check modding wiki or look how condition lists are written in configs\scripts\. If this returns true, then the task will be available to the player to take.
  • repeat_timeout - This is an optional number field dealing in milliseconds. If this is defined then this is the amount of time before this task will show up in the queue again for the player to take.
  • on_init - This field is for custom data logic a.k.a. condition lists. This will be parsed as soon as the task is given to the player.
  • on_complete - This field is for custom data logic a.k.a. condition lists. This will be parsed when the task status is marked as "completed".
  • on_fail - This field is for custom data logic a.k.a. condition lists. This will be parsed when the task status is marked as "failed".
  • fetch_descr - This optional field takes a string ID. This field was created to dynamically display and alter the names of items that were randomly generated. If you want to create your own repetable fetch tasks look at task examples using this field.
  • fetch_func - This optional field is for custom data logic. It's custom made to generate a list of fetch items.
  • stage_complete - This optional number field is used to complete a task when a stage flag equals this number. This is for more advanced task creation and allows you to separate complex tasks into stages.
  • status_functor - This optional field is the name of a function found in scripts\task_status_functor.script. It's used for more advanced tasks to dynamically change the task's status (ie. completed, selected, failed, reverse) based on scripted conditions.
  • target - This field is for custom data logic a.k.a. condition lists. The target marked on the PDA will be the result in the form of a story ID
  • target_functor - This field is the function name found in scripts\task_functor. The function should either return the game object ID or nil.
  • task_complete_descr - This field is a string ID. This custom field was created to be used with fetch tasks. It's to display spoken dialog by the task-giver after the return of the item.
  • reward_money - This field should be the amount of money you want rewarded to the player after the task is completed.
  • reward_item - This field can be a list of item sections separated by commas (ie. wpn_pm, wpn_fort, wpn_ak74). These items will be rewarded to the player when the task is completed.
  • dont_send_update_news - When true, it will not send a news tip when the task is updated.
  • condlist_* - replace * with a number. You can has as many as these as you want. This will process a condition list every update.

Call of Chernobyl has a variety of existing task types that can practically be copied and pasted to generate new tasks but also supports more advanced task creation for those who are capable enough.

Fetch Tasks (Your First Task!):
Okay, so you want to create a basic fetch task, such as collecting a certain amount of mutant parts or whatever. Let's take a look at an existing example,

Code: Select all

icon = ui_inGame2_Instrumenti
prior = 10
storyline = false
title = mar_base_stalker_tech_task_2_name
title_functor = general_fetch_task
descr = mar_base_stalker_tech_task_2_text
descr_functor = general_fetch_task
job_descr = mar_base_stalker_tech_task_2_about
fetch_descr = mar_base_stalker_tech_task_2_fetch_about
fetch_func = %=setup_generic_fetch_task(mar_base_stalker_tech_task_2_fetch:1:itm_gunsmith_toolkit_tier_2)%
stage_complete = 1
status_functor = actor_has_fetch_item
target_functor = general_fetch_task
task_complete_descr = mar_base_stalker_tech_task_2_fetch_finish
on_complete = %+mar_base_stalker_tech_upgrade_tier_2 =complete_task_inc_goodwill(5:csky) =reward_money(1000) =remove_fetch_item(mar_base_stalker_tech_task_2_fetch) =inc_task_stage(mar_base_stalker_tech_task_2)%
precondition = {+mar_base_stalker_tech_upgrade_tier_1 -mar_base_stalker_tech_upgrade_tier_2} true, false

There are new features added that streamline the process of adding and dealing with new tasks. These features are capable of generating dialog, allowing repeatability and dynamically altering task priorities based on A-life. One such feature is what I call the Ordered Task system. Basically, you create a new section for a task in tm_*.ltx using the task-giver's section name plus the task number. Be mindful
when creating new tasks and follow this specific rule if you want your task to be handled by the Ordered Task system, otherwise your task will not show up when talking to the NPC.

A.) We will use this to create a new task for a new NPC. Copy this and paste it into tm_*.ltx of the current level for your NPC. Do a string replace for mar_base_stalker_tech and replace it with the section name of your NPC (found in configs\creatures\spawn_sections_*.ltx).

You will want to create new dialog for all the string fields, I will list below:
1. title = mar_base_stalker_tech_task_2_name
2. descr = mar_base_stalker_tech_task_2_text
3. job_descr = mar_base_stalker_tech_task_2_about
4. fetch_descr = mar_base_stalker_tech_task_2_fetch_about
5. task_complete_descr = mar_base_stalker_tech_task_2_fetch_finish

Find these in the dialogs_marsh.xml and copy them to dialogs_*.xml for your NPC. Do another string replace for the NPC section name. Rewrite the dialog as you see fit.

  • fetch_func = %=setup_generic_fetch_task(mar_base_stalker_tech_task_2_fetch:1:itm_gunsmith_toolkit_tier_2)%

T-Bone at Clear Sky base wants the player to bring him a tier 2 gunsmith toolkit. xr_effects.script already has a nice method to handle what items are to be collected, with setup_generic_fetch_task. Param 1 will be a unique way for us to define this task, so it's best to use the task name and append "fetch" to it so that
it does not ever conflict with any other task the player may get from other task-givers. Param 2 is the amount of items the task-giver wants the player to bring him. Param 3 is the item section name!

  • This method does support multiple fetch items! However, each item has to be the same amount. Here is an example,


    You can add as many item sections as you want, but the player for this example must bring back 5 of each wpn_pm, wpn_fort and wpn_colt!

  • More complex fetch tasks can use their own unique function created in xr_effects. Check out yan_stalker_sakharov_task_1 in tm_yantar.ltx and setup_rare_mutant_fetch_task in xr_effects.script

C.) on_complete is where you want to deal with the reward. Call of Chernobyl usually gives some money and a bit of goodwill. If you are a knowledgeable modder you should be able to alter this for whatever you want to do, like giving Infoportions to unlock more tasks or other things.

D.) stage_complete = 1, this is because the status_functor adjusts the stage by checking if the player has found the item. If the player does happen to collect the item he is redirected to talk to the task-giver where task_complete_descr is used. Then the stage is incremented and on_complete is immediately triggered.

E.) Preconditions! You should leave this out for testing as this example will not be suitable for your specific fetch task. Preconditions is a good way to block off a task until the player has performed or met some kind of requirement. This would be a good way to tier faction tasks as the player gains ranks in a faction or allow certain tasks to be taken during different times of day, as examples. There are many possibilities here.

status_functor = actor_has_fetch_item
target_functor = general_fetch_task

Call of Chernobyl already has 'functors' setup to deal with fetch tasks. So instead of re-inventing the wheel, we will use these. If you are familiar with lua, you are welcome to take a look at these.

G.) You're Finished! No, really, try it out in-game! If you did things correctly, you should now have a new working fetch task with almost barely any effort or work put in. Cool, huh!?

"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

Return to “Modding Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest