Hey again. I am working on creating a function that will replace Ork Framework's "Player Grid Placement" event step at the start of grid battles. My end goal is for this function be called in my "gridBattleStartEvent" Event, find the nearest grid cell to the player, and place the player's combatant in that grid cell.

So far I have been able to find the objects for the "leader" combatant, BattleGridComponent, and the GridCells. However, when I add the combatant to one of the grid cells he does not seem to appear when the battle starts. Are there any additional steps I am missing for adding a character to a battle?

public void PlaceCombatantsOnGrid ()
{
List<Combatant> playerBattleGroup = new List<Combatant>();
ORK.Game.ActiveGroup.GetMembers(MenuCombatantScope.Battle, ref playerBattleGroup);

BattleGridComponent gridBattle = ORK.Battle.BattleArena.gridObject;

foreach (Combatant combatant in playerBattleGroup)
{
if (combatant.IsLeader)
{
gridBattle.GetCell(0, 0).AddGuest(combatant);
}
}
}


This is my first real attempt at scripting in ORK, so I am making a few assumptions. Such as that "ORK.Battle.BattleArena.gridObject" will give me the actual grid object of the current active battle.

Thanks!
  • edited November 2016
    Well, there's no need to write your own function, you can place the player's group using a Place On Grid node (just like the enemies are placed).

    When setting a combatant on a grid cell via script, do it like this:
    cell.Combatant = combatant;
    Using the AddGuest function is only temporarily adding the combatant to the cell, e.g. used when the combatant is moving over a cell.

    If you want to get the battle's active grid, use this:
    ORK.Battle.Grid
    While your attempt will usually also return the same grid, it's not always the case (e.g. you can set a different grid in events).

    Also, to get the battle group, you can just use this function:
    List<Combatant> battleGroup = ORK.Game.ActiveGroup.GetBattle();

    When a combatant isn't spawned yet, (i.e. combatant.GameObject == null), you need to spawn it using the combatant.Spawn function.
    Post edited by gamingislove on
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • Thanks for the explanation! I will try just using the "Place On Grid" node, and the additional information about the ORK scripting objects helps a lot.
  • edited November 2016
    I have replaced my function call with the "Place On Grid" node. However, it does not seem to be placing the player on the grid. I first tried putting the node at the very end of the event chain so that it is in the same place that "Player Grid Placement" was in the tutorial. I have also tried moving it before the "Destroy Object" step that destroys the Player Group, but that didn't seem to make any difference.

    Are there any additional steps that I should be taking in order to get this node to work? I have an attached an image to show you what I am doing.

    image
    Post edited by MatrixDragon on
  • Is the combatant spawned at this point? If one of the Spawn Combatants nodes is spawning the player group, try adding a small wait before the Place On Grid, might be that spawning isn't happening before the node (due to how Unity handles some things).
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • edited November 2016
    Good idea. I went ahead and added a wait in between the Spawn combatants and Place On Grid. The player combatant is now appearing, though something still isn't working right. It is as if the player combatant isn't actually on the grid, he is kind of standing in between two grid intersections and I have no control over him. The spot he is standing in also doesn't seem to be the closest grid space he could have appeared in.

    When I select the move command no grid spaces showing where I can move are highlighted. If I click on the grid to try and move, I get a NullReferenceException. If I end the character's turn the enemy doesn't do anything. The enemy acts as if there isn't anything on the grid for him to attack.

    Thanks for the help! Sorry, I know at this point this isn't exactly a scripting line of questions. Just let me know if I should move this into the main ORK support forum.
    Post edited by MatrixDragon on
  • Sounds like your player isn't actually placed on the grid - what's the Destroy Object node in your image destroying? If it's the player group, try removing that node :)
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • ...I knew I should have tried that. That fixed it. Thanks for the help!
Sign In or Register to comment.