Skip to content

Commit

Permalink
feat: JSONize activity speed/movecost modifier (#6064)
Browse files Browse the repository at this point in the history
* mroe based_on speed

* tmp

* temp

* json tidy

* restructure #1

* more fields

* style(autofix.ci): automated formatting

* wb_wrapper

* speed recalc

* speed calculation overhaul pt.1

* json overhaul #2

* minor logic fixes

* revert crafting changes (for now)

* style(autofix.ci): automated formatting

* Resolving reviews

* missied a spot

* consistency with player_activity constructor

* total moves must be set

* Activity message

* some saved info

* damn optional

* static

* Revert "consistency with player_activity constructor"

This reverts commit 60aa333.

* remove balance changes for now

* bool speacial and some other vals

* complex progress calc

* fix tests to use new value

* style(autofix.ci): automated formatting

* possible test fix

* I don't like this

* i don't like this less

* stats, skills and qualities

* style(autofix.ci): automated formatting

* fix json

* commentaries and json de//serializers

* style(autofix.ci): automated formatting

* fix de//serialization try 1

* minor fixes

* deserialize done right

* docs

* style(autofix.ci): automated formatting

* data migration

* fix migration

* Update src/activity_actor.cpp

Co-authored-by: scarf <[email protected]>

* style(autofix.ci): automated formatting

* remove default constructor

* reviews

* Apply suggestions from code review

Co-authored-by: OrenAudeles <[email protected]>

* Update src/activity_actor.cpp

Co-authored-by: OrenAudeles <[email protected]>

* review suggestions

* Update src/activity_actor.cpp

Co-authored-by: OrenAudeles <[email protected]>

* more suggestions

* move progress to actor

* style(autofix.ci): automated formatting

* back to deque

* forgotten returns

* fix endless gates

* fucking type

* json additions

* docs

* style(autofix.ci): automated formatting

* Apply suggestions from code review

Co-authored-by: OrenAudeles <[email protected]>

* empty() and debugmsg

* removed debug msg

* shuffle funcs

* reviews

* missed few benches

* style(autofix.ci): automated formatting

* get map

* nullptr check

* remove unused vars

* style(autofix.ci): automated formatting

* better way

* revert "some fucky arbitrary json formatting stuff"

* few more unused vars

* Woe, non-verbose tooltip upon thee

* I did it wrong way

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: scarf <[email protected]>
Co-authored-by: OrenAudeles <[email protected]>
Co-authored-by: Chaosvolt <[email protected]>
  • Loading branch information
5 people authored Feb 25, 2025
1 parent 2f2c759 commit 62cef48
Show file tree
Hide file tree
Showing 17 changed files with 1,305 additions and 418 deletions.
288 changes: 153 additions & 135 deletions data/json/player_activities.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,49 @@ something that takes more than just one turn.
roots into the ground. Should be true if the activity lasts longer than a few minutes, and can
always be accomplished without moving your feet.

- based_on: Can be 'time', 'speed', or 'neither'.

- time: The amount that `player_activity::moves_left` is decremented by is independent from the
character's speed.

- speed: `player_activity::moves_left` may be decremented faster or slower, depending on the
character's speed.

- neither: `moves_left` will not be decremented. Thus you must define a do_turn function;
otherwise the activity will never end!
- special (false): activity is considered special and expects to have unconventional logic,
compared to other activities

- complex_moves(false):
- if false - activity expects to have no speed calculations and do 100 moves per turn,
in JSON it's specified by absence of `complex_moves` block;
- if true - activity expects to have complex speed/moves calculations, based on several factors:
- assistable(false): activity can be assisted by other creatures;
- bench(false): activity can be done using workbench;
- light(false): activity speed is affected by current light level;
- speed(false): activity speed is affected by creature's speed;
- skills: activity speed is affected by skills provided in by pairs `skill_name: modifier`
or `"skills": true` if you want to explicitely show that activity expects to have modifications
based on skills, but those will have to be determine on go (like crafting or constructing):
- `"skills": true`
- `"skills": ["fabrication", 5]`
- stats: activity speed is affected by skills provided in by pairs `stat_name: modifier`
or `"stats": true` if you want to explicitely show that activity expects to have modifications
based on stats, but those will have to be determine on go (like crafting or constructing):
- `"stats": true`
- `"stats": ["DEX", 5]`
- qualities: activity speed is affected by qualities provided in by pairs `q_name: modifier`
or `"qualities": true` if you want to explicitely show that activity expects to have modifications
based on qualities, but those will have to be determine on go (like crafting or constructing):
- `"qualities": true`
- `"qualities": ["CUT_FINE", 5]`
- morale(false): activity speed is affected by creature's current morale level.

Example for whole block:
"complex_moves": {
"assistable": true,
"bench": true,
"light": true,
"speed": true,
"stats": true,
"skills": [ ], - //same as `"skills": true`
"qualities": [ ["CUT_FINE", "5"] ],
"morale": true
}

- morale_blocked(false): activity won't be performed if creature's morale level is below certain level.

- verbose_tooltip(true): activity will have an expanded progress window, showing a lot of information

- no_resume (false): Rather than resuming, you must always restart the activity from scratch.

Expand Down Expand Up @@ -76,12 +109,31 @@ There are several ways an activity can be ended:
should call `set_to_null()`. If there isn't a finish function, `set_to_null()` will be called for
you (from activity_actor::do_turn).

3. `Character::cancel_activity`
3. `progress.complete()`

Basically the same as `moves_left` <= 0, but with extra checks and using a progress system.

4. `Character::cancel_activity`

Canceling an activity prevents the `activity_actor::finish` function from running, and the
activity does therefore not yield a result. Instead, `activity_actor::canceled` is called. If
activity is suspendable, a copy of it is written to `Character::backlog`.

## Progress

`progress_counter` - class specialize on tracking progress of and activity

- targets: queue of targets that are expected to be processed, stores target name, moves_total and
moves_left for the target;

- moves_total (0): Total number of moves required to complete the activity aka all the tasks;

- moves_left (): The number of moves remaining in this activity before it is complete aka all the tasks;

- idx (1): 1-based index of currently prcessing task;

- total_tasks (0): Counts total amount of tasks - done and in queue.

## Notes

While the character performs the activity, `activity_actor::do_turn` is called on each turn.
Expand Down Expand Up @@ -110,9 +162,7 @@ based on time or speed.

To prevent an infinite loop, ensure that one of the following is satisfied:

- The `based_on` JSON property is `speed` or `time`

- The `player_activity::moves_left` is decreased in `do_turn`
- The `player_activity::progress.moves_left` is decreased in `do_turn`

- The the activity is stopped in `do_turn` (see 'Termination' above)

Expand Down
Loading

0 comments on commit 62cef48

Please sign in to comment.