Spell Timed Barrage

Immolation

Member
Reaction score
20
Timed Barrage​
Allows shooting of several arrows with a single attack for a short amount of time.

GUI/vJASS= vJASS
Leakless?= Yes(I hope).
Lagless= Yes(for me).
MUI/MPI?= MUI

Changelog:
v1.1
-Spell is now MUI. Thanks to Tom Kazansky for concept!
-Fixed a bug with Barrage shooting too many arrows.

v1.00a
-Updated code.

v1.00
-Public release.

Code:
JASS:
scope Barrage initializer Initialization
//-------------------------------------------------------------
//                Timed Barrage by Immolation                
//-------------------------------------------------------------

// Description:
//---------------------------
// Allows shooting of several arrows with a single attack for a short amount of time.

// What do I need to import it in my map?
//---------------------------
// You need to download JASS NewGen, available at the following links:

// -http://www.thehelper.net/forums/showthread.php?t=73936-
// -http://www.wc3c.net/showthread.php?t=90999-

//Install it and then read the following paragraph.

// How do I put it in my map?
//---------------------------
// 1. Copy:
//  a. The "Barrage" ability.
//  b. The "Barrage(Buff)" ability.
//  c. The "Barrage(Passive)" ability.
//  d. The "Passive Book (Disabled)" ability.
//  e. The "Barrage" buff.
//  f. Export the "dummy.mdx" file and import it back into your map. (Export the icons if you wish too, be sure to set the right path though).
//  g. Copy the "Dummy Unit" into your map.
//  h. Copy this trigger.
// 2. Press CTRL + D while in the Object Editor to find out the rawcode of:
//  a. The "Barrage" ability. Change the SPELL_ID to the rawcode that you find(it's 'A000' in this map).
//  b. The "Barrage(Passive)" ability. Change the BARRAGE_ID to the rawcode that you find(it's 'A002' in this map).
//  c. The "Barrage(Buff)" ability. Change the BUFFSPELL_ID to the rawcode that you find(it's 'A001' in this map).
//  d. The "Passive Book (Disabled)" ability. Change the SPELLBOOK_ID to the rawcode that you find(it's 'A003' in this map).
//  e. The "Barrage" buff. Change the BUFF_ID to the rawcode that you find(it's 'B000' in this map).
//  f. The "Dummy Unit" unit. Change the DUMMY_ID to the rawcode that you find(it's 'n000' in this map).
// 3. Be sure that the "Passive Book (Disabled)" has the "Barrage (Passive)" ability.
// 4. Give the Barrage ability to your hero.
// 5. You have succesfully imported the spell <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />

