formation movement

formation movement

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

formation movement

Post by Gota »

http://pastebin.com/md777a1

This is the CustomFormations widget.
Can anyone please modify it so that when air units are selected they would always move in formation(ATM this is done by pressing the right mouse button with ctrl) instead of moving regularly.
Basically switch the right click with the right click+ctrl for air units.

when you draw a line for them they shoul just move to it and on it as usual.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: formation movement

Post by CarRepairer »

Gota wrote:http://pastebin.com/md777a1

This is the CustomFormations widget.
Can anyone please modify it so that when air units are selected they would always move in formation(ATM this is done by pressing the right mouse button with ctrl) instead of moving regularly.
Basically switch the right click with the right click+ctrl for air units.

when you draw a line for them they shoul just move to it and on it as usual.
What you're asking for has nothing to do with the customformations widget, however it's very simple to do as its own widget.

I'll write it for you in exchange for the following task:

I want you to create for me 65 spring maps. The first map will have 2^0 islands (1 island). The second will have 2^1 islands (2 islands). The third will have 2^2 islands (4 islands). The fourth will have 2^3 islands (8 islands). The fifth will have 2^4 islands (16 islands). And so on until you reach a map with 2^64 islands for the greatest FFA experience ever.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: formation movement

Post by Gota »

Oo
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: formation movement

Post by Argh »

I think you should ask him to double that rice grain a few more times, myself. Ooh, obscure math joke!
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: formation movement

Post by CarRepairer »

Argh wrote:I think you should ask him to double that rice grain a few more times, myself. Ooh, obscure math joke!
Yay, you caught it!

(The other joke referenced here is an exchange between OP and I that I'd write him a gadget and he'd make me a map. The gadget I made for him didn't function properly in the end and the map he made me was nothing like I asked for.)
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: formation movement

Post by Tribulex »

* cough * cough * cough *

Image

* cough * cough * cough *
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: formation movement

Post by AF »

No be messin with ma colour scheme!
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: formation movement

Post by Niobium »

Just a note that the link to custom formations 2 in original post is terribly out of date.
"Basically switch the right click with the right click+ctrl for air units."
But what if you wanted them to move onto that spot? To keep this functionality you would need a way to toggle between the two options, for example the control key.. Oh hey that's how it is already, problem solved.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: formation movement

Post by Gota »

Niobium wrote:Just a note that the link to custom formations 2 in original post is terribly out of date.
"Basically switch the right click with the right click+ctrl for air units."
But what if you wanted them to move onto that spot? To keep this functionality you would need a way to toggle between the two options, for example the control key.. Oh hey that's how it is already, problem solved.
If you will try you will notice it is very frustrating to give multiple way point commands in the heat of battle when you have to press both shift and ctrl.
To make it convenient i need the default one to be formation move.
Even if there is no way to switch between the 2,and the default is formation move you can always draw a tiny line instead of right clicking.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: formation movement

Post by lurker »

Is it that obscure? Anyway, Car, I'll make those maps if you promise you'll use them.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: formation movement

Post by CarRepairer »

No need. I'll make this widget, it's not a bad idea.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: formation movement

Post by Tribulex »

Gota wrote:If you will try you will notice it is very frustrating to give multiple way point commands in the heat of battle when you have to press both shift and ctrl.

When have your battles been seeing any heat?

Also, shift and ctrl are right next to eachother on pretty much every keyboard layout.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: formation movement

Post by CarRepairer »

Not sure if you wanted it to apply only if all the selected units are air, or if some of them are. This works only if they all are.

Code: Select all

function widget:GetInfo()
  return {
    name      = "Air Formation",
    desc      = " v0.01 If all selected units fly, move order assigns formation by default.",
    author    = "CarRepairer",
    date      = "2009-12-01",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = true
  }
end

local echo = Spring.Echo

local function AllFlying()
	local selectedUnits = Spring.GetSelectedUnits()
	for _, unitID in ipairs(selectedUnits) do

		local unitDefID = Spring.GetUnitDefID(unitID)
		local ud = UnitDefs[unitDefID]

		if not ud.canFly then
			return false
		end
	end
	return true
end

function widget:CommandNotify(cmdID, cmdParams, cmdOptions)
	
	if cmdID == CMD.MOVE then
		if not AllFlying() then
			return false
		end
		
		local opts = {'ctrl'}
		if (cmdOptions.alt)   then table.insert(opts, "alt")   end
		if (cmdOptions.shift)  then table.insert(opts, "shift")  end
		if (cmdOptions.right) then table.insert(opts, "right") end
		Spring.GiveOrder(CMD.MOVE, cmdParams, opts)
		return true
	end
	return false
	
end
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: formation movement

Post by Gota »

Will try as soon as i get back home.thx.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: formation movement

Post by Gota »

Would this work fine with a large number of aircraft?by the way what if they are given a patrol command and fight command?will they move in formation?cause patrol and fight commands are used a lot with air maybe even more than move.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: formation movement

Post by CarRepairer »

Gota wrote:Would this work fine with a large number of aircraft?by the way what if they are given a patrol command and fight command?will they move in formation?cause patrol and fight commands are used a lot with air maybe even more than move.
Message me on the lobby with how you want this to work exactly. It can work with whatever commands you choose.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: formation movement

Post by Gota »

Ill try to catch you online but in general id like them to move in formation in as many occasions and commands as possible.
Post Reply

Return to “Lua Scripts”