From 79fd6651879e8e4f2560938c21061937ea2aae00 Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Thu, 24 Nov 2022 20:23:10 +0200 Subject: [PATCH 1/7] power_draw json --- .../armor/bespoke_armor/custom_bodysuits.json | 2 +- .../armor/bespoke_armor/custom_storage.json | 2 +- data/json/items/armor/cloaks.json | 2 +- data/json/items/armor/power_armor.json | 12 +++++------ data/json/items/armor/robofac_armor.json | 4 ++-- data/json/items/armor/suits_protection.json | 6 +++--- data/json/items/melee/bludgeons.json | 8 ++++---- data/json/items/melee/swords_and_blades.json | 2 +- data/json/items/tool/cooking.json | 4 ++-- data/json/items/tool/electronics.json | 20 +++++++++---------- data/json/items/tool/landscaping.json | 2 +- data/json/items/tool/lighting.json | 14 ++++++------- data/json/items/tool/misc.json | 4 ++-- data/json/items/tool/radio_tools.json | 2 +- data/json/items/tool/smoking.json | 2 +- data/json/items/tool/woodworking.json | 4 ++-- data/json/items/tool/workshop.json | 4 ++-- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/data/json/items/armor/bespoke_armor/custom_bodysuits.json b/data/json/items/armor/bespoke_armor/custom_bodysuits.json index 0dd46f6dc87ba..af66cb859e8fc 100644 --- a/data/json/items/armor/bespoke_armor/custom_bodysuits.json +++ b/data/json/items/armor/bespoke_armor/custom_bodysuits.json @@ -127,7 +127,7 @@ "description": "A reinforced but airy jumpsuit designed to survive the long-term wear and tear of exploring the apocalyptic wasteland. Its clever construction adds additional core support, helping you to carry more equipment. The internal cooling tubes are active and humming.", "revert_to": "armor_nomad_advanced", "flags": [ "VARSIZE", "POCKETS", "STURDY", "USES_BIONIC_POWER", "MUNDANE" ], - "power_draw": "100 J", + "power_draw": "100 W", "use_action": { "ammo_scale": 0, "type": "transform", diff --git a/data/json/items/armor/bespoke_armor/custom_storage.json b/data/json/items/armor/bespoke_armor/custom_storage.json index 9a43c4917e64d..809ccc1846151 100644 --- a/data/json/items/armor/bespoke_armor/custom_storage.json +++ b/data/json/items/armor/bespoke_armor/custom_storage.json @@ -469,7 +469,7 @@ "copy-from": "nomad_rig", "type": "TOOL_ARMOR", "name": { "str": "nomad harness (on)", "str_pl": "nomad harnesses (on)" }, - "power_draw": "15 J", + "power_draw": "15 W", "revert_to": "nomad_rig", "use_action": { "ammo_scale": 0, diff --git a/data/json/items/armor/cloaks.json b/data/json/items/armor/cloaks.json index abf241b327db5..632e9d1d16672 100644 --- a/data/json/items/armor/cloaks.json +++ b/data/json/items/armor/cloaks.json @@ -444,7 +444,7 @@ "name": { "str": "FB51 optical cloak (on)", "str_pl": "FB51 optical cloaks (on)" }, "description": "A plastic cloak embedded with cameras and LEDs that will render you fully invisible to normal vision when powered and worn. It is turned on, and continually draining power from a UPS. Use it to turn it off.", "flags": [ "USE_UPS", "OVERSIZE", "HOOD", "WATERPROOF", "OUTER", "VARSIZE", "ACTIVE_CLOAKING", "TRADER_AVOID", "SOFT" ], - "power_draw": "20 kJ", + "power_draw": "20 kW", "revert_to": "optical_cloak", "use_action": { "ammo_scale": 0, diff --git a/data/json/items/armor/power_armor.json b/data/json/items/armor/power_armor.json index aef00a5be6254..feb3cc1fb956d 100644 --- a/data/json/items/armor/power_armor.json +++ b/data/json/items/armor/power_armor.json @@ -244,7 +244,7 @@ "name": { "str": "combat exoskeleton (on)", "str_pl": "combat exoskeletons (on)" }, "description": "These were the second wave of military combat exoskeleton, and got a lot of media attention, with popular Navy commercials featuring them heavily. It consists of a muscle-boosting exoskeleton frame with overlaid segmented alloy plating. Despite advancements over the original bulky 'tank suits', the wearer still cannot easily fit through narrow spaces, or sit down comfortably (and it ruins upholstery). There is an integrated chemical-resistant bodyglove that precludes wearing other clothing. It is turned on and continually drawing power. Use it to turn it off.", "flags": [ "USE_UPS", "WATERPROOF", "STURDY", "ELECTRIC_IMMUNE", "TRADER_AVOID", "COMBAT_TOGGLEABLE" ], - "power_draw": "4 kJ", + "power_draw": "4 kW", "revert_to": "power_armor_basic", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s armor disengages.", "target": "power_armor_basic" }, "armor": [ @@ -441,7 +441,7 @@ "name": { "str": "heavy combat exoskeleton (on)", "str_pl": "heavy combat exoskeletons (on)" }, "description": "Colloquially known as a 'tank suit' in the media, these bulky exoskeletons, covered in thick segmented armor plates, were tested in military service a few years back and determined to be too heavy and expensive for regular use. Now that it's in your hands, though, you have a massive suit of power armor capable of resisting almost any small arms fire and most other forms of attack. On the other hand, it doubles your effective weight, and it's almost impossible not to bump into things. There is an integrated chemical-resistant bodyglove that precludes wearing other clothing. It is turned on and continually drawing power. Use it to turn it off.", "flags": [ "USE_UPS", "WATERPROOF", "STURDY", "ELECTRIC_IMMUNE", "TRADER_AVOID", "COMBAT_TOGGLEABLE" ], - "power_draw": "4 kJ", + "power_draw": "4 kW", "revert_to": "power_armor_heavy", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s armor disengages.", "target": "power_armor_heavy" }, "armor": [ @@ -492,7 +492,7 @@ "looks_like": "power_armor_helmet_basic", "name": { "str": "environmental combat helmet (on)", "str_pl": "environmental combat helmets (on)" }, "description": "A fully enclosed combat helmet for hazardous environments, this was designed to fit with a powered exoskeleton, using cameras to expand visual range. In practice, the cameras were unreliable and easily fouled. The environmental controls function best with direct-skin contact. The environmental controls function best with direct-skin contact. It is turned on and continually drawing power. Use it to turn it off.", - "power_draw": "435 mJ", + "power_draw": "435 mW", "revert_to": "power_armor_helmet_basic", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s disengages.", "target": "power_armor_helmet_basic" }, "extend": { "flags": [ "USE_UPS" ] }, @@ -538,7 +538,7 @@ "looks_like": "power_armor_helmet_heavy", "name": { "str": "heavy environmental combat helmet (on)", "str_pl": "heavy environmental combat helmets (on)" }, "description": "An extremely heavy-duty fully enclosed combat helmet for hazardous environments, this was designed to fit with a powered exoskeleton. In the field, soldiers reported that the protection was not worth the awkward size and limited visuals. The environmental controls function best with direct-skin contact. It is turned on and continually drawing power. Use it to turn it off.", - "power_draw": "435 mJ", + "power_draw": "435 mW", "revert_to": "power_armor_helmet_heavy", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s disengages.", "target": "power_armor_helmet_heavy" }, "extend": { "flags": [ "USE_UPS" ] }, @@ -583,7 +583,7 @@ "looks_like": "power_armor_helmet_light", "name": { "str": "light environmental combat helmet (on)", "str_pl": "light environmental combat helmets (on)" }, "description": "This full-enclosure helmet was designed based on commercial diving equipment, in response to complaints that earlier designs were impossible to use in combat. While still a little more restrictive than regular combat headgear - and frustrating should your nose itch - this one received far better reviews from soldiers. Sadly, civilization ended before they could roll out in significant numbers. The environmental controls function best with direct-skin contact. It is turned on and continually drawing power. Use it to turn it off.", - "power_draw": "435 mJ", + "power_draw": "435 mW", "revert_to": "power_armor_helmet_light", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s disengages.", "target": "power_armor_helmet_light" }, "extend": { "flags": [ "USE_UPS" ] }, @@ -710,7 +710,7 @@ "name": { "str": "field combat exoskeleton (on)", "str_pl": "field combat exoskeletons (on)" }, "description": "The final iteration of military power armor before the fall of civilization, this type - a powered exoskeleton with high-tech segmented plating - was designed for actual widespread combat use and was seen on the front lines during the last days of the Cataclysm. Like the heavier suits, it is resistant to most modern weaponry, but it is light and maneuverable, and can fit into normal vehicles and doorways without fuss, a huge advantage over predecessors. Unfortunately, the world ended before it could roll out in significant numbers. There is an integrated chemical-resistant bodyglove that precludes wearing other clothing. It is turned on and continually drawing power. Use it to turn it off.", "flags": [ "USE_UPS", "WATERPROOF", "STURDY", "ELECTRIC_IMMUNE", "TRADER_AVOID", "COMBAT_TOGGLEABLE" ], - "power_draw": "4 kJ", + "power_draw": "4 kW", "revert_to": "power_armor_light", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s armor disengages.", "target": "power_armor_light" }, "armor": [ diff --git a/data/json/items/armor/robofac_armor.json b/data/json/items/armor/robofac_armor.json index 29746bbb685ea..d2d748dc04f4e 100644 --- a/data/json/items/armor/robofac_armor.json +++ b/data/json/items/armor/robofac_armor.json @@ -305,7 +305,7 @@ "description": "Heavy duty hooded headwear for the true frontier explorer. The visor has been lowered over the eyes, and is drawing low power to provide light amplification by way of an infrared illuminator and detector. Activate to switch to full IR scanning.", "copy-from": "robofac_head_rig", "extend": { "flags": [ "GNV_EFFECT" ] }, - "power_draw": "375 mJ", + "power_draw": "375 mW", "revert_to": "robofac_head_rig", "use_action": [ { @@ -342,7 +342,7 @@ "description": "Heavy duty hooded headwear for the true frontier explorer. The visor has been lowered over the eyes, and is drawing moderate power to provide full infra-red scanning, allowing you to see warm blooded creatures in the dark. Activate to turn the visor off again.", "copy-from": "robofac_head_rig", "extend": { "flags": [ "IR_EFFECT" ] }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "robofac_head_rig", "use_action": [ { diff --git a/data/json/items/armor/suits_protection.json b/data/json/items/armor/suits_protection.json index f753a01ead2df..0e61f4effcac5 100644 --- a/data/json/items/armor/suits_protection.json +++ b/data/json/items/armor/suits_protection.json @@ -3057,7 +3057,7 @@ "type": "TOOL_ARMOR", "name": { "str": "nomad plate armor (on)", "str_pl": "nomad plate armors (on)" }, "revert_to": "armor_nomad_plate", - "power_draw": "100 J", + "power_draw": "100 W", "use_action": { "ammo_scale": 0, "type": "transform", @@ -3133,7 +3133,7 @@ "type": "TOOL_ARMOR", "name": { "str": "nomad light plate armor (on)", "str_pl": "nomad light plate armors (on)" }, "revert_to": "armor_nomad_lightplate", - "power_draw": "100 J", + "power_draw": "100 W", "use_action": { "ammo_scale": 0, "type": "transform", @@ -3209,7 +3209,7 @@ "type": "TOOL_ARMOR", "name": { "str": "nomad heavy plate armor (on)", "str_pl": "nomad heavy plate armors (on)" }, "revert_to": "armor_nomad_heavyplate", - "power_draw": "100 J", + "power_draw": "100 W", "use_action": { "ammo_scale": 0, "type": "transform", diff --git a/data/json/items/melee/bludgeons.json b/data/json/items/melee/bludgeons.json index 76a3b5a8a283a..6a6563969045b 100644 --- a/data/json/items/melee/bludgeons.json +++ b/data/json/items/melee/bludgeons.json @@ -394,7 +394,7 @@ "type": "TOOL", "name": { "str": "cheap wizard cane (on)", "str_pl": "cheap wizard canes (on)" }, "color": "blue", - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "wizard_cane_cheap", "use_action": { "menu_text": "Turn off", @@ -446,7 +446,7 @@ "type": "TOOL", "name": { "str": "wizard cane (on)", "str_pl": "wizard canes (on)" }, "color": "blue", - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "wizard_cane", "use_action": { "menu_text": "Turn off", @@ -816,7 +816,7 @@ "description": "Produced by the Light corporation, this stylish staff functions not just as a light source, but also a lightweight weapon thanks to its superalloy construction. Due to proprietary efficiency improvements over standard light sources, batteries last longer in the L-stick. The staff is glowing brightly, which is slowly draining the batteries.", "material": [ "superalloy", "steel" ], "revert_to": "l-stick", - "power_draw": "5 J", + "power_draw": "5 W", "use_action": { "ammo_scale": 0, "target": "l-stick", @@ -1419,7 +1419,7 @@ "type": "TOOL", "name": { "str": "tactical tonfa (on)", "str_pl": "tactical tonfas (on)" }, "description": "A reinforced plastic tonfa; the core is filled with capacitors and a high-yield rechargeable storage battery. When a switch on the handle is pressed, a high-voltage current is transmitted to the two electrodes mounted in the end of the weapon, and by extension to anyone unfortunate enough to be in contact with them. The integral flashlight is turned on, continually draining power and lighting the surrounding area.", - "power_draw": "15 J", + "power_draw": "15 W", "to_hit": { "grip": "weapon", "length": "short", "surface": "every", "balance": "good" }, "revert_to": "shocktonfa_off", "use_action": [ "SHOCKTONFA_ON" ], diff --git a/data/json/items/melee/swords_and_blades.json b/data/json/items/melee/swords_and_blades.json index 6ef8ac3c858f7..31197d6197f4b 100644 --- a/data/json/items/melee/swords_and_blades.json +++ b/data/json/items/melee/swords_and_blades.json @@ -3322,7 +3322,7 @@ "description": "This electric combat chainsaw is on, and is continuously draining power. Use it to turn it off.", "cutting": 50, "to_hit": { "grip": "weapon", "length": "short", "surface": "every", "balance": "neutral" }, - "power_draw": "2 kJ", + "power_draw": "2 kW", "charges_per_use": 0, "revert_to": "e_combatsaw_off", "qualities": [ [ "AXE", 3 ] ], diff --git a/data/json/items/tool/cooking.json b/data/json/items/tool/cooking.json index c7f1525718650..933a0906ee119 100644 --- a/data/json/items/tool/cooking.json +++ b/data/json/items/tool/cooking.json @@ -120,7 +120,7 @@ "description": "This carver is on and the blades are buzzing. Use it to turn it off.", "cutting": 30, "to_hit": 1, - "power_draw": "150 J", + "power_draw": "150 W", "charges_per_use": 0, "revert_to": "carver_off", "qualities": [ [ "CUT", 2 ], [ "BUTCHER", 25 ] ], @@ -674,7 +674,7 @@ "color": "red", "ammo": [ "battery" ], "flags": [ "WATER_BREAK", "ELECTRONIC" ], - "power_draw": "1500 J", + "power_draw": "1500 W", "qualities": [ [ "CONTAIN", 1 ] ], "use_action": [ "MULTICOOKER" ], "pocket_data": [ diff --git a/data/json/items/tool/electronics.json b/data/json/items/tool/electronics.json index 13f1fadefeb7d..1845c68b2f9e1 100644 --- a/data/json/items/tool/electronics.json +++ b/data/json/items/tool/electronics.json @@ -88,7 +88,7 @@ "copy-from": "cell_phone", "type": "TOOL", "name": { "str": "cellphone - Flashlight", "str_pl": "cellphones - Flashlight" }, - "power_draw": "500 mJ", + "power_draw": "500 mW", "revert_to": "cell_phone", "use_action": { "ammo_scale": 0, @@ -188,7 +188,7 @@ "id": "eink_tablet_pc_on", "copy-from": "eink_tablet_pc", "name": { "str": "e-ink tablet PC (on)", "str_pl": "e-ink tablet PCs (on)" }, - "power_draw": "2 J", + "power_draw": "2 W", "revert_to": "eink_tablet_pc", "use_action": [ "EINKTABLETPC", @@ -265,7 +265,7 @@ "type": "TOOL", "name": { "str": "geiger counter (on)", "str_pl": "geiger counters (on)" }, "description": "This is a tool for measuring radiation. It is in continuous scan mode, and will produce quiet clicking sounds in the presence of ambient radiation. Using it allows you to turn it off, or scan yourself or the ground. It is currently on.", - "power_draw": "200 mJ", + "power_draw": "200 mW", "revert_to": "geiger_off", "use_action": [ "GEIGER" ], "flags": [ "TRADER_AVOID", "WATER_BREAK" ] @@ -379,7 +379,7 @@ "copy-from": "laptop", "type": "TOOL", "name": { "str": "laptop computer - lit screen", "str_pl": "laptop computers - lit screen" }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "laptop", "use_action": [ "EINKTABLETPC", @@ -428,7 +428,7 @@ "type": "TOOL", "name": { "str": "mp3 player (on)", "str_pl": "mp3 players (on)" }, "description": "This mp3 player is turned on and playing some great tunes, raising your morale steadily while on your person. It runs through batteries quickly; you can turn it off by using it. It also obscures your hearing.", - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "mp3", "use_action": [ "MP3_ON" ], "flags": [ "TRADER_AVOID", "WATER_BREAK", "ELECTRONIC" ] @@ -466,7 +466,7 @@ "type": "TOOL", "name": { "str": "noise emitter (on)", "str_pl": "noise emitters (on)" }, "description": "This device has been turned on and is emitting horrible crackles, pops and other static sounds. Quick, get away from it before it draws zombies to you!", - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "noise_emitter", "use_action": [ "NOISE_EMITTER_ON" ], "flags": [ "RADIO_MODABLE", "RADIO_INVOKE_PROC", "TRADER_AVOID", "WATER_BREAK" ] @@ -506,7 +506,7 @@ "name": { "str": "EMF detector (on)", "str_pl": "EMF detectors (on)" }, "description": "This device detects and reads out different wave lengths. It currently is humming and beeps with proximity. It is sensitive enough you could use it to get a sense of direction.", "//": "lasts 12 hours with backlight off", - "power_draw": "6 J", + "power_draw": "6 W", "revert_to": "emf_detector", "use_action": [ "EMF_PASSIVE_ON" ], "flags": [ "TRADER_AVOID", "WATER_BREAK", "ELECTRONIC" ] @@ -588,7 +588,7 @@ "type": "TOOL", "name": { "str": "smartphone - music", "str_pl": "smartphones - music" }, "description": "This phone is playing music, steadily raising your morale. You can't hear anything else while you're listening.", - "power_draw": "300 mJ", + "power_draw": "300 mW", "revert_to": "smart_phone", "use_action": [ "MP3_ON", "PORTABLE_GAME", "EINKTABLETPC", "EBOOKSAVE", "EBOOKREAD" ], "extend": { "flags": [ "TRADER_AVOID" ] } @@ -598,7 +598,7 @@ "copy-from": "smart_phone", "type": "TOOL", "name": { "str": "smartphone - Flashlight", "str_pl": "smartphones - Flashlight" }, - "power_draw": "1500 mJ", + "power_draw": "1500 mW", "revert_to": "smart_phone", "use_action": [ "PORTABLE_GAME", @@ -722,7 +722,7 @@ "type": "TOOL", "name": { "str": "gas-powered UPS (on)", "str_pl": "gas-powered UPSes (on)" }, "description": "This is a compact thermoelectric generator. When connected to a fuel tank, it will slowly charge UPS-compatible devices.", - "power_draw": "60 mJ", + "power_draw": "60 mW", "revert_to": "gas_charger", "use_action": { "ammo_scale": 0, diff --git a/data/json/items/tool/landscaping.json b/data/json/items/tool/landscaping.json index cf66a463f06dd..64673a9cdad4a 100644 --- a/data/json/items/tool/landscaping.json +++ b/data/json/items/tool/landscaping.json @@ -384,7 +384,7 @@ "name": { "str": "hedge trimmer (on)", "str_pl": "hedge trimmers (on)" }, "description": "A cordless, double-sided, gasoline-powered hedge trimmer. It is currently on, ready to do some zombie topiary; use this item to turn it off.", "cutting": 40, - "power_draw": "500 J", + "power_draw": "500 W", "charges_per_use": 0, "revert_to": "trimmer_off", "use_action": [ "TRIMMER_ON" ], diff --git a/data/json/items/tool/lighting.json b/data/json/items/tool/lighting.json index 39560daf8689f..de4f154ffba62 100644 --- a/data/json/items/tool/lighting.json +++ b/data/json/items/tool/lighting.json @@ -171,7 +171,7 @@ "copy-from": "electric_lantern", "type": "TOOL", "name": { "str": "electric lantern (on)", "str_pl": "electric lanterns (on)" }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "electric_lantern", "use_action": { "menu_text": "Turn off", "type": "transform", "target": "electric_lantern", "msg": "You turn the lamp off." }, "flags": [ "RADIO_MODABLE", "RADIO_INVOKE_PROC", "LIGHT_15", "TRADER_AVOID", "ALLOWS_REMOTE_USE" ] @@ -214,7 +214,7 @@ "copy-from": "flashlight", "type": "TOOL", "name": { "str": "flashlight (on)", "str_pl": "flashlights (on)" }, - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "flashlight", "use_action": { "menu_text": "Turn off", @@ -406,7 +406,7 @@ "copy-from": "heavy_flashlight", "type": "TOOL", "name": { "str": "heavy-duty flashlight (on)", "str_pl": "heavy-duty flashlights (on)" }, - "power_draw": "15 J", + "power_draw": "15 W", "revert_to": "heavy_flashlight", "use_action": { "ammo_scale": 0, @@ -437,7 +437,7 @@ "copy-from": "lightstrip_base", "description": "This is a light-emitting circuit that has been wired directly to a battery. It provides some weak light and can't be turned off until the battery dies.", "color": "green", - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "lightstrip_inactive", "revert_msg": "The lightstrip dies.", "flags": [ "LIGHT_4", "NO_UNLOAD", "NO_RELOAD", "WATER_BREAK" ], @@ -647,7 +647,7 @@ "type": "TOOL", "name": { "str": "reading light (active)", "str_pl": "reading lights (active)" }, "description": "A little clip-on LED light, meant for reading books in the dark. This one is turned on.", - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "reading_light", "use_action": { "ammo_scale": 0, @@ -698,7 +698,7 @@ "type": "TOOL", "name": { "str": "smart lamp (on)", "str_pl": "smart lamps (on)" }, "description": "This is a smart lamp, this smart lamp is turned on. It can be deactivated remotely.", - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "smart_lamp", "use_action": { "ammo_scale": 0, @@ -808,7 +808,7 @@ "type": "TOOL", "name": { "str": "propane lantern (on)", "str_pl": "propane lanterns (on)" }, "description": "This is a small propane powered lantern. It does not provide much light, but it lasts a long time. It is turned on. Use it to turn it off.", - "power_draw": "60 mJ", + "power_draw": "60 mW", "revert_to": "propane_lantern", "use_action": [ { diff --git a/data/json/items/tool/misc.json b/data/json/items/tool/misc.json index a50640c0176e5..7d52848678670 100644 --- a/data/json/items/tool/misc.json +++ b/data/json/items/tool/misc.json @@ -383,7 +383,7 @@ "type": "TOOL", "name": { "str": "large space heater (on)", "str_pl": "large space heaters (on)" }, "description": "A portable electric heater that steadily emits warm air. Raises temperature about 10 degrees C and fills a larger volume of air than the smaller version.", - "power_draw": "1 kJ", + "power_draw": "1 kW", "emits": [ "emit_hot_air2_blast" ], "flags": [ "ALLOWS_REMOTE_USE", "LIGHT_2" ], "revert_to": "large_space_heater", @@ -583,7 +583,7 @@ "type": "TOOL", "name": { "str": "small space heater (on)", "str_pl": "small space heaters (on)" }, "description": "A portable electric heater that steadily emits warm air. Raises temperature about 10 degrees C.", - "power_draw": "500 J", + "power_draw": "500 W", "emits": [ "emit_hot_air2_stream" ], "flags": [ "ALLOWS_REMOTE_USE", "LIGHT_2" ], "revert_to": "small_space_heater", diff --git a/data/json/items/tool/radio_tools.json b/data/json/items/tool/radio_tools.json index bfeddfa5f4994..40962307126f2 100644 --- a/data/json/items/tool/radio_tools.json +++ b/data/json/items/tool/radio_tools.json @@ -117,7 +117,7 @@ "type": "TOOL", "name": { "str": "radio (on)", "str_pl": "radios (on)" }, "description": "This portable radio is turned on, and continually draining its batteries. It is playing the broadcast being sent from any nearby radio towers.", - "power_draw": "500 mJ", + "power_draw": "500 mW", "revert_to": "radio", "use_action": [ "RADIO_ON" ], "flags": [ "TRADER_AVOID", "WATER_BREAK", "ELECTRONIC" ] diff --git a/data/json/items/tool/smoking.json b/data/json/items/tool/smoking.json index c786126fd1b03..7b1748e58f41e 100644 --- a/data/json/items/tool/smoking.json +++ b/data/json/items/tool/smoking.json @@ -16,7 +16,7 @@ "ammo": [ "battery" ], "flags": [ "WATER_BREAK", "ELECTRONIC" ], "charges_per_use": 1, - "power_draw": "7500 mJ", + "power_draw": "7500 mW", "use_action": [ "ECIG" ], "pocket_data": [ { diff --git a/data/json/items/tool/woodworking.json b/data/json/items/tool/woodworking.json index 07429a79bb7e9..5a9e47712b03a 100644 --- a/data/json/items/tool/woodworking.json +++ b/data/json/items/tool/woodworking.json @@ -115,7 +115,7 @@ "description": "A lightweight handheld cordless circular saw. It is currently on and the blade is spinning; use this item to turn it off.", "cutting": 50, "to_hit": -4, - "power_draw": "1200 J", + "power_draw": "1200 W", "revert_to": "circsaw_off", "qualities": [ [ "CUT", 1 ], [ "SAW_W", 2 ], [ "BUTCHER", -40 ] ], "use_action": [ "CIRCSAW_ON" ], @@ -224,7 +224,7 @@ "to_hit": -4, "bashing": 4, "cutting": 70, - "power_draw": "2 kJ", + "power_draw": "2 kW", "charges_per_use": 0, "revert_to": "elec_chainsaw_off", "qualities": [ [ "AXE", 4 ], [ "BUTCHER", -100 ] ], diff --git a/data/json/items/tool/workshop.json b/data/json/items/tool/workshop.json index e4d3266c1a1ef..c107e178f5dd0 100644 --- a/data/json/items/tool/workshop.json +++ b/data/json/items/tool/workshop.json @@ -76,7 +76,7 @@ "charged_qualities": [ [ "GRIND", 2 ], [ "SAW_M", 10 ] ], "ammo": [ "battery" ], "charges_per_use": 1, - "power_draw": "800 J", + "power_draw": "800 W", "flags": [ "NONCONDUCTIVE", "WATER_BREAK" ], "pocket_data": [ { @@ -972,7 +972,7 @@ "charged_qualities": [ [ "SAW_M", 3 ], [ "SAW_W", 2 ] ], "ammo": [ "battery" ], "charges_per_use": 1, - "power_draw": "800 J", + "power_draw": "800 W", "flags": [ "NONCONDUCTIVE", "WATER_BREAK" ], "pocket_data": [ { From a041518880e37ccea6d8512222f4be148d524df3 Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Thu, 24 Nov 2022 20:23:36 +0200 Subject: [PATCH 2/7] power_draw json --- data/json/items/tool_armor.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/data/json/items/tool_armor.json b/data/json/items/tool_armor.json index d8c1624f03e5c..34529640f6d32 100644 --- a/data/json/items/tool_armor.json +++ b/data/json/items/tool_armor.json @@ -366,7 +366,7 @@ "name": { "str": "mining helmet (on)", "str_pl": "mining helmets (on)" }, "description": "This is a mining helmet with a heavy-duty LED flashlight. The flashlight is turned on, and continually draining its batteries. Use it to turn it off.", "flags": [ "LIGHT_450", "CHARGEDIM", "WATERPROOF", "TRADER_AVOID", "PADDED" ], - "power_draw": "15 J", + "power_draw": "15 W", "revert_to": "miner_hat", "use_action": { "ammo_scale": 0, "menu_text": "Turn off", "type": "transform", "msg": "The %s flicks off.", "target": "miner_hat" }, "techniques": [ "WBLOCK_1" ] @@ -626,7 +626,7 @@ "name": { "str": "pair of thermal electric socks (on)", "str_pl": "pairs of thermal electric socks (on)" }, "description": "This is a pair of socks with internal battery-powered heating elements. They are currently on, and continually draining batteries. Use it to turn them off.", "flags": [ "VARSIZE", "SKINTIGHT", "TRADER_AVOID" ], - "power_draw": "7500 mJ", + "power_draw": "7500 mW", "revert_to": "thermal_socks", "use_action": { "ammo_scale": 0, @@ -681,7 +681,7 @@ "name": { "str": "thermal electric suit (on)", "str_pl": "thermal electric suits (on)" }, "description": "This is a full-body suit of thin thermal underwear equipped with internal battery-powered heating elements. It is currently on, and continually draining batteries. Use it to turn it off.", "flags": [ "VARSIZE", "SKINTIGHT", "TRADER_AVOID" ], - "power_draw": "120 J", + "power_draw": "120 W", "revert_to": "thermal_suit", "warmth": 60, "use_action": { @@ -736,7 +736,7 @@ "name": { "str": "pair of thermal electric gloves (on)", "str_pl": "pairs of thermal electric gloves (on)" }, "description": "This is a pair of gloves with internal battery-powered heating elements. They are currently on, and continually draining batteries. Use it to turn them off.", "flags": [ "VARSIZE", "SKINTIGHT", "TRADER_AVOID" ], - "power_draw": "7500 mJ", + "power_draw": "7500 mW", "revert_to": "thermal_gloves", "use_action": { "ammo_scale": 0, @@ -791,7 +791,7 @@ "name": { "str": "thermal electric balaclava (on)", "str_pl": "thermal electric balaclavas (on)" }, "description": "This is a snug cloth mask with internal battery-powered heating elements. It is are currently on, and continually draining batteries. Use it to turn it off.", "flags": [ "VARSIZE", "SKINTIGHT", "TRADER_AVOID" ], - "power_draw": "7500 mJ", + "power_draw": "7500 mW", "revert_to": "thermal_mask", "use_action": { "ammo_scale": 0, @@ -922,7 +922,7 @@ "name": { "str": "headlamp (on)", "str_pl": "headlamps (on)" }, "description": "This is an LED headlamp with an adjustable strap so as to be comfortably worn on your head or attached to your helmet. It is turned on, and continually draining batteries. Use it to turn it off.", "flags": [ "LIGHT_300", "CHARGEDIM", "OVERSIZE", "BELTED", "PADDED", "ALLOWS_NATURAL_ATTACKS", "TRADER_AVOID" ], - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "wearable_light", "use_action": { "ammo_scale": 0, @@ -976,7 +976,7 @@ "name": { "str": "survivor headlamp (on)", "str_pl": "survivor headlamps (on)" }, "description": "This is a custom-made LED headlamp reinforced to be more durable, brighter, and with a larger and more efficient battery pack. The adjustable strap allows it to be comfortably worn on your head or attached to your helmet. It is turned on, and continually draining batteries. Use it to turn it off.", "flags": [ "LIGHT_350", "CHARGEDIM", "OVERSIZE", "BELTED", "PADDED", "ALLOWS_NATURAL_ATTACKS" ], - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "survivor_light", "use_action": { "ammo_scale": 0, @@ -1163,7 +1163,7 @@ "copy-from": "helmet_eod", "name": { "str": "EOD helmet (on)", "str_pl": "EOD helmets (on)" }, "extend": { "flags": [ "LIGHT_350", "CHARGEDIM", "TRADER_AVOID" ] }, - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "helmet_eod", "use_action": { "type": "transform", "menu_text": "Turn off headlamps", "msg": "\"Disabling illumination.\"", "target": "helmet_eod" } }, @@ -2236,7 +2236,7 @@ "material": [ "plastic", "steel" ], "flags": [ "GNV_EFFECT", "FRAGILE", "TRADER_AVOID", "OUTER" ], "//": "2019 commercial models can operate at under 0.375W with the IR illuminator on", - "power_draw": "375 mJ", + "power_draw": "375 mW", "revert_to": "goggles_nv", "use_action": { "ammo_scale": 0, "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "goggles_nv" }, "warmth": 15, @@ -2290,7 +2290,7 @@ "description": "A pair of battery-powered goggles that grant infrared vision, allowing you to see warm-blooded creatures in the dark. Use it to turn them off.", "material": [ "plastic", "steel" ], "flags": [ "IR_EFFECT", "FRAGILE", "TRADER_AVOID", "OUTER" ], - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "goggles_ir", "use_action": { "ammo_scale": 0, "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "goggles_ir" }, "warmth": 15, @@ -2617,7 +2617,7 @@ "name": { "str": "thermal electric outfit (on)", "str_pl": "thermal electric outfits (on)" }, "description": "This suit of thin thermal underwear covers you from head to toe and is equipped with internal battery-powered heating elements. It is currently on, and continually draining batteries. Use it to turn it off.", "flags": [ "VARSIZE", "SKINTIGHT", "TRADER_AVOID" ], - "power_draw": "130 J", + "power_draw": "130 W", "revert_to": "thermal_outfit", "use_action": { "ammo_scale": 0, @@ -2873,7 +2873,7 @@ "weight": "179 g", "volume": "1 L", "//": "3M Peltors claim to go 100 hours on 2 AAs", - "power_draw": "60 mJ", + "power_draw": "60 mW", "ammo": "battery", "charges_per_use": 1, "revert_to": "powered_earmuffs", @@ -2934,7 +2934,7 @@ "description": "A pair of in-ear drivers designed to dampen loud sounds and amplify quiet sounds. Without batteries or when turned off, they function like normal earplugs and block most sound. They will block sounds over a certain decibel amount when turned on. The earplugs are currently on.", "flags": [ "OVERSIZE", "PARTIAL_DEAF", "USE_UPS", "NO_UNLOAD", "NO_RELOAD" ], "//": "same power draw as the earmuffs, much smaller internal battery", - "power_draw": "60 mJ", + "power_draw": "60 mW", "revert_to": "powered_earplugs", "use_action": { "ammo_scale": 0, @@ -3377,7 +3377,7 @@ "description": "A heated blanket made of polyester. It's turned on, making it nice and toasty while it lasts.", "copy-from": "electric_blanket", "warmth": 90, - "power_draw": "100 J", + "power_draw": "100 W", "revert_to": "electric_blanket", "use_action": { "ammo_scale": 0, @@ -3571,7 +3571,7 @@ "flags": [ "VARSIZE", "STURDY", "PARTIAL_DEAF", "SUN_GLASSES", "TWO_WAY_RADIO", "PADDED" ], "charges_per_use": 1, "ammo": "battery", - "power_draw": "60 mJ", + "power_draw": "60 mW", "revert_to": "flight_helmet", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s flicks off.", "target": "flight_helmet" }, "pocket_data": [ @@ -3659,7 +3659,7 @@ "flags": [ "STURDY", "OVERSIZE", "BELTED", "WATER_FRIENDLY", "TRADER_AVOID" ], "relic_data": { "passive_effects": [ { "has": "WORN", "condition": "ACTIVE", "values": [ { "value": "STRENGTH", "add": 10 } ] } ] }, "ammo": "battery", - "power_draw": "972216 mJ", + "power_draw": "972216 mW", "//": "Battery should last two hours (02:00:07). Weight capacity bonus should include weight of item AND battery, plus 90kg.", "revert_to": "utility_exoskeleton_off", "weight_capacity_bonus": "215 kg", From 8fd4cc2051117cbf7b741bd3a35fab3bde886a5a Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Thu, 24 Nov 2022 20:52:01 +0200 Subject: [PATCH 3/7] power_draw --- src/item.cpp | 16 ++++++++-------- src/item_factory.cpp | 2 +- src/itype.h | 2 +- src/iuse.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index 3178a2ba17e99..81a170df973cc 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3916,7 +3916,7 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, item tmp = *this; //no need to clutter the ui with inactive versions when the armor is already active - if( !( active || ( type->tool && type->tool->power_draw > 0_J ) ) ) { + if( !( active || ( type->tool && type->tool->power_draw > 0_W ) ) ) { bool print_prot = true; if( parts->test( iteminfo_parts::ARMOR_PROTECTION ) ) { print_prot = !tmp.armor_full_protection_info( info, parts ); @@ -10965,8 +10965,8 @@ int item::ammo_consume( int qty, const tripoint &pos, Character *carrier ) // Consume UPS power from various sources if( carrier != nullptr && has_flag( flag_USE_UPS ) ) { - units::energy power_draw = units::from_kilojoule( qty ); - qty -= units::to_kilojoule( carrier->consume_ups( power_draw ) ); + units::energy energy_draw = units::from_kilojoule( qty ); + qty -= units::to_kilojoule( carrier->consume_ups( energy_draw ) ); } // Consume bio pwr directly @@ -13335,7 +13335,7 @@ bool item::process_tool( Character *carrier, const tripoint &pos ) avatar &player_character = get_avatar(); // if insufficient available charges shutdown the tool - if( ( type->tool->turns_per_charge > 0 || type->tool->power_draw > 0_J ) && + if( ( type->tool->turns_per_charge > 0 || type->tool->power_draw > 0_W ) && ammo_remaining( carrier ) == 0 ) { if( carrier && has_flag( flag_USE_UPS ) ) { carrier->add_msg_if_player( m_info, _( "You need an UPS to run the %s!" ), tname() ); @@ -13359,12 +13359,12 @@ bool item::process_tool( Character *carrier, const tripoint &pos ) if( type->tool->turns_per_charge > 0 && to_turn<int>( calendar::turn ) % type->tool->turns_per_charge == 0 ) { energy = std::max( ammo_required(), 1 ); - } else if( type->tool->power_draw > 0_J ) { + } else if( type->tool->power_draw > 0_W ) { // kJ (battery unit) per second - energy = units::to_kilojoule( type->tool->power_draw ); + energy = units::to_kilowatt( type->tool->power_draw ); // energy_bat remainder results in chance at additional charge/discharge - const int kj_in_mj = units::to_millijoule( 1_kJ ); - energy += x_in_y( units::to_millijoule( type->tool->power_draw ) % kj_in_mj, kj_in_mj ) ? 1 : 0; + const int kw_in_mw = units::to_milliwatt( 1_kW ); + energy += x_in_y( units::to_milliwatt( type->tool->power_draw ) % kw_in_mw, kw_in_mw ) ? 1 : 0; } if( energy > 0 ) { diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 87b7920103d30..5231d09df9f59 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -2889,7 +2889,7 @@ void Item_factory::load( islot_tool &slot, const JsonObject &jo, const std::stri assign( jo, "charges_per_use", slot.charges_per_use, strict, 0 ); assign( jo, "charge_factor", slot.charge_factor, strict, 1 ); assign( jo, "turns_per_charge", slot.turns_per_charge, strict, 0 ); - assign( jo, "power_draw", slot.power_draw, strict, 0_J ); + assign( jo, "power_draw", slot.power_draw, strict, 0_W ); assign( jo, "revert_to", slot.revert_to, strict ); assign( jo, "revert_msg", slot.revert_msg, strict ); assign( jo, "sub", slot.subtype, strict ); diff --git a/src/itype.h b/src/itype.h index e572e12d6fc7e..59c2f3db8b667 100644 --- a/src/itype.h +++ b/src/itype.h @@ -107,7 +107,7 @@ struct islot_tool { int charge_factor = 1; int charges_per_use = 0; int turns_per_charge = 0; - units::energy power_draw = 0_J; + units::power power_draw = 0_W; std::vector<int> rand_charges; }; diff --git a/src/iuse.cpp b/src/iuse.cpp index 7a06765a1f8d0..a08076d2d9e12 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -8370,7 +8370,7 @@ cata::optional<int> iuse::multicooker( Character *p, item *it, bool t, const tri mealtime = meal->time_to_craft_moves( *p ) * 2; } - const int all_charges = charges_to_start + mealtime / 100 * units::to_joule( + const int all_charges = charges_to_start + mealtime / 100 * units::to_watt( it->type->tool->power_draw ) / 1000; if( it->ammo_remaining( p ) < all_charges ) { From 03d2888cac815a7fda4bdd635f2358559bae3840 Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Thu, 24 Nov 2022 21:11:37 +0200 Subject: [PATCH 4/7] doc --- doc/ARMOR_BALANCE_AND_DESIGN.md | 2 +- doc/JSON_INFO.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ARMOR_BALANCE_AND_DESIGN.md b/doc/ARMOR_BALANCE_AND_DESIGN.md index 4b17c188b41a1..f0ab337c33798 100644 --- a/doc/ARMOR_BALANCE_AND_DESIGN.md +++ b/doc/ARMOR_BALANCE_AND_DESIGN.md @@ -485,7 +485,7 @@ Items with actions can be worn as armor. Usually you need to swap the type to `` "name": { "str": "survivor headlamp (on)", "str_pl": "survivor headlamps (on)" }, "description": "This is a custom-made LED headlamp reinforced to be more durable, brighter, and with a larger and more efficient battery pack. The adjustable strap allows it to be comfortably worn on your head or attached to your helmet. It is turned on, and continually draining batteries. Use it to turn it off.", "flags": [ "LIGHT_350", "CHARGEDIM", "OVERSIZE", "BELTED", "ALLOWS_NATURAL_ATTACKS" ], - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "survivor_light", "use_action": { "ammo_scale": 0, diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index c30a3ce98cda9..2b9c0544840a7 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -3599,7 +3599,7 @@ Alternately, every item (book, tool, armor, even food) can be used as a gunmod i "initial_charges": 75, // Charges when spawned "max_charges": 75, // Maximum charges tool can hold "rand_charges": [10, 15, 25], // Randomize the charges when spawned. This example has a 50% chance of rng(10, 15) charges and a 50% chance of rng(15, 25). (The endpoints are included.) -"power_draw": "50 mJ", // Energy consumption per second +"power_draw": "50 mW", // Energy consumption per second "revert_to": "torch_done", // Transforms into item when charges are expended "sub": "hotplate", // optional; this tool has the same functions as another tool ``` From da5c769897af914f920d85b86f5169fe1f5a095a Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Thu, 24 Nov 2022 21:25:10 +0200 Subject: [PATCH 5/7] mods --- .../items/armor/exosuit/exosuit_frame.json | 2 +- .../items/armor/exosuit/exosuit_melee.json | 2 +- .../items/armor/exosuit/exosuit_modules.json | 16 ++++++++-------- .../Aftershock/items/armor/winter_masks.json | 4 ++-- .../Aftershock/items/armor/winter_suits.json | 4 ++-- data/mods/Aftershock/items/tool_armor.json | 2 +- data/mods/Aftershock/items/tools.json | 4 ++-- data/mods/TEST_DATA/items.json | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/data/mods/Aftershock/items/armor/exosuit/exosuit_frame.json b/data/mods/Aftershock/items/armor/exosuit/exosuit_frame.json index c90582b4f9f55..d2fd870c0a8ee 100644 --- a/data/mods/Aftershock/items/armor/exosuit/exosuit_frame.json +++ b/data/mods/Aftershock/items/armor/exosuit/exosuit_frame.json @@ -351,7 +351,7 @@ ], "weight_capacity_bonus": "20 kg", "relic_data": { "passive_effects": [ { "has": "WORN", "condition": "ACTIVE", "values": [ { "value": "STRENGTH", "add": 10 } ] } ] }, - "power_draw": "6173 mJ", + "power_draw": "6173 mW", "revert_to": "modular_exosuit", "use_action": [ { "type": "transform", "menu_text": "Turn off", "msg": "The %s disengages.", "target": "modular_exosuit" } ], "armor": [ diff --git a/data/mods/Aftershock/items/armor/exosuit/exosuit_melee.json b/data/mods/Aftershock/items/armor/exosuit/exosuit_melee.json index a41b5c7632260..6ce31711c4647 100644 --- a/data/mods/Aftershock/items/armor/exosuit/exosuit_melee.json +++ b/data/mods/Aftershock/items/armor/exosuit/exosuit_melee.json @@ -101,7 +101,7 @@ "qualities": [ [ "HAMMER", 1 ], [ "DIG", 3 ] ], "extend": { "flags": [ "POWERED", "EXO_LARGE_GADGET" ] }, "to_hit": { "grip": "weapon", "length": "long", "surface": "every", "balance": "clumsy" }, - "power_draw": "1500 mJ", + "power_draw": "1500 mW", "revert_to": "heavy_drill", "use_action": { "ammo_scale": 0, "target": "heavy_drill", "msg": "You deactivate the drill.", "type": "transform" } }, diff --git a/data/mods/Aftershock/items/armor/exosuit/exosuit_modules.json b/data/mods/Aftershock/items/armor/exosuit/exosuit_modules.json index c89f0f55dfa86..1c4622888643e 100644 --- a/data/mods/Aftershock/items/armor/exosuit/exosuit_modules.json +++ b/data/mods/Aftershock/items/armor/exosuit/exosuit_modules.json @@ -185,7 +185,7 @@ "relic_data": { "passive_effects": [ { "has": "WORN", "condition": "ACTIVE", "values": [ { "value": "CARRY_WEIGHT", "add": 20000 } ] } ] }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "exo_carry", "use_action": { "ammo_scale": 0, @@ -232,7 +232,7 @@ "relic_data": { "passive_effects": [ { "has": "WORN", "condition": "ACTIVE", "values": [ { "value": "CARRY_WEIGHT", "add": 10000 } ] } ] }, - "power_draw": "500 mJ", + "power_draw": "500 mW", "revert_to": "exo_small_carry", "use_action": { "ammo_scale": 0, @@ -285,7 +285,7 @@ "copy-from": "exo_flashlight", "type": "TOOL", "name": { "str": "mounted lamp (low)", "str_pl": "mounted lamps (low)" }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "exo_flashlight", "use_action": { "ammo_scale": 0, @@ -301,7 +301,7 @@ "copy-from": "exo_flashlight", "type": "TOOL", "name": { "str": "mounted lamp (high)", "str_pl": "mounted lamps (high)" }, - "power_draw": "2 J", + "power_draw": "2 W", "revert_to": "exo_flashlight", "use_action": { "ammo_scale": 0, @@ -343,7 +343,7 @@ "copy-from": "exo_recoil", "type": "TOOL", "name": { "str": "recoil mitigation system (on)", "str_pl": "recoil mitigation systems (on)" }, - "power_draw": "2 J", + "power_draw": "2 W", "revert_to": "exo_recoil", "use_action": { "ammo_scale": 0, @@ -524,7 +524,7 @@ "material": [ "vacuum_carbide", "qt_steel" ], "symbol": "(", "color": "light_gray", - "power_draw": "5 J", + "power_draw": "5 W", "revert_to": "exo_forcefield", "flags": [ "CANT_WEAR", "ONLY_ONE", "EXO_MEDIUM_GADGET", "USE_UPS" ], "relic_data": { @@ -560,7 +560,7 @@ "material": [ "vacuum_carbide", "qt_steel" ], "symbol": "(", "color": "light_gray", - "power_draw": "5 J", + "power_draw": "5 W", "revert_to": "exo_forcefield", "flags": [ "CANT_WEAR", "ONLY_ONE", "EXO_MEDIUM_GADGET", "USE_UPS" ], "relic_data": { @@ -684,7 +684,7 @@ "type": "TOOL", "copy-from": "exo_AR_module", "name": { "str": "exosuit AR research module (on)", "str_pl": "exosuit AR research modules (on)" }, - "power_draw": "250 mJ", + "power_draw": "250 mW", "revert_to": "exo_AR_module", "use_action": { "ammo_scale": 0, diff --git a/data/mods/Aftershock/items/armor/winter_masks.json b/data/mods/Aftershock/items/armor/winter_masks.json index 3728da0a2bc53..16a9d71366da1 100644 --- a/data/mods/Aftershock/items/armor/winter_masks.json +++ b/data/mods/Aftershock/items/armor/winter_masks.json @@ -59,7 +59,7 @@ "name": { "str": "Magellan helmet CA. (on)", "str_pl": "Magellan helmets CA. (on)" }, "looks_like": "helmet_motor", "description": "The temperature control units and augmented reality overlays of this high-tech garment are currently active, and continuously draining battery power. Use it to turn them off.", - "power_draw": "8170 mJ", + "power_draw": "8170 mW", "warmth": 150, "revert_to": "afs_magellan_suit_helmet", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "afs_magellan_suit_helmet" }, @@ -120,7 +120,7 @@ "name": { "str": "frontier cryomask (on)", "str_pl": "frontier cryomasks (on)" }, "looks_like": "helmet_motor", "description": "The heater of this high-tech garment is currently active, and continuously draining battery power. Use it to turn the heat off.", - "power_draw": "6944 mJ", + "power_draw": "6944 mW", "warmth": 150, "revert_to": "afs_frontier_cryomask", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "afs_frontier_cryomask" } diff --git a/data/mods/Aftershock/items/armor/winter_suits.json b/data/mods/Aftershock/items/armor/winter_suits.json index e503edeef9e88..cecdf9295c9ae 100644 --- a/data/mods/Aftershock/items/armor/winter_suits.json +++ b/data/mods/Aftershock/items/armor/winter_suits.json @@ -59,7 +59,7 @@ "name": { "str": "Magellan exosuit (on)", "str_pl": "Magellan exosuits (on)" }, "looks_like": "afs_cryopod_bodyglove", "description": "The temperature control units of this high-tech garment are currently active, and continuously draining battery power. Use it to turn them off.", - "power_draw": "8170 mJ", + "power_draw": "8170 mW", "warmth": 150, "revert_to": "afs_magellan_suit", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "afs_magellan_suit" } @@ -120,7 +120,7 @@ "name": { "str": "frontier cryo suit (on)", "str_pl": "frontier cryo suits (on)" }, "looks_like": "afs_cryopod_bodyglove", "description": "The temperature control units of this high-tech garment are currently active, and continuously draining battery power. Use it to turn them off.", - "power_draw": "6944 mJ", + "power_draw": "6944 mW", "warmth": 150, "revert_to": "afs_frontier_cryo", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "afs_frontier_cryo" } diff --git a/data/mods/Aftershock/items/tool_armor.json b/data/mods/Aftershock/items/tool_armor.json index 0f55c5d9814d9..525b8a358e361 100644 --- a/data/mods/Aftershock/items/tool_armor.json +++ b/data/mods/Aftershock/items/tool_armor.json @@ -60,7 +60,7 @@ "name": { "str": "cryopod bodyglove (on)", "str_pl": "cryopod bodygloves (on)" }, "looks_like": "afs_cryopod_bodyglove", "description": "The temperature control units of this high-tech garment are currently active, and continuously draining battery power. Use it to turn them off.", - "power_draw": "90 J", + "power_draw": "90 W", "revert_to": "afs_cryopod_bodyglove", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "Your %s deactivates.", "target": "afs_cryopod_bodyglove" }, "flags": [ "STURDY", "WATERPROOF", "THERMOMETER", "RAINPROOF" ] diff --git a/data/mods/Aftershock/items/tools.json b/data/mods/Aftershock/items/tools.json index 106b7dbe2893f..5c719cf4a2cae 100644 --- a/data/mods/Aftershock/items/tools.json +++ b/data/mods/Aftershock/items/tools.json @@ -377,7 +377,7 @@ "copy-from": "control_laptop", "type": "TOOL", "name": { "str": "control laptop - lit screen", "str_pl": "control laptops - lit screen" }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "control_laptop", "use_action": { "target": "control_laptop", "msg": "You stop lighting up the screen.", "menu_text": "Turn off", "type": "transform" }, "flags": [ "WATCH", "LIGHT_10", "TRADER_AVOID" ] @@ -423,7 +423,7 @@ "copy-from": "vr_laptop", "type": "TOOL_ARMOR", "name": { "str": "vr rig - holosuite deployed", "str_pl": "vr rigs - holosuite deployed" }, - "power_draw": "1 J", + "power_draw": "1 W", "revert_to": "vr_laptop", "use_action": { "target": "vr_laptop", "msg": "You power down the virtual overlay.", "menu_text": "Turn off", "type": "transform" }, "flags": [ "WATCH", "TRADER_AVOID" ], diff --git a/data/mods/TEST_DATA/items.json b/data/mods/TEST_DATA/items.json index ab6b7f04af789..bd8f27ef10699 100644 --- a/data/mods/TEST_DATA/items.json +++ b/data/mods/TEST_DATA/items.json @@ -290,7 +290,7 @@ "copy-from": "test_shears_off", "name": { "str": "electric shears (on)" }, "description": "This is a set of electric shears designed to obtain wool from sheep. These shears have been turned on.", - "power_draw": "10 J", + "power_draw": "10 W", "revert_to": "test_shears_off", "use_action": { "type": "transform", "msg": "Your %s deactivates.", "target": "test_shears_off" }, "qualities": [ [ "SHEAR", 3 ] ] @@ -2470,7 +2470,7 @@ "name": { "str": "test power armor (on)" }, "description": "This is a prototype power armor just for testing.", "flags": [ "USE_UPS", "WATERPROOF", "STURDY", "ELECTRIC_IMMUNE", "TRADER_AVOID" ], - "power_draw": "4 kJ", + "power_draw": "4 kW", "revert_to": "test_power_armor", "use_action": { "type": "transform", "menu_text": "Turn off", "msg": "The %s armor disengages.", "target": "test_power_armor" } }, From d5bc6975fd69f30d7ea2efd4e5932b6d4ee6bcbd Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Thu, 24 Nov 2022 21:46:06 +0200 Subject: [PATCH 6/7] assign --- src/assign.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/assign.h | 5 ++++ 2 files changed, 74 insertions(+) diff --git a/src/assign.cpp b/src/assign.cpp index 6700e404f2ac6..459b5a3634c72 100644 --- a/src/assign.cpp +++ b/src/assign.cpp @@ -370,6 +370,75 @@ bool assign( const JsonObject &jo, const std::string &name, units::energy &val, return true; } +bool assign( const JsonObject &jo, const std::string &name, units::power &val, bool strict, + const units::power lo, const units::power hi ) +{ + const auto parse = [&name]( const JsonObject & obj, units::power & out ) { + if( obj.has_int( name ) ) { + const std::int64_t tmp = obj.get_int( name ); + if( tmp > units::to_kilowatt( units::power_max ) ) { + out = units::power_max; + } else { + out = units::from_kilowatt( tmp ); + } + return true; + } + if( obj.has_string( name ) ) { + + out = read_from_json_string<units::power>( obj.get_member( name ), units::power_units ); + return true; + } + return false; + }; + + units::power out; + + // Object via which to report errors which differs for proportional/relative values + const JsonObject *err = &jo; + JsonObject relative = jo.get_object( "relative" ); + relative.allow_omitted_members(); + JsonObject proportional = jo.get_object( "proportional" ); + proportional.allow_omitted_members(); + + // Do not require strict parsing for relative and proportional values as rules + // such as +10% are well-formed independent of whether they affect base value + if( relative.has_member( name ) ) { + units::power tmp; + err = &relative; + if( !parse( *err, tmp ) ) { + err->throw_error_at( name, "invalid relative value specified" ); + } + strict = false; + out = val + tmp; + + } else if( proportional.has_member( name ) ) { + double scalar; + err = &proportional; + if( !err->read( name, scalar ) || scalar <= 0 || scalar == 1 ) { + err->throw_error_at( name, "multiplier must be a positive number other than 1" ); + } + strict = false; + out = val * scalar; + + } else if( !parse( jo, out ) ) { + return false; + } + + if( out < lo || out > hi ) { + err->throw_error_at( name, "value outside supported range" ); + } + + if( strict && out == val ) { + report_strict_violation( *err, + "cannot assign explicit value the same as default or inherited value", + name ); + } + + val = out; + + return true; +} + bool assign( const JsonObject &jo, const std::string &name, nc_color &val ) { if( !jo.has_member( name ) ) { diff --git a/src/assign.h b/src/assign.h index ec9d88af1a397..b99453e37ec64 100644 --- a/src/assign.h +++ b/src/assign.h @@ -229,6 +229,11 @@ bool assign( const JsonObject &jo, const std::string &name, units::energy &val, units::energy lo = units::energy_min, units::energy hi = units::energy_max ); +bool assign( const JsonObject &jo, const std::string &name, units::power &val, + bool strict = false, + units::power lo = units::power_min, + units::power hi = units::power_max ); + bool assign( const JsonObject &jo, const std::string &name, nc_color &val ); class time_duration; From 05af14978b54a7bf2dc04589de055606593ae270 Mon Sep 17 00:00:00 2001 From: Hirmuolio <hirmuolio@gmail.com> Date: Fri, 9 Dec 2022 19:45:48 +0200 Subject: [PATCH 7/7] J->W --- data/json/items/tool/cooking.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/tool/cooking.json b/data/json/items/tool/cooking.json index 5157f6b0398c3..27ef467d48fe7 100644 --- a/data/json/items/tool/cooking.json +++ b/data/json/items/tool/cooking.json @@ -674,7 +674,7 @@ "color": "red", "ammo": [ "battery" ], "flags": [ "WATER_BREAK", "ELECTRONIC" ], - "power_draw": "100 J", + "power_draw": "100 W", "qualities": [ [ "CONTAIN", 1 ] ], "use_action": [ "MULTICOOKER" ], "pocket_data": [