Interaction with the game map

AW Arcaeca

Deus Vult
Joined
Mar 10, 2013
Messages
2,984
Location
Operation Padlock ground zero
For a possible upcoming mod I was theorizing about a unit ability akin to the paratrooper's ability of, well, deployment by parachute. I'm sure that's totally possible, except... is it possible without DLL to allow the player to select a plot by clicking on the map (like how the parachute ability works) and assigning the chosen plot to a variable?
 
No DLL mod needed, but you're going to have to mod either the InGame.lua or the WorldView.lua (can't remember off the top of my head which one the InterfaceMode code is in) core game file to achieve it.
 
I think there are some mods that have functionality like that -- I believe Chronicles of Ea lets you target locations on the map for spells?
 
I think there are some mods that have functionality like that -- I believe Chronicles of Ea lets you target locations on the map for spells?

Ea also makes extensive changes to the DLL. ;) But whoward is right, you don't need to mod the DLL to make UI interactions with the map, it can be done with lua overwriting.
 
By the looks of both files it appears to be InGame.lua. Case in point:
Spoiler :
InGame.lua said:
Code:
function ShowParadropRangeIndicator()
	local pHeadSelectedUnit = UI.GetHeadSelectedUnit();
	if not pHeadSelectedUnit then
		return;
	end
	
	local thisPlot = pHeadSelectedUnit:GetPlot();
	if pHeadSelectedUnit:CanParadrop(thisPlot, false) then
		local iRange= pHeadSelectedUnit:GetDropRange();
		print("irange: "..tostring(iRange))
		local thisX = pHeadSelectedUnit:GetX();
		local thisY = pHeadSelectedUnit:GetY();
		
		for iDX = -iRange, iRange, 1 do
			for iDY = -iRange, iRange, 1 do
				local pTargetPlot = Map.GetPlotXY(thisX, thisY, iDX, iDY);
				if pTargetPlot ~= nil then
					local plotX = pTargetPlot:GetX();
					local plotY = pTargetPlot:GetY();
					local plotDistance = Map.PlotDistance(thisX, thisY, plotX, plotY);
					if plotDistance <= iRange then
						if pHeadSelectedUnit:CanParadropAt(thisPlot, plotX, plotY) then
							local hexID = ToHexFromGrid( Vector2( plotX, plotY) );
							Events.SerialEventHexHighlight( hexID, true, turn1Color, pathBorderStyle );
						end
					end
				end
			end
		end
	end

end

function HideParadropRangeIndicator()
	ClearUnitHexHighlights();
end
So I'd basically add pretty much copy and paste this in the InGame.lua file and then include
Code:
include('InGame.lua');
in the lua file for the mission?

Related question: The mission will only have an accuracy of 5 plots, i.e. after selecting a plot, the unit will not necessarily be dropped at that plot but at a random plot within 5 plots of the selected one.
So I'm guessing to do this it would make sense to use the method Map.GetPlotXY, which passes the arguments of int x, int y, int xOffset, int yOffset...
Now I have no idea what exactly the "offsets" do but assuming they allow for a range of Xs and Ys, shouldn't this return the tile that the unit will actually land on?
Code:
toPlot = Map.GetPlotXY(hexID:GetX(), hexID:GetY(), math.random(0,5), math.random(0,5))
Where hexID is a variable from InGame.lua?
 
Sorry to necro, but I just realized something: how would I make the unit actually go to the (randomly) selected plot? The UI code from InGame.lua doesn't include the lua that actually moves the paratrooper to the selected plot, just returns the selected plot. I would assume there's some kind of Unit.SetXY function, but I wasn't able to find it on the reference...
 
Uhh, it's there: Unit.SetXY, under the Unit object instance, where you'd expect it to be...
I was looking under "S" on this page, not on the page about Unit instances. But the fact that I didn't think to look there... :cringe:
Nonetheless, thanks.
 
Top Bottom