Skip to content

Commit

Permalink
Merge pull request #77334 from ShnitzelX2/random-npc-equipment
Browse files Browse the repository at this point in the history
Modify random NPC starting equipment based on time passed
  • Loading branch information
Maleclypse authored Oct 30, 2024
2 parents 2536c10 + fb0fa75 commit 625b6ee
Show file tree
Hide file tree
Showing 9 changed files with 476 additions and 53 deletions.
128 changes: 128 additions & 0 deletions data/json/npcs/NC_NONE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
[
{
"type": "item_group",
"id": "NC_NONE_foot",
"subtype": "distribution",
"groups": [ [ "clothing_outdoor_shoes", 50 ], [ "shoes", 25 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_arm",
"subtype": "distribution",
"entries": [ { "item": "null" } ]
},
{
"type": "item_group",
"id": "NC_NONE_hand",
"subtype": "distribution",
"groups": [ [ "clothing_work_gloves", 25 ], [ "common_gloves", 25 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_head",
"subtype": "distribution",
"groups": [ [ "hatstore_hats", 50 ], [ "clothing_work_hat", 25 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_leg",
"subtype": "distribution",
"groups": [ [ "clothing_outdoor_pants", 50 ], [ "pants", 25 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_mouth",
"subtype": "distribution",
"groups": [ [ "hatstore_accessories", 50 ], [ "masks_unisex", 10 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_sensor",
"subtype": "distribution",
"groups": [ "clothing_glasses" ]
},
{
"type": "item_group",
"id": "NC_NONE_torso",
"subtype": "distribution",
"groups": [ [ "clothing_outdoor_torso", 50 ], [ "jackets", 25 ], [ "shirts", 25 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_stabbing",
"subtype": "distribution",
"items": [ "knife_folding" ]
},
{
"type": "item_group",
"id": "NC_NONE_bashing",
"items": [
[ "hammer", 20 ],
[ "wrench", 20 ],
[ "hammer_sledge", 20 ],
[ "pipe", 20 ],
[ "baton-extended", 20 ],
[ "crowbar", 20 ]
]
},
{
"type": "item_group",
"id": "NC_NONE_cutting",
"subtype": "distribution",
"items": [ "knife_cleaver" ]
},
{
"type": "item_group",
"id": "NC_NONE_throw",
"items": [ [ "throwing_knife", 50 ], [ "throwing_axe", 50 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_archery",
"subtype": "distribution",
"items": [ "crossbow" ]
},
{
"type": "item_group",
"id": "NC_NONE_pistol",
"subtype": "distribution",
"groups": [ "guns_pistol_common" ]
},
{
"type": "item_group",
"id": "NC_NONE_shotgun",
"subtype": "distribution",
"groups": [ "guns_shotgun_common" ]
},
{
"type": "item_group",
"id": "NC_NONE_smg",
"subtype": "distribution",
"groups": [ "guns_smg_milspec" ]
},
{
"type": "item_group",
"id": "NC_NONE_rifle",
"subtype": "distribution",
"groups": [ "guns_rifle_common" ]
},
{
"type": "item_group",
"id": "NC_NONE_storage",
"subtype": "distribution",
"groups": [ "bags" ]
},
{
"type": "item_group",
"id": "NC_NONE_extra",
"subtype": "distribution",
"groups": [
[ "vending_drink_items", 70 ],
[ "cannedfood", 50 ],
[ "drugs_heal_simple", 10 ],
[ "big_canned_food", 10 ],
[ "produce", 5 ],
[ "harddrugs", 5 ]
]
}
]
130 changes: 130 additions & 0 deletions data/json/npcs/NC_NONE_HARDENED.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[
{
"type": "item_group",
"id": "NC_NONE_HARDENED_foot",
"subtype": "distribution",
"groups": [ "survivorzed_boots" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_arm",
"subtype": "distribution",
"items": [ { "item": "null" } ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_hand",
"subtype": "distribution",
"groups": [ "survivorzed_gloves" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_head",
"subtype": "distribution",
"groups": [ "survivorzed_head" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_leg",
"subtype": "distribution",
"groups": [ "survivorzed_bottoms" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_mouth",
"subtype": "distribution",
"groups": [ [ "hatstore_accessories", 50 ], [ "clothing_work_mask", 50 ] ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_sensor",
"subtype": "distribution",
"groups": [ "clothing_work_glasses" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_torso",
"subtype": "distribution",
"entries": [
{ "group": "military_ballistic_vest", "prob": 25 },
{ "item": "kevlar", "prob": 25 },
{ "item": "chestguard_hard", "prob": 10 },
{ "group": "survivorzed_tops", "prob": 10 }
]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_stabbing",
"subtype": "distribution",
"items": [ "glaive" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_bashing",
"subtype": "distribution",
"items": [ "bat_metal" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_cutting",
"subtype": "distribution",
"items": [ "sword_sheets_welded_large" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_throw",
"subtype": "distribution",
"entries": [ { "group": "NC_NONE_throw", "prob": 50 }, { "item": "javelin_fletched", "prob": 50 } ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_archery",
"subtype": "distribution",
"items": [ "longbow" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_pistol",
"subtype": "distribution",
"groups": [ "guns_pistol_common" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_shotgun",
"subtype": "distribution",
"groups": [ "guns_shotgun_common" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_smg",
"subtype": "distribution",
"groups": [ "guns_smg_milspec" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_rifle",
"subtype": "distribution",
"groups": [ "guns_rifle_common" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_storage",
"subtype": "distribution",
"groups": [ "bags" ]
},
{
"type": "item_group",
"id": "NC_NONE_HARDENED_extra",
"subtype": "distribution",
"groups": [
[ "NC_NONE_extra", 50 ],
[ "electronics", 10 ],
[ "swat_gear", 5 ],
[ "gear_eod", 5 ],
[ "fireman_gear", 5 ],
[ "rad_gear", 5 ],
[ "military", 5 ],
[ "grenades", 5 ]
]
}
]
6 changes: 6 additions & 0 deletions data/json/npcs/classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
{ "skill": "ALL", "level": { "mul": [ { "one_in": 3 }, { "sum": [ { "dice": [ 4, 2 ] }, { "rng": [ -4, -1 ] } ] } ] } }
]
},
{
"type": "npc_class",
"id": "NC_NONE_HARDENED",
"name": { "str": "No class" },
"job_description": "I'm a dummy class for better NPC items later into the Cataclysm."
},
{
"type": "npc_class",
"id": "NC_TEST_CLASS",
Expand Down
11 changes: 5 additions & 6 deletions data/json/professions.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
{
"type": "profession_item_substitutions",
"item": "socks_wool",
"sub": [ { "present": [ "WOOLALLERGY", "VEGAN" ], "new": [ "socks" ] } ]
"sub": [ { "present": [ "VEGAN" ], "new": [ "socks" ] }, { "present": [ "WOOLALLERGY" ], "new": [ "socks" ] } ]
},
{
"type": "profession_item_substitutions",
Expand Down Expand Up @@ -600,7 +600,7 @@
{
"present": [ "ANTIWHEAT", "ANTIJUNK" ],
"absent": [ "VEGETARIAN" ],
"new": [ { "item": "fish_fried", "ratio": 2 }, { "item": "fork", "ratio": 0.5 } ]
"new": [ { "item": "fish_fried", "ratio": 1 }, { "item": "fork", "ratio": 0.5 } ]
}
]
},
Expand All @@ -618,7 +618,7 @@
{
"present": [ "ANTIWHEAT", "ANTIJUNK" ],
"absent": [ "VEGETARIAN" ],
"new": [ { "item": "fish_fried", "ratio": 2 }, { "item": "fork", "ratio": 0.5 } ]
"new": [ { "item": "fish_fried", "ratio": 1 }, { "item": "fork", "ratio": 0.5 } ]
},
{ "present": [ "MEATARIAN" ], "absent": [ "ANTIWHEAT" ], "new": [ "pizza_meat" ] }
]
Expand Down Expand Up @@ -1262,7 +1262,7 @@
{ "item": "mouthpiece" },
{ "item": "socks_ankle" },
{ "item": "cleats" },
{ "item": "football" },
{ "item": "football", "custom-flags": [ "auto_wield" ] },
{ "item": "knee_pads" },
{ "item": "sports_drink" },
{ "item": "jersey", "snippets": [ "endsville" ] },
Expand Down Expand Up @@ -4095,7 +4095,7 @@
{ "item": "bra" },
{ "item": "panties" },
{ "item": "dress" },
{ "item": "purse" },
{ "item": "purse", "custom-flags": [ "auto_wield" ] },
{ "item": "tourmaline_silver_bracelet" }
]
}
Expand Down Expand Up @@ -5153,7 +5153,6 @@
{ "item": "jacket_light" },
{ "item": "socks" },
{ "item": "sneakers" },
{ "item": "pizza_veggy", "count": 4, "container-item": "null", "entry-wrapper": "box_small" },
{ "item": "pizza_meat", "count": 4, "container-item": "null", "entry-wrapper": "box_small" },
{ "item": "money_strap_one" },
{ "item": "wristwatch" },
Expand Down
22 changes: 22 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,28 @@ void Character::randomize_cosmetics()
}
}

void Character::starting_inv_damage_worn( int days )
{
//damage equipment depending on days passed
int chances_to_damage = std::max( days / 14 + rng( -3, 3 ), 0 );
do {
std::vector<item *> worn_items;
worn.inv_dump( worn_items );
if( !worn_items.empty() ) {
item *to_damage = random_entry( worn_items );
int damage_count = rng( 1, 3 );
bool destroy = false;
do {
destroy = to_damage->inc_damage();
if( destroy ) {
//if the clothing was destroyed in a simulated "dangerous situation", all contained items are lost
i_rem( to_damage );
}
} while( damage_count-- > 0 && !destroy );
}
} while( chances_to_damage-- > 0 );
}

field_type_id Character::bloodType() const
{
if( has_flag( json_flag_ACIDBLOOD ) ) {
Expand Down
4 changes: 4 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ class Character : public Creature, public visitable
/** Returns the id of a random trait matching the given predicate */
trait_id get_random_trait( const std::function<bool( const mutation_branch & )> &func );
void randomize_cosmetic_trait( const std::string &mutation_type );
/** Damages worn equipment
@param days - simulated number of in-game days passed
*/
void starting_inv_damage_worn( int days );

// In mutation.cpp
/** Returns true if the player has a conflicting trait to the entered trait
Expand Down
Loading

0 comments on commit 625b6ee

Please sign in to comment.