Jump to content

Trigger infinite ammo / fuel possible?


Recommended Posts

Some of the guys I play with can't get enough of infinite ammo / fuel, but me; I can't stand it. Muh immersion is ruined!

 

Is there a way I can add toggle infinite X to client's aircraft as an F10 radio selection or another way? I can't seem to find a premade trigger for it so I'm guessing it'd have to be done via .lua scripting? Ideally the trigger could be activated by any aircraft occupied by a client...if such a thing is possible.

 

Any ideas?

[spoiler=PC SPECS]

Intel i5-8600k @3.60GHz

EVGA GTX 1070Ti

Windows 10

16GB RAM 3200 MHz

500 GB Samsung 850 SSD

2TB Seagate SSHD

Some cool LED fans that light up

 

 

Link to comment
Share on other sites

What you're suggesting is highly possible and not that hard to do (I think).

 

Here's a function to add radio commands: http://wiki.hoggit.us/view/DCS_func_addOtherCommandForGroup

 

I haven't really refilled/refueled with a script before, but I'm pretty confident it is possible.

 

The only "problem" as I see it is that you can't distinguish between players in a group that calls the command to refill/refuel. So if you have a group of 4, and 1 of them calls the refill/refuel command then the whole group will be refilled/refueled.

 

 

 

Another challenge is that the command will only be added for groups that are existing (have live players) in your mission. The way I've solved this before is I have a function that is scheduled at time intervals. The function removes the command for all groups (that has it), then re-adds it for all groups that exist (in-game players). Here's the code.

 

 

 

EDIT: Here's one way to add the radio command (requires the autogft script, version 1.2 download here).

Firstly, load the "autogft-standalone.lua" to your mission. Then load the following script:

 

