[MOD] Test Mission Grid v0.15.1 - 2017/10/07


(Sastrei) #3

Cooool!!!


(Herbyguitar) #4

Finally! A reason to play HWRM again :smiley:


#5

This mod does not contain any fun, so YMMV.


(Herbyguitar) #6

Fun? Define fun… It’s all good :slight_smile:


(Taiidan Republic Mod) #10

Would it be possible to change the contents of each mission/square dynamically? I mean you could have the player fleet starting in one corner of the grid and an enemy fleet starting in the other corner. The event fleet would move to another square depending on which direction the player moved…

Maybe even a sort of homeworld chess!


#11

I was planning on having persistent enemies that move around the galaxy just like you do. I was kind of modeling the idea on Jagged Alliance 2, where you start out toward the northeast of Arulco, and the main enemy base is in the southwest, and you and the enemy army can move around in small groups.

One thing I haven’t decided yet is, when and where does all this out-of-combat movement occur? In JA2 you have a strategic map where you can speed up time to many times real time. But the game still tracks hours and days and months, and it takes time to do stuff. Sometimes a lot of time. How do I do this in Homeworld? The frontend GUI has no clock, for instance. And there’s only so much stuff you can stuff into memory during normal play. (HWRM is a 32-bit application.)

Not sure whether I will ever get that far in development. I may put aside the project once I complete a few more tasks I had planned.


#14

Regarding persistent fleets.

There is the problem that a gametype script only allows you to check a ship’s position, not its rotation. So when loading a stored fleet, I can either:

  1. rotate all ships randomly
  2. rotate all ships to face some point, such as the map center

Beyond that, how should I store ships that are in transit between sectors? Should I:

  1. store them separately in a different table?
  2. just create a flag for each sector indicating that a ship located in it is in transit to a neighboring sector?

How did JA2 do this? I don’t know.


#16

Update to version 0.11.0.

I need to be more selective about who gets to hyperspace away from a sector and who does not. For instance, probes and platforms should not follow the mothership into hyperspace, and fighters and corvettes should need to be docked first. Also, I think that only capships that are selected or strikecraft that are docked to a selected capship should be able to hyperspace. Further, only ships that are actiually on an exit grid should be able to go. Lastly, capships should require a hyperspace module, or be located near a capship with a hyperspace module. Need to check “data\scripts\scar\singleplayerhyperspace.lua” to see how Gearbox did this.

[edit]

I decided to skip the above issue until later. Right now I am working on the sector map. Here’s what it looks like after a few hours work:

Visited sectors are yellow. Unvisited sectors are blue. The double arrow indicates the direction of travel. The map is displayed in both the frontend and in-game. Cumulative game time is displayed in the bottom-right.


#17

Update to 0.12.0.

The big change is that:

• The mod is now more selective about who gets to hyperspace away from a sector
and who does not. For instance, probes and platforms will not follow the
mothership into hyperspace, and fighters and corvettes need to be docked with
a capship first. Further, capships need to be selected using the mouse, and
must be located on top of an exit grid before they are allowed to leave the
sector. Lastly, capships require a hyperspace module, or need to be within
reach of another capship with a hyperspace module in order to travel. I need
to double-check “data\scripts\scar\singleplayerhyperspace.lua” to see how
Gearbox juggled all the conditions for hyperspacing.

Full change notes are located in the second post of this thread.


(Eville Jedi) #18

for orientation can you create two sobgroups, one with just the ship and one a set distance along its current heading, spawn a dummy ship temporarily with a sobgroup name like ORIENTATION…shipID and then when writing back out the positions for the stored level spawn all the dummy orientations first, then when spawning the coresponding shipID point it at the dummy, then kill all of the invisible dummy ships? It would be messy, but it only needs to happen on jump in and out which probably would have some other scripts running (do ships in hyperspace keep their orientation if they don’t move?)


#19

How do I determine the ship’s orientation “along its current heading”? I would need to track the ship’s movement in real time. What if the ship is stationary?


(Taiidan Republic Mod) #20

Have you tried SobGroup_GetCoordSys()? I have not used it, but it looks likes it might give an orientation…


#21

I tested it and it returns a table containing 9 numbers. Here is an example:

For this point:

this_pos1 = -33000 
this_pos2 = 0 
this_pos3 = 0 

The function returns these numbers:

this_sys1 = 1 
this_sys2 = 0 
this_sys3 = 0 
this_sys4 = 0 
this_sys5 = 1 
this_sys6 = 0 
this_sys7 = 0 
this_sys8 = 0 
this_sys9 = 1

