Help with damage value

Place to get help with not working mods / modding interface.
Post Reply
GreenGalaxyOnly
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun Jan 05, 2020 10:55 pm
Contact:

Help with damage value

Post by GreenGalaxyOnly »

Hello, I have hard time figuring out how to change the damage number for the Ammo mod that I made.
I would appreciate any help, tanks.

here is code so you have some Idea what I'm talking about...

-- newAmmo

local betterAmmo = table.deepcopy(data.raw.ammo["firearm-magazine"])

betterAmmo.name = "BetterAmmo"
betterAmmo.icons =
{
{
icon = table.deepcopy(data.raw.ammo["firearm-magazine"].icon),
tint = {r=0,g=1,b=0,a=0.3}
},
}
betterAmmo.damage = 30

local recipe = table.deepcopy(data.raw.recipe["firearm-magazine"])
recipe.enabled = true
recipe.name = "BetterAmmo"
recipe.ingredients = {{"copper-plate",2},{"steel-plate",1}}
recipe.result = "BetterAmmo"

data:extend{betterAmmo,recipe}

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Help with damage value

Post by DaveMcW »

The damage number is hidden in a bunch of sub-tables. I had to look at a data.raw dump to find it.

Code: Select all

betterAmmo.ammo_type.action.action_delivery.target_effects.damage.amount = 30

User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Re: Help with damage value

Post by Linver »

I dunno if this can help. This is an old code that I made for change the damage of some turrets of a mod, maybe can help u as an example:

Code: Select all

function applyDamageMultiplierOnAmmo(_target_effects)
	for _, target_effect in pairs(_target_effects) do
		if target_effect.damage then
			target_effect.damage.amount = target_effect.damage.amount * settings.startup["aturb_dmg_multiplier"].value 
		end
	end
end

function applyDamageMultiplierOnAmmoWithMultipleActions(actions)
	for _, action in pairs(actions) do
		if action and action.action_delivery and action.action_delivery.target_effects then
			applyDamageMultiplierOnAmmo(action.action_delivery.target_effects)
		end
	end
end

...

-- AMMO

local ammo_names =
{
	"small-coal-cannon-shell",
	"small-cannon-shell",		
	"small-coal-rocket",
	"small-rocket",
	"small-explosive-rocket",
	"electron-beam-1",
	"electron-beam-2",
	"at-advanced-laser-1",
	"acid-rocket"
}

for _, ammo_name in pairs(ammo_names) do
	applyDamageMultiplierOnAmmo(data.raw.projectile[ammo_name].action.action_delivery.target_effects)
end

ammo_names =
{
	"small-explosive-cannon-shell",
	"cluster-cannon-shell",
	"fire-cannon-shell",
	"fire-cluster-cannon-shell"
}

for _, ammo_name in pairs(ammo_names) do
	applyDamageMultiplierOnAmmoWithMultipleActions(data.raw.projectile[ammo_name].action)
end

Post Reply

Return to “Modding help”