Damage Change

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2124
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Damage Change

Post by Ranakastrasz »

I am trying to alter damage of a rocket.

Code: Select all

data.raw.projectile["rocket"].action.action_delivery.target_effects.damage = 
{
	 {amount = 120, type = "explosion"}
} 
However, this is invalid. It is the bess Guess I have at this time on how you might go about doing it, but It is clearly wrong. Projectile is invalid. I am uncertain as to how to determine the correct method.

Also, I am trying to alter flamethrower damage, but it is a lot more complex. One part deals 20 flame damage (the ammo) and the "explosion" seems to deal .25 flame damage. I am trying to make it more persistant, similar to poison capsules. It does however also stop at targets, like trees. I would like it to pierce though them instead. Tank shells have "Piercing damage", but I have no idea how it works.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Damage Change

Post by L0771 »

Code: Select all

local rocket = data.raw["projectile"]["rocket"].action.action_delivery.target_effects
for _,misil in ipairs(rocket) do
	if misil.type == "damage" then
		misil.damage.amount = 120
	end
end
i don't tested this.

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2124
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Damage Change

Post by Ranakastrasz »

That works. However, Is there a way to refer directly to the particular branch without a for-loop?
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Damage Change

Post by L0771 »

Ranakastrasz wrote:That works. However, Is there a way to refer directly to the particular branch without a for-loop?
I think change damage is easier with a for, and is compatible with all mods.

Code: Select all

data.raw["projectile"]["rocket"].action.action_delivery.target_effects =
          {
            type = "create-entity",
            entity_name = "explosion"
          },
          {
            type = "damage",
            damage = {amount = 120, type = "explosion"}
          },
          {
            type = "create-entity",
            entity_name = "small-scorchmark",
            check_buildability = true
          }

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2124
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Damage Change

Post by Ranakastrasz »

That isn't the problem. It works great with a loop, although for the Explosive rocket, i need two nested loops for that to work. I would prefer referring to it directly however.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Damage Change

Post by FreeER »

Ranakastrasz wrote: That works. However, Is there a way to refer directly to the particular branch without a for-loop?
un-'named' tables are assigned to an numeric index (starting at 1). So the base rocket damage could be accessed with

Code: Select all

data.raw.projectile.rocket.action.action_delivery.target_effects[2].damage.amount
and the explosive-rocket with

Code: Select all

data.raw.projectile["explosive-rocket"].action.action_delivery.target_effects[2].action.action_delivery.target_effects[1].damage.amount
for quick testing you can follow the adjustment with error(serpent.block(data.raw.projectile.rocket.action.action_delivery.target_effects)) which will print the table in an error box (of course it stops Factorio too) :)

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2124
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Damage Change

Post by Ranakastrasz »

PERFECT!!!!
That fixes EVERYTHING!

That will allow me to do a lot of other things that I couldn't manage myself before. Thanks!
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

Post Reply

Return to “Modding help”