[0.12.17] [Martin] Beam laser issues.

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

[0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

As you know, With the release of 0.12 came a new type of attack, the "beam" attack, used on the destroyer combat robot.

Well, I've been trying to mod the weapon onto other things, such as a turret, and a personal weapon.

When used on a turret, the weapon fires, but the animation lasts for only 1 frame.
When used on a personal weapon, the animation doesn't play at all, but it does still deal some damage.

here is an example weapon and ammo... you'll probably want to change the icon tags. It's using the existing beam used on the combat robot.

Code: Select all

data:extend(
{
  {
    type = "ammo-category",
    name = "beam-rifle"
  },
  {
    type = "gun",
    name = "laser-beam-rifle",
    icon = "__bobwarfare__/graphics/icons/laser-rifle.png",
    flags = {"goes-to-main-inventory"},
    subgroup = "gun",
    order = "b[laser-rifle]",
    stack_size = 5,
    attack_parameters =
    {
      type = "beam",
      ammo_category = "beam-rifle",
      cooldown = 20,
      range = 15,

      movement_slow_down_factor = 0.5,
      damage_modifier = 10,
      sound = make_laser_sounds(),
    },
  },
  {
    type = "ammo",
    name = "laser-beam-rifle-ammo",
    icon = "__bobwarfare__/graphics/icons/laser-rifle-battery-sapphire.png",
    flags = {"goes-to-main-inventory"},
    subgroup = "bob-ammo",
    order = "f[laser-beam]",
    stack_size = 100,
    magazine_size = 50,
    ammo_type =
    {
      category = "beam-rifle",
      action =
      {
        type = "direct",
        action_delivery =
        {
          type = "beam",
          beam = "electric-beam",
          max_length = 15,
          duration = 20,
        }
      }
    },
  },
}
)
Am I doing something wrong, or is the game broken?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Beam laser issues.

Post by bobingabout »

Oh, and it occassionally seems to crash when you kill something with said rifle

Code: Select all

   0.000 2015-11-15 20:45:34; Factorio 0.12.17 (Build 17307, win64)
   0.000 Operating system: Windows 7 Service Pack 1
   0.000 Program arguments: "D:\Games\Factorio 0.12\bin\x64\Factorio.exe" 
   0.000 Read data path: D:/Games/Factorio 0.12/data
   0.000 Write data path: D:/Games/Factorio 0.12
   0.000 Binaries path: D:/Games/Factorio 0.12/bin
   0.007 Available display adapters: 1
   0.007  [0]: \\.\DISPLAY1 - NVIDIA GeForce GTX 970 {0x80005, [0,0], 1920x1200, 32bit, 59Hz}
   0.007 Create display on adapter 0. Size 1280x720 at position [310, 222]. Monitor 0
   0.304 Initialised Direct3D:[0] NVIDIA GeForce GTX 970; driver: nvd3dumx.dll 10.18.13.5362
   0.342 Desktop composition is active.
   0.342 Graphics options: [FullScreen: true] [VSync: true] [UIScale: 100%] [MultiSampling: OFF] [Graphics quality: normal] [Video memory usage: all] [Light scale: 20%] [Screen: 255]
   0.382 Loading mod core 0.0.0 (data.lua)
   0.384 Loading mod base 0.12.17 (data.lua)
   0.421 Loading mod bobconfig 0.12.2 (data.lua)
   0.447 Loading mod boblibrary 0.12.3 (data.lua)
   0.474 Loading mod Treefarm-Lite 0.2.0 (data.lua)
   0.499 Loading mod bobassembly 0.12.7 (data.lua)
   0.533 Loading mod bobenemies 0.12.6 (data.lua)
   0.565 Loading mod bobores 0.12.7 (data.lua)
   0.598 Loading mod bobtech 0.12.4 (data.lua)
   0.632 Loading mod bobplates 0.12.10 (data.lua)
   0.678 Loading mod bobelectronics 0.12.6 (data.lua)
   0.716 Loading mod boblogistics 0.12.7 (data.lua)
   0.773 Loading mod bobmining 0.12.3 (data.lua)
   0.819 Loading mod bobpower 0.12.6 (data.lua)
   0.874 Loading mod bobwarfare 0.12.9 (data.lua)
   0.946 Loading mod bobmodules 0.12.9 (data.lua)
   1.010 Loading mod bobconfig 0.12.2 (data-updates.lua)
   1.097 Loading mod bobassembly 0.12.7 (data-updates.lua)
   1.158 Loading mod bobenemies 0.12.6 (data-updates.lua)
   1.221 Loading mod bobores 0.12.7 (data-updates.lua)
   1.298 Loading mod bobtech 0.12.4 (data-updates.lua)
   1.358 Loading mod bobplates 0.12.10 (data-updates.lua)
   1.424 Loading mod bobelectronics 0.12.6 (data-updates.lua)
   1.501 Loading mod boblogistics 0.12.7 (data-updates.lua)
   1.561 Loading mod bobmining 0.12.3 (data-updates.lua)
   1.626 Loading mod bobpower 0.12.6 (data-updates.lua)
   1.704 Loading mod bobwarfare 0.12.9 (data-updates.lua)
   1.767 Loading mod bobmodules 0.12.9 (data-updates.lua)
   1.836 Loading mod bobelectronics 0.12.6 (data-final-fixes.lua)
   2.619 Initial atlas bitmap size is 16384
   2.621 Created atlas bitmap 16384x8294
   7.657 Info Updater.cpp:752: Downloading https://www.factorio.com/updater/get-available-versions?username=bobingabout&token=<private>&apiVersion=2
   8.590 0 packages available to download (experimental updates enabled).
   8.618 Factorio initialised
  11.136 Loading map D:/Games\Factorio 0.12\saves\_autosave3.zip
  11.155 Info Scenario.cpp:123: Map version 0.12.17-0
  12.224 Applying migration: Bob's Warfare: bobwarfare_0.12.9.lua
 103.241 Loading map D:/Games\Factorio 0.12\saves\_autosave3.zip
 103.260 Info Scenario.cpp:123: Map version 0.12.17-0
 104.332 Applying migration: Bob's Warfare: bobwarfare_0.12.9.lua
Factorio crashed. Generating symbolized stacktrace, please wait ...
c:\cygwin64\tmp\factorio-3an4ly\libraries\stackwalker\stackwalker.cpp (923): StackWalker::ShowCallstack
c:\cygwin64\tmp\factorio-3an4ly\src\util\logger.cpp (284): Logger::writeStacktrace
c:\cygwin64\tmp\factorio-3an4ly\src\util\logger.cpp (338): Logger::logStacktrace
c:\cygwin64\tmp\factorio-3an4ly\src\util\crashhandler.cpp (81): CrashHandler::writeStackTrace
c:\cygwin64\tmp\factorio-3an4ly\src\util\crashhandler.cpp (90): CrashHandler::SehHandler
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 000000007700B9B0)
000000007700B9B0 (kernel32): (filename not available): UnhandledExceptionFilter
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00000000772199C8)
00000000772199C8 (ntdll): (filename not available): EtwEventSetInformation
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00000000771A7FA8)
00000000771A7FA8 (ntdll): (filename not available): _C_specific_handler
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00000000771B91AD)
00000000771B91AD (ntdll): (filename not available): RtlDecodePointer
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00000000771A8BAF)
00000000771A8BAF (ntdll): (filename not available): RtlUnwindEx
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00000000771DDB38)
00000000771DDB38 (ntdll): (filename not available): KiUserExceptionDispatcher
c:\cygwin64\tmp\factorio-3an4ly\src\trigger\shooter.cpp (400): Shooter::update
c:\cygwin64\tmp\factorio-3an4ly\src\entity\car.cpp (244): Car::update
c:\cygwin64\tmp\factorio-3an4ly\src\surface\chunk.cpp (441): Chunk::update
c:\cygwin64\tmp\factorio-3an4ly\src\surface\surface.cpp (818): Surface::update
c:\cygwin64\tmp\factorio-3an4ly\src\map\map.cpp (914): Map::update
c:\cygwin64\tmp\factorio-3an4ly\src\game.cpp (144): Game::update
c:\cygwin64\tmp\factorio-3an4ly\src\scenario\scenario.cpp (703): Scenario::update
c:\cygwin64\tmp\factorio-3an4ly\src\mainloop.cpp (262): MainLoop::gameUpdateStep
c:\cygwin64\tmp\factorio-3an4ly\src\mainloop.cpp (368): MainLoop::updateLoop
c:\boost_1_58_0\boost\function\function_template.hpp (160): boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void,void (__cdecl*)(ThreadBarrier * __ptr64,boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64,boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64,bool * __ptr64,bool),boost::_bi::list5<boost::_bi::value<ThreadBarrier * __ptr64>,boost::_bi::value<boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64>,boost::_bi::value<boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64>,boost::_bi::value<bool * __ptr64>,boost::_bi::value<bool> > >,void>::invoke
c:\cygwin64\tmp\factorio-3an4ly\src\util\thread.cpp (34): Thread::loop
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 000000013F8AC7E3)
000000013F8AC7E3 (Factorio): (filename not available): boost::`anonymous namespace'::thread_start_function
f:\dd\vctools\crt\crtw32\startup\threadex.c (376): _callthreadstartex
f:\dd\vctools\crt\crtw32\startup\threadex.c (354): _threadstartex
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 0000000076F859CD)
0000000076F859CD (kernel32): (filename not available): BaseThreadInitThunk
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00000000771BB981)
00000000771BB981 (ntdll): (filename not available): RtlUserThreadStart
 176.996 Error Util.cpp:63: Unexpected error occurred. You can help us to solve the problem by posting the contents of the log file on the Factorio forums.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
HanziQ
Former Staff
Former Staff
Posts: 630
Joined: Fri Mar 27, 2015 7:07 am
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by HanziQ »

Got the personal weapon fixed (and hopefully the crash), would you happen to have an example with the turret so I can take a look at that?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

HanziQ wrote:Got the personal weapon fixed (and hopefully the crash), would you happen to have an example with the turret so I can take a look at that?
Not at the moment, I am at work.
But from what I remember, I took the Laser Turret code, named it Beam Turret, and replaced the attack parameters section with the section from the robot that uses the beam weapon... +energy consumption tag.

I can get you quoted code in approximately 6 hours.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

The Atttack Parameters section.

Code: Select all

    attack_parameters =
    {
      type = "beam",
      ammo_category = "electric",
      cooldown = 20,
      damage_modifier = 4,
      projectile_center = {0, -0.2},
      projectile_creation_distance = 1.4,
      range = 25,
      ammo_type =
      {
        type = "beam",
        category = "laser-turret",
        energy_consumption = "800kJ",
        action =
        {
          type = "direct",
          action_delivery =
          {
            type = "beam",
            beam = "electric-beam",
            max_length = 15,
            duration = 20,
          }
        }
      },
      sound = make_laser_sounds(),
    }
Everything else was just a clone of the laser turret, but I no longer have that code. (I deleted it from my warfare mod experiment to release it with the other updates.)
Here is a quick re-hash, it may not be 100% correct, the original attempt was made using the fuctions within my warfare mod.

Code: Select all

data:extend(
{
  {
    type = "electric-turret",
    name = "beam-turret",
    icon = "__base__/graphics/icons/laser-turret.png",
    flags = { "placeable-player", "placeable-enemy", "player-creation"},
    minable = { mining_time = 0.5, result = "beam-turret" },
    max_health = 1000,
    corpse = "medium-remnants",
    collision_box = {{ -0.7, -0.7}, {0.7, 0.7}},
    selection_box = {{ -1, -1}, {1, 1}},
    rotation_speed = 0.01,
    preparing_speed = 0.05,
    dying_explosion = "medium-explosion",
    folding_speed = 0.05,
    energy_source =
    {
      type = "electric",
      buffer_capacity = "801kJ",
      input_flow_limit = "4800kW",
      drain = "24kW",
      usage_priority = "primary-input"
    },
    folded_animation =
    {
      layers =
      {
        laser_turret_extension{frame_count=1, line_length = 1},
        laser_turret_extension_shadow{frame_count=1, line_length=1},
        laser_turret_extension_mask{frame_count=1, line_length=1}
      }
    },
    preparing_animation =
    {
      layers =
      {
        laser_turret_extension{},
        laser_turret_extension_shadow{},
        laser_turret_extension_mask{}
      }
    },
    prepared_animation =
    {
      layers =
      {
        {
          filename = "__base__/graphics/entity/laser-turret/laser-turret-gun.png",
          line_length = 8,
          width = 68,
          height = 68,
          frame_count = 1,
          axially_symmetrical = false,
          direction_count = 64,
          shift = {0.0625, -1}
        },
        {
          filename = "__base__/graphics/entity/laser-turret/laser-turret-gun-mask.png",
          line_length = 8,
          width = 54,
          height = 44,
          frame_count = 1,
          axially_symmetrical = false,
          apply_runtime_tint = true,
          direction_count = 64,
          shift = {0.0625, -1.3125},
        },
        {
          filename = "__base__/graphics/entity/laser-turret/laser-turret-gun-shadow.png",
          line_length = 8,
          width = 88,
          height = 52,
          frame_count = 1,
          axially_symmetrical = false,
          direction_count = 64,
          draw_as_shadow = true,
          shift = {1.59375, 0}
        }
      }
    },
    folding_animation = 
    {
      layers =
      {
        laser_turret_extension{run_mode = "backward"},
        laser_turret_extension_shadow{run_mode = "backward"},
        laser_turret_extension_mask{run_mode = "backward"}
      }
    },
    base_picture =
    {
      layers =
      {
        {
          filename = "__base__/graphics/entity/laser-turret/laser-turret-base.png",
          priority = "high",
          width = 98,
          height = 82,
          axially_symmetrical = false,
          direction_count = 1,
          shift = { 0.109375, 0.03125 }
        },
        {
          filename = "__base__/graphics/entity/laser-turret/laser-turret-base-mask.png",
          line_length = 1,
          width = 54,
          height = 46,
          frame_count = 1,
          axially_symmetrical = false,
          apply_runtime_tint = true,
          direction_count = 1,
          shift = {0.046875, -0.109375},
        },
      }
    },
    vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
    attack_parameters =
    {
      type = "beam",
      ammo_category = "electric",
      cooldown = 20,
      damage_modifier = 4,
      projectile_center = {0, -0.2},
      projectile_creation_distance = 1.4,
      range = 25,
      ammo_type =
      {
        type = "beam",
        category = "laser-turret",
        energy_consumption = "800kJ",
        action =
        {
          type = "direct",
          action_delivery =
          {
            type = "beam",
            beam = "electric-beam",
            max_length = 15,
            duration = 20,
          }
        }
      },
      sound = make_laser_sounds(),
    }
  },
  {
    type = "item",
    name = "beam-turret",
    icon = "__base__/graphics/icons/laser-turret.png",
    flags = {"goes-to-quickbar"},
    subgroup = "defensive-structure",
    order = "b[turret]-c[beam-turret]",
    place_result = "beam-turret",
    stack_size = 50
  }
}
)
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

Oh, Also, see if the example weapon in the first post works when used as a vehicle weapon.

It was having similar issues when I tested it before, it has likely been fixed by your personal weapon fix, but would need testing.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
HanziQ
Former Staff
Former Staff
Posts: 630
Joined: Fri Mar 27, 2015 7:07 am
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by HanziQ »

The turret works after the fix, there is one slight annoyance though. There are 2 variables you can control - range in attack params and max_length in action delivery - they have to be set to the same value for the beam to work correctly (if range>max_length, the beam can exist for just 1 tick before it self-destructs), I'll look into merging those for a later version.
I have to test the vehicle weapon yet.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

HanziQ wrote:The turret works after the fix, there is one slight annoyance though. There are 2 variables you can control - range in attack params and max_length in action delivery - they have to be set to the same value for the beam to work correctly (if range>max_length, the beam can exist for just 1 tick before it self-destructs), I'll look into merging those for a later version.
I have to test the vehicle weapon yet.
Thanks, I'll keep that in mind.

If the Turret and hand held gun both work, then the tank weapon most likely will also.


What if I just set the max_length to be higher than the weapon's range? Will that still work?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
HanziQ
Former Staff
Former Staff
Posts: 630
Joined: Fri Mar 27, 2015 7:07 am
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by HanziQ »

Yes, it will work, range affects max creation range, max_length well... max length. :D So it might actually make sense to have those as separate.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

I see.
Patch notes for 0.12.18 sugest that the first issue, with the rifle was fixed for 0.12.18. My tests seem to indicate that beams still do not work on rifles for 0.12.18. Turrets do though if the beam length tags are adjusted.

Is this fix in 0.12.18 or was it left out for some reason?

Edit:
Okay, I lie, it didn't work when being fired from this weapon

Code: Select all

  {
    type = "gun",
    name = "laser-rifle",
    icon = "__bobwarfare__/graphics/icons/laser-rifle.png",
    flags = {"goes-to-main-inventory"},
    subgroup = "gun",
    order = "b[laser-rifle]",
    stack_size = 5,
    attack_parameters =
    {
      type = "projectile",
      ammo_category = "laser-rifle",
      cooldown = 30,
      movement_slow_down_factor = 0.5,
      damage_modifier = 1.2,--1
      projectile_center = {0, 0},
      projectile_creation_distance = 0.6,
      range = 20,
      sound = make_laser_sounds(),
    },
  },
However, when being fired from the weapon in the first post... it fires for a second or two, then the entire stack of ammo spontaniously disapears....

For completeness sake, firing projectile ammo from a beam weapon works, except the sound doesn't play.
Is there any way to remove the type=projectile/beam requirement from the weapon, and have it only on the ammo?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
HanziQ
Former Staff
Former Staff
Posts: 630
Joined: Fri Mar 27, 2015 7:07 am
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by HanziQ »

Weapons with type projectile will destroy the beam after 1 tick, I can take a look at that for 0.13, but for now, this stays. If you use the correct type, it should work, the ammo consumption has also been fixed for the next release.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.12.17] [Martin] Beam laser issues.

Post by bobingabout »

HanziQ wrote:Weapons with type projectile will destroy the beam after 1 tick, I can take a look at that for 0.13, but for now, this stays. If you use the correct type, it should work, the ammo consumption has also been fixed for the next release.
Using the correct weapon/ammo type shouldn't be an issue, that was just an error because when I re-added it to my mod I had both types of laser weapon with the same ammo category temporarily. It would be nice however to be able to use projectile/beam just by switching ammo, some of my other weapons fire different things depending what ammo is available.

Thanks for fixing the ammo, I'll give it a try when the next update hits, but for now I can still do the beam turrets.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Resolved Problems and Bugs”