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. :frowning:

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.

1 Like

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).

2 Likes

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 :smiley:

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!

3 Likes

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…

What would be my alternative to test? Create the MOD on steam and use MOD launch?

The print does nothing.

@b8factor

function GameSpeedUp()
  if (currentGameSpeed =< maxGameSpeed) then

should be

function GameSpeedUp()
  if (currentGameSpeed <= maxGameSpeed) then

Lua can’t handle the equals before the greater than or less than symbols.

my mistake from the code I posted earlier

I modified code to:

bind2("GameSpeedUp()", SHIFTKEY, BACKSLASHKEY)
bind2("GameSpeedDown()", CONTROLKEY, BACKSLASHKEY)
bind1("GameSpeedNormal()", BACKSLASHKEY)

print("billy")

currentGameSpeed = 2
maxGameSpeed = 32
minGameSpeed = 1
incGameSpeed = 2

function GameSpeedNormal()
  currentGameSpeed = 2
  TurboEnable(2)
end

function GameSpeedUp()
  if (currentGameSpeed <= maxGameSpeed) then

    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

Pressing shift+\ does nothing for both local run on desktop icon and when uploaded to steam as a MOD and ran with MOD option in homeworldRM. buggers!

I have gotten autoexec to work in the past, BitV walked me through adding camactions so I could make videos, and that worked. Just in case that was conflicting with this I removed it all and tried everything again, still no go. Puzzled.

The shortcut you use seems odd…
Mine is D:\Steam\steamapps\common\Homeworld\HomeworldRM\Bin\Release\HomeworldRM.exe -traceHODs -moddatapath Mod_Sandbox -freeMouse -luaTrace .
Difference being is that I am loading Homeworld directly rather then the launcher… I don’t know if this is the issue though

Also, I am able to get the speed mod working on mine

Check your HwRM log to see if ‘billy’ has appear.

I switched my shortcut to look like yours, that will save me some clicks… thanks!

I do see “billy” in the log, however the speed up/speed down is not happening in game. Silly question but, I am assuming I just hold down “SHIFT” and then press “/”…

at least for cam actions that is how i fired the camera.