I don’t know what these numbers represent. Some are below zero. None are greater than one. Some kind of matrix I’m guessing, but not sure how to handle it.

Here is the code to print these values:

function SobGroup_CheckCoordinates(check_group)
	local ship_pos = SobGroup_GetPosition(check_group)
	for i = 1, getn(ship_pos) do
		local this_pos = ship_pos[i]
		print("this_pos" .. i .. " = " .. this_pos)
	end
	local ship_sys = SobGroup_GetCoordSys(check_group)
	for i = 1, getn(ship_sys) do
		local this_sys = ship_sys[i]
		print("this_sys" .. i .. " = " .. this_sys)
	end
end

[edit]

I found this document about rotation matrices:

However, I’m not sure which formula to use to convert a matrix to Euler angles. There are several choices:

xyz, xzy, yxz, yzx, zxy, and zyx

or

xyx, xzx, yxy, yzy, zxz, and zyz

Not sure which one is appropriate for Homeworld.


(Taiidan Republic Mod) #22

So it could be local x, y and z rotations about each of the three global axes? Why don’t you try testing it with some known headings?


#23

I got lucky and it was the first formula I tried. Here is some code to convert from a rotation matrix to Euler angles.


function MatrixToEuler(in_matrix)
https://www.geometrictools.com/Documentation/EulerAngles.pdf
local r00 = in_matrix[1]
local r01 = in_matrix[2]
local r02 = in_matrix[3]
local r10 = in_matrix[4]
local r11 = in_matrix[5]
local r12 = in_matrix[6]
local r20 = in_matrix[7]
local r21 = in_matrix[8]
local r22 = in_matrix[9]
local thetaY = 0
local thetaX = 0
local thetaZ = 0
if (r02 < 1) then
if (r02 > -1) then
thetaY = asin(r02)
thetaX = atan2(-r12, r22)
thetaZ = atan2(-r01, r00)
else – r02 = -1
– Not a unique solution: thetaZ − thetaX = atan2(r10, r11)
thetaY = -90
thetaX = -atan2(r10, r11)
thetaZ = 0
end
else – r02 = 1
– Not a unique solution: thetaZ + thetaX = atan2(r10, r11)
thetaY = 90
thetaX = atan2(r10, r11)
thetaZ = 0
end
thetaX = thetaX * -1
thetaY = thetaY * -1
thetaZ = thetaZ * -1
thetaX = mod(thetaX, 360)
thetaY = mod(thetaY, 360)
thetaZ = mod(thetaZ, 360)
if (thetaX < 0) then
thetaX = thetaX + 360
end
if (thetaY < 0) then
thetaY = thetaY + 360
end
if (thetaZ < 0) then
thetaZ = thetaZ + 360
end
return {thetaX, thetaY, thetaZ}
end

[edit]

I added the code to the wiki.

[edit]

Don’t use the above code.


#24

Now that I’ve got the docked ships and ship rotation issues squared away, the next big hurdle is to implement roaming squads. This will require a very interactive sector map so that you can manage and split your forces into several smaller groups. The two main issues ATM are:

  1. The game does not kick you back to the “missionselect.lua” screen (where the sector map is located currently) when exiting a battle. Instead, it kicks you back to the main menu.
  2. You can’t write to disk from the frontend GUI.

As for the first issue, I have thought of two possible approaches so far:

a. Move the sector map to “newmainmenu.lua” instead of “missionselect.lua”, then convert “missionselect.lua” to a smaller menu that floats on top of “newmainmenu.lua”. In “missionselect.lua” I would put only the most basic functions needed to start the mission. Not sure this is possible.
b. Create a special dummy level that consists only of the sector map, with everything else (the compass, taskbar, ships, etc.) left hidden. This would solve issue 2 as well, but just feels like a weird approach.

I will have to put a lot of thought into this.


(Eville Jedi) #25

I like the idea of the navigation level, where you jump out into the galaxy map and then you can move the fleets around., I could even imagine where you could explore and discover hidden systems, have fleet fuel, etc. Mass Effect did this for navigating between planets


(Herbyguitar) #26

Exploration is a huge fun factor for me.


(Eville Jedi) #27

Not sure how you solved the heading coord system, but this was in the scar folder

scripts\scar\singleplayernis.lua (11 hits)
Line 239: position = SobGroup_GetCoordSys(nisCentreGroup)
Line 240: heading = Matrix3_GetVector3FromCol(SobGroup_GetCoordSys(nisCentreGroup), 2)


#28

I will have to test the Matrix3_GetVector3FromCol function as it might do the same thing as the function I wrote.