Custom Map Questions for knowledgeable Modders


(Paradoxnrt) #1

Hi Guys! I`m making a custom map (based off of Hyperspace Arena but about 40x bigger)! I can insert a neutral ship into the map, but I don’t know how to make it aggressively guard it’s area.

Anyway, here`s the question. “Is there a way to make a neutral faction ship that guards a location of the map, but isn’t an AI faction\player?”.

*I want to put a couple of non player\faction Dreadnaughts at the center of the map…but that are hostile to all players\AI factions. I want them to guard their location, but not venture very far from their start location. Thoughts?


(Taiidan Republic Mod) #2

Be careful, there are limits to things like draw distances. Have you tested that a map that big actually works?


(Paradoxnrt) #3

Yup, works okay. Close to the limit though…

On the Sensor Map, there is a bit of clipping in the distance…doesn’t quite cover the whole map. That said, it is very easy to just scroll (keys or using mouse) around = can see the whole map, just not all at once.

We’ve played some test games…the map size encourages carriers to be used with BattleGroups. Way more fun!

I just want to put those 2 Neutral (but hostile) Dreadnaughts in the resource rich center…and am not sure how…


(Herbyguitar) #4

Yup. It can be done. We have maps like this in STC. Unfortunately I don’t know the procedure. Someone should be along shortly to explain it. I have made maps that are the size you stipulated and they’re a complete ‘gass’ to play. Love big maps. Wish more people would venture to make them. Of course you can’t be in a hurry to play them. If the maps are random It takes a while to find your opponents.


(Paradoxnrt) #5

Okay, looking through old stuff, I found the following LEVEL entry that works.

addSquadron(“hgn_dreadnaught”, “hgn_dreadnaught”, {200, 100, 0}, -1, {0, 0, 0}, 0, 0)

BUT, there is a problem. While the Dreadnaught appears on the map, it isn’t hostile unless attacked first. Also, it can’t be captured.

Does anyone know how to make it hostile, BUT only guard its location so it doesn’t seek out player bases?


(Paradoxnrt) #6

Okay, I can insert a neutral faction (faction -1) Dreadnaught into the map. No problem.

However, the Dreadnaught isn’t aggressive at all. Anyone know how to make it aggressive?

FYI:

Looks like the ‘-1’ in that line designates faction ownership. Setting it to ‘0’ gives it to the player hosting the game. Setting it to ‘1’ gives it to however is in slot 2 for the game setup…and so on.

addSquadron(“hgn_dreadnaught”, “hgn_dreadnaught”, {200, 100, 0}, -1, {0, 0, 0}, 0, 0)


(ajlsunrise) #7

What you are trying to do cannot be done exclusively in the level files. This is a GameRule problem.

In data:scripts/rules/deathmatch/deathmatch.lua add dofilepath("data:leveldata/multiplayer/lib/guard.lua") at the bottom of the other dofilepaths. At the end of the OnInit function add Init_GuardMapVolume().

In the map file, add:

createSOBGroup("Volume1Guards")
addSphere("GuardVolume1", {0, 0, 0}, 5000) -- 5km sphere located at map center
-- these next two lines need to be duplicated for every ship intended as a guard, and must be in this order
addSquadron("Guard", "Hgn_Dreadnaught", {1000, 200, 400}, -1, {0, 0, 0}, 1, 0)
addToSOBGroup("Volume1Guards", "Guard")

Create a new file (data:leveldata/multiplayer/lib/guard.lua) with the following content:

function Init_GuardMapVolume()
    SobGroup_Create("Volume1Ships")
    
    Rule_AddInterval("Rule_GuardMapVolume", 5)
end

function Rule_GuardMapVolume()
    -- check to see if guards are dead; if so, remove rule (free some CPU cycles!)
    if SobGroup_Count("Volume1Guards") == 0 then
        Rule_Remove("Rule_GuardMapVolume")
        return
    end
    
    SobGroup_Clear("Volume1Ships")
    SobGroup_FillSobGroupInVolume("Volume1Ships", "AllShips", "GuardVolume1")
    
    -- we don't want the guards to be included in the list of ships to attack
    SobGroup_FillSubstract("Volume1Ships", "Volume1Ships", "Volume1Guards")
    
    if SobGroup_Count("Volume1Ships") > 0 then
        SobGroup_Attack(-1, "Volume1Guards", "Volume1Ships")
    else
        -- this tells the guards to move back into the guard area if no enemy ships are inside the volume
        SobGroup_Move(-1, "Volume1Guards", "GuardVolume1")
    end
