For simplicity's sake I drew my problem/request.
I'd like it so when I tell a unit to attack water, it attacks the point I tell it to.
EDIT: I realize there's already UI implimentation of an indicator showing where the unit will shoot on the water's surface depending where your mouse is in relation to the actual land underneath, and I SUPPOSE if thats all thats possible then OK -- I'd like the same implimented for moving, fight moving etc -- ALL mouse interaction features with water.
Camera angle, water, and you.
Moderator: Moderators
-
SpikedHelmet
- MC: Legacy & Spring 1944 Developer
- Posts: 1948
- Joined: 21 Sep 2004, 08:25
Camera angle, water, and you.
- Attachments
-
- camangle.jpg (20.81 KiB) Viewed 554 times
Re: Camera angle, water, and you.
Sounded like something that could be done in lua, so I went and tried it.
Here's a really simple widget for it, it doesn't account for amphibious units, or not issuing commands off the map, or notifying other widgets of what its doing, etc..
Here's a really simple widget for it, it doesn't account for amphibious units, or not issuing commands off the map, or notifying other widgets of what its doing, etc..
Code: Select all
local function AdjustForWater(px, py, pz)
if py >= 0 then return px, py, pz end
local cx, cy, cz = Spring.GetCameraPosition()
if cy < 0 then return px, py, pz end
local adj = -py / (py - cy)
return px + (px - cx) * adj, 0, pz + (pz - cz) * adj
end
function widget:CommandNotify(cmdID, cmdParams, cmdOpts)
if #cmdParams == 3 and cmdParams[2] < 0 then
local nx, ny, nz = AdjustForWater(cmdParams[1], cmdParams[2], cmdParams[3])
Spring.GiveOrder(cmdID, {nx, ny, nz}, cmdOpts)
return true
end
end