class JakuHelpers
{
public static void AddToVendorTable(BlueprintItemWeapon blueprintItemWeapon, String sharedVendorTable, int count)
{
BlueprintItemWeapon Weapon = blueprintItemWeapon;
int quantityToAdd = count;
var LootItemPackFixed = Helpers.Create<Kingmaker.Blueprints.Loot.LootItemsPackFixed>();
var lootItem = new Kingmaker.Blueprints.Loot.LootItem();
Traverse.Create(lootItem).Field("m_Item").SetValue(Weapon);
Traverse.Create(lootItem).Field("m_Type").SetValue(Kingmaker.Blueprints.Loot.LootItemType.Item);
Traverse.Create(LootItemPackFixed).Field("m_Item").SetValue(lootItem);
Traverse.Create(LootItemPackFixed).Field("m_Count").SetValue(quantityToAdd);
var libraryLoot = ResourcesLibrary.TryGetBlueprint<BlueprintSharedVendorTable>(sharedVendorTable);
libraryLoot.AddComponent(LootItemPackFixed);
}
public static void AddWandToVendorTable(String guidWand, String sharedVendorTable, int count)
{
BlueprintItemEquipmentUsable item = ResourcesLibrary.TryGetBlueprint<BlueprintItemEquipmentUsable>(guidWand);
int quantityToAdd = count;
var LootItemPackFixed = Helpers.Create<Kingmaker.Blueprints.Loot.LootItemsPackFixed>();
var lootItem = new Kingmaker.Blueprints.Loot.LootItem();
Traverse.Create(lootItem).Field("m_Item").SetValue(item);
Traverse.Create(lootItem).Field("m_Type").SetValue(Kingmaker.Blueprints.Loot.LootItemType.Item);
Traverse.Create(LootItemPackFixed).Field("m_Item").SetValue(lootItem);
Traverse.Create(LootItemPackFixed).Field("m_Count").SetValue(quantityToAdd);
var libraryLoot = ResourcesLibrary.TryGetBlueprint<BlueprintSharedVendorTable>(sharedVendorTable);
libraryLoot.AddComponent(LootItemPackFixed);
}
public static BlueprintItemWeapon CopyAndAddRename(String ogGUID, String newName, String newDisplayName, String newGUID)
{
var v = Main.library.CopyAndAdd<BlueprintItemWeapon>(ogGUID, newName, newGUID);
Helpers.SetLocalizedStringField(v, "m_DisplayNameText", newDisplayName);
return v;
}
public static void AddEnchantToWeapon(String guidTargetWpn, String guidWeaponEnchant)
{
var wpn = ResourcesLibrary.TryGetBlueprint<BlueprintItemWeapon>(guidTargetWpn);
var enchant = ResourcesLibrary.TryGetBlueprint<BlueprintWeaponEnchantment>(guidWeaponEnchant);
wpn.Enchantments.Add(enchant);
}
public static void AddUseInDungeonToUnit(BlueprintUnit unit)
{
var targcompo = Helpers.Create<Kingmaker.UnitLogic.FactLogic.AddTags>(t =>
{
t.UseInDungeon = true;
});
unit.AddComponent(targcompo);
}
public static void AddCreatureToArmy(String guidCrea, int iArmy, int iCr)
{
var bpDungeonRoot = ResourcesLibrary.TryGetBlueprint<Kingmaker.Dungeon.Blueprints.BlueprintDungeonRoot>("d5ac7a99563987948b653b03b341167b");
BlueprintUnit unit = ResourcesLibrary.TryGetBlueprint<BlueprintUnit>(guidCrea);
AddUseInDungeonToUnit(unit);
bpDungeonRoot.Armies[iArmy].UnitsByCR[iCr].Units = bpDungeonRoot.Armies[iArmy].UnitsByCR[iCr].Units.AddToArray(unit);
}
public static void disableTrashloot()
{
//test loot cleanup trash
var libtrash = ResourcesLibrary.TryGetBlueprint<TrashLootSettings>("77fe4de4c707e51439971ee480e94efc");
for (int count = 0; count < 5; count++)
{
libtrash.Table[count].Types[0].Weight = 20;
libtrash.Table[count].Types[3].Weight = 55;
libtrash.Table[count].Types[4].Weight = 0;
libtrash.Table[count].Types[5].Weight = 0;
libtrash.Table[count].Types[6].Weight = 0;
libtrash.Table[count].Types[7].Weight = 0;
libtrash.Table[count].Types[8].Weight = 0;
}
}
public static SharedStringAsset CreateSharedStringAsset(string uniqueString, string localizedname){
var sharedString = ScriptableObject.CreateInstance<SharedStringAsset>();
sharedString.String = Helpers.CreateString(uniqueString, localizedname);
return sharedString;
}
public static void CreateBardInstrument(String objectName, String newGUID, String spellToAdd, String itemName, String flavorText, int charges = 1)
{
BlueprintItemEquipmentUsable customBardInstrument = Main.library.CopyAndAdd<BlueprintItemEquipmentUsable>("c426180be627cf84284bc9abcada55af", objectName, newGUID);
BlueprintAbility customSpell = Main.library.TryGet<BlueprintAbility>(spellToAdd);
customBardInstrument.Ability = customSpell;
customBardInstrument.Charges = charges;
Sprite customBardInstrumentIcon = LoadIcons.Image2Sprite.Create(@"Mods\zQOLEndless\itemicons\" + objectName+".png");
customBardInstrument.SetItemIcon(customBardInstrumentIcon);
Helpers.SetLocalizedStringField(customBardInstrument, "m_DisplayNameText", itemName);
Helpers.SetLocalizedStringField(customBardInstrument, "m_FlavorText", flavorText);
}
public static void DungeonAddItemToItemList(String objectGUID, int iItemCategory)
{
var bpdungeonroot = ResourcesLibrary.TryGetBlueprint<Kingmaker.Dungeon.Blueprints.BlueprintDungeonRoot>("d5ac7a99563987948b653b03b341167b");
bpdungeonroot.Items[iItemCategory].Items = bpdungeonroot.Items[iItemCategory].Items.AddToArray(ResourcesLibrary.TryGetBlueprint<BlueprintItemEquipment>(objectGUID));
}
public static void DungeonAddScrollToItemList(String objectGUID)
{
var lib = ResourcesLibrary.TryGetBlueprint<TrashLootSettings>("77fe4de4c707e51439971ee480e94efc");
lib.Types[4].Items.Add(ResourcesLibrary.TryGetBlueprint<BlueprintItemEquipmentUsable>(objectGUID));
}
}