Author Topic: use item over and over  (Read 344 times)

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
use item over and over
« on: September 27, 2012, 01:49:42 am »


               i did have another question, and it's not strictly related to nwnx_func's ActionUseItemOnObject() so i made a new thread:
i have an item i'm using, and in the OnActivateItem script, i have it do something, just like normal.  but i then want it to do it again the next round, too, over and over.  i've got something kind of working as follows:
 if(sItemTag == "myitem"){
DoSomething();
AssignCommand(oPC, DelayCommand(6.0, ActionUseItemOnObject(oItem, oOther)));
}

this mostly works how i want it to, but i feel it's a hack.  is there a better way to do it?  some of the problems i have with it are:

- it doesn't have a little "pending action icon in the queue" thing.  you just stand there with no queued up actions until 6 seconds go by and you use the item again.  not a big deal.  i could live with that unless somebody has a better idea.
- but i can't "cancel" the action.  if i start running around, i'll still stop and activate the item after 6 seconds, just like i told it to.  which then causes another delaycommand, etc.  using the "drive" keys (wasd), seems to keep the action from being given, but clicking to move won't stop it.  i think this is slightly related to the first issue, that there's no queue of actions to cancel.

i think something like "DetermineCombatRound" is what i'd like, but i'm under the impression that's only for NPCs.


any ideas?  thanks!
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
use item over and over
« Reply #1 on: September 27, 2012, 02:32:54 am »


               Actions typically are queued up in a chain so I do not believe that you need the delay action in there.

So remove the delay and I think you are good to go. You should only get one action every 6 seconds since PCs can only act on one action per round, but immediately assigning the action will load up the queue.
               
               

               
            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
use item over and over
« Reply #2 on: September 27, 2012, 04:10:59 am »


               great scott why didn't i think of that!  you're absolutely right and it works perfectly.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
use item over and over
« Reply #3 on: September 27, 2012, 04:06:22 pm »


               don't kick yourself on this one. i had to script cutscenes before i realized precisely how this works as well.