end

I’ll continue updating this post as I work on it more.

Okay, that should do it. I haven’t tested it yet, but I’ll give it a whirl when I get home tonight.


(Paradoxnrt) #8

Thank you very much! I’ll implement your suggestions and give it a whirl!


(ajlsunrise) #9

Just updated my post.


(Paradoxnrt) #10

Well, I implemented the inserts and new files…the Dreadnaught does show up, but is is still not hostile.

Do we need to do anything with the .levels file in the (data\leveldata\multiplayer) directory?

*and thank you for the help…I have a feeling we are close!

**of course, feelings and programming aren’t exactly compatible lol!


(Taiidan Republic Mod) #11

You need to set it’s stance to aggressive. Check the Lua files for the vanilla missions to see how to do this. If you get stuck, ask for help. I’m on my phone at the moment so I can’t get you the exact function…

EDIT: ignore that, I just looked at radar’s script properly, and the Dreadnought should be attacking regardless of stance. Did you get any errors on the log file?


(Sastrei) #12

SobGroup_SetROE
SobGroup_GetROE


(Paradoxnrt) #13

Okay, STILL not hostile…maybe I did something wrong here…here are the lines I inserted (I’ll break this up into 3 replies so they are easier to look at).

  1. Created ‘guard.lua’ in the Data\leveldata\multiplayer\lib. Entered following lines:

function Init_GuardMapVolume()
SobGroup_Create(“Volume1Ships”)
SobGroup_SetROE
SobGroup_GetROE
Rule_AddInterval(“Rule_GuardMapVolume”, 5)
end

function Rule_GuardMapVolume()
– check to see if guards are dead; if so, remove rule (free some CPU cycles!)
if SobGroup_Count(“Volume1Guards”) == 0 then
Rule_Remove(“Rule_GuardMapVolume”)
return
end

SobGroup_Clear("Volume1Ships")
SobGroup_FillSobGroupInVolume("Volume1Ships", "AllShips", "GuardVolume1")

-- we don't want the guards to be included in the list of ships to attack
SobGroup_FillSubstract("Volume1Ships", "Volume1Ships", "Volume1Guards")

if SobGroup_Count("Volume1Ships") > 0 then
    SobGroup_Attack(-1, "Volume1Guards", "Volume1Ships")
else
    -- this tells the guards to move back into the guard area if no enemy ships are inside the volume
    SobGroup_Move(-1, "Volume1Guards", "GuardVolume1")
end

end

*notice I added

SobGroup_SetROE
SobGroup_GetROE

I don’t know if these 2 entries are necessary…


(Paradoxnrt) #14

#2. I altered deathmatch.lua in the Data\scripts\rules\deathmatch directory. File now reads as:

dofilepath(“data:scripts/SCAR/SCAR_Util.lua”)
dofilepath(“data:scripts/scar/restrict.lua”)
dofilepath(“data:leveldata/multiplayer/lib/lib.lua”)
dofilepath(“data:leveldata/multiplayer/lib/crates.lua”)
dofilepath(“data:leveldata/multiplayer/lib/relics.lua”)
dofilepath(“data:leveldata/multiplayer/lib/challenges.lua”)
dofilepath(“data:leveldata/multiplayer/lib/norushtime.lua”)
dofilepath(“data:leveldata/multiplayer/lib/research.lua”)
dofilepath(“data:leveldata/multiplayer/lib/ruinjections.lua”)
dofilepath(“data:leveldata/multiplayer/lib/bounties.lua”)
dofilepath(“data:leveldata/multiplayer/lib/cpuplayers.lua”)
dofilepath(“data:leveldata/multiplayer/lib/ui.lua”)
dofilepath(“data:leveldata/multiplayer/lib/dev.lua”)
dofilepath(“data:leveldata/multiplayer/lib/main.lua”)
dofilepath(“data:leveldata/multiplayer/lib/carriersonly.lua”)
dofilepath(“data:leveldata/multiplayer/lib/nocruisers.lua”)
dofilepath(“data:leveldata/multiplayer/lib/strikecraftgamemode.lua”)
dofilepath(“data:leveldata/multiplayer/lib/guard.lua”)