// Changelog:
//---------------------------
// v1.1
// -Spell is now MUI. (Thanks Tom Kazansky!)
//
// v1.00a:
// -Updated code.
//
// v1.00:
// -Public release.
//---------------------------
// TheHelper.net

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//                                    RAWCODES
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//About Configurables:
// The configurables can be found in the Object Editor.
// Modify the duration of the &quot;Barrage (Buff)&quot; ability to set the duration of the spell.
// Modify the cooldown&amp;manacost of &quot;Barrage&quot; ability to set the desired cooldown&amp;manacost.
// Check the &quot;Barrage (Passive)&quot; for the rest.

    globals
        private constant integer SPELL_ID = &#039;A000&#039;
        private constant integer BARRAGE_ID = &#039;A002&#039; 
        private constant integer BUFFSPELL_ID = &#039;A001&#039;
        private constant string  BUFFSPELL_ORDER = &quot;rejuvination&quot;
        private constant integer BUFF_ID = &#039;B000&#039;
        private constant integer DUMMY_ID = &#039;n000&#039;
        private constant integer SPELLBOOK_ID = &#039;A003&#039;
        private constant real TIMEOUT = 0.2 // Used to check if the spell is active or not after casting every second.
                                            // I suggest a number between 0.1-0.5. Default: 0.2
    endglobals

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Actions takes nothing returns nothing
    local unit TriggeringUnit = GetTriggerUnit()
    local real x = GetUnitX(TriggeringUnit)
    local real y = GetUnitY(TriggeringUnit)
    local player TriggeringPlayer = GetOwningPlayer(TriggeringUnit)
    local integer SpellLevel = GetUnitAbilityLevel(TriggeringUnit, SPELL_ID)
    local unit Dummy = CreateUnit(TriggeringPlayer, DUMMY_ID, x, y, 0.00)
    call UnitAddAbility(Dummy, BUFFSPELL_ID)
    call SetUnitAbilityLevel(Dummy, BUFFSPELL_ID, SpellLevel)
    call UnitApplyTimedLife(Dummy, &#039;BTLF&#039;, 3.00)
    call IssueTargetOrder(Dummy, BUFFSPELL_ORDER, TriggeringUnit)
    call UnitAddAbility(TriggeringUnit, SPELLBOOK_ID)
    call SetUnitAbilityLevel(TriggeringUnit, BARRAGE_ID, SpellLevel)
    call TriggerSleepAction(0.0)
    loop
        exitwhen GetUnitAbilityLevel(TriggeringUnit, BUFF_ID) == 0
        call TriggerSleepAction(TIMEOUT)
    endloop
    call UnitRemoveAbility(TriggeringUnit, SPELLBOOK_ID)
    endfunction

//=============================================================================================
    private function Initialization takes nothing returns nothing
        local trigger Trigger = CreateTrigger()
        local integer Loop = 0
        call TriggerRegisterAnyUnitEventBJ(Trigger, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition(Trigger, Condition(function Conditions))
        call TriggerAddAction(Trigger, function Actions)

        loop
            exitwhen Loop == 12
            call SetPlayerAbilityAvailable(Player(Loop), SPELLBOOK_ID, false)
            set Loop = Loop + 1
        endloop
    endfunction
endscope



P.S.: I know it's simple, but many people ask for it.

Lags a bit on the first cast, preload if needed.
 

Attachments

  • Timed Barrage v1.1.w3x
    74.1 KB · Views: 237

Immolation

Member
Reaction score
20
1) I would never, ever submit a non-working spell -.-

2) The order string of Rejuvenation is "rejuvination".
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
Here is the MUI version:
JASS:
scope Barrage initializer Initialization
//-------------------------------------------------------------
//                Timed Barrage by Immolation                
//-------------------------------------------------------------

// Description:
//---------------------------
// Allows shooting of several arrows with a single attack for a short amount of time.

// What do I need to import it in my map?
//---------------------------
// You need to download JASS NewGen, available at the following links:

// <a href="http://www.thehelper.net/forums/showthread.php?t=73936" class="link link--internal">http://www.thehelper.net/forums/showthread.php?t=73936</a>
// <a href="http://www.wc3c.net/showthread.php?t=90999" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://www.wc3c.net/showthread.php?t=90999</a>

//Install it and then read the following paragraph.

// How do I put it in my map?
//---------------------------
// 1. Copy:
//  a. The &quot;Barrage&quot; ability.
//  b. The &quot;Barrage(Buff)&quot; ability.
//  c. The &quot;Barrage(Passive)&quot; ability.
//  d. The &quot;Passive Book (Disabled)&quot; ability.
//  e. The &quot;Barrage&quot; buff.
//  f. Export the &quot;dummy.mdx&quot; file and import it back into your map. (Export the icons if you wish too, be sure to set the right path though).
//  g. Copy the &quot;Dummy Unit&quot; into your map.
//  h. Copy this trigger.
// 2. Press CTRL + D while in the Object Editor to find out the rawcode of:
//  a. The &quot;Barrage&quot; ability. Change the SPELL_ID to the rawcode that you find(it&#039;s &#039;A000&#039; in this map).
//  b. The &quot;Barrage(Passive)&quot; ability. Change the BARRAGE_ID to the rawcode that you find(it&#039;s &#039;A002&#039; in this map).
//  c. The &quot;Barrage(Buff)&quot; ability. Change the BUFFSPELL_ID to the rawcode that you find(it&#039;s &#039;A001&#039; in this map).
//  d. The &quot;Passive Book (Disabled)&quot; ability. Change the SPELLBOOK_ID to the rawcode that you find(it&#039;s &#039;A003&#039; in this map).
//  e. The &quot;Barrage&quot; buff. Change the BUFF_ID to the rawcode that you find(it&#039;s &#039;B000&#039; in this map).
//  f. The &quot;Dummy Unit&quot; unit. Change the DUMMY_ID to the rawcode that you find(it&#039;s &#039;n000&#039; in this map).
// 3. Be sure that the &quot;Passive Book (Disabled)&quot; has the &quot;Barrage (Passive)&quot; ability.
// 4. Add the &quot;Passive Book (Disabled)&quot; and the &quot;Barrage&quot; ability to the hero.
// 5. You have succesfully imported the spell <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />

// Changelog:
//---------------------------
// v1.00a:
// -Updated code.
//
// v1.00:
// -Public release.
//---------------------------
// TheHelper.net

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//                                    RAWCODES
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//About Configurables:
// The configurables can be found in the Object Editor.
// Modify the duration of the &quot;Barrage (Buff)&quot; ability to set the duration of the spell.
// Modify the cooldown&amp;manacost of &quot;Barrage&quot; ability to set the desired cooldown&amp;manacost.
// Check the &quot;Barrage (Passive)&quot; for the rest.

    globals
        private constant integer SPELL_ID = &#039;A000&#039;
        private constant integer BARRAGE_ID = &#039;A002&#039; 
        private constant integer BUFFSPELL_ID = &#039;A001&#039;
        private constant string  BUFFSPELL_ORDER = &quot;rejuvination&quot;
        private constant integer BUFF_ID = &#039;B000&#039;
        private constant integer DUMMY_ID = &#039;n000&#039;
        private constant integer SPELLBOOK_ID = &#039;A003&#039;
    endglobals

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    globals
        private group UnitsWhoHasBuff = CreateGroup()
    endglobals
    
    private function GroupCallback takes nothing returns nothing
        local unit Pick = GetEnumUnit()
        if GetUnitAbilityLevel( Pick, BUFF_ID ) == 0 then
            call UnitRemoveAbility( Pick, SPELLBOOK_ID )
            call GroupRemoveUnit( UnitsWhoHasBuff, Pick )
        endif
        set Pick = null
    endfunction
    
    private function TimerCallback takes nothing returns nothing
        call ForGroup( UnitsWhoHasBuff ,  function GroupCallback )
    endfunction

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Actions takes nothing returns nothing
        local unit TriggeringUnit = GetTriggerUnit()
        local real x = GetUnitX(TriggeringUnit)
        local real y = GetUnitY(TriggeringUnit)
        local integer SpellLevel = GetUnitAbilityLevel(TriggeringUnit, SPELL_ID)
        local player TriggeringPlayer = GetOwningPlayer(TriggeringUnit)
        local unit Dummy = CreateUnit(TriggeringPlayer, DUMMY_ID, x, y, 0.00)
        call UnitAddAbility(Dummy, BUFFSPELL_ID)
        call SetUnitAbilityLevel(Dummy, BUFFSPELL_ID, SpellLevel)
        call UnitApplyTimedLife(Dummy, &#039;BTLF&#039;, 3.00)
        call IssueTargetOrder(Dummy, BUFFSPELL_ORDER, TriggeringUnit)
        
        call UnitAddAbility( TriggeringUnit, SPELLBOOK_ID )
        call SetUnitAbilityLevel( TriggeringUnit, BARRAGE_ID, SpellLevel )
        call TriggerSleepAction(0.0)  //sometimes, the dummy&#039;s cast isn&#039;t fast enough, so add a wait should be fine <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
        call GroupAddUnit( UnitsWhoHasBuff, TriggeringUnit )
        
        set TriggeringUnit = null
        set Dummy = null
    endfunction

//=============================================================================================
    private function Initialization takes nothing returns nothing
        local trigger Trigger = CreateTrigger()
        local integer Loop = 0
        call TriggerRegisterAnyUnitEventBJ(Trigger, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition(Trigger, Condition(function Conditions))
        call TriggerAddAction(Trigger, function Actions)
        
        call TimerStart( CreateTimer(), 0.1, true, function TimerCallback )
        
        loop
            exitwhen Loop == 12
            call SetPlayerAbilityAvailable(Player(Loop), SPELLBOOK_ID, false)
            set Loop = Loop + 1
        endloop
    endfunction
endscope


and the demo map attached below
 

Attachments

  • [Spell] Timed Barrage (MUI).w3x
    74.4 KB · Views: 366

Immolation

Member
Reaction score
20
@Wolfie: WC3 doesn't have a good enough multishot icon(actually, it doesn't have any of that kind of icon)

@Tom: I'm now adding the spellbook like you, so spell is now MUI.

@Jesus4Lyf: Spell was MPI before :p BTW, what do you mean for attack speed?

Update: v1.1
-Spell is now MUI(Thanks to Tom Kazansky for concept!)
-Fixed a bug regarding Barrage shooting too many arrows.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top