From 9b4d4be94d0956ab07fbaadeb33f70dd4d31039e Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Fri, 29 Mar 2024 11:56:00 +0100 Subject: [PATCH 1/4] Add reinforced nodes: stone and glass Useful when building reactor explosion protection --- nodes.lua | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/nodes.lua b/nodes.lua index 78f683a..5543321 100644 --- a/nodes.lua +++ b/nodes.lua @@ -411,3 +411,85 @@ if not industrialtest.mods.mclRubber then }) end end + +definition={ + description=S("Reinforced Stone"), + tiles={"industrialtest_reinforced_stone.png"} +} +if industrialtest.mtgAvailable then + definition.groups={cracky=3} + definition.sounds=default.node_sound_stone_defaults() + definition.on_blast=function(pos,intensity) + if intensity>20 then + minetest.remove_node(pos) + minetest.add_item(pos,ItemStack("industrialtest:reinforced_stone")) + end + end +elseif industrialtest.mclAvailable then + definition.groups={ + pickaxey=1, + stone=1, + building_block=1, + material_stone=1 + } + definition.sounds=mcl_sounds.node_sound_stone_defaults() + definition._mcl_blast_resistance=1200 + definition._mcl_hardness=5 +end +minetest.register_node("industrialtest:reinforced_stone",definition) +minetest.register_craft({ + type="shaped", + output="industrialtest:reinforced_stone 8", + recipe={ + {industrialtest.elementKeys.stone,industrialtest.elementKeys.stone,industrialtest.elementKeys.stone}, + {industrialtest.elementKeys.stone,"industrialtest:advanced_alloy",industrialtest.elementKeys.stone}, + {industrialtest.elementKeys.stone,industrialtest.elementKeys.stone,industrialtest.elementKeys.stone} + } +}) + +definition={ + description=S("Reinforced Glass"), + drawtype="glasslike_framed_optional", + tiles={"industrialtest_reinforced_glass.png"}, + use_texture_alpha="clip", + paramtype="light", + sunlight_propagates=true +} +if industrialtest.mtgAvailable then + definition.groups={cracky=3} + definition.sounds=default.node_sound_glass_defaults() + definition.on_blast=function(pos,intensity) + if intensity>10 then + minetest.remove_node(pos) + minetest.add_item(pos,ItemStack("industrialtest:reinforced_glass")) + end + end +elseif industrialtest.mclAvailable then + definition.groups={ + glass=1, + building_block=1, + material_glass=1 + } + definition.sounds=mcl_sounds.node_sound_glass_defaults() + definition._mcl_blast_resistance=15 + definition._mcl_hardness=1.5 +end +minetest.register_node("industrialtest:reinforced_glass",definition) +minetest.register_craft({ + type="shaped", + output="industrialtest:reinforced_glass 7", + recipe={ + {industrialtest.elementKeys.glass,industrialtest.elementKeys.glass,industrialtest.elementKeys.glass}, + {"industrialtest:advanced_alloy",industrialtest.elementKeys.glass,"industrialtest:advanced_alloy"}, + {industrialtest.elementKeys.glass,industrialtest.elementKeys.glass,industrialtest.elementKeys.glass} + } +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:reinforced_glass 7", + recipe={ + {industrialtest.elementKeys.glass,"industrialtest:advanced_alloy",industrialtest.elementKeys.glass}, + {industrialtest.elementKeys.glass,industrialtest.elementKeys.glass,industrialtest.elementKeys.glass}, + {industrialtest.elementKeys.glass,"industrialtest:advanced_alloy",industrialtest.elementKeys.glass} + } +}) From b0de1042275cb2bb1aef86bcf56e5448980926bb Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Fri, 29 Mar 2024 11:57:09 +0100 Subject: [PATCH 2/4] Add Reinforced Stone texture --- textures/industrialtest_reinforced_stone.png | Bin 0 -> 869 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 textures/industrialtest_reinforced_stone.png diff --git a/textures/industrialtest_reinforced_stone.png b/textures/industrialtest_reinforced_stone.png new file mode 100644 index 0000000000000000000000000000000000000000..a6263204bc66f07b9d0e2e89764be6b3c98c6011 GIT binary patch literal 869 zcmV-r1DgDaP)EX>4Tx04R}tkv&MmKpe$iQ>7{u2aAX(WT;LSL`58H6^c+H)C#RSm|Xe=O&XFG z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0HI!Dn$-~nG`(Ub z<1sOvSrr4X@M8qsn81L{EMrcR67U>f_we!cF2b|C&;2=i)vUz;pGX{KhFKxrAfDN* z7@YTsL#!aH#OK80CS8#Dk?V@fZ=CZE3p_Jqrjql-A!0G##!4Hrf~gTt6Ngnzr+gvp zvdVdjvsS9I<~{ifgIRrLnd>x%5yv8yAVGwJDvBtff(WfTDHf8nAM@}JIev*;3b~44 z0{s+IiwQ^IFZc;D?biUa3$0!ik1sXNm{yw(t#tGnm2Cnp$zg!1qKS{5( zwD1wow+&oew=`uBxZD8-pA6ZQ9m!8q$mM|dGy0|s(0>c`thv24_i_3Fq^PUJ4RCM> zjO8hN-Q(R|?Y;ebrrF;QvnX=Ft++vM00006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=mQ-JAp})*lJNil02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00BKoL_t(2&s9>(Zp0uA92R4$COzzzwb%at7j(6$f(`2) zCP8UVfb4lDeSdud3FjB_n&<9aip*YYl+bs|TC4SqXL&q+ z0OTz04nRhpLtJpPl+w0s#{#EIDL?>-i0=KW!Otsz*BFws03bX7k^H_c)*7b)l#2}% zA@*UI3{$bH(w Date: Fri, 29 Mar 2024 11:57:37 +0100 Subject: [PATCH 3/4] Add Reinforced Glass texture --- textures/industrialtest_reinforced_glass.png | Bin 0 -> 654 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 textures/industrialtest_reinforced_glass.png diff --git a/textures/industrialtest_reinforced_glass.png b/textures/industrialtest_reinforced_glass.png new file mode 100644 index 0000000000000000000000000000000000000000..a98f724a5697bbd68523933e2ae6b7a34ea2b3d3 GIT binary patch literal 654 zcmV;90&)F`P)EX>4Tx04R}tkv&MmKpe$iQ>7{u2aAX(WT;LSL`58H6^c+H)C#RSm|Xe=O&XFG z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0HI!Dn$-~nG`(Ub z<1sOvSrr4X@M8qsn81L{EMrcR67U>f_we!cF2b|C&;2=i)vUz;pGX{KhFKxrAfDN* z7@YTsL#!aH#OK80CS8#Dk?V@fZ=CZE3p_Jqrjql-A!0G##!4Hrf~gTt6Ngnzr+gvp zvdVdjvsS9I<~{ifgIRrLnd>x%5yv8yAVGwJDvBtff(WfTDHf8nAM@}JIev*;3b~44 z0{s+IiwQ^IFZc;D?biUa3$0!ik1sXNm{yw(t#tGnm2Cnp$zg!1qKS{5( zwD1wow+&oew=`uBxZD8-pA6ZQ9m!8q$mM|dGy0|s(0>c`thv24_i_3Fq^PUJ4RCM> zjO8hN-Q(R|?Y;ebrrF;QvnX=Ft++vM00006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=mQ-IGyxFoJ~IFS02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{003r5L_t(I%VTsfGyBg#3BYGSu&e8TLVB4PC Date: Fri, 29 Mar 2024 12:06:48 +0100 Subject: [PATCH 4/4] Implement Quantum Suit Maximum tier armor with following features: - Breath points refill underwater - Electric Jetpack capabilities - Faster running with Aux1 key - Higher jumping with Aux1 key --- craftitems.lua | 11 ++ init.lua | 1 + tools/nano_suit.lua | 12 +- tools/quantum_suit.lua | 275 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 294 insertions(+), 5 deletions(-) create mode 100644 tools/quantum_suit.lua diff --git a/craftitems.lua b/craftitems.lua index c0a5df6..4b25455 100644 --- a/craftitems.lua +++ b/craftitems.lua @@ -561,6 +561,17 @@ industrialtest.api.registerPlate("lead_plate",S("Lead Plate"),{ } },"#eafef8ff",true) +industrialtest.api.registerPlate("iridium_plate",S("Iridium Plate"),{},false,"#ffffffff") +minetest.register_craft({ + type="shaped", + output="industrialtest:iridium_plate", + recipe={ + {"industrialtest:iridium_ingot","industrialtest:advanced_alloy","industrialtest:iridium_ingot"}, + {"industrialtest:advanced_alloy",industrialtest.elementKeys.diamond,"industrialtest:advanced_alloy"}, + {"industrialtest:iridium_ingot","industrialtest:advanced_alloy","industrialtest:iridium_ingot"} + } +}) + -- Cells minetest.register_craftitem("industrialtest:empty_cell",{ description=S("Empty Cell"), diff --git a/init.lua b/init.lua index 060fa8f..30766cb 100644 --- a/init.lua +++ b/init.lua @@ -66,6 +66,7 @@ dofile(modpath.."/tools/nano_suit.lua") dofile(modpath.."/tools/solar_helmet.lua") dofile(modpath.."/tools/static_boots.lua") dofile(modpath.."/tools/treetap.lua") +dofile(modpath.."/tools/quantum_suit.lua") dofile(modpath.."/tools/wrench.lua") dofile(modpath.."/upgrades.lua") diff --git a/tools/nano_suit.lua b/tools/nano_suit.lua index 0e4147c..0a4d1d1 100644 --- a/tools/nano_suit.lua +++ b/tools/nano_suit.lua @@ -38,7 +38,8 @@ local function registerNanoSuitPart(config) _industrialtest_powerStorage=true, _industrialtest_powerCapacity=1000000, _industrialtest_powerFlow=industrialtest.api.evPowerFlow, - _industrialtest_damageReduction=config.damageReduction + _industrialtest_damageReduction=config.damageReduction, + industrialtest_powerPerDamage=5000 }) elseif industrialtest.mclAvailable then groups.armor=1 @@ -58,7 +59,8 @@ local function registerNanoSuitPart(config) _industrialtest_powerStorage=true, _industrialtest_powerCapacity=1000000, _industrialtest_powerFlow=industrialtest.api.evPowerFlow, - _industrialtest_damageReduction=config.damageReduction + _industrialtest_damageReduction=config.damageReduction, + _industrialtest_powerPerDamage=5000 }) end end @@ -149,12 +151,12 @@ minetest.register_on_player_hpchange(function(player,hpChange) if def.groups and def.groups._industrialtest_nanoSuit then local meta=stack:get_meta() local targetReducedDamage=math.floor(math.abs(hpChange)*def._industrialtest_damageReduction) - local requiredPower=targetReducedDamage*5000 + local requiredPower=targetReducedDamage*def._industrialtest_powerPerDamage local availablePower=math.min(meta:get_int("industrialtest.powerAmount"),requiredPower) - local reducedDamage=math.floor(availablePower/5000) + local reducedDamage=math.floor(availablePower/def._industrialtest_powerPerDamage) if reducedDamage>0 then result=result+reducedDamage - industrialtest.api.addPowerToItem(stack,-reducedDamage*5000) + industrialtest.api.addPowerToItem(stack,-reducedDamage*def._industrialtest_powerPerDamage) inv:set_stack("armor",i,stack) end end diff --git a/tools/quantum_suit.lua b/tools/quantum_suit.lua new file mode 100644 index 0000000..8f1682c --- /dev/null +++ b/tools/quantum_suit.lua @@ -0,0 +1,275 @@ +-- IndustrialTest +-- Copyright (C) 2024 mrkubax10 + +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. + +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. + +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +local S=minetest.get_translator("industrialtest") + +local quantumSuit={} +quantumSuit.helmetBreathRefillOpPower=1000 +quantumSuit.leggingsSpeedOpPower=125 +quantumSuit.leggingsSpeedMaxVel=4 +quantumSuit.bootsJumpOpPower=50 +quantumSuit.bootsFallDamageReductionOpPower=900 + +local playerPositions={} +local playerLeggingsSpeedEnabled={} +local playerBootsJumpEnabled={} + +local function registerQuantumSuitPart(config) + config.groups=config.groups or {} + config.groups._industrialtest_nanoSuit=1 + if config.element=="head" then + config.groups.armor_head=1 + elseif config.element=="torso" then + config.groups.armor_torso=1 + elseif config.element=="legs" then + config.groups.armor_legs=1 + elseif config.element=="feet" then + config.groups.armor_feet=1 + end + local definition={ + description=config.displayName, + inventory_image="industrialtest_"..config.name.."_inv.png", + groups=config.groups, + _industrialtest_powerStorage=true, + _industrialtest_powerCapacity=10000000, + _industrialtest_powerFlow=industrialtest.api.ivPowerFlow, + _industrialtest_damageReduction=config.damageReduction, + _industrialtest_powerPerDamage=30 + } + if config.customKeys then + for k,v in pairs(config.customKeys) do + definition[k]=v + end + end + if industrialtest.mtgAvailable then + definition.groups.armor_heal=0 + armor:register_armor("industrialtest:"..config.name,definition) + elseif industrialtest.mclAvailable then + definition.groups.armor=1 + definition.groups.non_combat_armor=1 + definition.sounds={ + _mcl_armor_equip="mcl_armor_equip_iron", + _mcl_armor_unequip="mcl_armor_unequip_iron" + } + definition.on_place=mcl_armor.equip_on_use + definition.on_secondary_use=mcl_armor.equip_on_use + definition._mcl_armor_element=config.element + definition._mcl_armor_texture=(config.element=="feet" and "industrialtest_mcl_" or "industrialtest_")..config.name..".png" + minetest.register_tool("industrialtest:"..config.name,definition) + end +end + +local function findInPlayerArmorList(player,itemname) + local inv + if industrialtest.mclAvailable then + inv=player:get_inventory() + elseif industrialtest.mtgAvailable then + _,inv=armor:get_valid_player(player,"") + end + local armorList=inv:get_list("armor") + for i,stack in ipairs(armorList) do + if stack:get_name()==itemname then + return i,stack,inv + end + end +end + +quantumSuit.tryFly=function(itemstack) + local meta=itemstack:get_meta() + if meta:get_int("industrialtest.powerAmount")<10 then + return false + end + industrialtest.api.addPowerToItem(itemstack,-10) + return true +end + + +registerQuantumSuitPart({ + name="quantum_helmet", + displayName=S("Quantum Helmet"), + element="head", + damageReduction=0.15 +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:quantum_helmet", + recipe={ + {"industrialtest:reinforced_glass","industrialtest:nano_helmet","industrialtest:reinforced_glass"}, + {"industrialtest:iridium_plate","industrialtest:lapotron_crystal","industrialtest:iridium_plate"}, + {"industrialtest:advanced_electronic_circuit","industrialtest:empty_cell","industrialtest:advanced_electronic_circuit"} + } +}) + +registerQuantumSuitPart({ + name="quantum_bodyarmor", + displayName=S("Quantum Bodyarmor"), + element="torso", + damageReduction=0.4, + groups={ + _industrialtest_jetpack=1 + }, + customKeys={ + _industrialtest_tryFly=quantumSuit.tryFly + } +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:quantum_bodyarmor", + recipe={ + {"industrialtest:advanced_alloy","industrialtest:nano_bodyarmor","industrialtest:advanced_alloy"}, + {"industrialtest:iridium_plate","industrialtest:lapotron_crystal","industrialtest:iridium_plate"}, + {"industrialtest:iridium_plate","industrialtest:electric_jetpack","industrialtest:iridium_plate"} + } +}) + +registerQuantumSuitPart({ + name="quantum_leggings", + displayName=S("Quantum Leggings"), + element="legs", + damageReduction=0.30 +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:quantum_leggings", + recipe={ + {"industrialtest:machine_block","industrialtest:lapotron_crystal","industrialtest:machine_block"}, + {"industrialtest:iridium_plate","industrialtest:nano_leggings","industrialtest:iridium_plate"}, + {industrialtest.elementKeys.yellowDust,"",industrialtest.elementKeys.yellowDust} + } +}) + +registerQuantumSuitPart({ + name="quantum_boots", + displayName=S("Quantum Boots"), + element="feet", + damageReduction=0.15 +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:quantum_boots", + recipe={ + {"industrialtest:iridium_plate","industrialtest:nano_boots","industrialtest:iridium_plate"}, + {industrialtest.elementKeys.ironBoots,"industrialtest:lapotron_crystal",industrialtest.elementKeys.ironBoots} + } +}) + +minetest.register_globalstep(function(dtime) + local players=minetest.get_connected_players() + for _,player in ipairs(players) do + local control=player:get_player_control() + local playerName=player:get_player_name() + if playerLeggingsSpeedEnabled[playerName] then + local shouldStopSpeed=true + if control.up and control.aux1 then + local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_leggings") + if index and stack and inv then + local meta=stack:get_meta() + local requiredPower=vector.distance(player:get_pos(),playerPositions[playerName])*quantumSuit.leggingsSpeedOpPower + if meta:get_int("industrialtest.powerAmount")>=requiredPower then + industrialtest.api.addPowerToItem(stack,-requiredPower) + inv:set_stack("armor",index,stack) + shouldStopSpeed=false + end + end + end + if shouldStopSpeed then + player:set_physics_override({ + speed=1 + }) + playerLeggingsSpeedEnabled[playerName]=false + end + elseif control.up and control.aux1 then + local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_leggings") + if index and stack and inv then + local meta=stack:get_meta() + local requiredPower=vector.distance(player:get_pos(),playerPositions[playerName])*quantumSuit.leggingsSpeedOpPower + if meta:get_int("industrialtest.powerAmount")>=requiredPower then + player:set_physics_override({ + speed=quantumSuit.leggingsSpeedMaxVel + }) + playerLeggingsSpeedEnabled[playerName]=true + end + end + end + + if playerBootsJumpEnabled[playerName] then + local shouldStopJump=not control.aux1 + if control.jump and control.aux1 then + local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_boots") + if index and stack and inv then + local meta=stack:get_meta() + if meta:get_int("industrialtest.powerAmount")>=quantumSuit.bootsJumpOpPower then + industrialtest.api.addPowerToItem(stack,-quantumSuit.bootsJumpOpPower) + inv:set_stack("armor",index,stack) + shouldStopJump=false + end + end + end + if shouldStopJump then + player:set_physics_override({ + jump=1 + }) + playerBootsJumpEnabled[playerName]=false + end + elseif control.aux1 then + local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_boots") + if index and stack and inv then + local meta=stack:get_meta() + local requiredPower=vector.distance(player:get_pos(),playerPositions[playerName])*quantumSuit.leggingsSpeedOpPower + if meta:get_int("industrialtest.powerAmount")>=quantumSuit.bootsJumpOpPower then + player:set_physics_override({ + jump=2 + }) + playerBootsJumpEnabled[playerName]=true + end + end + end + + if player:get_breath()<10 then + local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_helmet") + if index and stack and inv then + local meta=stack:get_meta() + local refilled=math.min(9-player:get_breath(),math.floor(meta:get_int("industrialtest.powerAmount")/quantumSuit.helmetBreathRefillOpPower)) + if refilled>0 then + player:set_breath(player:get_breath()+refilled) + industrialtest.api.addPowerToItem(stack,-refilled*quantumSuit.helmetBreathRefillOpPower) + inv:set_stack("armor",index,stack) + end + end + end + + playerPositions[playerName]=player:get_pos() + end +end) + +minetest.register_on_player_hpchange(function(player,hpChange,reason) + if reason.type~="fall" then + return hpChange + end + + local index,stack,inv=findInPlayerArmorList(player,"industrialtest:quantum_boots") + if not index or not stack or not inv then + return hpChange + end + + local damage=math.abs(hpChange) + local meta=stack:get_meta() + local reducedDamage=math.min(damage,math.floor(meta:get_int("industrialtest.powerAmount")/(damage*quantumSuit.bootsFallDamageReductionOpPower))) + industrialtest.api.addPowerToItem(stack,-reducedDamage*quantumSuit.bootsFallDamageReductionOpPower) + inv:set_stack("armor",index,stack) + + return hpChange+reducedDamage +end,true)