function enableRefillCommand()

 local enabledGroupCommands = {}

 local function cleanEnabledGroupCommands()
   local newEnabledGroupCommands = {}
   for i = 1, #enabledGroupCommands do
     if not Group.getByName(enabledGroupCommands[i].groupName) then
       enabledGroupCommands[i]:disable()
     else
       newEnabledGroupCommands[#newEnabledGroupCommands + 1] = enabledGroupCommands[i]
     end
   end
   enabledGroupCommands = newEnabledGroupCommands
 end

 ---
 -- @param #number groupId
 local function groupHasCommandEnabled(groupId)
   for i = 1, #enabledGroupCommands do
     if enabledGroupCommands[i].groupId == groupId then
       return true
     end
   end
   return false
 end

 ---
 -- @param DCSGroup#Group group
 local function groupHasPlayer(group)
   local units = group:getUnits()
   for i = 1, #units do
     if units[i]:getPlayerName() ~= nil then return true end
   end
   return false
 end

 ---
 -- @param #list<DCSGroup#Group> groups
 local function enableForGroups(groups)
   for i = 1, #groups do
     local group = groups[i]
     if groupHasPlayer(group) then
       if not groupHasCommandEnabled(group:getID()) then
         local function triggerCommand()
           -- 
           -- DO THE REFILLING HERE, the "group" variable holds the target group
           --
         end
         local groupCommand = autogft_GroupCommand:new("Refuel & refill", group:getName(), triggerCommand)
         groupCommand:enable()
         enabledGroupCommands[#enabledGroupCommands + 1] = groupCommand
       end
     end
   end
 end

 local function reEnablingLoop()
   cleanEnabledGroupCommands()
   enableForGroups(coalition.getGroups(coalition.side.RED))
   enableForGroups(coalition.getGroups(coalition.side.BLUE))
   autogft.scheduleFunction(reEnablingLoop, 5) --   <- Checks for new groups every 5 seconds
 end

 reEnablingLoop()

end

enableRefillCommand()

 

 

 

EDIT2: I'm struggling a little to see how you can add fuel/ammo to units from a script :/


Edited by gromit190
Link to comment
Share on other sites

Many Thanks gromit190, it doesn't matter if an entire group is affected by a script because I can set each aircraft to be in it's own group.

 

I've found a DCS Func to add fuel to a unit but not an ammo script as of yet.

 

Fuel - http://wiki.hoggit.us/view/DCS_func_getFuel

 

I am kinda new to .lua scripting so where would I insert these DCS func scripts? Do they go as a .lua file within the mission file or do I insert them via a trigger inside the mission editor?

[spoiler=PC SPECS]

Intel i5-8600k @3.60GHz

EVGA GTX 1070Ti

Windows 10

16GB RAM 3200 MHz

500 GB Samsung 850 SSD

2TB Seagate SSHD

Some cool LED fans that light up

 

 

Link to comment
Share on other sites

Many Thanks gromit190, it doesn't matter if an entire group is affected by a script because I can set each aircraft to be in it's own group.

 

I've found a DCS Func to add fuel to a unit but not an ammo script as of yet.

 

Fuel - http://wiki.hoggit.us/view/DCS_func_getFuel

 

I am kinda new to .lua scripting so where would I insert these DCS func scripts? Do they go as a .lua file within the mission file or do I insert them via a trigger inside the mission editor?

 

Actually, this function only returns the fuel of a unit. You can't set it, only "get" it (for printing it to screen or whatever). Sorry :/

 

Maybe someone else knows how to set the fuel

Link to comment
Share on other sites

  • 3 years later...
What you're suggesting is highly possible and not that hard to do (I think).

 

Here's a function to add radio commands: http://wiki.hoggit.us/view/DCS_func_addOtherCommandForGroup

 

I haven't really refilled/refueled with a script before, but I'm pretty confident it is possible.

 

The only "problem" as I see it is that you can't distinguish between players in a group that calls the command to refill/refuel. So if you have a group of 4, and 1 of them calls the refill/refuel command then the whole group will be refilled/refueled.

 

 

 

Another challenge is that the command will only be added for groups that are existing (have live players) in your mission. The way I've solved this before is I have a function that is scheduled at time intervals. The function removes the command for all groups (that has it), then re-adds it for all groups that exist (in-game players). Here's the code.

 

 

 

EDIT: Here's one way to add the radio command (requires the autogft script, version 1.2 download here).

Firstly, load the "autogft-standalone.lua" to your mission. Then load the following script:

 

function enableRefillCommand()

 local enabledGroupCommands = {}

 local function cleanEnabledGroupCommands()
   local newEnabledGroupCommands = {}
   for i = 1, #enabledGroupCommands do
     if not Group.getByName(enabledGroupCommands[i].groupName) then
       enabledGroupCommands[i]:disable()
     else
       newEnabledGroupCommands[#newEnabledGroupCommands + 1] = enabledGroupCommands[i]
     end
   end
   enabledGroupCommands = newEnabledGroupCommands
 end

 ---
 -- @param #number groupId
 local function groupHasCommandEnabled(groupId)
   for i = 1, #enabledGroupCommands do
     if enabledGroupCommands[i].groupId == groupId then
       return true
     end
   end
   return false
 end

 ---
 -- @param DCSGroup#Group group
 local function groupHasPlayer(group)
   local units = group:getUnits()
   for i = 1, #units do
     if units[i]:getPlayerName() ~= nil then return true end
   end
   return false
 end

 ---
 -- @param #list<DCSGroup#Group> groups
 local function enableForGroups(groups)
   for i = 1, #groups do
     local group = groups[i]
     if groupHasPlayer(group) then
       if not groupHasCommandEnabled(group:getID()) then
         local function triggerCommand()
           -- 
           -- DO THE REFILLING HERE, the "group" variable holds the target group
           --
         end
         local groupCommand = autogft_GroupCommand:new("Refuel & refill", group:getName(), triggerCommand)
         groupCommand:enable()
         enabledGroupCommands[#enabledGroupCommands + 1] = groupCommand
       end
     end
   end
 end

 local function reEnablingLoop()
   cleanEnabledGroupCommands()
   enableForGroups(coalition.getGroups(coalition.side.RED))
   enableForGroups(coalition.getGroups(coalition.side.BLUE))
   autogft.scheduleFunction(reEnablingLoop, 5) --   <- Checks for new groups every 5 seconds
 end

 reEnablingLoop()

end

enableRefillCommand()

 

 

 

EDIT2: I'm struggling a little to see how you can add fuel/ammo to units from a script :/

 

 

hello, so what is the code would be if my target group name is Tanker?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...