Skip to content

Commit

Permalink
refactor(port): bolt cutting migrated to activity and jsonified (#3869)
Browse files Browse the repository at this point in the history
* Make bolt cutting an activity (#50057)

* wirecutting activity_actor

* bolt cutting use activity_actor

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

* generic activity json data loading

* boltcut data loading

* jsonize boltcut activity

* add boltcut data to terrain

* boltcutting tests

* boltcut doc in JSON_INFO.md

* Extract bolt cutting sound for translation

* Extract bolt cutting message for translation

* use jsonized iuse

* wire fence boltcut

* Make it work

---------

Co-authored-by: Saicchi <[email protected]>
Co-authored-by: Saicchi <[email protected]>
Co-authored-by: Binrui Dong <[email protected]>
  • Loading branch information
4 people authored Dec 11, 2023
1 parent d5f611f commit c24fbde
Show file tree
Hide file tree
Showing 13 changed files with 800 additions and 25 deletions.
24 changes: 24 additions & 0 deletions data/json/furniture_and_terrain/terrain-fences-gates.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
"move_cost": 0,
"lockpick_result": "t_chaingate_c",
"lockpick_message": "With a satisfying click, the lock on the gate opens.",
"boltcut": {
"result": "t_chaingate_c",
"duration": "1 seconds",
"sound": "Gachunk!",
"byproducts": [ { "item": "scrap", "count": 3 } ]
},
"flags": [ "TRANSPARENT", "PERMEABLE", "LOCKED", "THIN_OBSTACLE", "BURROWABLE" ],
"connects_to": "CHAINFENCE",
"examine_action": "locked_object_pickable",
Expand Down Expand Up @@ -374,6 +380,12 @@
"symbol": "LINE_OXOX",
"color": "cyan",
"move_cost": 0,
"boltcut": {
"result": "t_chainfence_posts",
"duration": "5 seconds",
"sound": "Snick, snick, gachunk!",
"byproducts": [ { "item": "wire", "count": 20 } ]
},
"flags": [ "TRANSPARENT", "NOITEM", "THIN_OBSTACLE", "PERMEABLE", "UNSTABLE", "CLIMBABLE", "AUTO_WALL_SYMBOL", "BURROWABLE" ],
"connects_to": "CHAINFENCE",
"examine_action": "chainfence",
Expand Down Expand Up @@ -507,6 +519,12 @@
"move_cost": 4,
"flags": [ "TRANSPARENT", "THIN_OBSTACLE", "SHORT", "EASY_DECONSTRUCT", "BURROWABLE" ],
"deconstruct": { "ter_set": "t_fence_post", "items": [ { "item": "wire", "count": 2 } ] },
"boltcut": {
"result": "t_fence_post",
"duration": "10 seconds",
"sound": "Snick, snick, gachunk!",
"byproducts": [ { "item": "wire", "count": 2 } ]
},
"bash": {
"str_min": 8,
"str_max": 20,
Expand All @@ -524,6 +542,12 @@
"symbol": "$",
"color": "blue",
"move_cost": 4,
"boltcut": {
"result": "t_fence_post",
"duration": "10 seconds",
"sound": "Snick, snick, gachunk!",
"byproducts": [ { "item": "wire_barbed", "count": 2 } ]
},
"flags": [ "TRANSPARENT", "SHARP", "THIN_OBSTACLE", "SHORT", "EASY_DECONSTRUCT", "BURROWABLE" ],
"deconstruct": { "ter_set": "t_fence_post", "items": [ { "item": "wire_barbed", "count": 2 } ] },
"bash": {
Expand Down
6 changes: 6 additions & 0 deletions data/json/player_activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@
"verb": "cutting the metal",
"based_on": "speed"
},
{
"id": "ACT_BOLTCUTTING",
"type": "activity_type",
"verb": "cutting the wire",
"based_on": "speed"
},
{
"id": "ACT_PRY_NAILS",
"type": "activity_type",
Expand Down
33 changes: 33 additions & 0 deletions data/mods/TEST_DATA/furniture.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,38 @@
"description": "A freezer that never runs out of juice! Will preserve your bugs during tests.",
"color": "blue",
"extend": { "flags": [ "FREEZER" ] }
},
{
"type": "furniture",
"id": "test_f_boltcut1",
"name": "Boltcut Test Furniture 1",
"description": "Boltcut furniture with valid data.",
"symbol": "f",
"color": "blue",
"move_cost_mod": 1,
"required_str": 8,
"boltcut": { "duration": "5 seconds" }
},
{
"type": "furniture",
"id": "test_f_boltcut2",
"name": "Boltcut Test Furniture 2",
"description": "Boltcut furniture with valid data.",
"symbol": "f",
"color": "blue",
"move_cost_mod": 1,
"required_str": 8,
"boltcut": { "result": "test_f_boltcut1", "duration": "5 seconds" }
},
{
"type": "furniture",
"id": "test_f_boltcut3",
"name": "Boltcut Test Furniture 1",
"description": "Boltcut furniture with valid data.",
"symbol": "f",
"color": "blue",
"move_cost_mod": 1,
"required_str": 8,
"boltcut": { "duration": "80 seconds" }
}
]
32 changes: 32 additions & 0 deletions data/mods/TEST_DATA/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,38 @@
"price": "75 USD",
"price_postapoc": "3 USD"
},
{
"type": "TOOL",
"id": "test_boltcutter",
"name": { "str": "test pair of bolt cutters" },
"description": "Test bolt cutters.",
"weight": "1 kg",
"volume": "1 L",
"symbol": ";"
},
{
"type": "TOOL",
"id": "test_boltcutter_elec",
"copy-from": "test_boltcutter",
"name": { "str": "test electric pair of bolt cutters" },
"description": "Test bolt cutters which uses batteries.",
"charges_per_use": 1,
"ammo": "battery",
"magazines": [
[
"battery",
[
"light_minus_battery_cell",
"light_battery_cell",
"light_plus_battery_cell",
"light_atomic_battery_cell",
"light_minus_atomic_battery_cell",
"light_minus_disposable_cell",
"light_disposable_cell"
]
]
]
},
{
"id": "test_swat_armor",
"repairs_like": "survivor_suit",
Expand Down
26 changes: 26 additions & 0 deletions data/mods/TEST_DATA/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,31 @@
"color": "green",
"roof": "t_strong_roof",
"bash": { "sound": "SMASH!", "ter_set": "t_null", "str_min": 1000, "str_max": 1000 }
},
{
"type": "terrain",
"id": "test_t_boltcut1",
"name": "Boltcut Test Terrain 1",
"description": "Boltcut terrain with valid data.",
"symbol": "t",
"color": "blue",
"move_cost": 2,
"bash": { "sound": "thump", "ter_set": "t_null", "str_min": 50, "str_max": 100, "str_min_supported": 100, "bash_below": true },
"boltcut": { "result": "t_dirt", "duration": "10 seconds" }
},
{
"type": "terrain",
"id": "test_t_boltcut2",
"name": "Boltcut Test Terrain 2",
"description": "Boltcut terrain with valid data.",
"symbol": "t",
"color": "blue",
"move_cost": 2,
"bash": { "sound": "thump", "ter_set": "t_null", "str_min": 50, "str_max": 100, "str_min_supported": 100, "bash_below": true },
"boltcut": {
"result": "t_dirt",
"duration": "5 seconds",
"byproducts": [ { "item": "test_rock", "count": 3 }, { "item": "test_2x4", "count": [ 7, 9 ] } ]
}
}
]
23 changes: 23 additions & 0 deletions doc/src/content/docs/en/mod/json/reference/json_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -2669,6 +2669,29 @@ How much light the furniture produces. 10 will light the tile it's on brightly,
tile and the tiles around it brightly, as well as slightly lighting the tiles two tiles away from
the source. For examples: An overhead light is 120, a utility light, 240, and a console, 10.

