Skip to content

Commit

Permalink
Energy Rework Part 5.3
Browse files Browse the repository at this point in the history
Starting with some macros, it's working alright. Updated the firework iuse actions to use the new transforms, removed the `taser2` iuse.

Remind myself to update the hand crank to actually recharge batteries after I'm done here.
  • Loading branch information
KheirFerrum committed Nov 21, 2024
1 parent 1b16cdf commit 098444c
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 258 deletions.
10 changes: 0 additions & 10 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,21 +409,11 @@
"id": "FILL_PIT",
"name": { "str": "Fill pit / tamp ground" }
},
{
"type": "item_action",
"id": "FIRECRACKER",
"name": { "str": "Light up" }
},
{
"type": "item_action",
"id": "FIRECRACKER_ACT",
"name": { "str": "Light up" }
},
{
"type": "item_action",
"id": "FIRECRACKER_PACK",
"name": { "str": "Light up" }
},
{
"type": "item_action",
"id": "FIRECRACKER_PACK_ACT",
Expand Down
22 changes: 20 additions & 2 deletions data/json/items/tool/explosives.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,16 @@
"material": "paper",
"symbol": ";",
"color": "red",
"use_action": "FIRECRACKER",
"use_action": {
"target": "firecracker_act",
"msg": "You light the firecracker.",
"target_charges": 1,
"active": true,
"menu_text": "Light up",
"need_dry": true,
"need_fire": true,
"type": "transform"
},
"flags": [ "GRENADE" ]
},
{
Expand Down Expand Up @@ -416,7 +425,16 @@
"initial_charges": 25,
"max_charges": 25,
"charges_per_use": 1,
"use_action": "FIRECRACKER_PACK",
"use_action": {
"target": "firecracker_pack_act",
"msg": "You light the pack of firecrackers.",
"target_charges": 25,
"active": true,
"menu_text": "Light up",
"need_dry": true,
"need_fire": true,
"type": "transform"
},
"flags": [ "GRENADE" ]
},
{
Expand Down
6 changes: 5 additions & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7822,8 +7822,12 @@ units::energy item::energy_required() const
return 0_J;
}

bool item::energy_sufficient( const Character &ch, units::energy p_needed ) const
bool item::energy_sufficient( const Character &ch, int uses ) const
{
units::energy p_needed = energy_required();
if( uses != -1 ) {
p_needed *= uses;
}
return energy_remaining() >= p_needed;
}

Expand Down
2 changes: 1 addition & 1 deletion src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ class item : public location_visitable<item>, public game_object<item>
units::energy energy_required() const;

/** Check that item has sufficient energy */
bool energy_sufficient( const Character &ch, units::energy p_needed = 0_J ) const;
bool energy_sufficient( const Character &ch, int uses = -1 ) const;

/**
* Consume power(if available) and return the amount of power that was consumed
Expand Down
Loading

0 comments on commit 098444c

Please sign in to comment.