Jump to content

Recommended Posts

Posted (edited)

Hi guys 😉

 

Having some trouble with this function in a very specific scenario. 

 

local EV = event.initiator
					local EVP = EV:getPosition().p
					local EVG = EV:getGroup():getName()
					
			
												
     local A =      {
           group =  EVG, -- Won't work. 
           point = {y = 1, x = 2, z = 3}, -- We don't care
           radius = 0, -- Same
		   heading = 180 -- Same
		   speed = 80,
		   disableRoads = true
               } 

I'm creating a little script which would allow a tank to have some chances to move a bit to face its target when it starts shooting at it (in order to maximize armor). 

Thing is that as I use an Event (SHOT), I don't want to work with a group which would have a pre-entered name. Therefore I tried to solve the issue as above. It works perfectly when I ask him to return me the group name etc. But as soon as I try to use the Mist.GroupRandomToPoint, I can't get it to work. 

From what I understand I need to give him the group exact name, like "Bibou". But I'm prettily sure there is a way to avoid it. Would you have any clue ? 

 

Nicolas

Edited by dimitriov
Posted

It should work if group is either a group name or the actual group object. So you could skip getName part from EV:getGroup():getName().

The speed value might be part of the problem because you are trying to tell a ground unit to go 80 meters per second. Which is 288 km/h and I don't think any ground unit can go that fast. 

Also point is not relative to where it is at, rather it is relative to map origin. 

 

Honestly I'd just do something basic like:

local path = {}
local posStart = mist.getLeadPos(EVG)          -- gets current position
path[#path + 1] = mist.ground.buildWP(posStart)   -- makes a waypoint there
local target = Unit.getByName('whatever'):getPoint()  -- gets the point where you want it to orient toward
local offset = mist.projectPoint(posStart, 10, mist.getHeadingPoints(posStart, target))  -- projects a point from current position toward a target with a set distance of 10 m
path[#path + 1] = mist.ground.buildWP(offset) -- adds that as a WP
mist.goRoute(EVG, path)  -- told to go there. 

 

  • Like 1

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

LMAO

 

Thank you Grimes as always very quick answer, but I'm a moooooron XD

 

"

 heading = 180 -- Same
		   speed = 80,
		   disableRoads = true

 

If I forget the "," at the ending of the heading line, I think I can spend hours trying to get the line above to work 🤣

  • Recently Browsing   0 members

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