Page 1 of 1

Runaway Light

Posted: Thu Jun 09, 2016 8:22 pm
by Ranakastrasz
Trying to make a flare Capsule. Since explosions are the only temperary light source I could find, I tried to make a capsule create one that lasts for an excessively long duration. For whatever reasons however, it decided that it should keep moving the same direction the capsule was when it impacted... So the light just slides away after the capsule lands.

Code: Select all

data:extend(
{
    {
        type = "explosion",
        name = "explosion-flare",
        flags = {"not-on-map"},
        animations =
        {
          {
            filename = "__Flare__/graphics/null.png",
            priority = "extra-high",
            width = 1,
            height = 1,
            frame_count = 1,
            animation_speed = 1.0/60.0/120.0,
            shift = {0, 0}
          }
        },
        rotate = false,
        light = {intensity = 0.9, size = 40},

        --light = {intensity = 0.05, size = 80,color = { r = 0.5, g = 0.9, b = 0.8,a = 0.0 }},

        --[[smoke = "smoke-fast",
        smoke_count = 1,
        smoke_slow_down_factor = 1]]--
    },
    {
        type = "smoke",
        name = "flare-cloud",
        flags = {"not-on-map"},
        show_when_smoke_off = true,
        animation =
        {
            filename = "__base__/graphics/entity/cloud/cloud-45-frames.png",
            priority = "low",
            width = 256,
            height = 256,
            frame_count = 45,
            animation_speed = 0.5,
            line_length = 7,
            scale = 0.2,
        },
        slow_down_factor = 0,
        affected_by_wind = false,
        cyclic = true,
        duration =  60 * 120,
        fade_away_duration = 2 * 60,
        spread_duration = 10,
        color = { r = 0.1, g = 0.9, b = 0.7 },
        action =
        {
            type = "direct",
            action_delivery =
            {
              type = "instant",
              source_effects =
              {
                  type = "create-explosion",
                  entity_name = "explosion-flare"
              },
            }
        },
        action_frequency = 60
    },
    {
        type = "projectile",
        name = "flare-capsule",
        flags = {"not-on-map"},
        acceleration = 0.005,
        action =
        {
            type = "direct",
            action_delivery =
            {
                type = "instant",
                target_effects =
                {
                    {
                        type = "create-entity",
                        entity_name = "flare-cloud"
                    },
                    {
                        type = "create-explosion",
                        entity_name = "explosion-flare"
                    },
                }
            }
        },
        light = {intensity = 0.9, size = 40},
        animation =
        {
            filename = "__Flare__/graphics/flare-capsule.png",
            frame_count = 1,
            width = 32,
            height = 32,
            priority = "high"
        },
        shadow =
        {
            filename = "__base__/graphics/entity/poison-capsule/poison-capsule-shadow.png",
            frame_count = 1,
            width = 32,
            height = 32,
            priority = "high"
        },
        smoke = capsule_smoke,
    },
    {
        type = "capsule",
        name = "flare-capsule",
        icon = "__Flare__/graphics/flare-capsule.png",
        flags = {"goes-to-quickbar"},
        capsule_action =
        {
            type = "throw",
            attack_parameters =
            {
                type = "projectile",
                ammo_category = "capsule",
                cooldown = 30,
                projectile_creation_distance = 0.6,
                range = 20,
                ammo_type =
                {
                    category = "capsule",
                    target_type = "position",
                    action =
                    {
                        type = "direct",
                        action_delivery =
                        {
                            type = "projectile",
                            projectile = "flare-capsule",
                            starting_speed = 0.3
                        }
                    }
                }
            }
        },
        subgroup = "capsule",
        order = "a[flare-capsule]",
        stack_size = 100
    },
})

Re: Runaway Light

Posted: Sun Jun 12, 2016 2:54 am
by thereaverofdarkness
If the light is part of the explosion or projectile, it may continue to fly away. You need to make it leave a light-producing entity where it explodes.

That probably doesn't help much. I don't know much about coding. :/

Re: Runaway Light

Posted: Mon Jun 13, 2016 2:32 pm
by Ranakastrasz
Doesn't seem likely. The capsule impacts the ground and creates an explosion entity. grenade light doesn't move, so I have no idea why this one does.

Re: Runaway Light

Posted: Mon Jun 13, 2016 3:49 pm
by thereaverofdarkness
Try copy-pasting the part of the grenade code that creates light.

Code: Select all

  {
    type = "projectile",
    name = "basic-grenade",
    flags = {"not-on-map"},
    acceleration = 0.005,
    action =
    {
      {
        type = "direct",
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "create-entity",
            entity_name = "medium-explosion"
            },
            {
            type = "create-entity",
            entity_name = "small-scorchmark",
            check_buildability = true
            }
          }
        }
      },
      {
        type = "area",
        perimeter = 6.5,
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "damage",
            damage = {amount = 25, type = "explosion"}
            },
            {
            type = "create-entity",
            entity_name = "explosion"
            }
          }
        }
      }
    },
    light = {intensity = 0.5, size = 4},
    animation =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade.png",
      frame_count = 1,
      width = 24,
      height = 24,
      priority = "high"
    },
    shadow =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade-shadow.png",
      frame_count = 1,
      width = 24,
      height = 32,
      priority = "high"
    }
  },
The part where it says:

Code: Select all

            {
            type = "create-entity",
            entity_name = "medium-explosion"
            },
            {
            type = "create-entity",
            entity_name = "small-scorchmark",
            check_buildability = true
            }
This is where it is creating new entities. It is using the action = segment to define what the projectile does when it finishes its job (when the grenade explodes and lands).

Code: Select all

      {
        type = "direct",
        action_delivery =
        {
This might be the command that tells it to deliver an action to the spot where the projectile hit.

And then it says:

Code: Select all

      {
        type = "area",
        perimeter = 6.5,
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "damage",
            damage = {amount = 25, type = "explosion"}
            },
            {
            type = "create-entity",
            entity_name = "explosion"
            }
          }
        }
      }
It's perhaps using the action_delivery = command to create an explosion on the target area. I think this part creates the explosions on everything that gets hit.


I don't actually know any coding, but some of this stuff is pretty intuitive. Just make sure you copy the format exactly how it is in the original (including the commas), but also check out working mods for cues.

Re: Runaway Light: RESOLVED

Posted: Mon Jun 13, 2016 4:18 pm
by Ranakastrasz
Turns out I thought explosions were supposed to be created by create_explosion, instead of create_entity Go figure.
Resolved

Re: Runaway Light

Posted: Mon Jun 13, 2016 4:47 pm
by thereaverofdarkness
Sweet! We both learned something here! :D