• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] One hit spell

Status
Not open for further replies.
Level 4
Joined
Feb 25, 2010
Messages
73
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?
 
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.


JASS:
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:
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---
 
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.

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)
 
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---

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)
 
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)

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:
 
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'?
 
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/
 
Status
Not open for further replies.
Back
Top