Use campaign units in scenario

Hello everyone!

So happy finding this place really. Took me a while to find a place where actual modding is discussed.

To keep it short, I am trying to use campaign units in my custom scenario and using my tuning pack. However, they always return without stats and can barely move them on the map. What is going on? How can I make it work?. I know I am missing something.

Also this error occurs like 6 times, dont know if it is related:
Instance instanceRef construction_menu in file c:\program files (x86)\steam\steamapps\common\age of empires iv\cardinal\attrib\instances\sbps\races\mongol\campaign\unit_ismail_cmp_mon.xml references an instance that doesn’t exist (2b68be0ca3f34580bb867f188bb77459:menu\siege_engineer_field_construction_mon). Value changed to null.

Many thanks

2 Likes

You should go to the modding discord if you want more discussion. Lots of people with more knowledge there.

Is this discord channel safe or should people tweak the firewall and watch lists, disable cams and mics and use a dummy logon before entering lol all i’ve encountered on that platform is trolls and phishing

Huh? What are you talking about?

How many AoE related Discord servers have you joined? I’m in about 8 AoE related ones I think, and they are all legit things, why wouldn’t they be?

is it a moderated and accredited channel or just another troll farm? lol

zilch, im talking discord in general, but thanks for the assurance though =)

Have you tried using an empty entity or squad object and filling it with the unique unit blueprint path? or maybe replacing an existing similar units data with the campaign specific units ebp/sbp in the mods attribute files, or is the *bps data nil from the get-go for these campaign units?
just spitballin’ here >.<
maybe creating an entirely new ebp, adding and filling all the same ext’s manually if the data exists but doesn’t transfer?
I too get "0 whatever(warnings i think) , 6 errors preceded by a path (or similar) and value changed to null 6 times each time a mod is opened or created but have not used the nullified files (so far) and just ignored lol (not broken dont fix it kinda thing) but if the blueprints are empty in the attribute editor then I’d wager the two issues are directly related.

looking forward to hearing more on this =)

Heyhey. Thank you for the answer. I have not tried that yet. But I will and will let you know. I have found a way for the units to work for me however, which is to place them amongst my starting squad from my civilisation. This however makes them spawn for every player using this same civ.

Hey, thanks. Loving it.

1 Like

To answer my own initial question, a working way to spawn these campaign units is to open the script that comes with your custom map. You open it and scroll down to the function:

function GetRecipe()
local recipe = {

And then you can add (or paste) this kind of code underneath to spawn the sbp like this code here:
modules = {
{
type = “UnitSpawner”,
player = player1,
spawnLocation = mkr_player1_spawn01,
units = {
{type = “scar_ribauldequin”, numSquads = 2, spawn = mkr_player1_spawn01},
{type = “scar_archer”, numSquads = 8, spawn = mkr_player1_spawn01},
{sbp = SBP.ENGLISH.UNIT_KING_HAROLD_CMP_ENG, spawn = mkr_player1_spawn01, sgroup = sg_kingharold},
{sbp = SBP.FRENCH.UNIT_GEOFFROY_DU_BLOIS_CMP_FRE, spawn = mkr_player1_spawn01, numSquads = 1},
{sbp = SBP.FRENCH.UNIT_JEAN_DE_BEAUMANOIR_CMP_FRE, spawn = mkr_player1_spawn01, numSquads = 1},
},
},

Putting this code to your map will spawn some units near the marker mkr_player1_spawn01. For this to work all you need to do it put a player spawn marker on the map using the editor, you name it mkr_player1_spawn01(or whatever you want) and give it a radius.

The last 3 lines in this piece of code are referring to units in the french and english campaign and they spawn entirely functional. The only tricky thing here is to find the correct sbp name. I realised the names can be slightly different from the ones used in the scenario editor therefore it is best to go to open a tuning pack, go to attributes and check out the sbps to see the proper unit names listed there, you write them in caps-lock into your script and the codeline should turn red if done correctly.

There are probably more ways and easier ways to use campaign units in custom scenarios but I just wanted to share this solution to anyone who can use it. Hope I could be of help.

1 Like

Just realised, to make the above code work with copy and paste into your own scenario, you will have to create the sgroup sg_kingharold

You can do so by putting this line in the function Mission_SetupVariables():

sg_kingharold = SGroup_CreateIfNotFound(“sg_kingharold”)

Additionally instead you can also alter the codeline to not contain any sgroup information:
{sbp = SBP.ENGLISH.UNIT_KING_HAROLD_CMP_ENG, spawn = mkr_player1_spawn01},

1 Like