function OnInit()
Volume_AddSphere(“centre”, {-11111, 11111, 11111,}, 10)
MPRestrict()
Init_GuardMapVolume()
nocruisers = GetGameSettingAsNumber(“nocruisers”)
strikecraftgamemode = GetGameSettingAsNumber(“strikecraftgamemode”)
cpuplayers = GetGameSettingAsNumber(“cpuplayers”)
bounties = GetGameSettingAsNumber(“bounties”)
research = GetGameSettingAsNumber(“research”)
ruinjections = GetGameSettingAsNumber(“ruinjections”)
challenges = GetGameSettingAsNumber(“challenges”)
relics = GetGameSettingAsNumber(“relics”)
crates = GetGameSettingAsNumber(“crates”)
carriersonly = GetGameSettingAsNumber(“carriersonly”)
norushtime = GetGameSettingAsNumber(“norushtime”)
if carriersonly == 0 then
SetStartFleetSuffix("")
elseif carriersonly == 1 then
SetStartFleetSuffix(“carriersonly”)
Rule_AddInterval(“carriersonly_init”,2)
elseif carriersonly == 2 then
SetStartFleetSuffix(“carriersonly1”)
Rule_AddInterval(“carriersonly_init”,2)
end
UI_SetElementEnabled(“NewTaskbar”, “btnObjectives”, 0)
UI_SetElementEnabled(“NewTaskbar”, “btnRecall”, 0)
UI_SetElementEnabled(“NewTaskbar”, “btnBuild”, 0)
UI_SetElementEnabled(“NewTaskbar”, “btnResearch”, 0)
UI_SetElementEnabled(“NewTaskbar”, “btnLaunch”, 0)

	if norushtime > 0 then
		UI_TimerStop("NewTaskbar", "GameTimer")	
	end

	Rule_AddInterval("timer_updating",1.02)	--timed with doai	

end

timer_timing = 1
timer_interval = 5.1

function timer_updating()
if timer_timing == 1 then
for playerIndex = 0,Universe_PlayerCount()-1,1 do
if Player_IsAlive(playerIndex) == 1 then
if Player_HasShipWithBuildQueue(playerIndex) == 1 then
Player_RestrictBuildOption(playerIndex, PlayerRace_GetString(playerIndex, “dm_build_restrict”, “”))
end
end
end
Rule_AddInterval(“sobgroups_init”,1)
–Rule_AddInterval(“sobgroups_updating”,1)
Rule_AddInterval(“UI_init”,0.1)
–Rule_AddInterval(“UI_updating”,0.5)
Rule_AddInterval(“cpuplayers_updating”,0.1)
–Rule_AddInterval(“balancing_updating”,0.25) --dev. to remove

			if nocruisers == 1 then
					Rule_AddInterval("nocruisers_init",timer_interval)
			end	
			if strikecraftgamemode == 1 then
					Rule_AddInterval("strikecraftgamemode_init",timer_interval)
			end	
					
			if research == 0 then
					Rule_AddInterval("research_init",timer_interval)
			end				
			if bounties > 0 then
					Rule_AddInterval("bounties_updating",timer_interval*2)
			end
			if norushtime > 0 then
					Rule_AddInterval("norushtime_updating",timer_interval*2)
			end	
			Rule_AddInterval("mainrule_updating",timer_interval*3)
	elseif timer_timing == 2 then
			if relics > 0 then				
					relics_init()	
					Rule_AddInterval("relics_updating",timer_interval*4)
			end	
	elseif timer_timing == 3 then						
			if challenges > 0 then
					Rule_AddInterval("challenges_updating",timer_interval)
			end				
	elseif timer_timing == 4 then				
			if crates > 0 then
					crates_init()
					Rule_AddInterval("CheckCratesRule",timer_interval)
					Rule_AddInterval("SpawnCratesRule",timer_interval*60)
			end
	elseif timer_timing == 5 then						
			if ruinjections > 0 then
					Rule_AddInterval("ruinjections_updating",timer_interval*48)
			end		
	elseif timer_timing == 6 then
			UI_SetElementEnabled("NewTaskbar", "btnObjectives", 1)
			UI_SetElementEnabled("NewTaskbar", "btnRecall", 1)
			UI_SetElementEnabled("NewTaskbar", "btnBuild", 1)
			if research == 1 then
				UI_SetElementEnabled("NewTaskbar", "btnResearch", 1)
			end	
			UI_SetElementEnabled("NewTaskbar", "btnLaunch", 1)
  end
  timer_timing = timer_timing + 1
  if timer_timing > 6 then
			Rule_Remove("timer_updating")
  end

