darozak / Advolition

1 stars 0 forks source link

Re equipping a battery adds power #53

Closed darozak closed 5 months ago

darozak commented 5 months ago

Every time a robot re activates the battery, more power is added to the system. I think I need to fix this by subtracting the power when removing the battery. Basically, I need to make sure that the current power doesn't exceed the max power after the battery is removed.

darozak commented 5 months ago

I solved this problem by creating a routine to track power and HP expenditures for individual items and not the robot itself (https://github.com/darozak/Advolition/commit/1fb5a06136f4fbed800b135d8a111f71ab01ee3d).

This means that individual batteries will be charged and drained and that their power levels will be remembered even when unequipped and dropped.

The same mechanism also applies to ablative armor, which takes damage for the robot. However, the damage sticks with the item and not the robot.

I'll also use this approach to track ammunition expenditures.