public GameObject CreateORKCombatant(string combatant_GUID, string faction_GUID)
{
CombatantSetting _settings = ORK.Combatants.Get(combatant_GUID);
Combatant _combatant = ORK.Access.Combatant.CreateInstance(_settings, null, false, false);
FactionSetting _faction = ORK.Factions.Get(faction_GUID);
_combatant.Group.Faction = _faction;
return _combatant.Object.GameObject;
}
It looks like you're new here. If you want to get involved, click one of these buttons!
I think the culprit might be the misisng Group and Faction assignment
This is from https://orkframework.com/guide/documentation/scripting/combatant-scripting/
Combatant combatant = ORK.Access.Combatant.CreateInstance(
ORK.Combatants.Get(combatantIndex), new Group(ORK.Factions.Get(factionIndex)), showNotification, showConsole,
level, classLevel, ORK.Classes.Get(classIndex), loadGame,
learnAbilities, useStartInventory, useStartEquipment,
useInitSchematic, useStatusEffects);
I set a Faction through: and my code-spawned combatants have the correct faction in the Combatant Component.
None of my combatants have groups, even when I use the regular ORK Combatant Spawner (I leave Use Group unchecked and select the combatants directly).
Looking at your code though I'm thinking it might be something related to extra options I didn't set learnAbilities, useStartInventory, useStartEquipment...
My combatants have the right equipment at start, but maybe they're not using it?
I think it's due to the combatant's battle system not being set - combatant spawners handle this, either using the default system or the one defined by the spawner.
It's set in the combatant's group via the BattleSystem property.
I'll look into allowing the combatant in any battle if the group's battle system isn't set.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
In the meantime, if there's a way to spawn a combatant group via code, I guess I could create a 1-memeber group for each combatant I need to test and use that.
combatant.Group.BattleSystem = ORK.BattleSettings.realTimeBattleAreaSystem.StoredAsset.Settings;
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
All the player's damage-dealing abilities now deal an incredible amount of damage (almost instant-kills) on the combatant spawned this way.
This is how I modified the code inside the spawn function, did I miss something?
FactionSetting _faction = ORK.Factions.Get(faction_GUID);
CombatantSetting _settings = ORK.Combatants.Get(combatant_GUID);
CombatantGroupAsset groupAsset = new CombatantGroupAsset();
Group _group = groupAsset.Settings.CreateGroup(_faction, true, position);
Combatant combatant = ORK.Access.Combatant.CreateInstance(_settings, _group, false, false);
_combatant.Group.BattleSystem = ORK.BattleSettings.realTimeBattleAreaSystem.StoredAsset.Settings;
The CreateInstance you use will create the combatant with it's starting level - maybe it's due to the level/stat difference?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
All the player's abilities that have a damage dealer hit every combatant in the game that was spawned with that method.
This happens regardless of the distance of the combatant from the ability or the size of the of the ability's collider.
When I spawn them without the BattleSettings option, this doesn't happen anymore.
Damage dealers should only damage what they physically hit, not sure how that can happen by creating the combatants via custom code - unless you somehow spawn them so huge that they cover the whole scene :D
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Regarding the damage dealers, I'm not sure either since the player's abilities are exactly the same in both scenarios and removing this single line of code is the only difference:
_combatant.Group.BattleSystem = ORK.BattleSettings.realTimeBattleAreaSystem.StoredAsset.Settings;
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thank you Nicholas :)
I was experiencing a framerate drop few days ago when I first added the Group.BattleSystem to all my combatants.
I assumed it was some mistake on my code, but I solved the issue and restored my framerate by removing the Group.BattleSystem from all my "passive" combatants (which only receive damage/status effects but do nothing else) since I have hundred of them across the map.
Is there a way I can either reduce the performance footprint of those passive combatants or remove them from the Group.BattleSystem?
Also, use either AI Decision Time (in the battle system) or the combatant's Real Time Settings (in their AI Settings) to have a timeout between action use, or they'll spam you with actions, especially if they don't have any schematics animating it.
What are those passive combatants used for?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!