1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  3. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  4. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] One hit spell

Discussion in 'Triggers & Scripts' started by Darkshine, Mar 5, 2010.

  1. Darkshine

    Darkshine

    Joined:
    Feb 25, 2010
    Messages:
    72
    Resources:
    0
    Resources:
    0
    Hello, i'm having problems to do a spell for my custom map and i like to know if anybody can help me with the triggers.

    Basically, i want to do a active spell, like Roar. When activated, it gives only to the caster a large bonus in damage, but only for a few seconds OR for the next attack. So, if you dont attack nothing in 10 seconds, the buff disapear.

    I already did the spell, taking Roar like base spell, but i dont know how to put in triggers the "next attack in 10 seconds" part. Anybody have ideas?
     
  2. Teelo

    Teelo

    Joined:
    Mar 31, 2009
    Messages:
    709
    Resources:
    1
    Maps:
    1
    Resources:
    1
    You probably want something like this:

    Trigger 1:
    Fires when a unit casts that ability
    Creates an instance of Trigger 2, adds an event to Trigger 2 that fires when the unit attacks.
    Creates a timer that fires in 10 seconds, the target method destroys that instance of Trigger 2.

    Trigger 2
    No default events.
    When fired, does what you want on the units next attack, and removes a specific buff from the unit.

    This should get you started. Not tested, not guaranteed to be working, not guaranteed to be leak-proof, and requires vJASS

    Code (vJASS):
    library oneHit initializer init

        globals
            trigger oneHitTrigger
        endglobals
       
        private function onCaseOneHitFilter takes nothing returns boolean
            local integer spell = GetSpellAbilityId()
            // Substitute the ability ID for Roar
            return spell == 'ROAR'
        endfunction
       
        private function onUseOneHitTimeout takes trigger t returns nothing
            call DestroyTrigger(t)
        endfunction
       
        private function onUseOneHitFilter takes nothing returns boolean
            local integer spell = GetSpellAbilityId()
            // Substitute the ability ID for melee attack
            return spell == 'ATTK'
        endfunction
       
        private function onUseOneHit takes nothing returns nothing
            local unit u = GetSpellAbilityUnit()
            // Do whatever to the units attack here.
            call DisableTrigger(GetTriggeringTrigger())
        endfunction
       
        private function onCastOneHit takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerAddAction(t, function onUseOneHit)
            call TriggerRegisterUnitEvent(t, GetSpellAbilityUnit(), EVENT_UNIT_SPELL_EFFECT)
            call TriggerAddCondition(t, function onUseOneHitFilter)
            call TimerStart(CreateTimer(), 10, false, function onUseOneHitTimeout(t))
        endfunction

        private function init takes nothing returns nothing
            set oneHitTrigger = CreateTrigger()
            // Substitute the ID of the player who will have this ability for "PLAYERS_NUMBER_HERE"
            // or to make it cover all players, loop it 0-11
            call TriggerRegisterPlayerUnitEvent(oneHitTrigger, Player(1), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            call TriggerAddAction(oneHitTrigger, function onCastOneHit)
            call TriggerAddCondition(oneHitTrigger, function onCastOneHitFilter)
        endfunction
     
    endlibrary
     
    Last edited: Mar 5, 2010
  3. Dynasti

    Dynasti

    Joined:
    Oct 18, 2007
    Messages:
    877
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Buff duration 10 sec ftw?
     
  4. Teelo

    Teelo

    Joined:
    Mar 31, 2009
    Messages:
    709
    Resources:
    1
    Maps:
    1
    Resources:
    1
    He probably wants the buff to vanish early if the unit attacks!

    I can't think of any WC3 abilities that do this, though there might be one I've missed.
     
  5. Tiche3

    Tiche3

    Joined:
    Jun 25, 2009
    Messages:
    432
    Resources:
    1
    Spells:
    1
    Resources:
    1
    You can use Battle Roar, then set time to 10seconds. (Duration)

    And make a trigger, look how it SHOULD look

    • Battle Roar
      • Events:
        • Unit - A unit is being attacked
      • Conditions:
        • (Attacking Unit) has a (Battle Roar buff)
      • Actions:
        • Set Battle_Roar_Attacks=((Battle_Roar_Attacks)+1)
        • If all (Conditions) are True, then do (actions):
          • If - Conditions:
            • Battle_Roar_Attacks is equal to 10
          • Then - Actions:
            • Set Battle_Roar_Attacks=0
            • Unit - Remove Buff of type (Battle Roar buff)
          • Else - Actions:
            • ---Do not EVER use Do nothing---
     
  6. Dynasti

    Dynasti

    Joined:
    Oct 18, 2007
    Messages:
    877
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    1. That is not MUI and will bugg if used by more than 1 unit.
    2. "When Unit is Attacked" will trigger when you command a unit to attack another unit, it will also bugg.

    There is no "easy" way to do this sadly. Wc3 triggers are limited.
     
  7. Tiche3

    Tiche3

    Joined:
    Jun 25, 2009
    Messages:
    432
    Resources:
    1
    Spells:
    1
    Resources:
    1
    He didn't ask for MUI spell, he didn't ask it to be when damaged (i mean the damage detection system, etc)

    And YES, i agree, this is just a simple 1 Guy spell, that is not perfect (It's kind of ursa's style in DotA, but without the damage detection)
     
  8. skamigo

    skamigo

    Joined:
    May 22, 2009
    Messages:
    265
    Resources:
    4
    Maps:
    4
    Resources:
    4
    that's right tiche, but he didn't say he wanted 10 attacks before the buff dissapears, he said if he attack within the 10 seconds the buff will dissapear, so you can easily just use:

    • Battle Roar
      • Events:
        • Unit - A unit is being attacked
      • Conditions:
        • (Attacking Unit) has a (Battle Roar buff)
      • Actions:
        • Unit - Remove Buff of type (Battle Roar buff) from (Attacking Unit)
     
  9. Tiche3

    Tiche3

    Joined:
    Jun 25, 2009
    Messages:
    432
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Oh, i'm so stupid :)cry:), sorry i didn't see that, i thought he wanted 10 attacks, so yes, the way to do it is Skamigo's way.

    Sorry for misunderstanding.
    Have fun mapping ;D

    Tiche3:grin:
     
  10. Darkshine

    Darkshine

    Joined:
    Feb 25, 2010
    Messages:
    72
    Resources:
    0
    Resources:
    0
    I really thanks for the help people.

    I tried to use the trigger of skamingo, but there is a problem: when the unit with the buff attacks, it disapear BEFORE the unit can do the extra damage from the buff! Should i use, maybe, a 'wait' action before the 'remove specific buff from attacking unit'?
     
  11. Darkshine

    Darkshine

    Joined:
    Feb 25, 2010
    Messages:
    72
    Resources:
    0
    Resources:
    0
    Hey people, i did it! Thanks to all for the priceless help :)

    I simply change the stance of "unit - a unit is attacked" for "a unit takes damage"

    I used another trigger to refer to the unit, so ir works :)

    One more time, thanks to all o/
     
  12. Tiche3

    Tiche3

    Joined:
    Jun 25, 2009
    Messages:
    432
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Your welcome, have fun in your map :wink: