Jump to content

setTask(AttackUnit)


ESAc_matador

Recommended Posts

I made this code

 

AttackUnit = { 
 id = 'AttackUnit', 
 params = { 
   unitId = "unit",
 } 
} 

_group = Group.getByName("Group1")
_controller = _group:getController()
_controller:setTask(AttackUnit);

 

first, I load the Mist, and 20 seconds later I run the script (Time more - do script)

 

The aircraft is named "Group1" and the enemy "unit".

 

What happen is the aircraft remove his WPs, and directly goes to the last WP (Land).

 

I thought this order is like "unit task" in the mission editor... but nothing happens. There is not even an error message.

 

I attached the mission.

 

Any guru can help me out here?

testscriptsettask.miz

Link to comment
Share on other sites

The unitId needs to be the unitsId not the unitname.

 

http://wiki.hoggit.us/view/DCS_task_attackUnit

 

 

Also when you set a task it eliminates the "mission" task assigned to the aircraft, so it forgets its route and RTBs since it wasn't given a valid task. Try using Controller:pushTask()

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

Link to comment
Share on other sites

Thanks, I thought, push task did not work. Thanks!

 

This should work, then?.

 

AttackUnit = { 
 id = 'AttackUnit', 
 params = { 
   unitId = function () Unit.getID("unit")
 } 
} 

_group = Group.getByName("Group1")
_controller = _group:getController()
_controller:pushTask(AttackUnit);


Edited by ESAc_matador
Link to comment
Share on other sites

Try

AttackUnit = { 
 id = 'AttackUnit', 
 params = { 
   unitId = Unit.getByName("unit"):getID()
 } 
} 

_group = Group.getByName("Group1")
_controller = _group:getController()
_controller:pushTask(AttackUnit);

 

thank you!!! do yo know how can I stop the task, but keep in flying the his route??? i can stop, and then he come backs to the airport.

 

I was doing Unit.getByName():getID("unit").

 

It works!!!!


Edited by ESAc_matador
Link to comment
Share on other sites

ops... now I cant make the attack stop.

 


NoTask = { 
  id = 'NoTask', 
  params = { 
  } 
} 
_group = Group.getByName("Group1")
_controller = _group:getController()
_controller:pushTask(NoTask);

 

it does not seems to work. What I want is the flight Group1 keep going with its original flight plan.


Edited by ESAc_matador
Link to comment
Share on other sites

Ian;2769480']You want popTask().

 

The underlying data structure you are manipulating is a stack, so the "opposite" of a push is a pop. The image on that Wikipedia page might help you visualize what is going on (and why pushing NoTask does not have the desired effect).

 

Yes! I checked most of the coomands, but I missed this one. I want to do some sdripts. One, is, with predefined triggerareas, send CAS fligths, to attack specifick areas, via Radio F10. Yes, you can do this via CA, but for single players, or even multi, with not so many people calling strikes in areas, looks nicer.

 

With the Gazelle it is awesome, I already dI'd it via ME, but is too much work, too many flags, etc. So if I can do something prédite via lua, would be awesome.

 

Also, I want to make a smarter infantry. They will hide from enemies (by becaming invisible) from the enemy when they are neither sooting nor moving during x time. So, you can use infantry as sneaky units, commandos insertion, ambushes, etc. When they are invisible, and an enemy unit get in range of fire, they will shoot and loose it's invisibility.

 

I am getting there with the lua, starting to understand the philosophy, that is why I still need some help.

Link to comment
Share on other sites

You can also click the button highlighted to get the ids for anything you want to hard-code into the script.

show_ids.thumb.jpg.b86d53e3240daf3b65109f89d1f007b3.jpg

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

Link to comment
Share on other sites

  • 1 month later...
  • Recently Browsing   0 members

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