In any combat mode your units always attack anything half the map away, so I don’t think it really matters. It’s buggy by default.
To add, stance is based on the strike group formation, generally
- Aggressive - Break into sub-formations by ‘combatGrouping’ or CombatFamily.
- Evasive - Same as Batch, but with ‘sub squadron’ population limits, aka ‘peel off’ logic from HW2.
- Neutral - Break into single ships or by squadron-batch.
Think along the lines of, ROE is when they attack, Stance is how they attack.
Question about testing.
For those MODERS out there, do you have some secret to loading up a quick test? I run window but I would like to be able to have the multi player setting filled in automatically and launched to save some clicks and time… i suppose I could code that but I wanted to make sure there was not some trick I did not know about?
How about speeding up game time as well? I know how to slow down, but i was not sure if you could speed up?
The autoexec.lua file you need to create in \HomeworldRM\Bin\Release .
To advance the code a bit
bind2("GameSpeedUp()", SHIFTKEY, BACKSLASHKEY)
bind2("GameSpeedDown()", CONTROLKEY, BACKSLASHKEY)
bind1("GameSpeedNormal()", BACKSLASHKEY)
currentGameSpeed = 2
maxGameSpeed = 32
minGameSpeed = 1
incGameSpeed = 2
function GameSpeedNormal()
currentGameSpeed = 2
TurboEnable(2)
end
function GameSpeedUp()
if (currentGameSpeed =< maxGameSpeed) then
currentGameSpeed = currentGameSpeed + incGameSpeed
if (currentGameSpeed > maxGameSpeed) then
currentGameSpeed = maxGameSpeed
end
TurboEnable(currentGameSpeed)
end
end
function GameSpeedDown()
if (currentGameSpeed >= minGameSpeed) then
currentGameSpeed = currentGameSpeed - incGameSpeed
if (currentGameSpeed < minGameSpeed) then
currentGameSpeed = minGameSpeed
end
TurboEnable(currentGameSpeed)
end
end
This allows you to speed up the game further by pressing Shift+ /
[Edit]
Incase TurboEnable doesn’t work properly, there is also SetTurboSpeed. Seems to be the same function that is also in the autoexec.lua globals, but is current used in ui\newui\developer\gamebalancescreen_code.lua and is shown to go up to 64. Where as 1 appears to be normal speed.
[Edit2]
As for jump straight into a game, I don’t think your able to with a skirmish match… maybe you could try editing HomworldRM\Bin\Profiles\ProfileX\PLAYERCFG.lua. If it was a campaign, you can use -campaign <campaign name> -startinglevel <level name>.
More command line parameters can be found at http://hw2wiki.net/wiki.hw2.info/CommandLineParameters.html. Possibly something there that I didn’t see. There are more parameters for HwRM, but I’m unsure of them… Should be in the forums somewhere I believe.
[Edit3]
Thinking about the above code, it could be that TurboEnable may only accept numbers that are a power of 2, if this is the game, change the + to * and - to \. Make sure to keep incGameSpeed = 2 and minGameSpeed = 1 . maxGameSpeed might be able to be 64 making available number 1, 2, 4, 8, 16, 32 & 64.
Anybody know how to change the individual ship attack priorities? e.g. fighters stop chasing scouts!
I believe the only way to tell a unit who they can and can’t attack is in the .ship file with addAbility("NewShipType","CanAttack",...)
I’m unsure if there is a better way to do it with scripting, but one way I can think of is to remove the unit’s from the sobgroups attack list.
function SobGroup_RemoveFromAttackList(SobGroup_In, FilterType, FilterExclude)
if (not SobGroup_In or not FilterType or not FilterExclude) then return end
if (SobGroup_IsDoingAbility(SobGroup_In, AB_Targeting)~= 1) then return end -- No need if they are not targeting anyone.
SobGroup_CreateIfNotExist("temp")
SobGroup_GetCommandTargets("temp", SobGroup_In, COMMAND_Attack) -- "temp" & SobGroup_In could be around the wrong way.
local count = SobGroup_Count("temp")
if (count > 0) then
SobGroup_FilterExclude("temp", "temp", FilterType, FilterExclude)
if (SobGroup_Count("temp") < count) then -- Only continue if we removed units
SobGroup_Attack(SobGroup_OwnedBy(SobGroup_In), SobGroup_In, "temp")
end
end
end
Call it using SobGroup_RemoveFromAttackList(SobGroup_In, "UnitCapsFamily", "Scout") to remove scouts from the attack list (Untested)
Possible options for FilterType are
- NoFilter
- ShipType
- ShipClass
- AttackFamily
- AvoidanceFamily
- CollisionFamily
- CollisionDamageFamily
- BuildFamily
- DockFamily
- DisplayFamily
- AutoformationFamily
- ArmourFamily
- UnitCapsFamily
- Ability
- Health
- Docked
- CurrentCommand
- CurrentCommandState
- PlayerOwner (Might only be used with
Selection_Filter[Include|Exclude]) - ScriptFlagsSetAll (Only used with
Selection_Filter[Include|Exclude]) - ScriptFlagsSetAny (Only used with
Selection_Filter[Include|Exclude]) - ScriptFlagsUnset (Only used with
Selection_Filter[Include|Exclude]) - NearPoint (Only used with
Selection_Filter[Include|Exclude])
FilterTypes taken from Malwr (Static Analysis > Strings). This may be an incomplete list as it’s from a 2.0 exe. I am unable to pull the string from the 2.1 exe so if anyone is able to, it may show a whole new list of additions that we do not know of
I ran some tests on Stance and ROE.
Code:
---Set ROE and Stance
--@param SobGroupChk The SobGroup to set for
--@parma action what action to set (Run, Fight, Hold, Strike Craft Stock)
----default strikecraft OffensiveROE AggressiveStance
function Tactics(SobGroupChk, action)
--Get AI home ASAP
print(SobGroupChk)
print(action)
if (action == "Run") then
SobGroup_SetStance(SobGroupChk, EvasiveStance)
SobGroup_SetROE(SobGroupChk, PassiveROE)
end
--Fight Hard
if (action == "Fight") then --Default for SS
SobGroup_SetStance(SobGroupChk, AggressiveStance)
SobGroup_SetROE(SobGroupChk, OffensiveROE)
end
--Hold your ground as long as you can
if (action == "Hold") then
SobGroup_SetStance(SobGroupChk, NeutralStance)
SobGroup_SetROE(SobGroupChk, DefensiveROE)
end
if (action == "Stock") then
SobGroup_SetStance(SobGroupChk, AggressiveStance)
SobGroup_SetROE(SobGroupChk, DefensiveROE)
end
local temp2 = SobGroup_GetStance(SobGroupChk)
print("SobGroups Stance is: "..temp2)
local temp = SobGroup_GetROE(SobGroupChk)
print("SobGroups ROE is: "..temp)
end
Results: (no upgrades)
5 hgn_interceptor Tactics(“1”,“Run”)
5 hgn_interceptor Tactics(“0”,“Fight”) 17 survived, 19 survived, 21 survived.
5 hgn_interceptor Tactics(“1”,“Run”)
5 hgn_interceptor Tactics(“0”,“Hold”) 16 survived, 15 survived.
5 hgn_interceptor Tactics(“1”,“Hold”)
5 hgn_interceptor Tactics(“0”,“Fight”) 4 survived, 15 survived.
5 hgn_interceptor Tactics(“1”,“Stock”) 10 survived, 5 survived.
5 hgn_interceptor Tactics(“0”,“Stock”)
5 hgn_interceptor Tactics(“1”,“Stock”) 15 survived 5 survived
***5 hgn_interceptor Tactics(“0”,“Stock”)
5 hgn_interceptor Tactics(“1”,“Stock”) 15 survived
5 hgn_interceptor Tactics(“0”,“Stock”) 2 survived, 15 survived.
*** this one puzzled me. After units spawned I hot keyed team 0 into 3 hot keys. before the engaged I set hotkey 1 attack a group, hotkey 2 attack a group, and left 3 one alone. I expected human control would focus down their groups faster but i lost.
Question for the MultiPlayer people out there… how do you micro your strike craft?
I also tried several test in addition with strike-group formations. the only notable difference is that using fighter screen or wall walking into a fight could be an issue if the other side has as any Flak Frigates at all hanging around. The Stock formation(none) breaks up more and therefore could potentially take a few rounds from the flak while also fighting.
Minor annoyance: I use the hw2bsg site often for reference, and have done so for years. This round it cost me 2 hours of debugging. 
I pulled this example to use in my code:
SobGroup_SpawnNewShipInSobGroup(0, "Hgn_Intercepter", "NewCrateShip", "Player_Ships0", "CrateDetectVolume0")
It is not accurate it has to be:
SobGroup_SpawnNewShipInSobGroup(0, "hgn_interceptor", "NewCrateShip", "Player_Ships0", "CrateDetectVolume0")
t w o h o u r s to f i n d t h a t
I can not really complain though it has saved me uncountable time over the years.
So thinking on this in regards to the AI (and I don’t know how BUG 666 played in the tests) but stock made units work pretty well. Running home though the “Run” does get home about the length of a BC faster.
Question:
I could not get this function to work. I had 3 players; 2 AI and myself. Both AI were enemies. Does it only work with allies?
Player_ShareVision(0, 1, 1)
Player_ShareVision(, , )
Description
Allows and to each see what the other sees.
Example
Arguments
: the index number of Player 1.
: the index number of PLayer 2.
: 0 = disable, 1 = enable.
2 items in this post.
Question: Is there a function for sending and AI SobGroup across the map as an attack move? In all my test, with all the stances set, they bypass everything and go for just the SobGroup or Volume I move them to.
BUG with docking the AI: I took a stab at docking AI strike craft that were damaged.
SobGroup_DockSobGroupAndStayDocked(<sSobGroupName>, <sSobGroupDockToName>)
When I launched the the strike craft after only a single ship came out for the damaged strike craft docking… even if the docking strike craft had more going on?
Is this known? Any work arounds if so?
Why are you using “dock and stay docked”? Just a plain dock function will work fine. They will only launch when fully repaired. My guess is that you manually launched them before they were fully repaired.
I wanted to keep them in the dock until i was ready to use them again… not to important though. I just wanted a way to make strike craft safe if some flacks came around… human player is smart enough to… the AI just tosses their lifeless ships into the flack.
It could be that the other strike craft were removed from the strike group (Might happen if they are batch squadrons like the hiigaran interceptor and the first unit in the squad is destroyed). You could try SobGroup_GetSobGroupDockedWithGroup(<sDockedWithName>, <sOutputName>) to see if there are any strike craft still docked with the ship.
Random question which may or may not be helpful for this thread… how does one determine if a player is a CPU player?
Idea is that you can toggle special attacks for CPU players as they don’t seem to be used, i.e.
SobGroup_AbilityActivate("CustomGroup", AB_UseSpecialWeaponsInNormalAttack, 1)
Sure there are other ways but this is how i did it:
local isAI = Player_GetLevelOfDifficulty(playerIndex)
if (isAI > 0) then
playerLOD[playerIndex] = isAI --Add each Players LOD in table to use to see who is HUMAN.
I loop all players and then load all AI players into a table so I can cycle through it when I need to run loops on each AI player… which I need to do often when MODing for multi player(because there could be multiple AI players).
Hmm, this is a really good way to go about it for purposes of getting special attacks to fire off. You can tie the LOD to different triggers for the ability switch like a higher health percentage…
Thanks 
Exactly.
I am writing a new AI, and decided to replace EASY AI with mine, LOD = 1.
I used LOD so that if a person plays a few default AI (med, hard, or expert) and also mine (B8factorAi in place of EASY) that the AI logic can still handle the default AI. And the code for my AI in place of where EASY was.
If you like I can PM you my brute force override of the AI, see if you can get anything out of it, as I couldn’t get the real AI to build anything?
I believe have cracked the AI code(to the best of my limited ability), I can get my AI to execute** a specific build order(actually can add as many custom build orders as I like now) as well as specific research, resourcing, and build subsystems. AND this was the hard part, with maintaining the original AI so they can play nicely together in game with real humans.
** And not actually force it but persuade so that I can gently or abruptly stop persuading and it picks up on its own and continues forward.
I am currently working on its military priority and groupings. Once I get it all worked out I will publish the documentation I am putting together for it.
But I would love to see anyone else AI code for sure, I learn something new everytime I read peoples code!
I am not able to get this to work… I wonder if that is also why I can not use the function to turn on wire frame of sphere’s inside the game…
If anyone has time this is what I have:
In the Autoexec.lua
bind2("GameSpeedUp()", SHIFTKEY, BACKSLASHKEY)
bind2("GameSpeedDown()", CONTROLKEY, BACKSLASHKEY)
bind1("GameSpeedNormal()", BACKSLASHKEY)
currentGameSpeed = 2
maxGameSpeed = 32
minGameSpeed = 1
incGameSpeed = 2
function GameSpeedNormal()
currentGameSpeed = 2
TurboEnable(2)
end
function GameSpeedUp()
if (currentGameSpeed =< maxGameSpeed) then
currentGameSpeed = currentGameSpeed + incGameSpeed
if (currentGameSpeed > maxGameSpeed) then
currentGameSpeed = maxGameSpeed
end
TurboEnable(currentGameSpeed)
end
end
function GameSpeedDown()
if (currentGameSpeed >= minGameSpeed) then
currentGameSpeed = currentGameSpeed - incGameSpeed
if (currentGameSpeed < minGameSpeed) then
currentGameSpeed = minGameSpeed
end
TurboEnable(currentGameSpeed)
end
end
I launch a shortcut on my desktop with these properties:
"C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HWLauncher\Launcher.exe" -moddatapath B8AI -luatrace - window
The keys do not speed up the game for me,… am I missing something simple?
I have tried remastered(HW 2 skirmish and Multiplayer HW2), neither work.
What happens if you stick a print in there? Is it running any of the code at all?
I have a strange feeling that auto exec may not work with moddatapath, but I don’t know where that feeling comes from or if it is based on any facts…