#### `boltcut`

(Optional) Data for using with an bolt cutter.

```cpp
"boltcut": {
"result": "furniture_id", // (optional) furniture it will become when done, defaults to f_null
"duration": "1 seconds", // ( optional ) time required for bolt cutting, default is 1 second
"message": "You finish cutting the metal.", // ( optional ) message that will be displayed when finished
"sound": "Gachunk!", // ( optional ) description of the sound when finished
"byproducts": [ // ( optional ) list of items that will be spawned when finished
{
"item": "item_id",
"count": 100 // exact amount
},
{
"item": "item_id",
"count": [ 10, 100 ] // random number in range ( inclusive )
}
]
}
```

#### `required_str`

Strength required to move the furniture around. Negative values indicate an unmovable furniture.
Expand Down
10 changes: 10 additions & 0 deletions lang/extract_json_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,16 @@ def extract_json(state, item):
if "sound_fail" in bash:
writestr(state, bash["sound_fail"])
wrote = True
if "boltcut" in item:
boltcut = item["boltcut"]
if "sound" in boltcut:
c = f"sound of bolt cutting {name}"
writestr(state, boltcut["sound"], comment=c)
wrote = True
if "message" in boltcut:
c = f"message when finished bolt cutting {name}"
writestr(state, boltcut["sound"], comment=c)
wrote = True
if "pry" in item:
pry = item["pry"]
if "sound" in pry:
Expand Down
Loading

0 comments on commit c24fbde

Please sign in to comment.