Jump to content

Script request: Smoke grenade


Recommended Posts

Hi all,

 

I have a request for the script experts here:

 

Is it possible to create a "Drop smoke" command for the Huey?

I thought about a F10 Radio command to drop smoke. Then, a smoke marker will be spawned on the ground of the actual position of the Huey.

 

Download:

http://forums.eagle.ru/showpost.php?p=1815752&postcount=12


Edited by Nirvi
Link to comment
Share on other sites

Don´t know if it works, but you could try following:

 

do
player1 = 'test' -- playerunitname
local _player = Unit.getByName(player1)
local _playergroup = _player:getGroup()
local _playerid = _playergroup:getID()

function SpawnSmoke(player1)
   local _player = Unit.getByName(player1)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Green)
end

missionCommands.addCommandForGroup(_playerid, "Drop smoke", nil, SpawnSmoke, player1)
end

  • Like 1

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Wow, thanks a lot SNAFU, the script works perfect. thumbup.gif

 

Don´t know if it works, but you could try following:

 

do
player1 = 'test' -- playerunitname
local _player = Unit.getByName(player1)
local _playergroup = _player:getGroup()
local _playerid = _playergroup:getID()

function SpawnSmokegreen(player1)
   local _player = Unit.getByName(player1)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Green)
end

function SpawnSmokered(player1)
   local _player = Unit.getByName(player1)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Red)
end

function SpawnSmokeblue(player1)
   local _player = Unit.getByName(player1)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Blue)
end

missionCommands.addCommandForGroup(_playerid, "Drop green smoke", nil, SpawnSmokegreen, player1)
missionCommands.addCommandForGroup(_playerid, "Drop red smoke", nil, SpawnSmokered, player1)
missionCommands.addCommandForGroup(_playerid, "Drop blue smoke", nil, SpawnSmokeblue, player1)
end

 

I have now added blue and red smoke to the script


Edited by Nirvi
Link to comment
Share on other sites

Simplest approach could be just to load the script several times, with the different names of each client-units.

 

So you change

 

"player1" to "player2"... and assigne it the name of the client-unit name.

 

Sure there are better ways, like f.e.:

 

player1 = 'test1' -- playerunitname
player2 = 'test2'
player3 = 'test3'
player4 = 'test4'
player5 = 'test5'
player6 = 'test6'
player7 = 'test7'
player8 = 'test8'
player9 = 'test9'
player10 = 'tes10'

function SpawnSmokegreen(PlayerUnit)
   local _player = Unit.getByName(PlayerUnit)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Green)
end
function SpawnSmokered(PlayerUnit)
   local _player = Unit.getByName(PlayerUnit)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Red)
end
function SpawnSmokeblue(PlayerUnit)
   local _player = Unit.getByName(PlayerUnit)
   local _smokepos = _player:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Blue)
end

F10RadioAddTable = {}
function SmokeDropper(PlayerUnit)
   if F10RadioAddTable[PlayerUnit] == nil then
       local _player = Unit.getByName(PlayerUnit)
       if _player == nil then
           return
       end
       
       local _playergroup = _player:getGroup()
       if _playergroup == nil then
           return
       end
 missionCommands.addCommandForGroup(_playerid, "Drop green smoke", nil, SpawnSmokegreen, PlayerUnit)
 missionCommands.addCommandForGroup(_playerid, "Drop red smoke", nil, SpawnSmokered, PlayerUnit)
 missionCommands.addCommandForGroup(_playerid, "Drop blue smoke", nil, SpawnSmokeblue, PlayerUnit)
 
       F10RadioAddTable[PlayerUnit] = true
   end
end

function AddSmokeDropCommands(arg, time)
   SmokeDropper(player1)
   SmokeDropper(player2)
   SmokeDropper(player3)
   SmokeDropper(player4)
   SmokeDropper(player5)
   SmokeDropper(player6)
   SmokeDropper(player7)
   SmokeDropper(player8) 
   SmokeDropper(player9)
SmokeDropper(player10)  
   return time + 5
end
timer.scheduleFunction(AddSmokeDropCommands, nil, timer.getTime() + 5)

 

But I don´t know if it works.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Simplest approach could be just to load the script several times, with the different names of each client-units.

 

So you change

 

"player1" to "player2"... and assigne it the name of the client-unit name.

 

Sure there are better ways, like f.e.:

 

Hi,

Sorry for the late answer. I tested both ways, but unfortunately none of these works in a MP mission with hueys as clients.

Link to comment
Share on other sites

AFAC Smoke Script

 

I finally got the script working in multiplayer with multiple Hueys.

 

As I had no previous experience with lua (or programming in general) I mixed the smokescript from SNAFU with Decks Dropscript to make it working in MP.

 

I am sure there are easier ways to to this, but at least it's working :D

 

We will use this script in our squad for AFAC Hueys to mark enemy positions.

 

Short vid:

 

  function GreenSmoke(unitName)
       local unit = Unit.getByName(unitName)
      
       if unit == nil then
           UnitStateTable[unitName] = false
           return
       end
      
       local unitId = unit:getID()
       local group = unit:getGroup()
       local groupName = group:getName()
       local playerName = unit:getPlayerName()
       local _smokepos = unit:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Green)
       if UnitStateTable[unitName] == nil then
           UnitStateTable[unitName] = false
       end
