edited June 18 in ORK Scripting
Hello -

I'm trying to use a health potion in and out of battle from script. Here is what I've tried:

ORK.Game.ActiveGroup.Leader.Inventory.Items.Get(ORK.Items.Get(orkItemID)).Use(ORK.Game.ActiveGroup.Leader, new List<Combatant> { ORK.Game.ActiveGroup.Leader }, true);

This works out of battle just fine. In battle, it does not use the item, but instead waits and uses the item after the Battle is over. Looking at the source code for the ItemShortcut Use() function, I tested to make sure that CanUse() returns true and targets.count is > 0. So with these test passed, it should move on use the action, but it does not. Man I would kill to be able to step through the code - it would make it so much easier to diagnose what's going on :) I don't know much about DLLs, but if there was a way to put them into debug mode and then step through the code, that would be amazing.

I should also mention that I have it setup so that using an item costs 1 action point and out of a pool of 1 action points per turn. So there should be available AP to use the item.

I also tried this:

ORK.Access.Action.UseItem(ORK.Game.ActiveGroup.Leader.Inventory.Items.Get(ORK.Items.Get(orkItemID)), ORK.Game.ActiveGroup.Leader, new List<Combatant> { ORK.Game.ActiveGroup.Leader }, null, true, true, true, 1, 1, null, null, null, new ItemAction(ORK.Game.ActiveGroup.Leader, ORK.Game.ActiveGroup.Leader.Inventory.Items.Get(ORK.Items.Get(orkItemID))));

This uses the item in Battle (yay) but it does not consume Action point when that happens and I need it to.

THanks,
-Mike
Post edited by indoflaven on
  • This heavily depends on your used battle system and it's setup. When using the action, it'll be registered with the battle system as if used via a battle menu or shortcut slot.

    I.e. it'll be part of the battle order and can also be completely dismissed if the combatant can't execute it (e.g. timebar/actions per turn not being enough).
    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 was able to get it working helped by stepping through the code as documented here; http://forum.orkframework.com/discussion/7463/debugging-the-orkframework3-dll

    So for some reason (haven't dug into this) it was not respecting the Default Item Action Cost (Set in Battles-BattleSystem-Phase) which I had set to 1 when using the item. Instead it was using the Default Action Cost which I had set to 0. So it no action points were being expended and it was waiting for the depletion of Action Points or an end turn command to progress to executing all actions for the phase. So setting the Default Action Cost to 1 fixed it. Or running the following code after using the item also fixed it:
    if(ORK.Game.ActiveGroup.Leader.Battle.InBattle)
    ORK.Game.ActiveGroup.Leader.Battle.EndTurnCommand(true);
Sign In or Register to comment.