Update, v2.1: I fixed issues with the last update from 2015, and I reduced all the global vars down to one array, with accessors. I further cleaned up the code a bit, and I modified the item to allow setting the repeating item and timer values from the item that enables them.
This set of functions permits the use of items that have hardcoded effects, called in an automatic manner. While this demo uses a self-shooting arrow, you can also do similar things with any item that the player has, and by varying the conditions, cause hardcoded effects created by items (e.g. Din's Fire) to occur without the player actually using the item.
The main drawback is that for a brief instant, the item that you are activating is visibly shifted into the B-button slot, and then, the item that was previously there is restored.
Import this library (AutoFire_v2.1.z), and its dependencies:
std.zh
ItemHandling.zh (v6.7 or higher)
Timers.zh (v1.0 or higher)
Using this is relatively straightforward, assuming that you want a single item of this nature at any given time.
AutofireInitiate() sets the condition on the item to use. If using an item that produces an lweapon, specify it with AutofireInitiate(item, true) , rather than AutofireInitiate(item).
(This technically also allows you to use any item, even if it has instances on the screen, thus allowing machimne-gun type weapons, or other auto-weapons, based around a timer.)
Note: The attached ZC Custrom Quest (AutoFire.qst) has all the functions needed to produce this effect in its buffer, so that you may see them as isolated functions, and understand what's happening, and required.
Set Up the Item
The script uses an item to set an on and off repeat state. Apply the script 'repeatingWeapon' to an item, and set up the script arguments as follows:
D0: The item that will be repeatedly activated. If unset, this defaults to I_REPEAT.
D1: The timer duration between uses, including the initial activation. if unset, the default is 100.
D2: The decrement rate of the timer. If unset, this defaults to '1'.
Using the Quest
Enable the item that appears to be a longbow as the B-button item, then press B, and wait. Link will start firing arrows, on a regular basis; and you may select a different B-item, while still firing.
The automated item sue continues until you again select the bow item, and press B to turn it off, or press R to suspend it (thus, using the setRepeatOff() function).