end

Events = {}
Events.endGame =
{
{
{ “wID = Wait_Start(5)”,“Wait_End(wID)”},
},
}
Events.startcinematic =
{
{HW2_Letterbox(1),},
{
{ “Camera_AllowControl(0)”, “”, },
{ “Universe_EnableSkip(0)”, “”, },
{ “Universe_AllowPlayerOrders(0)”, “”, },
{ “SobGroup_DeSelectAll()”, “”, },
{ “Sensors_Toggle(0)”, “”, },
},
}
Events.startcinematic_focusrestore =
{
{HW2_Letterbox(1),},
{
{ “Camera_AllowControl(0)”, “”, },
{ “Universe_EnableSkip(0)”, “”, },
{ “Universe_AllowPlayerOrders(0)”, “”, },
{ “SobGroup_DeSelectAll()”, “”, },
{ “Camera_FocusSave()”, “”, },
{ “Sensors_Toggle(0)”, “”, },
},
}
Events.stopcinematic =
{
{HW2_Letterbox(0),},
{
{ “Universe_AllowPlayerOrders(1)”, “”, },
{ “Camera_AllowControl(1)”, “”, },
},
}
Events.stopcinematic_focusrestore =
{
{HW2_Letterbox(0),},
{
{ “Universe_AllowPlayerOrders(1)”, “”, },
{ “Camera_FocusRestore()”, “”, },
{ “Camera_AllowControl(1)”, “”, },
},
}


(Paradoxnrt) #15

Finally, I added this to my .level file in Data\leveldata\multiplayer\deathmatch

createSOBGroup(“Volume1Guards”)
addSphere(“GuardVolume1”, {0, 0, 0}, 5000) – 5km sphere located at map center
addSquadron(“Guard”, “Hgn_Dreadnaught”, {500, 500, 400}, -1, {0, 0, 0}, 1, 0)
addToSOBGroup(“Volume1Guards”, “Guard”)

So, anybody see the error?


(Sastrei) #16

Apparently there’s also SobGroup_SetStance


(Paradoxnrt) #17

Hi sastrei…where would SobGroup_SetStance be put?

*I think you mean in the ‘guard.lua’ file…but I thought I should get that clarified before doing so…


(Sastrei) #18

I honestly don’t know. I’m just the guy rummaging through the toolbox. :frowning:

At a guess, wherever you spawn your ship, set it’s stance immediately after that.


(Paradoxnrt) #19

Sounds like a plan!

*I’ll be back to let you know if it was a good plan…


(Paradoxnrt) #20

Well, SobGroup_SetStance doesn’t crash my game now (when inserted into the guard.lua file). It did crash the game when inserted into the .level file. Regardless, the Dreadnaught remains passive.

*I noticed that the Dreadnaught has a red (hostile) shiptype icon within the game, but I can’t target the ship…is this significant?

**Also, I can try to capture the Dreadnaught, and it will actually fire on incoming Marine Frigates that are trying to capture it…but even once the progress bar reaches 100%, the marine frigates detatch and the Dreadnaught remains un-captured. Is this significant?