How to hide "artillery-flare" particle to other force?

Place to get help with not working mods / modding interface.
x2605
Inserter
Inserter
Posts: 42
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

How to hide "artillery-flare" particle to other force?

Post by x2605 »

I found a way to force artillery to attack any given position via scripting way.

Code: Select all

<SOME_LuaSurface>.create_entity{
position = <TARGET_POSITION>,
force = <ENEMY_FORCE>,
name = 'artillery-flare',
frame_speed=0, vertical_speed=0, height=0, movement={0,0}}
It's creating entity with these parameters.

But target mark is visible to other force. How to hide it?
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: How to hide "artillery-flare" particle to other force?

Post by orzelek »

Did you try to give it your force not enemy?
I think arty might not care and shoot it anyway.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to hide "artillery-flare" particle to other force?

Post by DaveMcW »

It is given to the enemy force to test whether it is visible. I don't think there is a way to hide it.

You could edit artillery-flare to make it invisible, then place a different entity for the mark.
x2605
Inserter
Inserter
Posts: 42
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

Re: How to hide "artillery-flare" particle to other force?

Post by x2605 »

I found a way.
When using arty remote, remove original flare, and make a flare again at skyhigh(height=2147483648) to make it never get in player's screen.
(And even moving up high, vertical_speed=2147483648)
To show target to specific players, place a entity which can have "render_player_index" as creation parameter.

Code: Select all

local on_player_used_capsule = function(event)
  if event.item.name == 'artillery-targeting-remote' then
    local player = game.players[event.player_index]
    local surface = player.surface
    local flares = surface.find_entities_filtered{name = 'artillery-flare', position = event.position, force = player.force }
    local flare
    for _, f in pairs(flares) do
      if f.position.x == event.position.x and f.position.y == event.position.y then
        flare = f
        break
      end
    end
    if not flare then return end
    flare.destroy()
    flare = surface.create_entity{
      name='artillery-flare',
      position=event.position,
      force=player.force,
      frame_speed=0, vertical_speed=2147483648, height=2147483648, movement={0,0},
    }
    local targetbox = surface.create_entity{
      name='highlight-box',
      position=event.position,
      bounding_box={{event.position.x-0.5,event.position.y-0.5},{event.position.x+0.5,event.position.y+0.5}},
      box_type='not-allowed',
      time_to_live=120,
      blink_interval=5,
      render_player_index=event.player_index,
    }
  end
end
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)
Post Reply

Return to “Modding help”