end

 function RedSmoke(unitName)
       local unit = Unit.getByName(unitName)
      
       if unit == nil then
           UnitStateTable[unitName] = false
           return
       end
      
       local unitId = unit:getID()
       local group = unit:getGroup()
       local groupName = group:getName()
       local playerName = unit:getPlayerName()
       local _smokepos = unit:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Red)
       if UnitStateTable[unitName] == nil then
           UnitStateTable[unitName] = false
       end
end

 function BlueSmoke(unitName)
       local unit = Unit.getByName(unitName)
      
       if unit == nil then
           UnitStateTable[unitName] = false
           return
       end
      
       local unitId = unit:getID()
       local group = unit:getGroup()
       local groupName = group:getName()
       local playerName = unit:getPlayerName()
       local _smokepos = unit:getPosition().p
   trigger.action.smoke({x=_smokepos.x + math.random(5,10), y= land.getHeight({x = _smokepos.x, y = _smokepos.z}), z=_smokepos.z + math.random(5,10)}, trigger.smokeColor.Blue)
       if UnitStateTable[unitName] == nil then
           UnitStateTable[unitName] = false
       end
end

 RadioCommandTable = {}
    
   function AddRadioCommand(unitName)
       if RadioCommandTable[unitName] == nil then
           local unit = Unit.getByName(unitName)
           if unit == nil then
               return
           end
          
           local group = unit:getGroup()
           if group == nil then
               return
           end
          
           local gid = group:getID()
          
           missionCommands.addCommandForGroup(gid, "Drop green smoke", nil, GreenSmoke, unitName)
           missionCommands.addCommandForGroup(gid, "Drop red smoke", nil, RedSmoke, unitName)
           missionCommands.addCommandForGroup(gid, "Drop blue smoke", nil, BlueSmoke, unitName)
           RadioCommandTable[unitName] = true
       end
   end
    
    
   function AddRadioCommands(arg, time)
       AddRadioCommand("AFAC1")
       AddRadioCommand("AFAC2")
       AddRadioCommand("AFAC3")
       AddRadioCommand("AFAC4")
       AddRadioCommand("AFAC5")
       AddRadioCommand("AFAC6")
       AddRadioCommand("AFAC7")
       AddRadioCommand("AFAC8")
       AddRadioCommand("AFAC9")      
       return time + 5
   end
           
             do
       timer.scheduleFunction(AddRadioCommands, nil, timer.getTime() + 5)
    end


Edited by Nirvi
Link to comment
Share on other sites

Nice!

 

I also worked on an AFAC script combined with the F-10 menu, but for the A-10C. The A-10C AFA C can call in AI striker, give them an IP and after putting a mark with the WilliePete Rockets the AI flight will bomb the area where the smoke marker hit the ground. Combined with the 9 line text messages. Due to the fact that the smoke frome the WPs is not as visible as the trigger smoke, I destroy the WP before it explodes and put a trigger smoke on the position, where the WP hit the ground.

 

I started the script some time ago, but could not finish it, yet due to lack of spare time, but maybe we can combine these 2 variants. Can the Huey also use some sort of WilliePetes or MarkerdRockets? So then I can integrate your variant in the A-10C AFAC script or ortherwise.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Nice!

 

I also worked on an AFAC script combined with the F-10 menu, but for the A-10C. The A-10C AFA C can call in AI striker, give them an IP and after putting a mark with the WilliePete Rockets the AI flight will bomb the area where the smoke marker hit the ground. Combined with the 9 line text messages. Due to the fact that the smoke frome the WPs is not as visible as the trigger smoke, I destroy the WP before it explodes and put a trigger smoke on the position, where the WP hit the ground.

 

I started the script some time ago, but could not finish it, yet due to lack of spare time, but maybe we can combine these 2 variants. Can the Huey also use some sort of WilliePetes or MarkerdRockets? So then I can integrate your variant in the A-10C AFAC script or ortherwise.

 

Yes the Huey has the WP Rockets.

 

There are a few more things I'd love to add in this script, I started to read lua tutorials just for this :D

 

Things like:

- Voice Message "Smoke is on the deck" when you dropped a smoke grenade. (This should be easy)

 

- Dropping smoke is only possible with open doors.

 

- Limited amount of smoke grenades, refill them only when landed on a base/FOB

Link to comment
Share on other sites

Sounds good, so I can add the Huey WPs to my AFAC script.

 

What I ve got so far you can see below, but note this is WIP, with the F/A-18C it works, still have to finish the text messages and work around the flow, but basically the main functions, which track the WPs and replace them by trigger smokes and let the AI drop on the marks work fine. Maybe you find some piece useful.

 

PS: I will post the script again, when I finished it... some day...

A10AFAC_v6.lua


Edited by SNAFU

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 1 year later...
Have you guys tried the new updated CTTS version that Ciribob made?

He corrected the script and made it more efficient.

 

Yes!

 

That script is soooo complete. Also there is a new version of medevac for infantry units in development. I need to try them togethr.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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