Posting my log up to the billy in case anybody see anything fishy in it?

   Thu Nov 16 07:00:16 2017
 Version 2.1, Build Number 31, Changelist Number 1237961 
 Loaded Archive: 'Homeworld2.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateHomeworld2.big' 
 Loaded Archive: 'HW1Ships.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateHW1Ships.big' 
 Loaded Archive: 'HW2Ships.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateHW2Ships.big' 
 Loaded Archive: 'HWBackgrounds.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateHWBackgrounds.big' 
 UTIL -- filepath failure, path doesn't exists 'C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\data\locale\English' 
 Loaded Archive: 'English.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateEnglish.big' 
 Failed to Load Archive '..\..\DATAUPDATES\Compatibility.big' 
 Uing ..profiles\ for profiles folder 
 GAME -- Using player profile Agent_B8factor 
 Changing from a 32 bit colour depth in winNT (6.1 build 7601), Service Pack 1 
 Display: (0, 0, 1920, 1080) - (8, 30) 
 GL Info: 4.6 - 4.6.0 NVIDIA 388.13 
 GL Vendor: NVIDIA Corporation 
 GL Renderer: GeForce GTX 1080 Ti/PCIe/SSE2 
 GL Part ID: 1080 
 Loaded Archive: 'EnglishSpeech.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateEnglishSpeech.big' 
 Loaded Archive: 'Music.big' 
 Failed to Load Archive '..\..\DATAUPDATES\UpdateMusic.big' 
 SOUND -- created destination [ fdaudio ], handle [ 4 ] with [ 48 ] channels created 
 SOUND -- created destination [ fda streamer ], handle [ 5 ] with [ 8 ] channels created 
 SOUND -- created destination [ dxa streamer ], handle [ 0 ] with [ 8 ] channels created 
 SOUND -- created destination [ dxaudio ], handle [ 1 ] with [ 48 ] channels created 
 Build name: 
 Data path : C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\data 
 Font Load: data:UI\Font\Blender.rcf, 1920,1080 
 Font Attr: 14, Biu 
 No mapping for font 'Blender' - using 'default' 
 Resetting fp PC control word. 
 CmdLine: -moddatapath B8AI -luatrace 
 CPU: Loading /AI Mod/src/leveldata/multiplayer/lib/lib.lua 
 CPU: Loading /AI Mod/src/leveldata/multiplayer/lib/cpuplayers.lua 
 Cannot overwrite function HW2_rgb 
 Cannot overwrite function HW2_SubTitleEvent 
 Cannot overwrite function HW2_LocationCardEvent 
 Cannot overwrite function HW2_CameraRotated 
 Cannot overwrite function HW2_CameraPanned 
 Cannot overwrite function HW2_Wait 
 Cannot overwrite function HW2_PingCreateWithLabel 
 Cannot overwrite function HW2_PingCreateWithLabelPoint 
 Cannot overwrite function HW2_CreateEventPointerSobGroup 
 Cannot overwrite function HW2_CreateEventPointerVolume 
 Cannot overwrite function HW2_CreateEventPointerSubSystem 
 Cannot overwrite function HW2_Letterbox 
 Cannot overwrite function HW2_Pause 
 Cannot overwrite function HW2_Fade 
 Cannot overwrite function instantParadeOnSkip 
 Cannot overwrite function HW2_DisableBuilderOnCapture 
 Cannot overwrite function HW2_VaygrBuildShips 
 Cannot overwrite function HW2_VaygrOrder 
 Cannot overwrite function HW2_InitializeBuilder 
 Cannot overwrite function HW2_SobGroup_ReduceHealthPercentage 
 Cannot overwrite function HW2_SobGroup_AddHealthPercentage 
 Cannot overwrite function HW2_IsRunTimeSobGroupEmpty 
 Cannot overwrite function HW2_IsRunTimeSobGroupAlive 
 Cannot overwrite function HW2_PlayerHasMilitary 
 Cannot overwrite function HW2_ReactiveInfo 
 Cannot overwrite function HW2_RestrictBuild 
 Cannot overwrite function HW2_GrantBuild 
 Cannot overwrite function HW2_RestrictResearch 
 Cannot overwrite function HW2_GrantResearch 
 Cannot overwrite function HW2_SetResearchLevel 
 Cannot overwrite function Timer_Start 
 Cannot overwrite function Timer_Add 
 Cannot overwrite function Timer_Pause 
 Cannot overwrite function Timer_GetRemaining 
 Cannot overwrite function Timer_Resume 
 Cannot overwrite function Timer_Display 
 Cannot overwrite function Timer_End 
 Cannot overwrite function SPRestrict 
 Cannot overwrite function MPRestrict 
 Cannot overwrite function SPRestrictOptions 
 Cannot overwrite function RestrictOptions 
 print LOADING /Homeworld/scripts/gamerules/AIMod.lua 
 Cannot overwrite function OnInit 
 Race Filtering: DEATHMATCHHW2 rules - @Deathmatch,DeathmatchHW2,Extras 
 12 Races Discovered 
 ContentDownloader: Waiting for players 
 ContentDownload: Player 2925716526 joined. 
 ContentDownloader: All players connected. Sending file requests. 
 ContentDownloader: entering main phase 
 ContentDownload: 2925716526 is READY 
 Starting Level: DATA:\LevelData\Multiplayer\DeathMatchHW2\3p_dantes_requiem.level 
 Font Load: data:UI\Font\SmallFonts7.rcf, 1920,1080 
 Font Attr: 14, Biu 
 CPU:  LOADING /AI Mod/src/ai/default/default.lua 
 CPU: PersonalityDemand: Fi:0.5 Co:0.25 Fr:0 
 Unable to retrieve UI (animated) texture () 
 Error, LoadScreen failed to screen of type GameBalanceScreen when loading section GameBalanceScreen from file DATA:\UI\NewUI\Developer\GameBalanceScreen.lua 
 Error, LoadScreen failed to screen of type DeveloperScreen when loading section DeveloperScreen from file DATA:\UI\NewUI\Developer\DeveloperScreen.lua 
 CPU: Loading /AI Mod/src/leveldata/multiplayer/lib/lib.lua 
 CPU: Loading /AI Mod/src/leveldata/multiplayer/lib/cpuplayers.lua 
 Cannot overwrite function HW2_rgb 
 Cannot overwrite function HW2_SubTitleEvent 
 Cannot overwrite function HW2_LocationCardEvent 
 Cannot overwrite function HW2_CameraRotated 
 Cannot overwrite function HW2_CameraPanned 
 Cannot overwrite function HW2_Wait 
 Cannot overwrite function HW2_PingCreateWithLabel 
 Cannot overwrite function HW2_PingCreateWithLabelPoint 
 Cannot overwrite function HW2_CreateEventPointerSobGroup 
 Cannot overwrite function HW2_CreateEventPointerVolume 
 Cannot overwrite function HW2_CreateEventPointerSubSystem 
 Cannot overwrite function HW2_Letterbox 
 Cannot overwrite function HW2_Pause 
 Cannot overwrite function HW2_Fade 
 Cannot overwrite function instantParadeOnSkip 
 Cannot overwrite function HW2_DisableBuilderOnCapture 
 Cannot overwrite function HW2_VaygrBuildShips 
 Cannot overwrite function HW2_VaygrOrder 
 Cannot overwrite function HW2_InitializeBuilder 
 Cannot overwrite function HW2_SobGroup_ReduceHealthPercentage 
 Cannot overwrite function HW2_SobGroup_AddHealthPercentage 
 Cannot overwrite function HW2_IsRunTimeSobGroupEmpty 
 Cannot overwrite function HW2_IsRunTimeSobGroupAlive 
 Cannot overwrite function HW2_PlayerHasMilitary 
 Cannot overwrite function HW2_ReactiveInfo 
 Cannot overwrite function HW2_RestrictBuild 
 Cannot overwrite function HW2_GrantBuild 
 Cannot overwrite function HW2_RestrictResearch 
 Cannot overwrite function HW2_GrantResearch 
 Cannot overwrite function HW2_SetResearchLevel 
 Cannot overwrite function Timer_Start 
 Cannot overwrite function Timer_Add 
 Cannot overwrite function Timer_Pause 
 Cannot overwrite function Timer_GetRemaining 
 Cannot overwrite function Timer_Resume 
 Cannot overwrite function Timer_Display 
 Cannot overwrite function Timer_End 
 Cannot overwrite function SPRestrict 
 Cannot overwrite function MPRestrict 
 Cannot overwrite function SPRestrictOptions 
 Cannot overwrite function RestrictOptions 
 print LOADING /Homeworld/scripts/gamerules/AIMod.lua 
 Cannot overwrite function OnInit 
 3p_dantes_requiem 
 table: 2F6FEC60 
 23348.130859375 
 12152.9296875 
 23348.130859375 
 Resources558445 
 build available 
 generic build available 
 build available 
 generic build available 
 billy 
 Killing player 2 () at time 0.000000 
 userdata(8): 10C93048 
 print Player 1 LOD is 1 
 userdata(8): 33C3BDA8 
 userdata(8): 15903CFC

Yes, except its ‘\’, not ‘/’