I am having a little spawning issue.
When my combatant is spawned through a Combatant Spawner, it works as expected.
If the same exact combatant (identified by combatant_GUID) is spawned through code, it just moves toward the target but when in range it doesn't attack or use any ability.
This is the function I'm using to spawn my combatants runtime. Am I missing something?

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;
}
  • edited July 2022
    Hi @ChimpLogik,
    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);
    Post edited by RustedGames on
  • Hi @RustedGames
    I set a Faction through:
    FactionSetting _faction = ORK.Factions.Get(faction_GUID);
    _combatant.Group.Faction = _faction;
    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?
  • Is this in a real time battle area?
    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited July 2022
    Yes, it is a real time battle area. If you could allow the combatant in any battle if the group's battle system isn't set, that would be much appreciated :)

    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.
    Post edited by ChimpLogik on
  • edited July 2022
    I tried a different approach by creating a new group for the combatant, but it still didn't work :(
                
    FactionSetting _faction = ORK.Factions.Get(faction_GUID);
    CombatantGroupAsset groupAsset = new CombatantGroupAsset();
    Group _group = groupAsset.Settings.CreateGroup(_faction, true, position);

    CombatantSetting _settings = ORK.Combatants.Get(combatant_GUID);
    Combatant _combatant = ORK.Access.Combatant.CreateInstance(_settings, _group, false, false);
    Post edited by ChimpLogik on
  • You'd need to set the group's battle system to the default real time system:
    combatant.Group.BattleSystem = ORK.BattleSettings.realTimeBattleAreaSystem.StoredAsset.Settings;
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • It worked, but there's a strange side effect.
    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;
  • Hm, I don't think so.
    The CreateInstance you use will create the combatant with it's starting level - maybe it's due to the level/stat difference?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited July 2022
    I did some more tests and there is other odd (and very problematic) side effect.
    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.
    Post edited by ChimpLogik on
  • ORK 3.5 removed the need to set the battle system for the group for real time areas.

    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
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I'm really looking forward to ORK 3.5!!

    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;
  • Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • That's awesome, I'm getting it right away!!
    Thank you Nicholas :)
  • edited July 2022
    I just synched to ORK 3.5 but now my framerate has dropped so much I can't even test the game anymore :(

    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?
    Post edited by ChimpLogik on
  • If they're all spawned/added without a battle system, they're now joining the ongoing real time battle area with this change. You can reduce their impact via the different battle ranges (Battles > Battle System > General Settings), e.g. using an AI range or battle range.
    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?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.