Skip to content

Commit

Permalink
Shields can interact with ranged attacks, add some vanilla shields (c…
Browse files Browse the repository at this point in the history
…ataclysmbnteam#2851)

* Commit what I've got for the moment

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update character.cpp

* Update character.cpp

* [Eternal Screaming]

* Update src/creature.h

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix it up to a basic working state

* Continue code tweaks, add ballistic shield

* And some hopefully final touches

* Commit what I've got for the moment

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update character.cpp

* Update character.cpp

* [Eternal Screaming]

* Update src/creature.h

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix it up to a basic working state

* Continue code tweaks, add ballistic shield

* Update JSON_FLAGS.md

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* refactor: extract covered by shield

* refactor: extract shieldlevel

* refactor: extract damage calculation

* refactor: use switch instead

using map is kinda overkill

* Fix a slight recipe inconsistency I spotted

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: scarf <[email protected]>
  • Loading branch information
3 people authored May 21, 2023
1 parent 42454cc commit 6dcdd71
Show file tree
Hide file tree
Showing 18 changed files with 331 additions and 12 deletions.
14 changes: 11 additions & 3 deletions data/json/itemgroups/Clothing_Gear/clothing.json
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,8 @@
[ "beret_wool", 40 ],
[ "elbow_pads", 50 ],
[ "knee_pads", 50 ],
[ "solarpack", 5 ]
[ "solarpack", 5 ],
[ "shield_ballistic", 3 ]
]
},
{
Expand Down Expand Up @@ -1903,6 +1904,7 @@
[ "elbow_pads", 40 ],
[ "knee_pads", 40 ],
[ "mask_bal", 5 ],
[ "shield_ballistic", 2 ],
[ "e_tool", 10 ],
[ "waterproof_gunmod", 8 ],
[ "grapnel", 3 ],
Expand Down Expand Up @@ -2398,7 +2400,11 @@
[ "survivor_shavingkit", 3 ],
[ "survivor_hairtrimmer", 1 ],
[ "survivor_scope", 1 ],
[ "survnote", 30 ]
[ "survnote", 30 ],
[ "shield_wooden", 1 ],
[ "shield_wooden_large", 1 ],
[ "shield_riot", 3 ],
[ "shield_ballistic", 2 ]
]
},
{
Expand Down Expand Up @@ -2429,7 +2435,9 @@
[ "legguard_metal", 10 ],
[ "helmet_corinthian", 45 ],
[ "armor_cuirass", 25 ],
[ "legguard_bronze", 20 ]
[ "legguard_bronze", 20 ],
[ "shield_wooden", 10 ],
[ "shield_wooden_large", 5 ]
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion data/json/itemgroups/Clothing_Gear/gear.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
[ "suppressor_compact", 20 ],
[ "swat_armor", 20 ],
[ "tac_fullhelmet", 5 ],
[ "tac_helmet", 10 ]
[ "tac_helmet", 10 ],
[ "shield_riot", 20 ],
[ "shield_ballistic", 5 ]
]
},
{
Expand Down
1 change: 1 addition & 0 deletions data/json/itemgroups/Locations_MapExtras/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@
[ "gloves_tactical", 10 ],
[ "armguard_hard", 20 ],
[ "legguard_hard", 20 ],
[ "shield_riot", 20 ],
[ "emergency_book", 1 ]
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@
[ "silver_medal", 2 ],
[ "gold_medal", 1 ],
[ "bionic_scanner", 5 ],
{ "group": "tinware", "prob": 10 }
{ "group": "tinware", "prob": 10 },
[ "shield_riot", 5 ]
]
},
{
Expand Down
7 changes: 6 additions & 1 deletion data/json/itemgroups/Locations_MapExtras/mansion.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
"id": "soa_mail",
"type": "item_group",
"subtype": "collection",
"items": [ { "group": "soa_weapons_mail" }, [ "chainmail_suit", 100 ] ]
"items": [ { "group": "soa_weapons_mail" }, { "group": "soa_shields_mail", "prob": 50 }, [ "chainmail_suit", 100 ] ]
},
{
"id": "soa_weapons_mail",
Expand All @@ -480,6 +480,11 @@
{ "group": "soa_real_weapon_mail", "prob": 3 }
]
},
{
"id": "soa_shields_mail",
"type": "item_group",
"items": [ [ "shield_wooden", 10 ], [ "shield_wooden_large", 5 ] ]
},
{
"id": "soa_samurai",
"type": "item_group",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@
{ "item": "pur_tablets", "prob": 10 },
{ "item": "pastaextruder", "prob": 10 },
{ "item": "can_sealer", "prob": 10 },
{ "item": "remotevehcontrol", "prob": 8 }
{ "item": "remotevehcontrol", "prob": 8 },
{ "item": "shield_ballistic", "prob": 10 }
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions data/json/itemgroups/art_antiques_crafts.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
{ "item": "tinderbox", "prob": 4 },
{ "item": "flint_steel", "prob": 7 },
{ "item": "canteen_wood", "prob": 5 },
{ "item": "shield_wooden", "prob": 3 },
{ "item": "shield_wooden_large", "prob": 3 },
{ "item": "apron_leather", "prob": 1 },
{ "item": "pot_copper", "prob": 3 },
{ "group": "tinware", "prob": 10 }
Expand Down
88 changes: 88 additions & 0 deletions data/json/items/armor/shields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[
{
"id": "shield_wooden",
"type": "ARMOR",
"name": { "str": "wooden shield" },
"description": "A crude wooden shield, lacking any metal or leather reinforcement. Tolerable weight but not very tough.",
"weight": "3 kg",
"volume": "3 L",
"price": "50 USD",
"price_postapoc": "5 USD",
"to_hit": -1,
"bashing": 8,
"material": [ "wood" ],
"symbol": "[",
"color": "brown",
"covers": [ "arm_either", "hand_either" ],
"coverage": 90,
"encumbrance": 15,
"material_thickness": 3,
"techniques": [ "WBLOCK_2" ],
"flags": [ "OVERSIZE", "BELTED", "RESTRICT_HANDS", "BLOCK_WHILE_WORN" ]
},
{
"id": "shield_wooden_large",
"type": "ARMOR",
"name": { "str": "large wooden shield" },
"description": "An crude wooden tower shield, lacking any metal or leather reinforcement. Bulky, but offers a decent amount of protection.",
"weight": "5 kg",
"volume": "5 L",
"price": "60 USD",
"price_postapoc": "750 cent",
"to_hit": -2,
"bashing": 10,
"material": [ "wood" ],
"symbol": "[",
"color": "brown",
"covers": [ "arm_either", "hand_either" ],
"coverage": 90,
"encumbrance": 25,
"material_thickness": 3,
"techniques": [ "WBLOCK_3" ],
"flags": [ "OVERSIZE", "BELTED", "RESTRICT_HANDS", "BLOCK_WHILE_WORN" ]
},
{
"id": "shield_riot",
"type": "ARMOR",
"name": { "str": "riot shield" },
"description": "A large but fairly light plastic shield, designed for riot police officers. Not too encumbering, but designed for fending off thrown rocks rather than bullets.",
"weight": "2500 g",
"volume": "5 L",
"price": "200 USD",
"price_postapoc": "25 USD",
"to_hit": -1,
"bashing": 4,
"material": [ "plastic" ],
"symbol": "[",
"color": "light_gray",
"covers": [ "arm_either", "hand_either" ],
"coverage": 100,
"encumbrance": 10,
"material_thickness": 4,
"environmental_protection": 3,
"techniques": [ "WBLOCK_3" ],
"flags": [ "OVERSIZE", "BELTED", "RESTRICT_HANDS", "BLOCK_WHILE_WORN" ]
},
{
"id": "shield_ballistic",
"type": "ARMOR",
"name": { "str": "ballistic shield" },
"description": "A heavy composite shield used by SWAT teams and other armed forces. It can handle the occasional pistol bullet, but its heavy-duty nature means it's quite encumbering and doesn't cover the legs very well.",
"weight": "8 kg",
"volume": "4 L",
"price": "1000 USD",
"price_postapoc": "50 USD",
"to_hit": -3,
"bashing": 12,
"material": [ "ceramic", "kevlar" ],
"symbol": "[",
"color": "light_gray",
"covers": [ "arm_either", "hand_either" ],
"coverage": 100,
"encumbrance": 30,
"material_thickness": 6,
"environmental_protection": 2,
"techniques": [ "WBLOCK_2" ],
"flags": [ "OVERSIZE", "BELTED", "RESTRICT_HANDS", "BLOCK_WHILE_WORN" ]
}
]
6 changes: 4 additions & 2 deletions data/json/monsterdrops/zombie_cop.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"collection": [ { "item": "badge_deputy", "prob": 100 }, { "item": "badge_detective", "prob": 20 } ],
"prob": 10
},
{ "item": "cash_card", "charges-min": 0, "charges-max": 50000 }
{ "item": "cash_card", "charges-min": 0, "charges-max": 50000 },
{ "item": "shield_riot", "prob": 5, "damage": [ 1, 4 ] }
]
},
{
Expand Down Expand Up @@ -98,7 +99,8 @@
{ "group": "clothing_glasses", "prob": 5 },
{ "group": "clothing_watch", "prob": 10 },
{ "item": "badge_swat", "prob": 10 },
{ "item": "cash_card", "charges-min": 0, "charges-max": 50000, "prob": 50 }
{ "item": "cash_card", "charges-min": 0, "charges-max": 50000, "prob": 50 },
{ "item": "shield_riot", "prob": 10, "damage": [ 1, 4 ] }
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion data/json/monsterdrops/zombie_soldier.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"collection": [ { "group": "infantry_officer_gear", "prob": 90 }, { "group": "infantry_medical_gear", "prob": 80 } ]
},
{ "item": "cash_card", "prob": 10, "charges-min": 0, "charges-max": 50000 },
{ "group": "misc_smoking", "prob": 30 }
{ "group": "misc_smoking", "prob": 30 },
{ "item": "shield_ballistic", "prob": 10, "damage": [ 1, 4 ] }
]
},
{
Expand Down
32 changes: 32 additions & 0 deletions data/json/recipes/armor/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,37 @@
"time": "4 m",
"autolearn": true,
"components": [ [ [ "water", 1 ], [ "water_clean", 1 ] ], [ [ "towel_soiled", 1 ] ] ]
},
{
"result": "shield_wooden",
"type": "recipe",
"category": "CC_ARMOR",
"subcategory": "CSC_ARMOR_OTHER",
"skill_used": "fabrication",
"difficulty": 2,
"time": "30 m",
"autolearn": true,
"qualities": [ { "id": "CUT", "level": 1 }, { "id": "HAMMER", "level": 1 } ],
"components": [
[ [ "nail", 8 ] ],
[ [ "2x4", 4 ], [ "wood_panel", 1 ] ],
[ [ "rag", 2 ], [ "felt_patch", 2 ], [ "fur", 2 ], [ "leather", 2 ] ]
]
},
{
"result": "shield_wooden_large",
"type": "recipe",
"category": "CC_ARMOR",
"subcategory": "CSC_ARMOR_OTHER",
"skill_used": "fabrication",
"difficulty": 3,
"time": "50 m",
"autolearn": true,
"qualities": [ { "id": "CUT", "level": 1 }, { "id": "HAMMER", "level": 1 } ],
"components": [
[ [ "nail", 16 ] ],
[ [ "2x4", 8 ], [ "wood_panel", 2 ] ],
[ [ "rag", 2 ], [ "felt_patch", 2 ], [ "fur", 2 ], [ "leather", 2 ] ]
]
}
]
18 changes: 17 additions & 1 deletion doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- [Skills](#skills)
- [Tags](#tags)
- [Techniques](#techniques)
- [WBLOCK_X](#wblock-x)
- [Tools](#tools)
- [Flags](#flags-12)
- [Flags that apply to items](#flags-that-apply-to-items)
Expand Down Expand Up @@ -239,7 +240,7 @@ Some armor flags, such as `WATCH` and `ALARMCLOCK` are compatible with other ite
- ```BAROMETER``` This gear is equipped with an accurate barometer (which is used to measure atmospheric pressure).
- ```BELTED``` Layer for backpacks and things worn over outerwear.
- ```BLIND``` Blinds the wearer while worn, and provides nominal protection v. flashbang flashes.
- ```BLOCK_WHILE_WORN``` Allows worn armor or shields to be used for blocking attacks.
- ```BLOCK_WHILE_WORN``` Allows worn armor or shields to be used for blocking attacks. See also the `Techniques` section.
- ```BULLET_IMMNUE``` Wearing an item with this flag makes you immune to bullet damage
- ```CLIMATE_CONTROL``` This piece of clothing has climate control of some sort, keeping you warmer or cooler depending on ambient and bodily temperature.
- ```COLLAR``` This piece of clothing has a wide collar that can keep your mouth warm.
Expand Down Expand Up @@ -1260,6 +1261,21 @@ Techniques may be used by tools, armors, weapons and anything else that can be w
- See contents of `data/json/techniques.json`.
- Techniques are also used with martial arts styles, see `data/json/martialarts.json`.
### WBLOCK_X
The following weapon techniques have some additional usage. These are defensive techniques that allow the item to assist in blocking attacks in melee, with some additional special uses.
- ```WBLOCK_1``` "Medium blocking ability"
- ```WBLOCK_2``` "High blocking ability"
- ```WBLOCK_3``` "Very high blocking ability"
An item with one of these techniques can be wielded to provide a bonus to damage reduced by blocking compared, or armor with the `BLOCK_WHILE_WORN` flag can also provide the use of this bonus while wearing the item, serving as a shield. Additionally, wielding or wearing an item with a combination of one of these techniques plus said flag will allow the item to block projectiles aimed at body parts the item otherwise does not cover (or is not covering, in the case of wielded items that meet those prerequisites). The chance that this will happen is based on the `coverage` percentage of the item used for its normal armor value, reduced by a penalty that depends on which blocking technique it possesses. The chance of it intercepting shots that strike the legs (again, unless the armor was set to cover the legs by default already, in which case it uses `coverage` as normal) is furtther penalized. The feet will always be vulnerable unless (for whatever reason a JSON author may devise, forcefield items for example) an item happens to be a shield that already covers the feet as armor.
Technique | Chance to intercept (head, torso, opposing arm, etc) | Chance to intercept (legs)
-----------|------------------------------------------------------|-------------------------------
WBLOCK_1 | 90% of default coverage value | 75% of default coverage value
WBLOCK_2 | 90% of default coverage value | 75% of default coverage value
WBLOCK_3 | 90% of default coverage value | 75% of default coverage value
## Tools
Expand Down
Loading

0 comments on commit 6dcdd71

Please sign in to comment.