Skip to content

Commit

Permalink
Merge pull request CleverRaven#79442 from QuillInkwell/aftershock_ven…
Browse files Browse the repository at this point in the history
…ding_machines_use_bank

Vending Machines can optionally use your Bank Balance
  • Loading branch information
GuardianDll authored Feb 1, 2025
2 parents f741f43 + 512d6ab commit 68cdd03
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 23 deletions.
5 changes: 5 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -2686,5 +2686,10 @@
"id": "CANNOT_GAIN_EFFECTS",
"type": "json_flag",
"//": "Creatures with this flag will not gain any new effects or gain extra time on their current ones."
},
{
"id": "BANK_NETWORKED",
"type": "json_flag",
"//": "Vending machines with this flag will allow purchasing items with your bank balance."
}
]
14 changes: 14 additions & 0 deletions data/json/furniture_and_terrain/furniture-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,13 @@
]
}
},
{
"type": "furniture",
"id": "f_vending_reinforced_networked",
"name": "reinforced vending machine",
"copy-from": "f_vending_reinforced",
"extend": { "flags": [ "BANK_NETWORKED" ] }
},
{
"type": "furniture",
"id": "f_vending_reinforced_off",
Expand Down Expand Up @@ -1749,6 +1756,13 @@
"items": [ { "item": "glass_shard", "count": [ 25, 50 ] } ]
}
},
{
"type": "furniture",
"id": "f_vending_c_networked",
"name": "vending machine",
"copy-from": "f_vending_c",
"extend": { "flags": [ "BANK_NETWORKED" ] }
},
{
"type": "furniture",
"id": "f_vending_c_off",
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Aftershock/maps/crashing_ship.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"p": "t_foamcrete_floor_seal",
"z": "t_escape_pod_floor"
},
"vendingmachines": { "V": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true } },
"vendingmachines": { "V": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true } },
"place_zones": [ { "type": "ZONE_START_POINT", "faction": "your_followers", "x": 19, "y": 14 } ],
"mapping": {
"e": { "items": [ { "item": "afs_ballistic_armory", "chance": 20 } ] },
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Aftershock/maps/mapgen/augmentation_clinic.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"?": { "item": "autodoc_supplies", "chance": 100 }
},
"monster": { "ö": { "monster": "mon_skitterbot" } },
"vendingmachines": { "V": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true } }
"vendingmachines": { "V": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true, "networked": true } }
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Aftershock/maps/mapgen/exosuit_garage_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"terrain": { "2": "t_afs_security_gate_closed", "1": "t_afs_door_metal_elocked" },
"furniture": { "4": "f_machinery_light", "5": "f_machinery_electronic" },
"place_monster": [ { "group": "AFS_GROUP_RUIN_MOXIE", "x": [ 0, 23 ], "y": [ 0, 23 ], "pack_size": [ 1, 3 ], "chance": 20 } ],
"vendingmachines": { "3": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true } },
"vendingmachines": { "3": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true } },
"place_nested": [
{ "chunks": [ { "param": "lightstatus", "fallback": "null" } ], "x": 0, "y": 0 },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"afs_light_param_palette"
],
"furniture": { "1": "f_washer", "2": "f_dryer", "3": "f_atm" },
"vendingmachines": { "V": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true } },
"vendingmachines": { "V": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true } },
"place_monster": [
{ "group": "AFS_GROUP_RUIN_MOXIE", "x": [ 0, 23 ], "y": [ 0, 23 ], "pack_size": [ 1, 3 ], "chance": 20 },
{ "group": "AFS_GROUP_RUIN_MOXIE", "x": [ 24, 47 ], "y": [ 0, 23 ], "pack_size": [ 1, 3 ], "chance": 20 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
},
"furniture": { "á": "f_bookcase", "2": "f_bathtub", "6": "f_table" },
"items": { "á": { "item": "homebooks", "repeat": [ 2, 3 ] } },
"vendingmachines": { "V": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true } },
"vendingmachines": { "V": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true } },
"place_monster": [
{ "group": "AFS_GROUP_RUIN_MOXIE", "x": [ 4, 13 ], "y": [ 2, 23 ], "pack_size": [ 1, 3 ], "chance": 30 },
{ "group": "AFS_GROUP_RUIN_MOXIE", "x": [ 34, 43 ], "y": [ 2, 23 ], "pack_size": [ 1, 3 ], "chance": 30 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"é": { "item": "afs_old_food_storage", "chance": 60, "repeat": [ 1, 3 ] },
"ê": { "item": "afs_old_beverage_storage", "chance": 60, "repeat": [ 1, 5 ] }
},
"vendingmachines": { "2": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true } },
"vendingmachines": { "2": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true } },
"place_monster": [ { "group": "AFS_GROUP_RUIN_MOXIE", "x": [ 0, 23 ], "y": [ 0, 23 ], "pack_size": [ 1, 5 ], "chance": 45 } ],
"place_nested": [ { "chunks": [ { "param": "lightstatus", "fallback": "null" } ], "x": 0, "y": 0 } ]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"í": { "item": "afs_tools_agricultural_hazardous", "chance": 90 },
"t": { "item": "farming_tools", "chance": 60, "repeat": [ 2, 3 ] }
},
"vendingmachines": { "V": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true } }
"vendingmachines": { "V": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true, "networked": true } }
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@
"flags": [ "ERASE_ALL_BEFORE_PLACING_TERRAIN" ],
"terrain": { "1": "t_metal_floor", "2": "t_metal_floor", "3": "t_metal_floor" },
"vendingmachines": {
"1": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true },
"2": { "item_group": "afs_vending_ballistic_ammo", "reinforced": true, "powered": true },
"3": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true }
"1": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true },
"2": { "item_group": "afs_vending_ballistic_ammo", "reinforced": true, "powered": true, "networked": true },
"3": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true, "networked": true }
}
}
},
Expand Down Expand Up @@ -457,9 +457,9 @@
"flags": [ "ERASE_ALL_BEFORE_PLACING_TERRAIN" ],
"terrain": { "1": "t_metal_floor", "2": "t_metal_floor", "3": "t_metal_floor" },
"vendingmachines": {
"1": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true },
"2": { "item_group": "afs_vending_ballistic_ammo", "reinforced": true, "powered": true },
"3": { "item_group": "afs_vending_energy_ammo", "reinforced": true, "powered": true }
"1": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true },
"2": { "item_group": "afs_vending_ballistic_ammo", "reinforced": true, "powered": true, "networked": true },
"3": { "item_group": "afs_vending_energy_ammo", "reinforced": true, "powered": true, "networked": true }
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions data/mods/Aftershock/maps/mapgen/s_gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
],
"place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 1, 22 ], "y": [ 1, 22 ], "density": 0.1 } ],
"vendingmachines": {
"ñ": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true },
"V": { "item_group": "plut_cell_vending", "reinforced": true, "powered": true }
"ñ": { "item_group": "afs_vending_false_meals", "reinforced": true, "powered": true, "networked": true },
"V": { "item_group": "plut_cell_vending", "reinforced": true, "powered": true, "networked": true }
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Aftershock/maps/mapgen/urban_worm_farm.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
]
},
"monster": { "ö": { "monster": "mon_skitterbot" } },
"vendingmachines": { "V": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true } }
"vendingmachines": { "V": { "item_group": "afs_vending_medicine", "reinforced": true, "powered": true, "networked": true } }
}
},
{
Expand Down
1 change: 1 addition & 0 deletions doc/JSON/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ List of known flags, used in both `furniture` and `terrain`. Some work for both
- ```BLOCKSDOOR``` This will boost map terrain's resistance to bashing if `str_*_blocked` is set (see `map_bash_info`).
- ```BRIDGE``` If this furniture is placed over water tiles, it prevents player from becoming wet.
- ```FLOATS_IN_AIR``` If this furniture is placed over open air it won't fall.
- ```BANK_NETWORKED``` This vending machine allows purchases with your bank balance as well as your cash cards.
## Generic
Expand Down
14 changes: 13 additions & 1 deletion src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,12 @@ void iexamine::vending( Character &you, const tripoint_bub_ms &examp )
int money = you.charges_of( itype_cash_card );
map_stack vend_items = get_map().i_at( examp );

bool use_bank = get_map().has_flag_furn( "BANK_NETWORKED", examp );

if( use_bank ) {
money = you.cash + you.charges_of( itype_cash_card );
}

if( vend_items.empty() ) {
add_msg( m_info, _( "The vending machine is empty." ) );
return;
Expand Down Expand Up @@ -1375,7 +1381,13 @@ void iexamine::vending( Character &you, const tripoint_bub_ms &examp )
}

money -= iprice;
you.use_charges( itype_cash_card, iprice );

if( iprice < you.charges_of( itype_cash_card ) ) {
// necessary to check just your cash card charges here because aftershock charges your cards first then your bank
you.use_charges( itype_cash_card, iprice );
} else if( use_bank ) {
you.cash -= iprice;
}
you.i_add_or_drop( *cur_item );

vend_items.erase( cur_item );
Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ class map
// 6 liters at 250 ml per charge
void place_toilet( const tripoint_bub_ms &p, int charges = 6 * 4 );
void place_vending( const tripoint_bub_ms &p, const item_group_id &type, bool reinforced = false,
bool lootable = false, bool powered = false );
bool lootable = false, bool powered = false, bool networked = false );
// places an NPC, if static NPCs are enabled or if force is true
character_id place_npc( const point_bub_ms &p, const string_id<npc_template> &type );
void apply_faction_ownership( const point_bub_ms &p1, const point_bub_ms &p2,
Expand Down
23 changes: 18 additions & 5 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ static const furn_str_id furn_f_sign( "f_sign" );
static const furn_str_id furn_f_table( "f_table" );
static const furn_str_id furn_f_toilet( "f_toilet" );
static const furn_str_id furn_f_vending_c( "f_vending_c" );
static const furn_str_id furn_f_vending_c_networked( "f_vending_c_networked" );
static const furn_str_id furn_f_vending_c_off( "f_vending_c_off" );
static const furn_str_id furn_f_vending_reinforced( "f_vending_reinforced" );
static const furn_str_id furn_f_vending_reinforced_networked( "f_vending_reinforced_networked" );
static const furn_str_id furn_f_vending_reinforced_off( "f_vending_reinforced_off" );

static const item_group_id Item_spawn_data_ammo_rare( "ammo_rare" );
Expand Down Expand Up @@ -2205,10 +2207,12 @@ class jmapgen_vending_machine : public jmapgen_piece_with_has_vehicle_collision
mapgen_value<item_group_id> group_id;
bool lootable;
bool powered;
bool networked;
jmapgen_vending_machine( const JsonObject &jsi, const std::string_view/*context*/ ) :
reinforced( jsi.get_bool( "reinforced", false ) )
, lootable( jsi.get_bool( "lootable", false ) )
, powered( jsi.get_bool( "powered", false ) ) {
, powered( jsi.get_bool( "powered", false ) )
, networked( jsi.get_bool( "networked", false ) ) {
if( jsi.has_member( "item_group" ) ) {
group_id = mapgen_value<item_group_id>( jsi.get_member( "item_group" ) );
} else {
Expand All @@ -2223,7 +2227,7 @@ class jmapgen_vending_machine : public jmapgen_piece_with_has_vehicle_collision
if( chosen_id.is_null() ) {
return;
}
dat.m.place_vending( r, chosen_id, reinforced, lootable, powered );
dat.m.place_vending( r, chosen_id, reinforced, lootable, powered, networked );
}

void check( const std::string &oter_name, const mapgen_parameters &parameters,
Expand Down Expand Up @@ -6673,7 +6677,7 @@ void map::place_toilet( const tripoint_bub_ms &p, int charges )
}

void map::place_vending( const tripoint_bub_ms &p, const item_group_id &type, bool reinforced,
bool lootable, bool powered )
bool lootable, bool powered, bool networked )
{
if( !powered ) {
if( reinforced ) {
Expand All @@ -6683,9 +6687,18 @@ void map::place_vending( const tripoint_bub_ms &p, const item_group_id &type, bo
}
} else {
if( reinforced ) {
furn_set( p, furn_f_vending_reinforced );
if( networked ) {
furn_set( p, furn_f_vending_reinforced_networked );
} else {
furn_set( p, furn_f_vending_reinforced );
}
} else {
furn_set( p, furn_f_vending_c );
if( networked ) {
furn_set( p, furn_f_vending_c_networked );
} else {
furn_set( p, furn_f_vending_c );
}

}
}
// The chance to find a non-ransacked vending machine reduces greatly with every day after the Cataclysm,
Expand Down

0 comments on commit 68cdd03

Please sign in to comment.