Page 1 of 1

Damage Change

Posted: Sat Jan 03, 2015 10:35 pm
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.

Re: Damage Change

Posted: Sun Jan 04, 2015 9:24 pm
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.

Re: Damage Change

Posted: Mon Jan 19, 2015 8:08 pm
by Ranakastrasz
That works. However, Is there a way to refer directly to the particular branch without a for-loop?

Re: Damage Change

Posted: Mon Jan 19, 2015 8:30 pm
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
          }

Re: Damage Change

Posted: Mon Jan 19, 2015 8:32 pm
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.

Re: Damage Change

Posted: Fri Jan 23, 2015 11:10 pm
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) :)

Re: Damage Change

Posted: Fri Feb 27, 2015 2:09 am
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!