Author Topic: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)  (Read 26509 times)

0 Members and 1 Guest are viewing this topic.

jrider

  • Veteran
  • *
    • View Profile
  • Faction: Neutral
  • WB
The way food is handled in warband can be a bit frustrating especially if you have a large party forcing you to fill a lot of your inventory slots with food if you don't want to go back every 2 day or so refill supplies.

So I started to think about a way to address the problem (without changing the food quantities) and came up with foraging as skill which was very common in older armies (soldiers lived off the land).

First the design part:
  • standard character skill that the player or companion can invest in
  • it does not provide food items, it simply reduce the food consumed at each meal
  • this is an Agility based party skill with max level of 10
  • the skill level (modified by party bonus) sets a hard limit of the maximum number of food unit that can be foraged (5 units max per level for now)
    i.e. even if you can forage 30 food units from the area and you have only 1 level you foraging, you'll get a 5 units reduction to food consumption.
  • the skill level determine the range around player party foraging will be done (set at 2, try 5 first but the radius was too large)
  • since the main goal is to reduce food consumption (a minimum of 1 unit is eaten from the player's inventory), it's triggered at meal time
  • a visible way to see the impact of food consumption
  • works all the time but the amount foraged has a bonus of x1.5 if camping (standard camp, waiting 24h on siege),
    limited by max forage according to skill level
  • Tiers (2-4, 5-7, 8-9 and 10+) of skill (modified by party bonus) provide a bonus (respectively, x1.5, x2, x2.5, x.3) to foraged food to represent the character's experience,
    limited by max forage according to skill level
  • The amount of food that can be foraged depends on local resources (these a modified by the bonus mentionned above):
    • Current party terrain provide a flat base value depending on type
      Steppe/Plain (for game): 2, Rivers/Bridge (for fish): 4, all forests (for game): 4
    • Nearby village or town within the current range provide forage according to the following resources
      • Household gardens and apiaries give a flat value (2 and 1 respectively)
      • Grain fields, vineyards (twice for grapes and fruits), olives fields and date fields provide about 1/4 of the production value
      • Cattle and sheep provide 1/4 of the production value for meat products only (i.e. beef and sausage)
      • Fur traps provide as many units as there are traps in the center (for game, if you skin it you kill it first, usually)
           
Adding the code won't cause problem for an existing savegame (moving the skill in module_skills.py will though).

Changelog:
(click to show/hide)

This is a work in progress as, indicated in the subject so there's a TODO list
  • tweak the numbers
  • the character's sheet placement is awkward and doesn't scale, if someone can find a way to resize that or shift the list a bit downward
  • impact on party morale
  • impact on foraged from town and villages (relation, production)
and here is the code (v1.0, for Warband v1.127) :

  • new (well modified since it replaces reserved_8, to have it displayed after looting) entry to put in module_skills.py
Code: [Select]
  ## Jrider + FORAGING 1.0 adding skill
  #("reserved_8","Reserved Skill 8",sf_base_att_int|sf_inactive,10,"This is a reserved skill."),
  ("foraging","Foraging",sf_base_att_agi|sf_effects_party,10,"Allows the party to forage for 5 food per skill level (camp, siege, raiding) and increase foraging range (Party skill) Max level: 10."),
  ## Jrider -

  • in header_skills.py do the following changes
    (click to show/hide)
Code: [Select]
## Jrider + FORAGING v1.0
#skl_reserved_8 = 21
skl_foraging = 21
## Jrider -
[/spoiler]
(click to show/hide)
[/li]
[/list]
  • Hooks in simple_triggers.py, insert the tagged code in this trigger :
    (click to show/hide)

    still in the same trigger, a bit lower insert the following tagged code for the display message :
    (click to show/hide)
  • finally, in game menu add the following line to the following character backgrounds' stats additions in the begin_adventuring menu :
              cb_forester, cb2_urchin, cb3_poacher
    (click to show/hide)
« Last Edit: August 21, 2010, 03:31:40 PM by jrider »

jrider

  • Veteran
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [WB, SP, code, WIP] Adding a new skill: Foraging
« Reply #1 on: August 14, 2010, 09:48:06 PM »
<reserved>

Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: [WB, SP, code, WIP] Adding a new skill: Foraging
« Reply #2 on: August 14, 2010, 10:45:10 PM »
To adjust the skill display, changing the following in addition to char_b/sc/t/bo_skills... should work:
Code: (game_variables.txt) [Select]
char_b_skill_increment_x = 0.2625
char_b_skill_increment_y_a = 0.005
char_b_skill_increment_h_a = 0.002
char_b_skill_increment_t_s = 0.018

Party morale can be changed here by adjusting the bonus based on the skill.
Code: (script_get_player_party_morale_values) [Select]
          (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten),
          (item_get_slot, ":food_bonus", ":cur_edible", slot_item_food_bonus),
In addition, you could conceivably modify slot_item_food_bonus (or create another one) directly inside script_forage_for_food, and reset it every call. You could probably also display this value inside script_game_get_item_extra_text just for kicks.

You'll want to change the line (neg|party_slot_eq, ":foraging_site", slot_village_state, svs_looted), to (party_slot_eq, ":foraging_site", slot_village_state, svs_normal), which also works for towns since the slot value (and those of svs_normal) are 0 by default. Otherwise, foraging is possible from centers under siege and deserted/recovering/currently raided villages, etc.

Tyrinius

  • Squire
  • *
    • View Profile
  • Faction: Neutral
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #3 on: August 25, 2010, 01:42:30 PM »
Wow, that's cool  :)

Marcolino

  • Knight
  • *
  • Fortitudinem et honorem
    • View Profile
  • Faction: Neutral
  • MP nick: Marcolino
  • M&BWB
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #4 on: August 30, 2011, 02:56:22 PM »
sorry to reply to this post as it is already quite old. I added the code and it works fine. The issue that i have is that by adding this I seem to have lost access to game notes. when I compile, what I get is:

Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
WARNING: Script can fail at operation #1. Use cf_ at the beginning of its name:
get_player_party_morale_values
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .


so, basically, the issue is directly linked to the last portion of the code which tries to adjust party morale.

The issue when I play the game is that any game notes (eg: when I press view notes about a character or town, etc) become blanc. Nothing shows.

Has anyone, who has implemented this code, come up with the same issue? If yes, what is the solution?

Thanks
Ego nunquam mendacio, sed sanguinarius et indomitus sum

Fortes fortuna adiuvat

"Quod melius est in vita? Ut conteret inimicos tuos, educ tecum, et audiunt lamenta feminarum suarum"

Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #5 on: August 30, 2011, 03:58:35 PM »
The code snippet I posted isn't meant to be added to the beginning of the script - it's a reference location to where you can modify the party morale bonus based on your foraging skills.

Marcolino

  • Knight
  • *
  • Fortitudinem et honorem
    • View Profile
  • Faction: Neutral
  • MP nick: Marcolino
  • M&BWB
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #6 on: August 30, 2011, 07:25:24 PM »
Somebody, thanks. I got it working properly now.
Ego nunquam mendacio, sed sanguinarius et indomitus sum

Fortes fortuna adiuvat

"Quod melius est in vita? Ut conteret inimicos tuos, educ tecum, et audiunt lamenta feminarum suarum"

Superelastic

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #7 on: April 22, 2012, 02:41:58 PM »
Thanks for the script jrider!

One small typo in  the module_scripts text, I think:

(lt, ":max_foraging_in_party",,

should be

(lt, ":max_foraging_in_party", 8),
Whatever doesn't compile makes you stronger.

cuts

  • Regular
  • *
    • View Profile
  • Faction: Nord
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #8 on: February 05, 2014, 11:53:05 PM »
Hey everyone, I'm resurrecting this thread, because I found some flaws with this WIP script and I'd like to contribute to make it perfect :p

A few years ago, I found that the code doesn't correctly predict the remaining days of food left and it was pretty annoying wathing mods telling me I had food for a period I knew was blatantly wrong. Back then, I was a big, big, noob (like that was even possible), so I began testing this for days until I got it right. Because of my limited coding skills, it took me quite a while to figure the right formulae and proper checks, but here is my contribution. So far, I am yet to be disappointed with the results, so I'm sharing this one with you :)

Naturally, throughout the years I turned this into a much simpler and personalized code to fit my needs (I like short and simple). You only need to take a look at the math and change it accordingly to make it work like the original. Otherwise, you can just use the whole thing, like I do.

Before, I release it, let me tell you about the main differences. On my script, the skill isn't called foraging, it's called hunting and I merged it with the tracking skill. It made sense, to me (and I will probably merge these with spotting if I find more useful skills to add to my mod). So, although it makes things simpler, you'll still have to account for this. Also, each skill point steadily gives you 10 food units, regardless of terrain and whatnot. It may seem much, but it isn't, really, as I changed the food consumption for one food ration per troop to make it more manageable. I also changed the frequency at which you troops feed for once a day to make it easier to account, reduce spam/lag, etc. Other minor things, like giving your party morale if your hunters are successful in feeding everybody, etc...

and, now, here goes (blue should be the original Native code, so you know where things go):

on module_skills:

(click to show/hide)

on module_scripts:

(click to show/hide)

On simple_triggers:

(click to show/hide)

Thanks for this script, Jrider! If I screwed anything up, let me now :)
« Last Edit: February 07, 2014, 11:29:26 PM by cuts »

Lionheart2

  • Veteran
  • *
  • Would rather be a pikeman than a knight
    • Skype - BBSpecs2
    • View Profile
  • Faction: Rhodok
Re: [WB, SP, code, WIP] Adding a new skill: Foraging
« Reply #9 on: September 28, 2014, 07:53:36 PM »
To adjust the skill display, changing the following in addition to char_b/sc/t/bo_skills... should work:
Code: (game_variables.txt) [Select]
char_b_skill_increment_x = 0.2625
char_b_skill_increment_y_a = 0.005
char_b_skill_increment_h_a = 0.002
char_b_skill_increment_t_s = 0.018

How would I change these values?

Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #10 on: September 28, 2014, 09:21:38 PM »
You should have a text file called game_variables.txt somewhere in your module's directory.

Lionheart2

  • Veteran
  • *
  • Would rather be a pikeman than a knight
    • Skype - BBSpecs2
    • View Profile
  • Faction: Rhodok
Re: [WB v1.127, SP, code, WIP] Adding a new skill: Foraging (v0.1)
« Reply #11 on: October 01, 2014, 02:15:32 AM »
Nvm I fixed it. I knew where the game_variables.txt is, I just was confused which values did what.