From 05e5661bb276738c3e72f32a5679020a5762061c Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Fri, 2 Feb 2018 22:40:01 -0800 Subject: [PATCH] biter spawn tables and friendly fire setting --- Upgrade.lua | 5 ++++ changelog.txt | 7 +++++ info.json | 2 +- libs/AIPredicates.lua | 4 +-- libs/Constants.lua | 1 + locale/en/locale.cfg | 4 ++- prototypes/SwarmUtils.lua | 11 ++++---- prototypes/utils/AttackBall.lua | 5 ++++ prototypes/utils/AttackBobs.lua | 16 +++++++++-- prototypes/utils/AttackFlame.lua | 5 ++++ prototypes/utils/AttackNE.lua | 7 +++++ prototypes/utils/BiterUtils.lua | 46 ++++++++++++++++++++++++++++++++ settings.lua | 11 ++++++++ 13 files changed, 111 insertions(+), 13 deletions(-) diff --git a/Upgrade.lua b/Upgrade.lua index e2de94f..3285a36 100755 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -197,6 +197,11 @@ function upgrade.attempt(natives) game.surfaces[1].print("Rampant - Version 0.16.16") global.version = constants.VERSION_51 end + if (global.version < constants.VERSION_52) then + + game.surfaces[1].print("Rampant - Version 0.16.17") + global.version = constants.VERSION_52 + end return starting ~= global.version, natives end diff --git a/changelog.txt b/changelog.txt index dfecfc3..26ecce5 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +--------------------------------------------------------------------------------------------------- +Version: 0.16.17 +Date: 2. 02. 2018 + Improvements: + - Changed defualt for friendly fire to off for worm and spitter splash damage + - Generating unit spawner probability for each variation and tier instead of sharing a single table + --------------------------------------------------------------------------------------------------- Version: 0.16.16 Date: 1. 31. 2018 diff --git a/info.json b/info.json index 9604569..d1ecb22 100755 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name" : "Rampant", "factorio_version" : "0.16", - "version" : "0.16.16", + "version" : "0.16.17", "title" : "Rampant", "author" : "Veden", "homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445", diff --git a/libs/AIPredicates.lua b/libs/AIPredicates.lua index 3897e47..9283538 100755 --- a/libs/AIPredicates.lua +++ b/libs/AIPredicates.lua @@ -14,9 +14,7 @@ local AI_STATE_NOCTURNAL = constants.AI_STATE_NOCTURNAL -- module code function aiPredicates.canAttack(natives, surface) - return (((natives.state == AI_STATE_AGGRESSIVE) or aiPredicates.canAttackDark(natives, surface)) - and not surface.peaceful_mode -- and (#natives.squads < natives.maxSquads) - ) + return ((natives.state == AI_STATE_AGGRESSIVE) or aiPredicates.canAttackDark(natives, surface)) and not surface.peaceful_mode end function aiPredicates.isDark(surface) diff --git a/libs/Constants.lua b/libs/Constants.lua index 03efed9..de1a6b4 100755 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -20,6 +20,7 @@ constants.VERSION_38 = 38 constants.VERSION_41 = 41 constants.VERSION_44 = 44 constants.VERSION_51 = 51 +constants.VERSION_52 = 52 -- misc diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 2d86bcc..9e24019 100755 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -9038,6 +9038,7 @@ rampant-newEnemyUnitVariations=Unit Variations rampant-newEnemyUnitTiers=Unit Tiers rampant-enableBobsUnits=Enable Bobs as a faction rampant-enableNEUnits=Enable NE as a faction +rampant-disallowFriendlyFire=Disallow Friendly Fire Splash Damage [mod-setting-description] rampant-useDumbProjectiles=Turns off homing projectiles for worms and spitters @@ -9074,4 +9075,5 @@ rampant-newEnemyWormTiers=This number corresponds to number of tiers. The higher rampant-newEnemyUnitVariations=This number corresponds to the number of variations per tier. The higher the number the smoother the enemy power curve. Min 1, Max 20 rampant-newEnemyUnitTiers=This number corresponds to number of tiers. The higher the number the smoother the enemy power curve. rampant-enableBobsUnits=Adds bobs spawners, units, and worms to the base upgrade and placement list -rampant-enableNEUnits=Adds NE spawners, units, and worms to the base upgrade and placement list \ No newline at end of file +rampant-enableNEUnits=Adds NE spawners, units, and worms to the base upgrade and placement list +rampant-disallowFriendlyFire=Prevents enemy spitters and worms from damaging units or buildings from the same force through splash damage \ No newline at end of file diff --git a/prototypes/SwarmUtils.lua b/prototypes/SwarmUtils.lua index 9217d8b..8b389af 100755 --- a/prototypes/SwarmUtils.lua +++ b/prototypes/SwarmUtils.lua @@ -298,17 +298,16 @@ end function swarmUtils.buildUnitSpawner(templates, upgradeTable, attackGenerator, variations, tiers) - local unitSet = buildUnits(templates.unit, - attackGenerator, - upgradeTable.unit, - variations.unit, - tiers.unit) - for tier=1, tiers.unitSpawner do local t = ((tiers.unitSpawner == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] for i=1,variations.unitSpawner do local unitSpawner = deepcopy(templates.unitSpawner) unitSpawner.name = unitSpawner.name .. "-v" .. i .. "-t" .. t + local unitSet = buildUnits(templates.unit, + attackGenerator, + upgradeTable.unit, + variations.unit, + tiers.unit) local unitTable = unitSetToProbabilityTable(upgradeTable.probabilityTable, unitSet) generateApperance(unitSpawner, t) diff --git a/prototypes/utils/AttackBall.lua b/prototypes/utils/AttackBall.lua index c48e858..dff8aa8 100755 --- a/prototypes/utils/AttackBall.lua +++ b/prototypes/utils/AttackBall.lua @@ -2,6 +2,10 @@ local streamUtils = require("StreamUtils") +-- constants + +local DISALLOW_FRIENDLY_FIRE = settings.startup["rampant-disallowFriendlyFire"].value + -- imported functions local makeStream = streamUtils.makeStream @@ -15,6 +19,7 @@ function AttackBall.createAttackBall(attributes) local templateArea = { type = "area", radius = attributes.radius, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { { diff --git a/prototypes/utils/AttackBobs.lua b/prototypes/utils/AttackBobs.lua index 478c6e8..5a53f3d 100755 --- a/prototypes/utils/AttackBobs.lua +++ b/prototypes/utils/AttackBobs.lua @@ -3,14 +3,16 @@ -- import local streamUtils = require("StreamUtils") -local colorUtils = require("ColorUtils") local fireUtils = require("FireUtils") local stickerUtils = require("StickerUtils") +-- constants + +local DISALLOW_FRIENDLY_FIRE = settings.startup["rampant-disallowFriendlyFire"].value + -- imported functions local makeStream = streamUtils.makeStream -local makeColor = colorUtils.makeColor local makeSpreadEffect = fireUtils.makeSpreadEffect local makeFire = fireUtils.makeFire local makeSticker = stickerUtils.makeSticker @@ -55,6 +57,7 @@ makeStream({ { type = "area", radius = 3, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -111,6 +114,7 @@ makeStream({ { type = "area", radius = 2, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -155,6 +159,7 @@ makeStream({ { type = "area", radius = 2, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -182,6 +187,7 @@ data:extend({ action = { type = "direct", + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -226,6 +232,7 @@ makeStream({ { type = "area", radius = 3, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -253,6 +260,7 @@ data:extend({ action = { type = "direct", + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -308,6 +316,7 @@ makeStream({ { type = "area", radius = 3, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -352,6 +361,7 @@ makeStream({ { type = "area", radius = 3, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -404,6 +414,7 @@ makeStream({ { type = "area", radius = 3, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -475,6 +486,7 @@ makeStream({ { type = "area", radius = 3, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", diff --git a/prototypes/utils/AttackFlame.lua b/prototypes/utils/AttackFlame.lua index 13970ea..8703c9f 100755 --- a/prototypes/utils/AttackFlame.lua +++ b/prototypes/utils/AttackFlame.lua @@ -7,6 +7,10 @@ local colorUtils = require("ColorUtils") local fireUtils = require("FireUtils") local stickerUtils = require("StickerUtils") +-- constants + +local DISALLOW_FRIENDLY_FIRE = settings.startup["rampant-disallowFriendlyFire"].value + -- imported functions local makeColor = colorUtils.makeColor @@ -61,6 +65,7 @@ function attackFlame.createAttackFlame(attributes) { type = "area", radius = attributes.radius or 2.5, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", diff --git a/prototypes/utils/AttackNE.lua b/prototypes/utils/AttackNE.lua index 8da73a1..1f62ab8 100755 --- a/prototypes/utils/AttackNE.lua +++ b/prototypes/utils/AttackNE.lua @@ -2,6 +2,10 @@ local streamUtils = require("StreamUtils") +-- constants + +local DISALLOW_FRIENDLY_FIRE = settings.startup["rampant-disallowFriendlyFire"].value + -- imported functions local makeStream = streamUtils.makeStream @@ -84,6 +88,7 @@ makeStream({ { type = "area", radius = 2, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -128,6 +133,7 @@ makeStream({ { type = "area", radius = 1.5, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", @@ -176,6 +182,7 @@ makeStream({ { type = "area", radius = 2, + force = (DISALLOW_FRIENDLY_FIRE and "enemy") or nil, action_delivery = { type = "instant", diff --git a/prototypes/utils/BiterUtils.lua b/prototypes/utils/BiterUtils.lua index d3201bf..d40cb07 100755 --- a/prototypes/utils/BiterUtils.lua +++ b/prototypes/utils/BiterUtils.lua @@ -630,6 +630,52 @@ function biterFunctions.createElectricAttack(attributes, electricBeam, animation } end + +function biterFunctions.createRailAttack(attributes, railBeam, animation) + return { + type = "projectile", + ammo_category = "railgun", + cooldown = 3 * 60, + movement_slow_down_factor = 0.6, + projectile_creation_distance = 0.6, + ammo_type = { + category = "railgun", + target_type = "direction", + clamp_position = true, + action = + { + type = "line", + range = 50, + width = attributes.width or 0.5, + + source_effects = + { + type = "create-explosion", + entity_name = railBeam or "railgun-beam" + }, + action_delivery = + { + type = "instant", + target_effects = + { + type = "damage", + damage = { amount = attributes.damage or 100, type=attributes.damageType or "physical" } + } + } + } + }, + animation = animation, + range = 50, + sound = + { + { + filename = "__base__/sound/railgun.ogg", + volume = 0.8 + } + } + } +end + function biterFunctions.createMeleeAttack(attributes) return { diff --git a/settings.lua b/settings.lua index f0bcb2c..29d559c 100755 --- a/settings.lua +++ b/settings.lua @@ -334,7 +334,18 @@ data:extend({ default_value = true, order = "b[modifier]-d[trigger]", per_user = false + }, + + { + type = "bool-setting", + name = "rampant-disallowFriendlyFire", + setting_type = "startup", + default_value = true, + order = "b[modifier]-e[trigger]", + per_user = false } + + -- { -- type = "bool-setting",