Jump to content

Dynamic FireAtPoint - how do I get this to work?


Go to solution Solved by Terminator357,

Recommended Posts

Posted

Apologies if somebody's already addressed this in another thread, I looked but didn't find anything that seemed to fit. I'm a bit of a newb to scripting and everything I've done with it up till now has been limited to displaying text in-game. 

Here's my scenario: A lone armor unit (RedTarget1) stops at a random spot. An artillery group (BlueArty2) that is outside of visual range but within firing range is assigned a "FireAtPoint" task using the point RedTarget1 stopped at for its target.

That's the plan anyway.

Piecing together what I find at Hoggit and here I came up with the below scripts. The ME should wait for RedTarget1 to stop, then attempt to get it's coordinates and use those to assign a FireAtPoint task to BlueArty2 through a "Do Script" action.

I've tried a number of ways to pass the target's position to the FireAtPoint task (a couple are below) but it doesn't work (artillery does nothing).

I know it isn't a matter of just waiting for the arty to spool up, these are M109's so the turrets should pivot into the desired direction as soon as they receive the command, although I've waited up to 5 minutes and still gotten no results.

So, am I trying to do the impossible or am I just overlooking some important detail?

Gracias! 👍

 

local fire = {id = 'FireAtPoint', params = { 
    point = Unit.getByName('RedTarget1'):getPoint(),
    radius = 10, 
    expendQty = 20, 
    expendQtyEnabled = true}
 }

local group = Group.getByName("BlueArty2") group:getController():pushTask(fire)

 

=============================================================

 

 local target = {}
 target.point = Unit.getByName('RedTarget1'):getPoint()

 target.radius = 10
 target.expendQty = 20
 target.expendQtyEnabled = true
local fire = {id = 'FireAtPoint', params = target}
 Group.getByName('BlueArty2'):getController():pushTask(fire)

  • Solution
Posted (edited)

So... It looks like I couldn't pass the target point to the FireAtPoint task because I wasn't using "getPoint" correctly. Newb oversight, but there ya go...

"getPoint" returns Vec3 coordinates, but artillery needs Vec2 coordinates, so "getPoint" by itself will not fetch a valid FireAtPoint target point.

Vec3 points are defined by "x, y, z", Vec2 are defined by "x, y", so you have convert the Vec3 to Vec2 before passing it to the FireAtPoint task. 

To convert a Vec3 point to a Vec2 point, just take the Vec3 "z" coordinate and use it for your Vec2 "y" coordinate. After that, everything works like you'd expect.

Simple in hindsight, don't know why it was stumping me like that 🙂 

Anyway, this script will dynamically assign a FireAtPoint task to the coordinates of any ground target you want based on whatever conditions you apply to it in the "getBy" function(s) and/or the ME. 

local Target = {}

Target.x = Unit.getByName('Target1'):getPoint().x
Target.y = Unit.getByName('Target1'):getPoint().z
target.radius = 10
Target.expendQty = 20

local fire = {id = 'FireAtPoint', params = Target}
Group.getByName('Arty2'):getController():pushTask(fire)

 

Edited by Terminator357
  • Like 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...