From d43aa217c7373bfb91a251ed191f3789d64dfd2d Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Fri, 19 Jul 2019 15:07:44 -0400 Subject: [PATCH 1/2] automatic racial techs --- player.config.patch | 40 ++++++++-------- scripts/techHandler.lua | 67 ++++++++++++++++++++++++++ species/avali.raceeffect | 3 +- species/avian.raceeffect | 3 +- species/cat.raceeffect | 5 +- species/elduukhar.raceeffect | 3 +- species/felin.raceeffect | 3 +- species/fenerox.raceeffect | 3 +- species/gyrusen.raceeffect | 3 +- species/juux.raceeffect | 3 +- species/kazdra.raceeffect | 3 +- species/moogle.raceeffect | 3 +- species/nightar.raceeffect | 4 +- species/novali.raceeffect | 3 +- species/radien.raceeffect | 93 +++++++++++------------------------- species/saturn.raceeffect | 3 +- species/saturn2.raceeffect | 3 +- species/sergal.raceeffect | 3 +- species/shadow.raceeffect | 3 +- species/thelusian.raceeffect | 3 +- species/veluu.raceeffect | 3 +- 21 files changed, 150 insertions(+), 107 deletions(-) create mode 100644 scripts/techHandler.lua diff --git a/player.config.patch b/player.config.patch index 4199fce0..311b8668 100644 --- a/player.config.patch +++ b/player.config.patch @@ -1,23 +1,21 @@ [ - { - "op": "remove", - "path": "/statusControllerSettings/resources/food/maxValue" - }, - { - "op": "add", - "path": "/statusControllerSettings/resources/food/maxStat", - "value": "maxFood" - }, - { - "op": "add", - "path": "/statusControllerSettings/stats/maxFood", - "value": { - "baseValue": 70 - } - }, - { "op": "add", "path": "/defaultBlueprints/tier1/-", "value": {"item": "robosnax"} }, - { "op": "add", "path": "/defaultBlueprints/tier1/-", "value": {"item": "raceEffectEnabler"} }, - { "op": "add", "path": "/defaultBlueprints/tier1/-", "value": {"item": "meatkibble"} }, - { "op": "add", "path" : "/statusControllerSettings/primaryScriptSources/-" , "value" : "/scripts/raceEffects.lua" } - + { + "op": "remove", + "path": "/statusControllerSettings/resources/food/maxValue" + }, + { + "op": "add", + "path": "/statusControllerSettings/resources/food/maxStat", + "value": "maxFood" + }, + { + "op": "add", + "path": "/statusControllerSettings/stats/maxFood", + "value": { "baseValue": 70 } + }, + { "op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : {"item": "robosnax"} }, + //{ "op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : {"item": "raceEffectEnabler"} }, + { "op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : {"item": "meatkibble"} }, + { "op" : "add", "path" : "/statusControllerSettings/primaryScriptSources/-" , "value" : "/scripts/raceEffects.lua" }, + { "op" : "add", "path" : "/companionsConfig/scripts/-", "value" : "/scripts/techHandler.lua" } ] \ No newline at end of file diff --git a/scripts/techHandler.lua b/scripts/techHandler.lua new file mode 100644 index 00000000..2ce0c939 --- /dev/null +++ b/scripts/techHandler.lua @@ -0,0 +1,67 @@ +--require("/scripts/vec2.lua") +--require("/scripts/FRHelper.lua") + +local FR_old_init = init +--local FR_old_update = update + +function init() + FR_old_init() + local species = player.species() + local _,speciesConfig = pcall( function () return root.assetJson(string.format("/species/%s.raceeffect", species)) end ) + if speciesConfig and speciesConfig.tech then + for _,tech in pairs(speciesConfig.tech) do + local playerTechs = player.availableTechs() + player.makeTechAvailable(tech) + if #(player.availableTechs()) > #playerTechs then -- check to see if this added a tech (if not, we have it already) + player.enableTech(tech) + player.equipTech(tech) + end + end + end +end + +--[[function update(dt) + FR_old_update(dt) + + if not self.species then + self.species = world.entitySpecies(entity.id()) + self.helper = FRHelper:new(self.species, world.entityGender(entity.id())) + + -- Script setup + for map,path in pairs(self.helper.frconfig.scriptMaps) do + if self.helper.speciesConfig[map] then + self.helper:loadScript({script=path, args=self.helper.speciesConfig[map]}) + end + end + for _,script in pairs(self.helper.speciesConfig.scripts or {}) do + self.helper:loadScript(script) + end + + -- Apply the persistent effect + status.setPersistentEffects("FR_racialStats", self.helper.speciesConfig.stats or {}) + + -- Add any other special effects + if self.helper.speciesConfig.special then + for _,thing in pairs(self.helper.speciesConfig.special) do + status.addEphemeralEffect(thing,math.huge) + end + end + end + + -- Update stuff + --self.helper:clearPersistent() + self.helper:applyControlModifiers() + self.helper:runScripts("racialscript", self, dt) + + -- Breath handling + if entity.entityType() ~= "npc" then + local mouthPosition = vec2.add(mcontroller.position(), status.statusProperty("mouthPosition")) + if status.statPositive("breathProtection") or world.breathable(mouthPosition) + or status.statPositive("waterbreathProtection") and world.liquidAt(mouthPosition) + then + status.modifyResource("breath", status.stat("breathRegenerationRate") * dt) + else + status.modifyResource("breath", -status.stat("breathDepletionRate") * dt) + end + end +end]] diff --git a/species/avali.raceeffect b/species/avali.raceeffect index 9d974767..29149651 100644 --- a/species/avali.raceeffect +++ b/species/avali.raceeffect @@ -95,5 +95,6 @@ } } } - } + }, + "tech" : [ "flight_avali" ] } \ No newline at end of file diff --git a/species/avian.raceeffect b/species/avian.raceeffect index 3967ffb5..4afbf797 100644 --- a/species/avian.raceeffect +++ b/species/avian.raceeffect @@ -85,5 +85,6 @@ } } } - } + }, + "tech" : [ "flight_avian" ] } \ No newline at end of file diff --git a/species/cat.raceeffect b/species/cat.raceeffect index 60ab7641..e0709d23 100644 --- a/species/cat.raceeffect +++ b/species/cat.raceeffect @@ -98,7 +98,6 @@ ] } ], - "special": [ - "headlampcat" - ] + "special": [ "headlampcat" ], + "tech" : [ "veluuclaw" ] } \ No newline at end of file diff --git a/species/elduukhar.raceeffect b/species/elduukhar.raceeffect index 7849495a..e85ec58b 100644 --- a/species/elduukhar.raceeffect +++ b/species/elduukhar.raceeffect @@ -129,5 +129,6 @@ ], "special": [ "elduukharBonus" - ] + ], + "tech" : [ "elduukharburst" ] } \ No newline at end of file diff --git a/species/felin.raceeffect b/species/felin.raceeffect index c0cf7852..4f1e2c38 100644 --- a/species/felin.raceeffect +++ b/species/felin.raceeffect @@ -110,5 +110,6 @@ } ] } - ] + ], + "tech" : [ "huntersclaw" ] } \ No newline at end of file diff --git a/species/fenerox.raceeffect b/species/fenerox.raceeffect index 27ac1663..8d3020ad 100644 --- a/species/fenerox.raceeffect +++ b/species/fenerox.raceeffect @@ -87,5 +87,6 @@ }], "special": [ "darkregenfenerox" - ] + ], + "tech" : [ "huntersclaw" ] } \ No newline at end of file diff --git a/species/gyrusen.raceeffect b/species/gyrusen.raceeffect index 98dd7ace..dff369df 100644 --- a/species/gyrusen.raceeffect +++ b/species/gyrusen.raceeffect @@ -66,5 +66,6 @@ "baseMultiplier": 1.15 }] } - ] + ], + "tech" : [ "minersclaw" ] } \ No newline at end of file diff --git a/species/juux.raceeffect b/species/juux.raceeffect index 06cc9a41..d68d5d8a 100644 --- a/species/juux.raceeffect +++ b/species/juux.raceeffect @@ -121,5 +121,6 @@ } ], "weaponScripts": [], - "special": [ ] + "special": [ ], + "tech" : [ "juuxharden" ] } \ No newline at end of file diff --git a/species/kazdra.raceeffect b/species/kazdra.raceeffect index 4ed0eb5f..bfe7e294 100644 --- a/species/kazdra.raceeffect +++ b/species/kazdra.raceeffect @@ -82,5 +82,6 @@ }], "special": [ "kazdraBonus" - ] + ], + "tech" : [ "dragonfireburst" ] } \ No newline at end of file diff --git a/species/moogle.raceeffect b/species/moogle.raceeffect index c15a63e4..aa102fee 100644 --- a/species/moogle.raceeffect +++ b/species/moogle.raceeffect @@ -126,5 +126,6 @@ } } } - } + }, + "tech" : [ "flight_moogle" ] } diff --git a/species/nightar.raceeffect b/species/nightar.raceeffect index ad22ac24..c7e68552 100644 --- a/species/nightar.raceeffect +++ b/species/nightar.raceeffect @@ -135,6 +135,6 @@ } ], - "special": [ "nightarglow3", "darkhunternightar", "drainnightar"] - + "special": [ "nightarglow3", "darkhunternightar", "drainnightar"], + "tech" : [ "nightarconshak" ] } \ No newline at end of file diff --git a/species/novali.raceeffect b/species/novali.raceeffect index e1d8eb28..d152c9fc 100644 --- a/species/novali.raceeffect +++ b/species/novali.raceeffect @@ -152,5 +152,6 @@ } } } - } + }, + "tech" : [ "flight_avali" ] } diff --git a/species/radien.raceeffect b/species/radien.raceeffect index 86bca5a1..6a8330c2 100644 --- a/species/radien.raceeffect +++ b/species/radien.raceeffect @@ -1,76 +1,39 @@ { - "stats": [ - { - "stat": "maxHealth", - "baseMultiplier": 0.90 - }, - { - "stat": "maxEnergy", - "baseMultiplier": 1.1 - }, - - { - "stat": "foodDelta", - "baseMultiplier": 1.25 - }, - { - "stat": "radiationburnImmunity", - "amount": 1 - }, - { - "stat": "healingStatusImmunity", - "amount": 1 - } + "stats" : [ + { "stat" : "maxHealth", "baseMultiplier" : 0.90 }, + { "stat" : "maxEnergy", "baseMultiplier" : 1.1 }, + { "stat" : "foodDelta", "baseMultiplier" : 1.25 }, + { "stat" : "radiationburnImmunity", "amount" : 1 }, + { "stat" : "healingStatusImmunity", "amount" : 1 } ], "diet" : "entity", - "special": [ "radienFoodBoost" ], + "special" : [ "radienFoodBoost" ], - "envEffects": [{ - "biomes": [ - "hot" - ], - "stats": [{ - "stat": "protection", - "effectiveMultiplier": 0.85 - }, - { - "stat": "foodDelta", - "baseMultiplier": 1.35 - } + "envEffects" : [ + { + "biomes" : [ "hot" ], + "stats" : [ + { "stat" : "protection", "effectiveMultiplier" : 0.85 }, + { "stat" : "foodDelta", "baseMultiplier" : 1.35 } ] }, { - "biomes": [ - "toxic", - "alien", - "protoworld", - "irradiated", - "chromatic", - "protoworlddark", - "jungle", - "fungus", - "fungal" - ], - "stats": [{ - "stat": "powerMultiplier", - "baseMultiplier": 1.15 - }, - { - "stat": "energyRegenPercentageRate", - "baseMultiplier": 1.15 - }, - { - "stat": "foodDelta", - "baseMultiplier": 1.05 - } + "biomes" : [ "toxic", "alien", "protoworld", "irradiated", "chromatic", "protoworlddark", "jungle", "fungus", "fungal" ], + "stats" : [ + { "stat" : "powerMultiplier", "baseMultiplier" : 1.15 }, + { "stat" : "energyRegenPercentageRate", "baseMultiplier" : 1.15 }, + { "stat" : "foodDelta", "baseMultiplier" : 1.05 } + ] + } + ], + "weaponEffects" : [ + { + "weapons" : [ "radien" ], + "stats" : [ + { "stat" : "critChance", "amount" : 1.5 }, + { "stat" : "protection", "effectiveMultiplier" : 1.15 } ] } ], - "weaponEffects": [{ - "weapons": [ "radien" ], - "stats": [ - {"stat": "critChance","amount": 1.5}, - {"stat": "protection","effectiveMultiplier": 1.15} - ] - }] + "tech" : [ "xi_bulb" ] } \ No newline at end of file diff --git a/species/saturn.raceeffect b/species/saturn.raceeffect index 5b02049a..31a1340a 100644 --- a/species/saturn.raceeffect +++ b/species/saturn.raceeffect @@ -66,5 +66,6 @@ "effectiveMultiplier": 1.2 }] } - ] + ], + "tech" : [ "flight_saturnian" ] } \ No newline at end of file diff --git a/species/saturn2.raceeffect b/species/saturn2.raceeffect index 0f6ff687..ff4db892 100644 --- a/species/saturn2.raceeffect +++ b/species/saturn2.raceeffect @@ -60,5 +60,6 @@ "weapons": ["scythe"], "stats": [{"stat": "powerMultiplier","effectiveMultiplier": 1.12}] } - ] + ], + "tech" : [ "flight_saturnianmoth" ] } \ No newline at end of file diff --git a/species/sergal.raceeffect b/species/sergal.raceeffect index 541231b7..762d76e8 100644 --- a/species/sergal.raceeffect +++ b/species/sergal.raceeffect @@ -83,5 +83,6 @@ } ] } - ] + ], + "tech" : [ "huntersclaw" ] } \ No newline at end of file diff --git a/species/shadow.raceeffect b/species/shadow.raceeffect index a32c04c4..b1dff312 100644 --- a/species/shadow.raceeffect +++ b/species/shadow.raceeffect @@ -84,5 +84,6 @@ "special": [ "shadowglow1", "darkhunternightar" - ] + ], + "tech" : [ "tenebrhaeburst" ] } \ No newline at end of file diff --git a/species/thelusian.raceeffect b/species/thelusian.raceeffect index 176fdceb..816d6fe3 100644 --- a/species/thelusian.raceeffect +++ b/species/thelusian.raceeffect @@ -117,5 +117,6 @@ "energyAmt": 0.25 } } - ] + ], + "tech" : [ "bugarmor" ] } \ No newline at end of file diff --git a/species/veluu.raceeffect b/species/veluu.raceeffect index 5a925ca1..04b72223 100644 --- a/species/veluu.raceeffect +++ b/species/veluu.raceeffect @@ -49,5 +49,6 @@ ] } ], - "special" : [ "headlampveluu" ] + "special" : [ "headlampveluu" ], + "tech" : [ "veluuclaw" ] } \ No newline at end of file From ec2ab55586c08363c7dde413711001cb3e0cb1de Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Fri, 19 Jul 2019 15:13:11 -0400 Subject: [PATCH 2/2] oop --- scripts/techHandler.lua | 50 ----------------------------------------- 1 file changed, 50 deletions(-) diff --git a/scripts/techHandler.lua b/scripts/techHandler.lua index 2ce0c939..0c766a9a 100644 --- a/scripts/techHandler.lua +++ b/scripts/techHandler.lua @@ -1,8 +1,4 @@ ---require("/scripts/vec2.lua") ---require("/scripts/FRHelper.lua") - local FR_old_init = init ---local FR_old_update = update function init() FR_old_init() @@ -19,49 +15,3 @@ function init() end end end - ---[[function update(dt) - FR_old_update(dt) - - if not self.species then - self.species = world.entitySpecies(entity.id()) - self.helper = FRHelper:new(self.species, world.entityGender(entity.id())) - - -- Script setup - for map,path in pairs(self.helper.frconfig.scriptMaps) do - if self.helper.speciesConfig[map] then - self.helper:loadScript({script=path, args=self.helper.speciesConfig[map]}) - end - end - for _,script in pairs(self.helper.speciesConfig.scripts or {}) do - self.helper:loadScript(script) - end - - -- Apply the persistent effect - status.setPersistentEffects("FR_racialStats", self.helper.speciesConfig.stats or {}) - - -- Add any other special effects - if self.helper.speciesConfig.special then - for _,thing in pairs(self.helper.speciesConfig.special) do - status.addEphemeralEffect(thing,math.huge) - end - end - end - - -- Update stuff - --self.helper:clearPersistent() - self.helper:applyControlModifiers() - self.helper:runScripts("racialscript", self, dt) - - -- Breath handling - if entity.entityType() ~= "npc" then - local mouthPosition = vec2.add(mcontroller.position(), status.statusProperty("mouthPosition")) - if status.statPositive("breathProtection") or world.breathable(mouthPosition) - or status.statPositive("waterbreathProtection") and world.liquidAt(mouthPosition) - then - status.modifyResource("breath", status.stat("breathRegenerationRate") * dt) - else - status.modifyResource("breath", -status.stat("breathDepletionRate") * dt) - end - end -end]]